mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
working on rendering panel with phantomjs
This commit is contained in:
BIN
_vendor/phantomjs/phantomjs
Executable file
BIN
_vendor/phantomjs/phantomjs
Executable file
Binary file not shown.
32
_vendor/phantomjs/render.js
Normal file
32
_vendor/phantomjs/render.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
var page = require('webpage').create();
|
||||||
|
var args = require('system').args;
|
||||||
|
var params = {};
|
||||||
|
|
||||||
|
args.forEach(function(arg) {
|
||||||
|
var parts = arg.split('=');
|
||||||
|
params[parts[0]] = parts[1];
|
||||||
|
});
|
||||||
|
|
||||||
|
var usage = "url=<url> png=<filename> width=<width> height=<height>";
|
||||||
|
|
||||||
|
if (!params.url || !params.png) {
|
||||||
|
console.log(usage);
|
||||||
|
phantom.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
page.viewportSize = {
|
||||||
|
width: '800',
|
||||||
|
height: '400'
|
||||||
|
};
|
||||||
|
|
||||||
|
page.open(params.url, function (status) {
|
||||||
|
console.log('Loading a web page');
|
||||||
|
|
||||||
|
setTimeout(function() {
|
||||||
|
console.log('rendering panel to ' + params.png);
|
||||||
|
|
||||||
|
page.render(params.png);
|
||||||
|
phantom.exit();
|
||||||
|
|
||||||
|
}, 2000);
|
||||||
|
});
|
||||||
9
backend/components/phantom_renderer.go
Normal file
9
backend/components/phantom_renderer.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package components
|
||||||
|
|
||||||
|
type PhantomRenderer struct {
|
||||||
|
ImagesDir string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (renderer *PhantomRenderer) Render(url string) {
|
||||||
|
|
||||||
|
}
|
||||||
22
backend/components/phantom_renderer_test.go
Normal file
22
backend/components/phantom_renderer_test.go
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package components
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
. "github.com/smartystreets/goconvey/convey"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPhantomRender(t *testing.T) {
|
||||||
|
|
||||||
|
Convey("Can render url", func() {
|
||||||
|
tempDir, _ := ioutil.TempDir("", "img")
|
||||||
|
renderer := &PhantomRenderer{ImagesDir: tempDir}
|
||||||
|
renderer.Render("http://www.google.com")
|
||||||
|
//So(err, ShouldBeNil)
|
||||||
|
|
||||||
|
//_, err = os.Stat(store.getFilePathForDashboard("hello"))
|
||||||
|
//So(err, ShouldBeNil)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
2
grafana
2
grafana
Submodule grafana updated: 91a6ae756f...f068b2c1d3
Reference in New Issue
Block a user