CreateTeamCtrl.ts 806 B

1234567891011121314151617181920212223242526272829
  1. import coreModule from 'app/core/core_module';
  2. import { BackendSrv } from 'app/core/services/backend_srv';
  3. import { ILocationService } from 'angular';
  4. import { NavModelSrv } from 'app/core/core';
  5. export class CreateTeamCtrl {
  6. name: string;
  7. email: string;
  8. navModel: any;
  9. /** @ngInject */
  10. constructor(private backendSrv: BackendSrv, private $location: ILocationService, navModelSrv: NavModelSrv) {
  11. this.navModel = navModelSrv.getNav('cfg', 'teams', 0);
  12. }
  13. create() {
  14. const payload = {
  15. name: this.name,
  16. email: this.email,
  17. };
  18. this.backendSrv.post('/api/teams', payload).then((result: any) => {
  19. if (result.teamId) {
  20. this.$location.path('/org/teams/edit/' + result.teamId);
  21. }
  22. });
  23. }
  24. }
  25. coreModule.controller('CreateTeamCtrl', CreateTeamCtrl);