app_plugin.go 710 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package plugins
  2. import (
  3. "encoding/json"
  4. "github.com/grafana/grafana/pkg/models"
  5. )
  6. type AppPluginPage struct {
  7. Text string `json:"text"`
  8. Url string `json:"url"`
  9. ReqRole models.RoleType `json:"reqRole"`
  10. }
  11. type AppPluginCss struct {
  12. Light string `json:"light"`
  13. Dark string `json:"dark"`
  14. }
  15. type AppPlugin struct {
  16. FrontendPluginBase
  17. Css *AppPluginCss `json:"css"`
  18. Page []*AppPluginPage `json:"page"`
  19. Pinned bool `json:"-"`
  20. Enabled bool `json:"-"`
  21. }
  22. func (p *AppPlugin) Load(decoder *json.Decoder, pluginDir string) error {
  23. if err := decoder.Decode(&p); err != nil {
  24. return err
  25. }
  26. p.PluginDir = pluginDir
  27. p.initFrontendPlugin()
  28. Apps[p.Id] = p
  29. return nil
  30. }