folder.ts 1000 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import coreModule from 'app/core/core_module';
  3. import appEvents from 'app/core/app_events';
  4. import _ from 'lodash';
  5. export class FolderCtrl {
  6. title: string;
  7. /** @ngInject */
  8. constructor(private backendSrv, private $scope, $sce) {
  9. }
  10. create() {
  11. if (!this.title || this.title.trim().length === 0) {
  12. return;
  13. }
  14. const title = this.title.trim();
  15. return this.backendSrv.createDashboardFolder(title).then((result) => {
  16. appEvents.emit('alert-success', ['Dashboard saved', 'Saved as ' + title]);
  17. appEvents.emit('dashboard-saved', result);
  18. this.dismiss();
  19. });
  20. }
  21. dismiss() {
  22. appEvents.emit('hide-modal');
  23. }
  24. }
  25. export function folderModal() {
  26. return {
  27. restrict: 'E',
  28. templateUrl: 'public/app/features/dashboard/folder_modal/folder.html',
  29. controller: FolderCtrl,
  30. bindToController: true,
  31. controllerAs: 'ctrl',
  32. };
  33. }
  34. coreModule.directive('folderModal', folderModal);