Commit 79a8017f by Torkel Ödegaard

feat(export): more progress on dashboard export

parent db664c61
...@@ -16,6 +16,7 @@ export class DashboardExporter { ...@@ -16,6 +16,7 @@ export class DashboardExporter {
dynSrv.process(dash, {cleanUpOnly: true}); dynSrv.process(dash, {cleanUpOnly: true});
var inputs = []; var inputs = [];
var requires = {};
var datasources = {}; var datasources = {};
var promises = []; var promises = [];
...@@ -30,6 +31,13 @@ export class DashboardExporter { ...@@ -30,6 +31,13 @@ export class DashboardExporter {
pluginId: ds.meta.id, pluginId: ds.meta.id,
}; };
panel.datasource = '${' + refName +'}'; 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 { ...@@ -40,7 +48,13 @@ export class DashboardExporter {
inputs.push(value); inputs.push(value);
}); });
requires = _.map(requires, req => {
return req;
});
dash["__inputs"] = inputs; dash["__inputs"] = inputs;
dash["__requires"] = requires;
return dash; return dash;
}); });
} }
......
...@@ -2,7 +2,7 @@ import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/co ...@@ -2,7 +2,7 @@ import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/co
import {DashboardExporter} from '../exporter'; import {DashboardExporter} from '../exporter';
describe('given dashboard with repeated panels', function() { describe.only('given dashboard with repeated panels', function() {
var dash, exported; var dash, exported;
beforeEach((done) => { beforeEach((done) => {
...@@ -39,6 +39,7 @@ describe('given dashboard with repeated panels', function() { ...@@ -39,6 +39,7 @@ describe('given dashboard with repeated panels', function() {
exporter.makeExportable(dash).then(clean => { exporter.makeExportable(dash).then(clean => {
exported = clean; exported = clean;
done(); done();
console.log('done');
}); });
}); });
...@@ -56,5 +57,11 @@ describe('given dashboard with repeated panels', function() { ...@@ -56,5 +57,11 @@ describe('given dashboard with repeated panels', function() {
expect(panel.datasource).to.be("${DS_GFDB}"); 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");
});
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment