create_team_modal.ts 847 B

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