mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 06:32:17 +08:00
feat(plugins): made panels work as plugins
This commit is contained in:
@ -14,6 +14,7 @@ import (
|
||||
|
||||
var (
|
||||
DataSources map[string]DataSourcePlugin
|
||||
Panels []PanelPlugin
|
||||
ExternalPlugins []ExternalPlugin
|
||||
StaticRoutes []*StaticRootConfig
|
||||
)
|
||||
@ -27,6 +28,7 @@ func Init() error {
|
||||
DataSources = make(map[string]DataSourcePlugin)
|
||||
ExternalPlugins = make([]ExternalPlugin, 0)
|
||||
StaticRoutes = make([]*StaticRootConfig, 0)
|
||||
Panels = make([]PanelPlugin, 0)
|
||||
|
||||
scan(path.Join(setting.StaticRootPath, "app/plugins"))
|
||||
checkExternalPluginPaths()
|
||||
@ -124,6 +126,21 @@ func (scanner *PluginScanner) loadPluginJson(pluginJsonFilePath string) error {
|
||||
addStaticRoot(p.StaticRootConfig, currentDir)
|
||||
}
|
||||
|
||||
if pluginType == "panel" {
|
||||
p := PanelPlugin{}
|
||||
reader.Seek(0, 0)
|
||||
if err := jsonParser.Decode(&p); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if p.Type == "" {
|
||||
return errors.New("Did not find type property in plugin.json")
|
||||
}
|
||||
|
||||
Panels = append(Panels, p)
|
||||
addStaticRoot(p.StaticRootConfig, currentDir)
|
||||
}
|
||||
|
||||
if pluginType == "external" {
|
||||
p := ExternalPlugin{}
|
||||
reader.Seek(0, 0)
|
||||
|
Reference in New Issue
Block a user