feat(external plugins): worked on supporting external plugins better
This commit is contained in:
@@ -2,14 +2,15 @@ package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
|
||||
"github.com/Unknwon/macaron"
|
||||
"github.com/grafana/grafana/pkg/log"
|
||||
"github.com/grafana/grafana/pkg/middleware"
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
func InitExternalPluginRoutes(r *macaron.Macaron) {
|
||||
@@ -31,10 +32,10 @@ func InitExternalPluginRoutes(r *macaron.Macaron) {
|
||||
}
|
||||
*/
|
||||
for _, plugin := range plugins.ExternalPlugins {
|
||||
log.Info("adding routes for external plugin")
|
||||
for _, route := range plugin.Settings.Routes {
|
||||
log.Info("adding route %s /plugins%s", route.Method, route.Path)
|
||||
r.Route(util.JoinUrlFragments("/plugins/", route.Path), route.Method, ExternalPlugin(route.Url))
|
||||
log.Info("Plugin: Adding proxy routes for backend plugin")
|
||||
for _, route := range plugin.Routes {
|
||||
log.Info("Plugin: Adding route %s /api/plugin-proxy/%s", route.Method, route.Path)
|
||||
r.Route(util.JoinUrlFragments("/api/plugin-proxy/", route.Path), route.Method, ExternalPlugin(route.Url))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-5
@@ -57,16 +57,15 @@ func setIndexViewData(c *middleware.Context) error {
|
||||
externalPluginCss := make([]string, 0)
|
||||
externalPluginMenu := make([]*plugins.ExternalPluginMenuItem, 0)
|
||||
for _, plugin := range plugins.ExternalPlugins {
|
||||
for _, js := range plugin.Settings.Js {
|
||||
externalPluginJs = append(externalPluginJs, js.Src)
|
||||
for _, js := range plugin.Js {
|
||||
externalPluginJs = append(externalPluginJs, js.Module)
|
||||
}
|
||||
for _, css := range plugin.Settings.Css {
|
||||
for _, css := range plugin.Css {
|
||||
externalPluginCss = append(externalPluginCss, css.Href)
|
||||
}
|
||||
for _, item := range plugin.Settings.MenuItems {
|
||||
for _, item := range plugin.MenuItems {
|
||||
externalPluginMenu = append(externalPluginMenu, item)
|
||||
}
|
||||
|
||||
}
|
||||
c.Data["ExternalPluginJs"] = externalPluginJs
|
||||
c.Data["ExternalPluginCss"] = externalPluginCss
|
||||
|
||||
Reference in New Issue
Block a user