Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
05f9e5ee
Commit
05f9e5ee
authored
Oct 01, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rendering
parent
4a73e2d0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
17 deletions
+40
-17
_vendor/phantomjs/render.js
+16
-7
grafana
+1
-1
pkg/api/api_render.go
+12
-5
pkg/components/phantom_renderer.go
+10
-4
todo.txt
+1
-0
No files found.
_vendor/phantomjs/render.js
View file @
05f9e5ee
...
...
@@ -17,18 +17,27 @@ if (!params.url || !params.png) {
}
page
.
viewportSize
=
{
width
:
'800'
,
height
:
'400'
width
:
params
.
width
||
'800'
,
height
:
params
.
height
||
'400'
};
page
.
open
(
params
.
url
,
function
(
status
)
{
console
.
log
(
'Loading a web page: '
+
params
.
url
);
setTimeout
(
function
()
{
console
.
log
(
'rendering panel to '
+
params
.
png
);
function
checkIsReady
()
{
var
canvas
=
page
.
evaluate
(
function
()
{
return
$
(
'canvas'
).
length
>
0
;
});
page
.
render
(
params
.
png
);
phantom
.
exit
();
if
(
canvas
)
{
page
.
render
(
params
.
png
);
phantom
.
exit
();
}
else
{
setTimeout
(
checkIsReady
,
10
);
}
}
setTimeout
(
checkIsReady
,
200
);
},
2000
);
});
grafana
@
eb28e63c
Subproject commit
de1de852fc130d6b5c75c28a93aab38bbbe726b8
Subproject commit
eb28e63c08a43ada747fbcdae9612301c9c7a531
pkg/api/api_render.go
View file @
05f9e5ee
...
...
@@ -3,22 +3,29 @@ package api
import
(
"strconv"
log
"github.com/alecthomas/log4go"
"github.com/gin-gonic/gin"
"github.com/torkelo/grafana-pro/pkg/components"
)
func
init
()
{
addRoutes
(
func
(
self
*
HttpServer
)
{
self
.
addRoute
(
"GET"
,
"/
api/
render/*url"
,
self
.
renderToPng
)
self
.
addRoute
(
"GET"
,
"/render/*url"
,
self
.
renderToPng
)
})
}
func
(
self
*
HttpServer
)
renderToPng
(
c
*
gin
.
Context
,
auth
*
authContext
)
{
url
:=
c
.
Params
.
ByName
(
"url"
)
accountId
:=
auth
.
getAccountId
()
query
:=
c
.
Request
.
URL
.
Query
()
queryParams
:=
"?render&accountId="
+
strconv
.
Itoa
(
accountId
)
+
"&"
+
c
.
Request
.
URL
.
RawQuery
renderOpts
:=
&
components
.
RenderOpts
{
Url
:
c
.
Params
.
ByName
(
"url"
)
+
queryParams
,
Width
:
query
[
"width"
][
0
],
Height
:
query
[
"height"
][
0
],
}
renderOpts
.
Url
=
"http://localhost:3000"
+
renderOpts
.
Url
log
.
Info
(
"Rendering url %v"
,
url
)
pngPath
,
err
:=
self
.
renderer
.
RenderToPng
(
"http://localhost:3000"
+
url
+
"?render&accountId="
+
strconv
.
Itoa
(
accountId
))
pngPath
,
err
:=
self
.
renderer
.
RenderToPng
(
renderOpts
)
if
err
!=
nil
{
c
.
HTML
(
500
,
"error.html"
,
nil
)
}
...
...
pkg/components/phantom_renderer.go
View file @
05f9e5ee
...
...
@@ -17,14 +17,20 @@ type PhantomRenderer struct {
PhantomDir
string
}
func
(
self
*
PhantomRenderer
)
RenderToPng
(
url
string
)
(
string
,
error
)
{
log
.
Info
(
"PhantomRenderer::renderToPng url %v"
,
url
)
type
RenderOpts
struct
{
Url
string
Width
string
Height
string
}
func
(
self
*
PhantomRenderer
)
RenderToPng
(
params
*
RenderOpts
)
(
string
,
error
)
{
log
.
Info
(
"PhantomRenderer::renderToPng url %v"
,
params
.
Url
)
binPath
,
_
:=
filepath
.
Abs
(
filepath
.
Join
(
self
.
PhantomDir
,
"phantomjs"
))
scriptPath
,
_
:=
filepath
.
Abs
(
filepath
.
Join
(
self
.
PhantomDir
,
"render.js"
))
pngPath
,
_
:=
filepath
.
Abs
(
filepath
.
Join
(
self
.
ImagesDir
,
getHash
(
u
rl
)))
pngPath
,
_
:=
filepath
.
Abs
(
filepath
.
Join
(
self
.
ImagesDir
,
getHash
(
params
.
U
rl
)))
pngPath
=
pngPath
+
".png"
cmd
:=
exec
.
Command
(
binPath
,
scriptPath
,
"url="
+
url
,
"width=100"
,
"height=100"
,
"png="
+
pngPath
)
cmd
:=
exec
.
Command
(
binPath
,
scriptPath
,
"url="
+
params
.
Url
,
"width="
+
params
.
Width
,
"height="
+
params
.
Height
,
"png="
+
pngPath
)
stdout
,
err
:=
cmd
.
StdoutPipe
()
if
err
!=
nil
{
...
...
todo.txt
View file @
05f9e5ee
...
...
@@ -2,3 +2,4 @@
- OAuth and email, unique?
- Form authentication token
- Password hash
- Account security for png rendering
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment