Andrzej Ressel hace 7 años
padre
commit
bff174dba9

+ 6 - 2
public/app/features/dashboard/settings/settings.html

@@ -87,12 +87,16 @@
 	<gf-dashboard-history dashboard="dashboard"></gf-dashboard-history>
 </div>
 
-<div class="dashboard-settings__content" ng-if="ctrl.viewId === 'view_json'" >
-	<h3 class="dashboard-settings__header">View JSON</h3>
+<div class="dashboard-settings__content" ng-if="ctrl.viewId === 'dashboard_json'" >
+	<h3 class="dashboard-settings__header">Dashboard JSON</h3>
 
 	<div class="gf-form">
 		<code-editor content="ctrl.json" data-mode="json" data-max-lines=30 ></code-editor>
 	</div>
+
+	<button class="btn btn-success dashboard-settings__json-save-button" ng-click="ctrl.saveDashboardJson()" ng-show="ctrl.canSave">
+		<i class="fa fa-save"></i> Save JSON
+	</button>
 </div>
 
 <div class="dashboard-settings__content" ng-if="ctrl.viewId === 'permissions'" >

+ 17 - 10
public/app/features/dashboard/settings/settings.ts

@@ -17,7 +17,14 @@ export class SettingsCtrl {
   hasUnsavedFolderChange: boolean;
 
   /** @ngInject */
-  constructor(private $scope, private $location, private $rootScope, private backendSrv, private dashboardSrv) {
+  constructor(
+    private $scope,
+    private $route,
+    private $location,
+    private $rootScope,
+    private backendSrv,
+    private dashboardSrv
+  ) {
     // temp hack for annotations and variables editors
     // that rely on inherited scope
     $scope.dashboard = this.dashboard;
@@ -93,8 +100,8 @@ export class SettingsCtrl {
     }
 
     this.sections.push({
-      title: 'View JSON',
-      id: 'view_json',
+      title: 'Dashboard JSON',
+      id: 'dashboard_json',
       icon: 'gicon gicon-json',
     });
 
@@ -134,13 +141,13 @@ export class SettingsCtrl {
   }
 
   saveDashboard() {
-    if (this.viewId === 'view_json') {
-      this.dashboardSrv.saveJSONDashboard(this.json).then(() => {
-        window.location.reload();
-      });
-    } else {
-      this.dashboardSrv.saveDashboard();
-    }
+    this.dashboardSrv.saveDashboard();
+  }
+
+  saveDashboardJson() {
+    this.dashboardSrv.saveJSONDashboard(this.json).then(() => {
+      this.$route.reload();
+    });
   }
 
   onPostSave() {

+ 4 - 0
public/sass/components/_dashboard_settings.scss

@@ -80,3 +80,7 @@
     margin-bottom: 10px;
   }
 }
+
+.dashboard-settings__json-save-button {
+  margin-top: $spacer;
+}