grafana/public/app/core/controllers/invited_ctrl.js
Torkel Ödegaard ca84ef38f8 angular2 test
2015-12-16 12:21:13 +01:00

39 lines
1.0 KiB
JavaScript

define([
'angular',
'../core_module',
'app/core/config',
],
function (angular, coreModule, config) {
'use strict';
coreModule.default.controller('InvitedCtrl', function($scope, $routeParams, contextSrv, backendSrv) {
contextSrv.sidemenu = false;
$scope.formModel = {};
$scope.init = function() {
backendSrv.get('/api/user/invite/' + $routeParams.code).then(function(invite) {
$scope.formModel.name = invite.name;
$scope.formModel.email = invite.email;
$scope.formModel.username = invite.email;
$scope.formModel.inviteCode = $routeParams.code;
$scope.greeting = invite.name || invite.email || invite.username;
$scope.invitedBy = invite.invitedBy;
});
};
$scope.submit = function() {
if (!$scope.inviteForm.$valid) {
return;
}
backendSrv.post('/api/user/invite/complete', $scope.formModel).then(function() {
window.location.href = config.appSubUrl + '/';
});
};
$scope.init();
});
});