create_team_modal.ts 844 B

123456789101112131415161718192021222324252627282930313233343536
  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 CreateTeamCtrl {
  5. teamName = '';
  6. /** @ngInject */
  7. constructor(private backendSrv, private $location) {}
  8. createTeam() {
  9. this.backendSrv.post('/api/teams', { name: this.teamName }).then(result => {
  10. if (result.teamId) {
  11. this.$location.path('/org/teams/edit/' + result.teamId);
  12. }
  13. this.dismiss();
  14. });
  15. }
  16. dismiss() {
  17. appEvents.emit('hide-modal');
  18. }
  19. }
  20. export function createTeamModal() {
  21. return {
  22. restrict: 'E',
  23. templateUrl: 'public/app/features/org/partials/create_team.html',
  24. controller: CreateTeamCtrl,
  25. bindToController: true,
  26. controllerAs: 'ctrl',
  27. };
  28. }
  29. coreModule.directive('createTeamModal', createTeamModal);