Merge pull request #3795 from raintank/apiPlugin

get apiPlugins working again.
This commit is contained in:
Torkel Ödegaard 2016-01-20 07:42:36 +01:00
commit f30df8bb57
2 changed files with 30 additions and 16 deletions

30
pkg/plugins/api_plugin.go Normal file
View File

@ -0,0 +1,30 @@
package plugins
import (
"encoding/json"
"github.com/grafana/grafana/pkg/models"
)
type ApiPluginRoute struct {
Path string `json:"path"`
Method string `json:"method"`
ReqSignedIn bool `json:"reqSignedIn"`
ReqGrafanaAdmin bool `json:"reqGrafanaAdmin"`
ReqRole models.RoleType `json:"reqRole"`
Url string `json:"url"`
}
type ApiPlugin struct {
PluginBase
Routes []*ApiPluginRoute `json:"routes"`
}
func (app *ApiPlugin) Load(decoder *json.Decoder, pluginDir string) error {
if err := decoder.Decode(&app); err != nil {
return err
}
ApiPlugins[app.Id] = app
return nil
}

View File

@ -2,8 +2,6 @@ package plugins
import ( import (
"encoding/json" "encoding/json"
"github.com/grafana/grafana/pkg/models"
) )
type PluginLoader interface { type PluginLoader interface {
@ -44,20 +42,6 @@ type PluginStaticRoute struct {
PluginId string PluginId string
} }
type ApiPluginRoute struct {
Path string `json:"path"`
Method string `json:"method"`
ReqSignedIn bool `json:"reqSignedIn"`
ReqGrafanaAdmin bool `json:"reqGrafanaAdmin"`
ReqRole models.RoleType `json:"reqRole"`
Url string `json:"url"`
}
type ApiPlugin struct {
PluginBase
Routes []*ApiPluginRoute `json:"routes"`
}
type EnabledPlugins struct { type EnabledPlugins struct {
Panels []*PanelPlugin Panels []*PanelPlugin
DataSources map[string]*DataSourcePlugin DataSources map[string]*DataSourcePlugin