From 17adb58d803008562faaaa6ff51546816154e773 Mon Sep 17 00:00:00 2001 From: bergquist Date: Mon, 5 Nov 2018 17:32:28 +0100 Subject: [PATCH 1/3] export: provide more help regarding export format this will provide the user with more info about the export format and default to not use the format for sharing on grafana.com etc. ref #13781 --- .../dashboard/export/export_modal.html | 12 +++++- .../features/dashboard/export/export_modal.ts | 40 ++++++++++++++----- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/public/app/features/dashboard/export/export_modal.html b/public/app/features/dashboard/export/export_modal.html index 0598c612fd6..3505e50b821 100644 --- a/public/app/features/dashboard/export/export_modal.html +++ b/public/app/features/dashboard/export/export_modal.html @@ -15,11 +15,19 @@ You can share dashboards on Grafana.com

+ + +
- - Cancel diff --git a/public/app/features/dashboard/export/export_modal.ts b/public/app/features/dashboard/export/export_modal.ts index f99946915d6..08a79702ed5 100644 --- a/public/app/features/dashboard/export/export_modal.ts +++ b/public/app/features/dashboard/export/export_modal.ts @@ -8,27 +8,47 @@ export class DashExportCtrl { dash: any; exporter: DashboardExporter; dismiss: () => void; + shareExternally: boolean; /** @ngInject */ constructor(private dashboardSrv, datasourceSrv, private $scope, private $rootScope) { this.exporter = new DashboardExporter(datasourceSrv); - this.exporter.makeExportable(this.dashboardSrv.getCurrent()).then(dash => { - this.$scope.$apply(() => { - this.dash = dash; - }); - }); + this.dash = this.dashboardSrv.getCurrent(); } - save() { - const blob = new Blob([angular.toJson(this.dash, true)], { + saveDashboardAsFile() { + if (this.shareExternally) { + this.exporter.makeExportable(this.dash).then((dashboardJson: any) => { + this.$scope.$apply(() => { + this._saveFile(dashboardJson); + }); + }); + } else { + this._saveFile(this.dash.getSaveModelClone()); + } + } + + viewJson() { + if (this.shareExternally) { + this.exporter.makeExportable(this.dash).then((dashboardJson: any) => { + this.$scope.$apply(() => { + this._viewJson(dashboardJson); + }); + }); + } else { + this._viewJson(this.dash.getSaveModelClone()); + } + } + + _saveFile(dash: any) { + const blob = new Blob([angular.toJson(dash, true)], { type: 'application/json;charset=utf-8', }); - saveAs(blob, this.dash.title + '-' + new Date().getTime() + '.json'); + saveAs(blob, dash.title + '-' + new Date().getTime() + '.json'); } - saveJson() { - const clone = this.dash; + _viewJson(clone: any) { const editScope = this.$rootScope.$new(); editScope.object = clone; editScope.enableCopy = true; From 7bde98aff9789c071bb3221d50ffe17798e371bb Mon Sep 17 00:00:00 2001 From: bergquist Date: Tue, 6 Nov 2018 09:00:17 +0100 Subject: [PATCH 2/3] rename and mark functions as private --- public/app/features/dashboard/export/export_modal.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/public/app/features/dashboard/export/export_modal.ts b/public/app/features/dashboard/export/export_modal.ts index 08a79702ed5..0e48041ca87 100644 --- a/public/app/features/dashboard/export/export_modal.ts +++ b/public/app/features/dashboard/export/export_modal.ts @@ -21,11 +21,11 @@ export class DashExportCtrl { if (this.shareExternally) { this.exporter.makeExportable(this.dash).then((dashboardJson: any) => { this.$scope.$apply(() => { - this._saveFile(dashboardJson); + this.openSaveAsDialog(dashboardJson); }); }); } else { - this._saveFile(this.dash.getSaveModelClone()); + this.openSaveAsDialog(this.dash.getSaveModelClone()); } } @@ -33,22 +33,22 @@ export class DashExportCtrl { if (this.shareExternally) { this.exporter.makeExportable(this.dash).then((dashboardJson: any) => { this.$scope.$apply(() => { - this._viewJson(dashboardJson); + this.openJsonModal(dashboardJson); }); }); } else { - this._viewJson(this.dash.getSaveModelClone()); + this.openJsonModal(this.dash.getSaveModelClone()); } } - _saveFile(dash: any) { + private openSaveAsDialog(dash: any) { const blob = new Blob([angular.toJson(dash, true)], { type: 'application/json;charset=utf-8', }); saveAs(blob, dash.title + '-' + new Date().getTime() + '.json'); } - _viewJson(clone: any) { + private openJsonModal(clone: any) { const editScope = this.$rootScope.$new(); editScope.object = clone; editScope.enableCopy = true; From c52e91ee6c17effe9c18f0324cacf68f2b118c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 7 Nov 2018 10:46:09 -0800 Subject: [PATCH 3/3] minor text change in export modal --- .../app/features/dashboard/export/export_modal.html | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/public/app/features/dashboard/export/export_modal.html b/public/app/features/dashboard/export/export_modal.html index 3505e50b821..3c14c4b184d 100644 --- a/public/app/features/dashboard/export/export_modal.html +++ b/public/app/features/dashboard/export/export_modal.html @@ -1,20 +1,8 @@ - - - - - -