invited_ctrl.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. define([
  2. 'angular',
  3. '../core_module',
  4. 'app/core/config',
  5. ],
  6. function (angular, coreModule, config) {
  7. 'use strict';
  8. config = config.default;
  9. coreModule.default.controller('InvitedCtrl', function($scope, $routeParams, contextSrv, backendSrv) {
  10. contextSrv.sidemenu = false;
  11. $scope.formModel = {};
  12. $scope.init = function() {
  13. backendSrv.get('/api/user/invite/' + $routeParams.code).then(function(invite) {
  14. $scope.formModel.name = invite.name;
  15. $scope.formModel.email = invite.email;
  16. $scope.formModel.username = invite.email;
  17. $scope.formModel.inviteCode = $routeParams.code;
  18. $scope.greeting = invite.name || invite.email || invite.username;
  19. $scope.invitedBy = invite.invitedBy;
  20. });
  21. };
  22. $scope.submit = function() {
  23. if (!$scope.inviteForm.$valid) {
  24. return;
  25. }
  26. backendSrv.post('/api/user/invite/complete', $scope.formModel).then(function() {
  27. window.location.href = config.appSubUrl + '/';
  28. });
  29. };
  30. $scope.init();
  31. });
  32. });