diff --git a/admin/static/js/app.js b/admin/static/js/app.js index 6705ded0..e9a1601c 100644 --- a/admin/static/js/app.js +++ b/admin/static/js/app.js @@ -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(); diff --git a/admin/static/views/team-edit.html b/admin/static/views/team-edit.html index 4fdf8064..2c658454 100644 --- a/admin/static/views/team-edit.html +++ b/admin/static/views/team-edit.html @@ -38,20 +38,48 @@