diff --git a/public/app/features/dashboard/dashboard_srv.ts b/public/app/features/dashboard/dashboard_srv.ts
index 1890323da29..b1419df7376 100644
--- a/public/app/features/dashboard/dashboard_srv.ts
+++ b/public/app/features/dashboard/dashboard_srv.ts
@@ -100,7 +100,7 @@ export class DashboardSrv {
.catch(this.handleSaveDashboardError.bind(this, clone, options));
}
- saveDashboard(options, clone) {
+ saveDashboard(options?, clone?) {
if (clone) {
this.setCurrent(this.create(clone, this.dash.meta));
}
@@ -124,6 +124,10 @@ export class DashboardSrv {
return this.save(this.dash.getSaveModelClone(), options);
}
+ saveJSONDashboard(json: string) {
+ return this.save(JSON.parse(json), {});
+ }
+
showDashboardProvisionedModal() {
this.$rootScope.appEvent('show-modal', {
templateHtml: '',
diff --git a/public/app/features/dashboard/settings/settings.html b/public/app/features/dashboard/settings/settings.html
index 5103fab8b75..46d84a7a2fd 100644
--- a/public/app/features/dashboard/settings/settings.html
+++ b/public/app/features/dashboard/settings/settings.html
@@ -87,12 +87,22 @@
-
-
+
+
+
+
+
+
+
diff --git a/public/app/features/dashboard/settings/settings.ts b/public/app/features/dashboard/settings/settings.ts
index 68fd20a3b91..5acbbcf29c5 100755
--- a/public/app/features/dashboard/settings/settings.ts
+++ b/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: 'JSON Model',
+ id: 'dashboard_json',
icon: 'gicon gicon-json',
});
@@ -137,6 +144,12 @@ export class SettingsCtrl {
this.dashboardSrv.saveDashboard();
}
+ saveDashboardJson() {
+ this.dashboardSrv.saveJSONDashboard(this.json).then(() => {
+ this.$route.reload();
+ });
+ }
+
onPostSave() {
this.hasUnsavedFolderChange = false;
}
diff --git a/public/sass/components/_dashboard_settings.scss b/public/sass/components/_dashboard_settings.scss
index 2c709f1ddf9..5e17e025196 100644
--- a/public/sass/components/_dashboard_settings.scss
+++ b/public/sass/components/_dashboard_settings.scss
@@ -53,6 +53,13 @@
margin-bottom: $spacer*2;
}
+.dashboard-settings__subheader {
+ color: $text-muted;
+ font-style: italic;
+ position: relative;
+ top: -1.5rem;
+}
+
.dashboard-settings__nav-item {
padding: 7px 12px;
color: $text-color;
@@ -85,3 +92,7 @@
margin-bottom: 10px;
}
}
+
+.dashboard-settings__json-save-button {
+ margin-top: $spacer;
+}