folder.ts 943 B

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