merge apiPlugins with appPlugins

This commit is contained in:
Anthony Woods
2016-01-22 01:15:04 +08:00
parent 28fabadeae
commit f94599cd29
7 changed files with 33 additions and 84 deletions

View File

@ -26,14 +26,30 @@ type AppIncludeInfo struct {
type AppPlugin struct {
FrontendPluginBase
Css *AppPluginCss `json:"css"`
Pages []AppPluginPage `json:"pages"`
Includes []AppIncludeInfo `json:"-"`
Css *AppPluginCss `json:"css"`
Pages []AppPluginPage `json:"pages"`
Routes []*AppPluginRoute `json:"routes"`
Includes []AppIncludeInfo `json:"-"`
Pinned bool `json:"-"`
Enabled bool `json:"-"`
}
type AppPluginRoute 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"`
Headers []AppPluginRouteHeader `json:"headers"`
}
type AppPluginRouteHeader struct {
Name string `json:"name"`
Content string `json:"content"`
}
func (app *AppPlugin) Load(decoder *json.Decoder, pluginDir string) error {
if err := decoder.Decode(&app); err != nil {
return err
@ -59,18 +75,6 @@ func (app *AppPlugin) Load(decoder *json.Decoder, pluginDir string) error {
}
}
// check if we have child apiPlugins
for _, plugin := range ApiPlugins {
if strings.HasPrefix(plugin.PluginDir, app.PluginDir) {
plugin.IncludedInAppId = app.Id
app.Includes = append(app.Includes, AppIncludeInfo{
Name: plugin.Name,
Id: plugin.Id,
Type: plugin.Type,
})
}
}
Apps[app.Id] = app
return nil
}