From 79a8017fe916698f1979e68d591ef2ef96bf1417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 10 May 2016 20:31:47 +0200 Subject: [PATCH] feat(export): more progress on dashboard export --- public/app/features/dashboard/exporter.ts | 14 ++++++++++++++ .../app/features/dashboard/specs/exporter_specs.ts | 9 ++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/public/app/features/dashboard/exporter.ts b/public/app/features/dashboard/exporter.ts index c1f5a13fd9b..8ed3f950c7f 100644 --- a/public/app/features/dashboard/exporter.ts +++ b/public/app/features/dashboard/exporter.ts @@ -16,6 +16,7 @@ export class DashboardExporter { dynSrv.process(dash, {cleanUpOnly: true}); var inputs = []; + var requires = {}; var datasources = {}; var promises = []; @@ -30,6 +31,13 @@ export class DashboardExporter { pluginId: ds.meta.id, }; panel.datasource = '${' + refName +'}'; + + requires['datasource' + ds.meta.id] = { + type: 'datasource', + id: ds.meta.id, + name: ds.meta.name, + version: ds.meta.info.version + }; })); } }); @@ -40,7 +48,13 @@ export class DashboardExporter { inputs.push(value); }); + requires = _.map(requires, req => { + return req; + }); + dash["__inputs"] = inputs; + dash["__requires"] = requires; + return dash; }); } diff --git a/public/app/features/dashboard/specs/exporter_specs.ts b/public/app/features/dashboard/specs/exporter_specs.ts index 190ad85743a..5b0576b729c 100644 --- a/public/app/features/dashboard/specs/exporter_specs.ts +++ b/public/app/features/dashboard/specs/exporter_specs.ts @@ -2,7 +2,7 @@ import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/co import {DashboardExporter} from '../exporter'; -describe('given dashboard with repeated panels', function() { +describe.only('given dashboard with repeated panels', function() { var dash, exported; beforeEach((done) => { @@ -39,6 +39,7 @@ describe('given dashboard with repeated panels', function() { exporter.makeExportable(dash).then(clean => { exported = clean; done(); + console.log('done'); }); }); @@ -56,5 +57,11 @@ describe('given dashboard with repeated panels', function() { expect(panel.datasource).to.be("${DS_GFDB}"); }); + it('should add datasource as input', function() { + expect(exported.__inputs[0].name).to.be("DS_GFDB"); + expect(exported.__inputs[0].pluginId).to.be("testdb"); + expect(exported.__inputs[0].type).to.be("datasource"); + }); + });