admin: manage team certificate from interface

This commit is contained in:
nemunaire 2017-04-05 01:56:14 +02:00
commit f26cb4ef4f
2 changed files with 78 additions and 13 deletions

View file

@ -546,10 +546,47 @@ angular.module("FICApp")
}
}
})
.controller("TeamController", function($scope, $location, Team, TeamMember, $routeParams) {
.controller("TeamController", function($scope, $location, Team, TeamMember, $routeParams, $http) {
$scope.team = Team.get({ teamId: $routeParams.teamId });
$scope.fields = ["name", "color"];
$scope.hasCertificate = false;
$http({
url: "/api/teams/" + Math.floor($routeParams.teamId) + "/certificate.p12",
method: "HEAD",
transformResponse: null
}).then(function(response) {
$scope.hasCertificate = true;
}, function(response) {
$scope.hasCertificate = false;
});
$scope.generateCertificate = function() {
$http({
url: "/api/teams/" + Math.floor($routeParams.teamId) + "/certificate/generate",
method: "GET",
transformResponse: null
}).then(function(response) {
$scope.hasCertificate = true;
}, function(response) {
console.log(response.data);
});
}
$scope.revokeCertificate = function() {
if (!confirm("Are you sure you want to revoke this certificate?"))
return false;
$http({
url: "/api/teams/" + Math.floor($routeParams.teamId) + "/certificate.p12",
method: "DELETE",
transformResponse: null
}).then(function(response) {
$scope.hasCertificate = false;
}, function(response) {
console.log(response.data);
});
}
$scope.saveTeam = function() {
if (this.team.id) {
this.team.$update();