From c8ead22722a66bb447d811fb8c9d6f65d68c6dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 1 Dec 2017 21:04:48 +0100 Subject: [PATCH 01/89] started on dashboard settings refactor --- public/app/core/directives/dash_class.js | 4 ++ public/app/core/directives/dash_edit_link.js | 1 - public/app/features/dashboard/all.ts | 4 +- .../app/features/dashboard/dashnav/dashnav.ts | 2 - .../features/dashboard/settings/settings.html | 27 +++++++++++ .../features/dashboard/settings/settings.ts | 47 +++++++++++++++++++ .../features/dashboard/submenu/submenu.html | 1 - public/app/partials/dashboard.html | 6 +-- 8 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 public/app/features/dashboard/settings/settings.html create mode 100644 public/app/features/dashboard/settings/settings.ts diff --git a/public/app/core/directives/dash_class.js b/public/app/core/directives/dash_class.js index d8ad335de5c..b7323ea0161 100644 --- a/public/app/core/directives/dash_class.js +++ b/public/app/core/directives/dash_class.js @@ -34,6 +34,10 @@ function (_, $, coreModule) { $scope.$watch('ctrl.playlistSrv.isPlaying', function(newValue) { elem.toggleClass('playlist-active', newValue === true); }); + + $scope.$watch('ctrl.dashboardViewState.state.editView', function(newValue) { + elem.toggleClass('dashboard-settings-open', _.isString(newValue)); + }); } }; }); diff --git a/public/app/core/directives/dash_edit_link.js b/public/app/core/directives/dash_edit_link.js index 02c7d55b99e..f0dc6f59a6a 100644 --- a/public/app/core/directives/dash_edit_link.js +++ b/public/app/core/directives/dash_edit_link.js @@ -13,7 +13,6 @@ function ($, angular, coreModule, _) { 'templating': { src: 'public/app/features/templating/partials/editor.html'}, 'history': { html: ''}, 'timepicker': { src: 'public/app/features/dashboard/timepicker/dropdown.html' }, - 'add-panel': { html: '' }, 'import': { html: '', isModal: true }, 'permissions': { html: '', isModal: true }, 'new-folder': { diff --git a/public/app/features/dashboard/all.ts b/public/app/features/dashboard/all.ts index b4f1f4e77f0..ec99fcf098a 100644 --- a/public/app/features/dashboard/all.ts +++ b/public/app/features/dashboard/all.ts @@ -27,8 +27,8 @@ import './acl/acl'; import './folder_picker/picker'; import './folder_modal/folder'; import './move_to_folder_modal/move_to_folder'; +import './settings/settings'; + import coreModule from 'app/core/core_module'; - import {DashboardListCtrl} from './dashboard_list_ctrl'; - coreModule.controller('DashboardListCtrl', DashboardListCtrl); diff --git a/public/app/features/dashboard/dashnav/dashnav.ts b/public/app/features/dashboard/dashnav/dashnav.ts index 6985d27be5f..57f75b1388d 100644 --- a/public/app/features/dashboard/dashnav/dashnav.ts +++ b/public/app/features/dashboard/dashnav/dashnav.ts @@ -1,5 +1,3 @@ -/// - import _ from 'lodash'; import moment from 'moment'; import angular from 'angular'; diff --git a/public/app/features/dashboard/settings/settings.html b/public/app/features/dashboard/settings/settings.html new file mode 100644 index 00000000000..b2371960a26 --- /dev/null +++ b/public/app/features/dashboard/settings/settings.html @@ -0,0 +1,27 @@ +

Settings

+ +
+ + +
+ general +
+ +
+ annotations +
+ +
+ annotations +
+ +
+ diff --git a/public/app/features/dashboard/settings/settings.ts b/public/app/features/dashboard/settings/settings.ts new file mode 100644 index 00000000000..28065fb5916 --- /dev/null +++ b/public/app/features/dashboard/settings/settings.ts @@ -0,0 +1,47 @@ +import {coreModule, appEvents} from 'app/core/core'; +import {DashboardModel} from '../dashboard_model'; + +export class SettingsCtrl { + dashboard: DashboardModel; + isOpen: boolean; + viewId: string; + + sections: any[] = [ + {title: 'General', id: 'general'}, + {title: 'Annotations', id: 'annotations'}, + {title: 'Templating', id: 'templating'}, + {title: 'Versions', id: 'versions'}, + ]; + + /** @ngInject */ + constructor($scope, private $location, private $rootScope) { + appEvents.on('hide-dash-editor', this.hideSettings.bind(this), $scope); + + var urlParams = this.$location.search(); + this.viewId = urlParams.editview; + } + + hideSettings() { + var urlParams = this.$location.search(); + delete urlParams.editview; + setTimeout(() => { + this.$rootScope.$apply(() => { + this.$location.search(urlParams); + }); + }); + } +} + +export function dashboardSettings() { + return { + restrict: 'E', + templateUrl: 'public/app/features/dashboard/settings/settings.html', + controller: SettingsCtrl, + bindToController: true, + controllerAs: 'ctrl', + transclude: true, + scope: { dashboard: "=" } + }; +} + +coreModule.directive('dashboardSettings', dashboardSettings); diff --git a/public/app/features/dashboard/submenu/submenu.html b/public/app/features/dashboard/submenu/submenu.html index 9e9d22fb495..f240a86efba 100644 --- a/public/app/features/dashboard/submenu/submenu.html +++ b/public/app/features/dashboard/submenu/submenu.html @@ -1,5 +1,4 @@