Commit be34417b by Torkel Ödegaard

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

parent 634a26d2
...@@ -70,6 +70,10 @@ export class AnnotationsEditorCtrl { ...@@ -70,6 +70,10 @@ export class AnnotationsEditorCtrl {
this.mode = 'list'; this.mode = 'list';
} }
move(index, dir) {
_.move(this.annotations, index, index + dir);
}
add() { add() {
this.annotations.push(this.currentAnnotation); this.annotations.push(this.currentAnnotation);
this.reset(); this.reset();
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
<td class="pointer" ng-click="ctrl.edit(annotation)"> <td class="pointer" ng-click="ctrl.edit(annotation)">
{{annotation.datasource || 'Default'}} {{annotation.datasource || 'Default'}}
</td> </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="ctrl.move($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="$last" class="pointer fa fa-arrow-down"></i></td>
<td style="width: 1%"> <td style="width: 1%">
<a ng-click="ctrl.removeAnnotation(annotation)" class="btn btn-danger btn-mini" ng-hide="annotation.builtIn"> <a ng-click="ctrl.removeAnnotation(annotation)" class="btn btn-danger btn-mini" ng-hide="annotation.builtIn">
<i class="fa fa-remove"></i> <i class="fa fa-remove"></i>
......
...@@ -48,7 +48,7 @@ export class SaveProvisionedDashboardModalCtrl { ...@@ -48,7 +48,7 @@ export class SaveProvisionedDashboardModalCtrl {
constructor(dashboardSrv) { constructor(dashboardSrv) {
this.dash = dashboardSrv.getCurrent().getSaveModelClone(); this.dash = dashboardSrv.getCurrent().getSaveModelClone();
delete this.dash.id; delete this.dash.id;
this.dashboardJson = JSON.stringify(this.dash, null, 2); this.dashboardJson = angular.toJson(this.dash, true);
} }
save() { save() {
......
...@@ -2,6 +2,7 @@ import { coreModule, appEvents, contextSrv } from 'app/core/core'; ...@@ -2,6 +2,7 @@ import { coreModule, appEvents, contextSrv } from 'app/core/core';
import { DashboardModel } from '../dashboard_model'; import { DashboardModel } from '../dashboard_model';
import $ from 'jquery'; import $ from 'jquery';
import _ from 'lodash'; import _ from 'lodash';
import angular from 'angular';
import config from 'app/core/config'; import config from 'app/core/config';
export class SettingsCtrl { export class SettingsCtrl {
...@@ -118,7 +119,7 @@ export class SettingsCtrl { ...@@ -118,7 +119,7 @@ export class SettingsCtrl {
this.viewId = this.$location.search().editview; this.viewId = this.$location.search().editview;
if (this.viewId) { 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) { if (this.viewId === 'settings' && this.dashboard.meta.canMakeEditable) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment