folder.ts 1.0 KB

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. dismiss: any;
  8. /** @ngInject */
  9. constructor(private backendSrv, private $scope, private $location) {
  10. }
  11. create() {
  12. if (!this.title || this.title.trim().length === 0) {
  13. return;
  14. }
  15. const title = this.title.trim();
  16. return this.backendSrv.createDashboardFolder(title).then(result => {
  17. appEvents.emit('alert-success', ['Folder Created', 'OK']);
  18. this.dismiss();
  19. var folderUrl = '/dashboard/db/' + result.slug;
  20. this.$location.url(folderUrl);
  21. });
  22. }
  23. }
  24. export function folderModal() {
  25. return {
  26. restrict: 'E',
  27. templateUrl: 'public/app/features/dashboard/folder_modal/folder.html',
  28. controller: FolderCtrl,
  29. bindToController: true,
  30. controllerAs: 'ctrl',
  31. scope: {
  32. dismiss: "&"
  33. }
  34. };
  35. }
  36. coreModule.directive('folderModal', folderModal);