folder.ts 997 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ///<reference path="../../../headers/common.d.ts" />
  2. import coreModule from 'app/core/core_module';
  3. import appEvents from 'app/core/app_events';
  4. export class FolderCtrl {
  5. title: string;
  6. dismiss: any;
  7. /** @ngInject */
  8. constructor(private backendSrv, private $location) {
  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', ['Folder Created', 'OK']);
  17. this.dismiss();
  18. var folderUrl = '/dashboard/db/' + result.slug;
  19. this.$location.url(folderUrl);
  20. });
  21. }
  22. }
  23. export function folderModal() {
  24. return {
  25. restrict: 'E',
  26. templateUrl: 'public/app/features/dashboard/folder_modal/folder.html',
  27. controller: FolderCtrl,
  28. bindToController: true,
  29. controllerAs: 'ctrl',
  30. scope: {
  31. dismiss: "&"
  32. }
  33. };
  34. }
  35. coreModule.directive('folderModal', folderModal);