2016-01-09 16:34:20 -06:00
|
|
|
package plugins
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
|
|
)
|
|
|
|
|
|
|
|
type AppPluginPage struct {
|
|
|
|
Text string `json:"text"`
|
|
|
|
Url string `json:"url"`
|
|
|
|
ReqRole models.RoleType `json:"reqRole"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type AppPluginCss struct {
|
|
|
|
Light string `json:"light"`
|
|
|
|
Dark string `json:"dark"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type AppPlugin struct {
|
|
|
|
FrontendPluginBase
|
2016-01-11 11:03:08 -06:00
|
|
|
Css *AppPluginCss `json:"css"`
|
|
|
|
Page []*AppPluginPage `json:"page"`
|
2016-01-11 03:44:04 -06:00
|
|
|
|
|
|
|
Pinned bool `json:"-"`
|
|
|
|
Enabled bool `json:"-"`
|
2016-01-09 16:34:20 -06:00
|
|
|
}
|
|
|
|
|
2016-01-12 03:20:04 -06:00
|
|
|
func (app *AppPlugin) Load(decoder *json.Decoder, pluginDir string) error {
|
|
|
|
if err := decoder.Decode(&app); err != nil {
|
2016-01-09 16:34:20 -06:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-01-12 03:20:04 -06:00
|
|
|
if app.Css != nil {
|
|
|
|
app.Css.Dark = evalRelativePluginUrlPath(app.Css.Dark, app.Id)
|
|
|
|
app.Css.Light = evalRelativePluginUrlPath(app.Css.Light, app.Id)
|
|
|
|
}
|
|
|
|
|
|
|
|
app.PluginDir = pluginDir
|
|
|
|
app.initFrontendPlugin()
|
|
|
|
Apps[app.Id] = app
|
2016-01-09 16:34:20 -06:00
|
|
|
return nil
|
|
|
|
}
|