working on rendering panel with phantomjs

This commit is contained in:
Torkel Ödegaard
2014-08-08 15:53:31 +02:00
parent 8154b4f60d
commit c669f8c612
5 changed files with 64 additions and 1 deletions

BIN
_vendor/phantomjs/phantomjs Executable file

Binary file not shown.

View 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);
});

View File

@@ -0,0 +1,9 @@
package components
type PhantomRenderer struct {
ImagesDir string
}
func (renderer *PhantomRenderer) Render(url string) {
}

View 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)
})
}

Submodule grafana updated: 91a6ae756f...f068b2c1d3