From abeaef71ccdfc3712da54f79e5fecb65eb3d5941 Mon Sep 17 00:00:00 2001 From: Daniel Lee Date: Wed, 30 Aug 2017 09:56:49 +0200 Subject: [PATCH] DashExport: fix View JSON in export menu ref #9002 --- .../features/dashboard/export/export_modal.ts | 18 +++++++++++------- .../dashboard/partials/shareModal.html | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/public/app/features/dashboard/export/export_modal.ts b/public/app/features/dashboard/export/export_modal.ts index c334818b3e7..6c76b7e824f 100644 --- a/public/app/features/dashboard/export/export_modal.ts +++ b/public/app/features/dashboard/export/export_modal.ts @@ -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: "&"} }; } diff --git a/public/app/features/dashboard/partials/shareModal.html b/public/app/features/dashboard/partials/shareModal.html index 382baec1aba..36dacfad9d8 100644 --- a/public/app/features/dashboard/partials/shareModal.html +++ b/public/app/features/dashboard/partials/shareModal.html @@ -47,7 +47,7 @@