mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Rendering: Have phantomjs wait a bit before rendering to give fonts a change to load (#22623)
This commit is contained in:
parent
917860c4d3
commit
5a53c2d02b
@ -8,11 +8,13 @@
|
||||
|
||||
args.forEach(function(arg) {
|
||||
var parts = arg.match(regexp);
|
||||
if (!parts) { return; }
|
||||
if (!parts) {
|
||||
return;
|
||||
}
|
||||
params[parts[1]] = parts[2];
|
||||
});
|
||||
|
||||
var usage = "url=<url> png=<filename> width=<width> height=<height> renderKey=<key>";
|
||||
var usage = 'url=<url> png=<filename> width=<width> height=<height> renderKey=<key>';
|
||||
|
||||
if (!params.url || !params.png || !params.renderKey || !params.domain) {
|
||||
console.log(usage);
|
||||
@ -20,14 +22,14 @@
|
||||
}
|
||||
|
||||
phantom.addCookie({
|
||||
'name': 'renderKey',
|
||||
'value': params.renderKey,
|
||||
'domain': params.domain,
|
||||
name: 'renderKey',
|
||||
value: params.renderKey,
|
||||
domain: params.domain,
|
||||
});
|
||||
|
||||
page.viewportSize = {
|
||||
width: params.width || '800',
|
||||
height: params.height || '400'
|
||||
height: params.height || '400',
|
||||
};
|
||||
|
||||
var timeoutMs = (parseInt(params.timeout) || 10) * 1000;
|
||||
@ -56,9 +58,9 @@
|
||||
|
||||
if (panelsRendered || totalWaitMs > timeoutMs) {
|
||||
var bb = page.evaluate(function() {
|
||||
var container = document.getElementsByClassName("dashboard-container")
|
||||
var container = document.getElementsByClassName('dashboard-container');
|
||||
if (container.length == 0) {
|
||||
container = document.getElementsByClassName("panel-container")
|
||||
container = document.getElementsByClassName('panel-container');
|
||||
}
|
||||
return container[0].getBoundingClientRect();
|
||||
});
|
||||
@ -66,11 +68,13 @@
|
||||
// reset viewport to render full page
|
||||
page.viewportSize = {
|
||||
width: bb.width,
|
||||
height: bb.height
|
||||
height: bb.height,
|
||||
};
|
||||
|
||||
setTimeout(function() {
|
||||
page.render(params.png);
|
||||
phantom.exit();
|
||||
}, 5);
|
||||
} else {
|
||||
totalWaitMs += waitBetweenReadyCheckMs;
|
||||
setTimeout(checkIsReady, waitBetweenReadyCheckMs);
|
||||
|
Loading…
Reference in New Issue
Block a user