models.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package plugins
  2. import (
  3. "encoding/json"
  4. )
  5. type PluginLoader interface {
  6. Load(decoder *json.Decoder, pluginDir string) error
  7. }
  8. type PluginBase struct {
  9. Type string `json:"type"`
  10. Name string `json:"name"`
  11. Id string `json:"id"`
  12. Info PluginInfo `json:"info"`
  13. IncludedInAppId string `json:"-"`
  14. PluginDir string `json:"-"`
  15. }
  16. type PluginInfo struct {
  17. Author PluginInfoLink `json:"author"`
  18. Description string `json:"description"`
  19. Links []PluginInfoLink `json:"links"`
  20. Logos PluginLogos `json:"logos"`
  21. Version string `json:"version"`
  22. Updated string `json:"updated"`
  23. }
  24. type PluginInfoLink struct {
  25. Name string `json:"name"`
  26. Url string `json:"url"`
  27. }
  28. type PluginLogos struct {
  29. Small string `json:"small"`
  30. Large string `json:"large"`
  31. }
  32. type PluginStaticRoute struct {
  33. Directory string
  34. PluginId string
  35. }
  36. type EnabledPlugins struct {
  37. Panels []*PanelPlugin
  38. DataSources map[string]*DataSourcePlugin
  39. Apps []*AppPlugin
  40. }
  41. func NewEnabledPlugins() EnabledPlugins {
  42. return EnabledPlugins{
  43. Panels: make([]*PanelPlugin, 0),
  44. DataSources: make(map[string]*DataSourcePlugin),
  45. Apps: make([]*AppPlugin, 0),
  46. }
  47. }