Browse Source

fix: refactoring PR #11996 and fixing issue #11551 16706hashkey in json editors

Torkel Ödegaard 7 years ago
parent
commit
be34417b3a

+ 4 - 0
public/app/features/annotations/editor_ctrl.ts

@@ -70,6 +70,10 @@ export class AnnotationsEditorCtrl {
     this.mode = 'list';
   }
 
+  move(index, dir) {
+    _.move(this.annotations, index, index + dir);
+  }
+
   add() {
     this.annotations.push(this.currentAnnotation);
     this.reset();

+ 2 - 2
public/app/features/annotations/partials/editor.html

@@ -33,8 +33,8 @@
 					<td class="pointer" ng-click="ctrl.edit(annotation)">
 						{{annotation.datasource || 'Default'}}
 					</td>
-					<td style="width: 1%"><i ng-click="_.move(ctrl.annotations,$index,$index-1)" ng-hide="$first" class="pointer fa fa-arrow-up"></i></td>
-					<td style="width: 1%"><i ng-click="_.move(ctrl.annotations,$index,$index+1)" ng-hide="$last" class="pointer fa fa-arrow-down"></i></td>
+					<td style="width: 1%"><i ng-click="ctrl.move($index,-1)" ng-hide="$first" class="pointer fa fa-arrow-up"></i></td>
+					<td style="width: 1%"><i ng-click="ctrl.move($index,1)" ng-hide="$last" class="pointer fa fa-arrow-down"></i></td>
 					<td style="width: 1%">
 						<a ng-click="ctrl.removeAnnotation(annotation)" class="btn btn-danger btn-mini" ng-hide="annotation.builtIn">
 							<i class="fa fa-remove"></i>

+ 1 - 1
public/app/features/dashboard/save_provisioned_modal.ts

@@ -48,7 +48,7 @@ export class SaveProvisionedDashboardModalCtrl {
   constructor(dashboardSrv) {
     this.dash = dashboardSrv.getCurrent().getSaveModelClone();
     delete this.dash.id;
-    this.dashboardJson = JSON.stringify(this.dash, null, 2);
+    this.dashboardJson = angular.toJson(this.dash, true);
   }
 
   save() {

+ 2 - 1
public/app/features/dashboard/settings/settings.ts

@@ -2,6 +2,7 @@ import { coreModule, appEvents, contextSrv } from 'app/core/core';
 import { DashboardModel } from '../dashboard_model';
 import $ from 'jquery';
 import _ from 'lodash';
+import angular from 'angular';
 import config from 'app/core/config';
 
 export class SettingsCtrl {
@@ -118,7 +119,7 @@ export class SettingsCtrl {
     this.viewId = this.$location.search().editview;
 
     if (this.viewId) {
-      this.json = JSON.stringify(this.dashboard.getSaveModelClone(), null, 2);
+      this.json = angular.toJson(this.dashboard.getSaveModelClone(), true);
     }
 
     if (this.viewId === 'settings' && this.dashboard.meta.canMakeEditable) {