DashExport: fix View JSON in export menu

ref #9002
This commit is contained in:
Daniel Lee 2017-08-30 09:56:49 +02:00
parent 54129b1340
commit abeaef71cc
2 changed files with 12 additions and 8 deletions

View File

@ -12,13 +12,14 @@ import {DashboardExporter} from './exporter';
export class DashExportCtrl {
dash: any;
exporter: DashboardExporter;
dismiss: () => void;
/** @ngInject */
constructor(private backendSrv, dashboardSrv, datasourceSrv, $scope) {
constructor(private backendSrv, private dashboardSrv, datasourceSrv, private $scope) {
this.exporter = new DashboardExporter(datasourceSrv);
this.exporter.makeExportable(dashboardSrv.getCurrent()).then(dash => {
$scope.$apply(() => {
this.exporter.makeExportable(this.dashboardSrv.getCurrent()).then(dash => {
this.$scope.$apply(() => {
this.dash = dash;
});
});
@ -31,11 +32,13 @@ export class DashExportCtrl {
}
saveJson() {
var html = angular.toJson(this.dash, true);
var uri = "data:application/json," + encodeURIComponent(html);
var newWindow = window.open(uri);
}
var clone = this.dashboardSrv.getCurrent().getSaveModelClone();
this.$scope.$root.appEvent('show-json-editor', {
object: clone,
});
this.dismiss();
}
}
export function dashExportDirective() {
@ -45,6 +48,7 @@ export function dashExportDirective() {
controller: DashExportCtrl,
bindToController: true,
controllerAs: 'ctrl',
scope: {dismiss: "&"}
};
}

View File

@ -47,7 +47,7 @@
</script>
<script type="text/ng-template" id="shareExport.html">
<dash-export-modal></dash-export-modal>
<dash-export-modal dismiss="dismiss()"></dash-export-modal>
</script>
<script type="text/ng-template" id="shareLinkOptions.html">