From 135679096be4db01b793e4c8fe4acbf97fae06cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 7 Mar 2016 14:31:02 +0100 Subject: [PATCH] feat(plugins): progress on plugin details page, # 4275 --- examples/nginx-app/plugin.json | 2 +- pkg/api/dtos/plugins.go | 23 +++++++------ pkg/api/plugin_setting.go | 9 ++--- pkg/cmd/grafana-server/main.go | 2 +- pkg/plugins/frontend_plugin.go | 8 ++--- pkg/plugins/models.go | 21 +++++++++--- .../features/dashboard/partials/settings.html | 1 - public/app/features/plugins/edit_ctrl.ts | 16 ++++++++- .../app/features/plugins/partials/edit.html | 32 +++++++++++++++--- public/app/partials/unsaved-changes.html | 2 +- .../elasticsearch/img/logo_large.png | Bin 0 -> 40972 bytes .../datasource/elasticsearch/plugin.json | 18 +++++++++- public/sass/layout/_page.scss | 2 -- public/sass/pages/_plugins.scss | 8 ++++- 14 files changed, 107 insertions(+), 37 deletions(-) create mode 100644 public/app/plugins/datasource/elasticsearch/img/logo_large.png diff --git a/examples/nginx-app/plugin.json b/examples/nginx-app/plugin.json index 7e3cdd7ad08..4e0c4a114fa 100644 --- a/examples/nginx-app/plugin.json +++ b/examples/nginx-app/plugin.json @@ -35,7 +35,7 @@ }, "dependencies": { - "grafanaVersion": "2.6.x", + "grafanaVersion": "3.x.x", "plugins": [ {"type": "datasource", "id": "graphite", "name": "Graphite", "version": "1.0.0"}, {"type": "panel", "id": "graph", "name": "Graph", "version": "1.0.0"} diff --git a/pkg/api/dtos/plugins.go b/pkg/api/dtos/plugins.go index af96202222f..20b976af122 100644 --- a/pkg/api/dtos/plugins.go +++ b/pkg/api/dtos/plugins.go @@ -3,17 +3,18 @@ package dtos import "github.com/grafana/grafana/pkg/plugins" type PluginSetting struct { - Name string `json:"name"` - Type string `json:"type"` - PluginId string `json:"pluginId"` - Enabled bool `json:"enabled"` - Pinned bool `json:"pinned"` - Module string `json:"module"` - BaseUrl string `json:"baseUrl"` - Info *plugins.PluginInfo `json:"info"` - Pages []*plugins.AppPluginPage `json:"pages"` - Includes []*plugins.AppIncludeInfo `json:"includes"` - JsonData map[string]interface{} `json:"jsonData"` + Name string `json:"name"` + Type string `json:"type"` + PluginId string `json:"pluginId"` + Enabled bool `json:"enabled"` + Pinned bool `json:"pinned"` + Module string `json:"module"` + BaseUrl string `json:"baseUrl"` + Info *plugins.PluginInfo `json:"info"` + Pages []*plugins.AppPluginPage `json:"pages"` + Includes []*plugins.AppIncludeInfo `json:"includes"` + Dependencies *plugins.PluginDependencies `json:"dependencies"` + JsonData map[string]interface{} `json:"jsonData"` } type PluginListItem struct { diff --git a/pkg/api/plugin_setting.go b/pkg/api/plugin_setting.go index 08fc5296434..4509cc00c35 100644 --- a/pkg/api/plugin_setting.go +++ b/pkg/api/plugin_setting.go @@ -42,10 +42,11 @@ func GetPluginSettingById(c *middleware.Context) Response { return ApiError(404, "Plugin not found, no installed plugin with that id", nil) } else { dto := &dtos.PluginSetting{ - Type: def.Type, - PluginId: def.Id, - Name: def.Name, - Info: &def.Info, + Type: def.Type, + PluginId: def.Id, + Name: def.Name, + Info: &def.Info, + Dependencies: &def.Dependencies, } if app, exists := plugins.Apps[pluginId]; exists { diff --git a/pkg/cmd/grafana-server/main.go b/pkg/cmd/grafana-server/main.go index d78b8f700ff..dad3f437390 100644 --- a/pkg/cmd/grafana-server/main.go +++ b/pkg/cmd/grafana-server/main.go @@ -24,7 +24,7 @@ import ( "github.com/grafana/grafana/pkg/social" ) -var version = "master" +var version = "3.0.0-pre1" var commit = "NA" var buildstamp string var build_date string diff --git a/pkg/plugins/frontend_plugin.go b/pkg/plugins/frontend_plugin.go index 5acb9966495..d09342c84bb 100644 --- a/pkg/plugins/frontend_plugin.go +++ b/pkg/plugins/frontend_plugin.go @@ -28,8 +28,8 @@ func (fp *FrontendPluginBase) initFrontendPlugin() { fp.handleModuleDefaults() - fp.Info.Logos.Small = evalRelativePluginUrlPath(fp.Info.Logos.Small, fp.Id) - fp.Info.Logos.Large = evalRelativePluginUrlPath(fp.Info.Logos.Large, fp.Id) + fp.Info.Logos.Small = evalRelativePluginUrlPath(fp.Info.Logos.Small, fp.BaseUrl) + fp.Info.Logos.Large = evalRelativePluginUrlPath(fp.Info.Logos.Large, fp.BaseUrl) for i := 0; i < len(fp.Info.Screenshots); i++ { fp.Info.Screenshots[i].Path = evalRelativePluginUrlPath(fp.Info.Screenshots[i].Path, fp.Id) @@ -55,7 +55,7 @@ func (fp *FrontendPluginBase) handleModuleDefaults() { fp.BaseUrl = path.Join("public/app/plugins", fp.Type, fp.Id) } -func evalRelativePluginUrlPath(pathStr string, pluginId string) string { +func evalRelativePluginUrlPath(pathStr string, baseUrl string) string { if pathStr == "" { return "" } @@ -64,5 +64,5 @@ func evalRelativePluginUrlPath(pathStr string, pluginId string) string { if u.IsAbs() { return pathStr } - return path.Join("public/plugins", pluginId, pathStr) + return path.Join(baseUrl, pathStr) } diff --git a/pkg/plugins/models.go b/pkg/plugins/models.go index 83f43c1f544..26620a45fea 100644 --- a/pkg/plugins/models.go +++ b/pkg/plugins/models.go @@ -14,10 +14,11 @@ type PluginLoader interface { } type PluginBase struct { - Type string `json:"type"` - Name string `json:"name"` - Id string `json:"id"` - Info PluginInfo `json:"info"` + Type string `json:"type"` + Name string `json:"name"` + Id string `json:"id"` + Info PluginInfo `json:"info"` + Dependencies PluginDependencies `json:"dependencies"` IncludedInAppId string `json:"-"` PluginDir string `json:"-"` @@ -37,6 +38,18 @@ func (pb *PluginBase) registerPlugin(pluginDir string) error { return nil } +type PluginDependencies struct { + GrafanaVersion string `json:"grafanaVersion"` + Plugins []PluginDependencyItem `json:"plugins"` +} + +type PluginDependencyItem struct { + Type string `json:"type"` + Id string `json:"id"` + Name string `json:"name"` + Version string `json:"version"` +} + type PluginInfo struct { Author PluginInfoLink `json:"author"` Description string `json:"description"` diff --git a/public/app/features/dashboard/partials/settings.html b/public/app/features/dashboard/partials/settings.html index 8fd2b34ae5a..deccd22305b 100644 --- a/public/app/features/dashboard/partials/settings.html +++ b/public/app/features/dashboard/partials/settings.html @@ -19,7 +19,6 @@
-
Dashboard Detail
diff --git a/public/app/features/plugins/edit_ctrl.ts b/public/app/features/plugins/edit_ctrl.ts index 6d693c19a4e..5a0e565f3db 100644 --- a/public/app/features/plugins/edit_ctrl.ts +++ b/public/app/features/plugins/edit_ctrl.ts @@ -5,6 +5,7 @@ import _ from 'lodash'; export class PluginEditCtrl { model: any; + pluginIcon: string; pluginId: any; includedPanels: any; includedDatasources: any; @@ -22,9 +23,22 @@ export class PluginEditCtrl { this.model = result; this.includedPanels = _.where(result.includes, {type: 'panel'}); this.includedDatasources = _.where(result.includes, {type: 'datasource'}); + this.pluginIcon = this.getPluginIcon(this.model.type); + + this.model.dependencies.plugins.forEach(plug => { + plug.icon = this.getPluginIcon(plug.type); + }); }); } + getPluginIcon(type) { + switch (type) { + case 'datasource': return 'icon-gf icon-gf-datasources'; + case 'panel': return 'icon-gf icon-gf-panel'; + case 'app': return 'icon-gf icon-gf-apps'; + } + } + update() { var chain = Promise.resolve(); var self = this; @@ -53,7 +67,7 @@ export class PluginEditCtrl { // if set, performt he postUpdate hook. If a promise is returned it will block // the final step of the update procedure (reloading the page) until the promise - // resolves. If the promise is rejected the page will not be reloaded. + // resolves. If the promise is rejected the page will not be reloaded. if (this.postUpdateHook != null) { chain = chain.then(function() { return Promise.resolve(this.postUpdateHook()); diff --git a/public/app/features/plugins/partials/edit.html b/public/app/features/plugins/partials/edit.html index 815e165cc85..70bc3af4a93 100644 --- a/public/app/features/plugins/partials/edit.html +++ b/public/app/features/plugins/partials/edit.html @@ -1,7 +1,6 @@ - - Apps + Plugin details @@ -15,7 +14,7 @@
By {{ctrl.model.info.author.name}}
- {{ctrl.model.type}} + {{ctrl.model.type}}
@@ -59,7 +58,7 @@