Skip to content

Instantly share code, notes, and snippets.

@azasypkin
Created November 8, 2018 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azasypkin/dfc059fa444189fa91ba413a43cd4cab to your computer and use it in GitHub Desktop.
Save azasypkin/dfc059fa444189fa91ba413a43cd4cab to your computer and use it in GitHub Desktop.
make-phantom-report.js
var url = "http://elastic:changeme@127.0.0.1:5601/app/kibana#/visualize/edit/1a36d1d0-e371-11e8-8a31-0d7a694da690?_g=()&_a=(filters:!(),linked:!f,query:(language:lucene,query:''),uiState:(),vis:(aggs:!((enabled:!t,id:'1',params:(),schema:metric,type:count),(enabled:!t,id:'2',params:(field:_type,missingBucket:!f,missingBucketLabel:Missing,order:desc,orderBy:'1',otherBucket:!f,otherBucketLabel:Other,size:5),schema:segment,type:terms)),params:(addLegend:!t,addTimeMarker:!f,addTooltip:!t,categoryAxes:!((id:CategoryAxis-1,labels:(show:!t,truncate:100),position:bottom,scale:(type:linear),show:!t,style:(),title:(),type:category)),grid:(categoryLines:!f,style:(color:%23eee)),legendPosition:right,seriesParams:!((data:(id:'1',label:Count),drawLinesBetweenPoints:!t,interpolate:linear,mode:stacked,show:true,showCircles:!t,type:area,valueAxis:ValueAxis-1)),times:!(),type:area,valueAxes:!((id:ValueAxis-1,labels:(filter:!f,rotate:0,show:!t,truncate:100),name:LeftAxis-1,position:left,scale:(mode:normal,type:linear),show:!t,style:(),title:(text:Count),type:value))),title:'New%20Visualization',type:area))";
var delayMs = 5000;
var page = require('webpage').create();
var onError = function (err) { console.log(err);};
page.onError = function (err) { console.log(JSON.stringify(err));};
page.onResourceError = function (err) { console.log(JSON.stringify(err));};
page.onConsoleMessage = function (message) { console.log(message);};
page.onLoadFinished = function(status) {console.log('onLoadFinished: ' + status);};
page.onResourceRequested = function(requestData, networkRequest) {console.log('Request (#' + requestData.id + '): ' + JSON.stringify(requestData));};
try {
page.viewportSize = { width: 1950, height: 1200 };
page.open(url, function (status) {
if (status === "success") {
page.evaluate(function () { window.addEventListener("load", function(event) { console.log("All resources finished loading!");});});
setTimeout(function () { page.render('screenshot.png'); phantom.exit(); }, delayMs);
} else {
console.log('status');
phantom.exit();
}
});
} catch (err) { onError(err);}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment