settings.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import {coreModule, appEvents} from 'app/core/core';
  2. import {DashboardModel} from '../dashboard_model';
  3. export class SettingsCtrl {
  4. dashboard: DashboardModel;
  5. isOpen: boolean;
  6. viewId: string;
  7. sections: any[] = [
  8. {title: 'General', id: 'general'},
  9. {title: 'Annotations', id: 'annotations'},
  10. {title: 'Templating', id: 'templating'},
  11. {title: 'Versions', id: 'versions'},
  12. ];
  13. /** @ngInject */
  14. constructor($scope, private $location, private $rootScope) {
  15. appEvents.on('hide-dash-editor', this.hideSettings.bind(this), $scope);
  16. var urlParams = this.$location.search();
  17. this.viewId = urlParams.editview;
  18. }
  19. hideSettings() {
  20. var urlParams = this.$location.search();
  21. delete urlParams.editview;
  22. setTimeout(() => {
  23. this.$rootScope.$apply(() => {
  24. this.$location.search(urlParams);
  25. });
  26. });
  27. }
  28. }
  29. export function dashboardSettings() {
  30. return {
  31. restrict: 'E',
  32. templateUrl: 'public/app/features/dashboard/settings/settings.html',
  33. controller: SettingsCtrl,
  34. bindToController: true,
  35. controllerAs: 'ctrl',
  36. transclude: true,
  37. scope: { dashboard: "=" }
  38. };
  39. }
  40. coreModule.directive('dashboardSettings', dashboardSettings);