From fe2e6b8a80800e3811af6286dac89e5c7ec6161b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 9 Feb 2016 18:37:08 +0100 Subject: [PATCH] feat(apps): began work on support for apps that contain data sources --- pkg/plugins/app_plugin.go | 13 +++++++++++++ public/app/features/apps/edit_ctrl.ts | 2 ++ public/app/features/apps/partials/edit.html | 5 ++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/pkg/plugins/app_plugin.go b/pkg/plugins/app_plugin.go index cb1349047da..b59eb47a939 100644 --- a/pkg/plugins/app_plugin.go +++ b/pkg/plugins/app_plugin.go @@ -77,6 +77,19 @@ func (app *AppPlugin) Load(decoder *json.Decoder, pluginDir string) error { } } + // check if we have child datasources + for _, ds := range DataSources { + if strings.HasPrefix(ds.PluginDir, app.PluginDir) { + ds.IncludedInAppId = app.Id + app.Includes = append(app.Includes, &AppIncludeInfo{ + Name: ds.Name, + Id: ds.Id, + Type: ds.Type, + }) + } + } + + // slugify pages for _, page := range app.Pages { if page.Slug == "" { page.Slug = slug.Make(page.Name) diff --git a/public/app/features/apps/edit_ctrl.ts b/public/app/features/apps/edit_ctrl.ts index fc87c53f7fd..1cb4dd269ef 100644 --- a/public/app/features/apps/edit_ctrl.ts +++ b/public/app/features/apps/edit_ctrl.ts @@ -7,6 +7,7 @@ export class AppEditCtrl { appModel: any; appId: any; includedPanels: any; + includedDatasources: any; /** @ngInject */ constructor(private backendSrv: any, private $routeParams: any) { @@ -16,6 +17,7 @@ export class AppEditCtrl { this.backendSrv.get(`/api/org/apps/${this.appId}/settings`).then(result => { this.appModel = result; this.includedPanels = _.where(result.includes, {type: 'panel'}); + this.includedDatasources = _.where(result.includes, {type: 'datasource'}); }); } diff --git a/public/app/features/apps/partials/edit.html b/public/app/features/apps/partials/edit.html index 5211ac27cf3..4a06d99f8ec 100644 --- a/public/app/features/apps/partials/edit.html +++ b/public/app/features/apps/partials/edit.html @@ -68,7 +68,10 @@ Datasources