app_plugin.go 781 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. Icon string `json:"icon"`
  9. Url string `json:"url"`
  10. ReqRole models.RoleType `json:"reqRole"`
  11. }
  12. type AppPluginCss struct {
  13. Light string `json:"light"`
  14. Dark string `json:"dark"`
  15. }
  16. type AppPlugin struct {
  17. FrontendPluginBase
  18. Enabled bool `json:"enabled"`
  19. Pinned bool `json:"pinned"`
  20. Css *AppPluginCss `json:"css"`
  21. Page *AppPluginPage `json:"page"`
  22. }
  23. func (p *AppPlugin) Load(decoder *json.Decoder, pluginDir string) error {
  24. if err := decoder.Decode(&p); err != nil {
  25. return err
  26. }
  27. p.PluginDir = pluginDir
  28. p.initFrontendPlugin()
  29. Apps[p.Id] = p
  30. return nil
  31. }