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
581ffb86
Commit
581ffb86
authored
Mar 13, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(plugins): polish to plugin page, better handling for reading readme file contents
parent
4a3c19c6
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
75 additions
and
11 deletions
+75
-11
pkg/api/api.go
+3
-3
pkg/api/plugins.go
+14
-0
pkg/plugins/models.go
+3
-0
pkg/plugins/plugins.go
+29
-0
public/app/features/plugins/import_list/import_list.ts
+2
-2
public/app/features/plugins/partials/plugin_list.html
+2
-2
public/app/features/plugins/plugin_edit_ctrl.ts
+2
-2
public/sass/_variables.dark.scss
+2
-2
public/sass/pages/_plugins.scss
+18
-0
No files found.
pkg/api/api.go
View file @
581ffb86
...
...
@@ -175,9 +175,8 @@ func Register(r *macaron.Macaron) {
r
.
Group
(
"/plugins"
,
func
()
{
r
.
Get
(
"/"
,
wrap
(
GetPluginList
))
r
.
Get
(
"/dashboards/:pluginId"
,
wrap
(
GetPluginDashboards
))
r
.
Post
(
"/dashboards/import"
,
bind
(
dtos
.
ImportDashboardCommand
{}),
wrap
(
ImportDashboard
))
r
.
Get
(
"/:pluginId/readme"
,
wrap
(
GetPluginReadme
))
r
.
Get
(
"/:pluginId/dashboards/"
,
wrap
(
GetPluginDashboards
))
r
.
Get
(
"/:pluginId/settings"
,
wrap
(
GetPluginSettingById
))
r
.
Post
(
"/:pluginId/settings"
,
bind
(
m
.
UpdatePluginSettingCmd
{}),
wrap
(
UpdatePluginSetting
))
},
reqOrgAdmin
)
...
...
@@ -193,6 +192,7 @@ func Register(r *macaron.Macaron) {
r
.
Get
(
"/file/:file"
,
GetDashboardFromJsonFile
)
r
.
Get
(
"/home"
,
GetHomeDashboard
)
r
.
Get
(
"/tags"
,
GetDashboardTags
)
r
.
Post
(
"/import"
,
bind
(
dtos
.
ImportDashboardCommand
{}),
wrap
(
ImportDashboard
))
})
// Dashboard snapshots
...
...
pkg/api/plugins.go
View file @
581ffb86
...
...
@@ -122,6 +122,20 @@ func GetPluginDashboards(c *middleware.Context) Response {
}
}
func
GetPluginReadme
(
c
*
middleware
.
Context
)
Response
{
pluginId
:=
c
.
Params
(
":pluginId"
)
if
content
,
err
:=
plugins
.
GetPluginReadme
(
pluginId
);
err
!=
nil
{
if
notfound
,
ok
:=
err
.
(
plugins
.
PluginNotFoundError
);
ok
{
return
ApiError
(
404
,
notfound
.
Error
(),
nil
)
}
return
ApiError
(
500
,
"Could not get readme"
,
err
)
}
else
{
return
Respond
(
200
,
content
)
}
}
func
ImportDashboard
(
c
*
middleware
.
Context
,
apiCmd
dtos
.
ImportDashboardCommand
)
Response
{
cmd
:=
plugins
.
ImportDashboardCommand
{
...
...
pkg/plugins/models.go
View file @
581ffb86
...
...
@@ -43,6 +43,9 @@ type PluginBase struct {
IncludedInAppId
string
`json:"-"`
PluginDir
string
`json:"-"`
// cache for readme file contents
Readme
[]
byte
`json:"-"`
}
func
(
pb
*
PluginBase
)
registerPlugin
(
pluginDir
string
)
error
{
...
...
pkg/plugins/plugins.go
View file @
581ffb86
...
...
@@ -3,6 +3,7 @@ package plugins
import
(
"encoding/json"
"errors"
"io/ioutil"
"os"
"path"
"path/filepath"
...
...
@@ -155,3 +156,31 @@ func (scanner *PluginScanner) loadPluginJson(pluginJsonFilePath string) error {
reader
.
Seek
(
0
,
0
)
return
loader
.
Load
(
jsonParser
,
currentDir
)
}
func
GetPluginReadme
(
pluginId
string
)
([]
byte
,
error
)
{
plug
,
exists
:=
Plugins
[
pluginId
]
if
!
exists
{
return
nil
,
PluginNotFoundError
{
pluginId
}
}
if
plug
.
Readme
!=
nil
{
return
plug
.
Readme
,
nil
}
readmePath
:=
filepath
.
Join
(
plug
.
PluginDir
,
"README.md"
)
if
_
,
err
:=
os
.
Stat
(
readmePath
);
os
.
IsNotExist
(
err
)
{
readmePath
=
filepath
.
Join
(
plug
.
PluginDir
,
"readme.md"
)
}
if
_
,
err
:=
os
.
Stat
(
readmePath
);
os
.
IsNotExist
(
err
)
{
plug
.
Readme
=
make
([]
byte
,
0
)
return
plug
.
Readme
,
nil
}
if
readmeBytes
,
err
:=
ioutil
.
ReadFile
(
readmePath
);
err
!=
nil
{
return
nil
,
err
}
else
{
plug
.
Readme
=
readmeBytes
return
plug
.
Readme
,
nil
}
}
public/app/features/plugins/import_list/import_list.ts
View file @
581ffb86
...
...
@@ -12,7 +12,7 @@ export class DashImportListCtrl {
constructor
(
private
$http
,
private
backendSrv
,
private
$rootScope
)
{
this
.
dashboards
=
[];
backendSrv
.
get
(
`/api/plugins/
dashboards/
${
this
.
plugin
.
id
}
`
).
then
(
dashboards
=>
{
backendSrv
.
get
(
`/api/plugins/
${
this
.
plugin
.
id
}
/dashboards
`
).
then
(
dashboards
=>
{
this
.
dashboards
=
dashboards
;
});
}
...
...
@@ -34,7 +34,7 @@ export class DashImportListCtrl {
});
}
this
.
backendSrv
.
post
(
`/api/
plugins/
dashboards/import`
,
installCmd
).
then
(
res
=>
{
this
.
backendSrv
.
post
(
`/api/dashboards/import`
,
installCmd
).
then
(
res
=>
{
this
.
$rootScope
.
appEvent
(
'alert-success'
,
[
'Dashboard Installed'
,
dash
.
title
]);
_
.
extend
(
dash
,
res
);
});
...
...
public/app/features/plugins/partials/plugin_list.html
View file @
581ffb86
...
...
@@ -26,8 +26,8 @@
{{plugin.type}}
</td>
<td>
<span
class=
"label label-
info
"
ng-if=
"plugin.enabled"
>
Enabled
</span>
<span
class=
"label label-
info
"
ng-if=
"plugin.pinned"
>
Pinned
</span>
<span
class=
"label label-
secondary
"
ng-if=
"plugin.enabled"
>
Enabled
</span>
<span
class=
"label label-
secondary
"
ng-if=
"plugin.pinned"
>
Pinned
</span>
</td>
<td
class=
"text-right"
>
<a
href=
"plugins/{{plugin.id}}/edit"
class=
"btn btn-inverse btn-small"
>
...
...
public/app/features/plugins/plugin_edit_ctrl.ts
View file @
581ffb86
...
...
@@ -40,10 +40,10 @@ export class PluginEditCtrl {
}
initReadme
()
{
return
this
.
$http
.
get
(
this
.
model
.
baseUrl
+
'/readme.md'
).
then
(
res
=>
{
return
this
.
backendSrv
.
get
(
`/api/plugins/
${
this
.
pluginId
}
/readme`
).
then
(
res
=>
{
return
System
.
import
(
'remarkable'
).
then
(
Remarkable
=>
{
var
md
=
new
Remarkable
();
this
.
readmeHtml
=
this
.
$sce
.
trustAsHtml
(
md
.
render
(
res
.
data
));
this
.
readmeHtml
=
this
.
$sce
.
trustAsHtml
(
md
.
render
(
res
));
});
});
}
...
...
public/sass/_variables.dark.scss
View file @
581ffb86
...
...
@@ -113,8 +113,8 @@ $scrollbarBorder: black;
// Tables
// -------------------------
$table-bg
:
transparent
;
// overall background-color
$table-bg-accent
:
rgba
(
100
,
100
,
100
,
0
.3
)
;
// for striping
$table-bg-hover
:
$dark-
3
;
// for hover
$table-bg-accent
:
$dark-3
;
// for striping
$table-bg-hover
:
$dark-
4
;
// for hover
$table-border
:
$dark-3
;
// table and cell border
// Buttons
...
...
public/sass/pages/_plugins.scss
View file @
581ffb86
...
...
@@ -30,6 +30,7 @@
img
{
width
:
16px
;
}
white-space
:
nowrap
;
max-width
:
$page-sidebar-width
;
text-overflow
:
ellipsis
;
...
...
@@ -40,8 +41,25 @@
img
{
max-width
:
100%
;
}
ul
{
padding-left
:
$spacer
*
1
.5
;
margin-bottom
:
$spacer
*
2
;
}
table
{
td
,
th
{
padding
:
$spacer
*.
5
$spacer
;
}
th
{
font-weight
:
normal
;
background
:
$table-bg-accent
;
}
}
table
,
th
,
td
{
border
:
1px
solid
$table-border
;
border-collapse
:
collapse
;
}
}
...
...
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