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
09f5e6f4
Commit
09f5e6f4
authored
Jan 19, 2016
by
utkarshcmu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/utkarshcmu/grafana
into snapshot-view
parents
e26cd210
36e99ac5
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
82 additions
and
58 deletions
+82
-58
pkg/api/dtos/apps.go
+3
-1
pkg/plugins/app_plugin.go
+22
-1
pkg/plugins/frontend_plugin.go
+3
-2
pkg/plugins/models.go
+2
-1
pkg/plugins/plugins.go
+1
-33
pkg/plugins/queries.go
+18
-15
public/app/features/apps/edit_ctrl.ts
+2
-0
public/app/features/apps/partials/edit.html
+4
-1
public/app/features/panel/panel_loader.ts
+10
-2
public/app/plugins/panel/unknown/module.ts
+15
-0
public/less/simple-box.less
+1
-1
symlink_git_hooks.sh
+1
-1
No files found.
pkg/api/dtos/apps.go
View file @
09f5e6f4
...
...
@@ -12,7 +12,8 @@ type AppSettings struct {
Pinned
bool
`json:"pinned"`
Module
string
`json:"module"`
Info
*
plugins
.
PluginInfo
`json:"info"`
Pages
[]
*
plugins
.
AppPluginPage
`json:"pages"`
Pages
[]
plugins
.
AppPluginPage
`json:"pages"`
Includes
[]
plugins
.
AppIncludeInfo
`json:"includes"`
JsonData
map
[
string
]
interface
{}
`json:"jsonData"`
}
...
...
@@ -23,6 +24,7 @@ func NewAppSettingsDto(def *plugins.AppPlugin, data *models.AppSettings) *AppSet
Info
:
&
def
.
Info
,
Module
:
def
.
Module
,
Pages
:
def
.
Pages
,
Includes
:
def
.
Includes
,
}
if
data
!=
nil
{
...
...
pkg/plugins/app_plugin.go
View file @
09f5e6f4
...
...
@@ -2,6 +2,7 @@ package plugins
import
(
"encoding/json"
"strings"
"github.com/grafana/grafana/pkg/models"
)
...
...
@@ -17,10 +18,17 @@ type AppPluginCss struct {
Dark
string
`json:"dark"`
}
type
AppIncludeInfo
struct
{
Name
string
`json:"name"`
Type
string
`json:"type"`
Id
string
`json:"id"`
}
type
AppPlugin
struct
{
FrontendPluginBase
Css
*
AppPluginCss
`json:"css"`
Pages
[]
*
AppPluginPage
`json:"pages"`
Pages
[]
AppPluginPage
`json:"pages"`
Includes
[]
AppIncludeInfo
`json:"-"`
Pinned
bool
`json:"-"`
Enabled
bool
`json:"-"`
...
...
@@ -38,6 +46,19 @@ func (app *AppPlugin) Load(decoder *json.Decoder, pluginDir string) error {
app
.
PluginDir
=
pluginDir
app
.
initFrontendPlugin
()
// check if we have child panels
for
_
,
panel
:=
range
Panels
{
if
strings
.
HasPrefix
(
panel
.
PluginDir
,
app
.
PluginDir
)
{
panel
.
IncludedInAppId
=
app
.
Id
app
.
Includes
=
append
(
app
.
Includes
,
AppIncludeInfo
{
Name
:
panel
.
Name
,
Id
:
panel
.
Id
,
Type
:
panel
.
Type
,
})
}
}
Apps
[
app
.
Id
]
=
app
return
nil
}
pkg/plugins/frontend_plugin.go
View file @
09f5e6f4
...
...
@@ -10,19 +10,20 @@ type FrontendPluginBase struct {
PluginBase
Module
string
`json:"module"`
StaticRoot
string
`json:"staticRoot"`
StaticRootAbs
string
`json:"-"`
}
func
(
fp
*
FrontendPluginBase
)
initFrontendPlugin
()
{
if
fp
.
StaticRoot
!=
""
{
fp
.
StaticRootAbs
=
filepath
.
Join
(
fp
.
PluginDir
,
fp
.
StaticRoot
)
StaticRoutes
=
append
(
StaticRoutes
,
&
PluginStaticRoute
{
Directory
:
f
ilepath
.
Join
(
fp
.
PluginDir
,
fp
.
StaticRoot
)
,
Directory
:
f
p
.
StaticRootAbs
,
PluginId
:
fp
.
Id
,
})
}
fp
.
Info
.
Logos
.
Small
=
evalRelativePluginUrlPath
(
fp
.
Info
.
Logos
.
Small
,
fp
.
Id
)
fp
.
Info
.
Logos
.
Large
=
evalRelativePluginUrlPath
(
fp
.
Info
.
Logos
.
Large
,
fp
.
Id
)
fp
.
handleModuleDefaults
()
}
...
...
pkg/plugins/models.go
View file @
09f5e6f4
...
...
@@ -14,8 +14,9 @@ type PluginBase struct {
Type
string
`json:"type"`
Name
string
`json:"name"`
Id
string
`json:"id"`
App
string
`json:"app"`
Info
PluginInfo
`json:"info"`
IncludedInAppId
string
`json:"-"`
PluginDir
string
`json:"-"`
}
...
...
pkg/plugins/plugins.go
View file @
09f5e6f4
package
plugins
import
(
"bytes"
"encoding/json"
"errors"
"io"
"os"
"path"
"path/filepath"
"reflect"
"strings"
"text/template"
"github.com/grafana/grafana/pkg/log"
"github.com/grafana/grafana/pkg/setting"
...
...
@@ -122,28 +119,6 @@ func (scanner *PluginScanner) walker(currentPath string, f os.FileInfo, err erro
return
nil
}
func
interpolatePluginJson
(
reader
io
.
Reader
,
pluginCommon
*
PluginBase
)
(
io
.
Reader
,
error
)
{
buf
:=
new
(
bytes
.
Buffer
)
buf
.
ReadFrom
(
reader
)
jsonStr
:=
buf
.
String
()
//
tmpl
,
err
:=
template
.
New
(
"json"
)
.
Parse
(
jsonStr
)
if
err
!=
nil
{
return
nil
,
err
}
data
:=
map
[
string
]
interface
{}{
"PluginPublicRoot"
:
"public/plugins/"
+
pluginCommon
.
Id
,
}
var
resultBuffer
bytes
.
Buffer
if
err
:=
tmpl
.
ExecuteTemplate
(
&
resultBuffer
,
"json"
,
data
);
err
!=
nil
{
return
nil
,
err
}
return
bytes
.
NewReader
(
resultBuffer
.
Bytes
()),
nil
}
func
(
scanner
*
PluginScanner
)
loadPluginJson
(
pluginJsonFilePath
string
)
error
{
currentDir
:=
filepath
.
Dir
(
pluginJsonFilePath
)
reader
,
err
:=
os
.
Open
(
pluginJsonFilePath
)
...
...
@@ -163,20 +138,13 @@ func (scanner *PluginScanner) loadPluginJson(pluginJsonFilePath string) error {
return
errors
.
New
(
"Did not find type and id property in plugin.json"
)
}
reader
.
Seek
(
0
,
0
)
if
newReader
,
err
:=
interpolatePluginJson
(
reader
,
&
pluginCommon
);
err
!=
nil
{
return
err
}
else
{
jsonParser
=
json
.
NewDecoder
(
newReader
)
}
var
loader
PluginLoader
if
pluginGoType
,
exists
:=
PluginTypes
[
pluginCommon
.
Type
];
!
exists
{
return
errors
.
New
(
"Unkown plugin type "
+
pluginCommon
.
Type
)
}
else
{
loader
=
reflect
.
New
(
reflect
.
TypeOf
(
pluginGoType
))
.
Interface
()
.
(
PluginLoader
)
}
reader
.
Seek
(
0
,
0
)
return
loader
.
Load
(
jsonParser
,
currentDir
)
}
pkg/plugins/queries.go
View file @
09f5e6f4
...
...
@@ -27,8 +27,7 @@ func GetEnabledPlugins(orgId int64) (*EnabledPlugins, error) {
return
nil
,
err
}
seenPanels
:=
make
(
map
[
string
]
bool
)
seenApi
:=
make
(
map
[
string
]
bool
)
enabledApps
:=
make
(
map
[
string
]
bool
)
for
appId
,
installedApp
:=
range
Apps
{
var
app
AppPlugin
...
...
@@ -42,34 +41,38 @@ func GetEnabledPlugins(orgId int64) (*EnabledPlugins, error) {
}
if
app
.
Enabled
{
enabledApps
[
app
.
Id
]
=
true
enabledPlugins
.
Apps
=
append
(
enabledPlugins
.
Apps
,
&
app
)
}
}
isPluginEnabled
:=
func
(
appId
string
)
bool
{
if
appId
==
""
{
return
true
}
_
,
ok
:=
enabledApps
[
appId
]
return
ok
}
// add all plugins that are not part of an App.
for
d
,
installedD
s
:=
range
DataSources
{
if
i
nstalledDs
.
App
==
""
{
enabledPlugins
.
DataSources
[
d
]
=
installedD
s
for
d
sId
,
d
s
:=
range
DataSources
{
if
i
sPluginEnabled
(
ds
.
IncludedInAppId
)
{
enabledPlugins
.
DataSources
[
d
sId
]
=
d
s
}
}
for
p
,
panel
:=
range
Panels
{
if
panel
.
App
==
""
{
if
_
,
ok
:=
seenPanels
[
p
];
!
ok
{
seenPanels
[
p
]
=
true
for
_
,
panel
:=
range
Panels
{
if
isPluginEnabled
(
panel
.
IncludedInAppId
)
{
enabledPlugins
.
Panels
=
append
(
enabledPlugins
.
Panels
,
panel
)
}
}
}
for
a
,
api
:=
range
ApiPlugins
{
if
api
.
App
==
""
{
if
_
,
ok
:=
seenApi
[
a
];
!
ok
{
seenApi
[
a
]
=
true
for
_
,
api
:=
range
ApiPlugins
{
if
isPluginEnabled
(
api
.
IncludedInAppId
)
{
enabledPlugins
.
ApiList
=
append
(
enabledPlugins
.
ApiList
,
api
)
}
}
}
return
&
enabledPlugins
,
nil
}
public/app/features/apps/edit_ctrl.ts
View file @
09f5e6f4
...
...
@@ -5,6 +5,7 @@ import _ from 'lodash';
export
class
AppEditCtrl
{
appModel
:
any
;
includedPanels
:
any
;
/** @ngInject */
constructor
(
private
backendSrv
:
any
,
private
$routeParams
:
any
)
{
...
...
@@ -12,6 +13,7 @@ export class AppEditCtrl {
this
.
backendSrv
.
get
(
`/api/org/apps/
${
this
.
$routeParams
.
appId
}
/settings`
).
then
(
result
=>
{
this
.
appModel
=
result
;
this
.
includedPanels
=
_
.
where
(
result
.
includes
,
{
type
:
'panel'
});
});
}
...
...
public/app/features/apps/partials/edit.html
View file @
09f5e6f4
...
...
@@ -56,7 +56,10 @@
Panels
</div>
<ul>
<li><em
class=
"small"
>
None
</em></li>
<li
ng-show=
"!ctrl.includedPanels.length"
><em
class=
"small"
>
None
</em></li>
<li
ng-repeat=
"panel in ctrl.includedPanels"
>
{{panel.name}}
</li>
</ul>
</div>
<div
class=
"simple-box-body simple-box-column"
>
...
...
public/app/features/panel/panel_loader.ts
View file @
09f5e6f4
...
...
@@ -3,13 +3,21 @@
import
angular
from
'angular'
;
import
config
from
'app/core/config'
;
import
{
unknownPanelDirective
}
from
'../../plugins/panel/unknown/module'
;
/** @ngInject */
function
panelLoader
(
$parse
,
dynamicDirectiveSrv
)
{
return
dynamicDirectiveSrv
.
create
({
directive
:
scope
=>
{
let
modulePath
=
config
.
panels
[
scope
.
panel
.
type
].
module
;
let
panelInfo
=
config
.
panels
[
scope
.
panel
.
type
];
if
(
!
panelInfo
)
{
return
Promise
.
resolve
({
name
:
'panel-directive-'
+
scope
.
panel
.
type
,
fn
:
unknownPanelDirective
});
}
return
System
.
import
(
modulePath
).
then
(
function
(
panelModule
)
{
return
System
.
import
(
panelInfo
.
module
).
then
(
function
(
panelModule
)
{
return
{
name
:
'panel-directive-'
+
scope
.
panel
.
type
,
fn
:
panelModule
.
panel
,
...
...
public/app/plugins/panel/unknown/module.ts
0 → 100644
View file @
09f5e6f4
///<reference path="../../../headers/common.d.ts" />
export
function
unknownPanelDirective
()
{
return
{
restrict
:
'E'
,
template
:
`
<grafana-panel>
<div class="text-center" style="padding-top: 2rem">
Unknown panel type: <strong>{{panel.type}}</strong>
</div>
</grafana-panel>
`
,
};
}
public/less/simple-box.less
View file @
09f5e6f4
@simpleBoxBorderWidth: 0.2rem;
@simpleBoxMargin: 1.5rem;
@simpleBoxBodyPadding:
0.5
rem 0 0.5rem 1rem;
@simpleBoxBodyPadding:
1
rem 0 0.5rem 1rem;
.simple-box {
margin-top: @simpleBoxMargin;
...
...
symlink_git_hooks.sh
View file @
09f5e6f4
#/bin/bash
ln
-s
.hooks/
*
.git/hooks/
ln
-s
-f
.hooks/
*
.git/hooks/
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