admin: new route and interface to manage symlink for team association exclusing certificates

This commit is contained in:
nemunaire 2019-02-04 19:59:29 +01:00
parent 2b95995104
commit 14d31737e0
6 changed files with 132 additions and 21 deletions

View file

@ -179,6 +179,9 @@ angular.module("FICApp")
.factory("TeamCertificate", function($resource) {
return $resource("/api/teams/:teamId/certificates", { teamId: '@id' })
})
.factory("TeamAssociation", function($resource) {
return $resource("/api/teams/:teamId/associations/:assoc", { teamId: '@teamId', assoc: '@assoc' })
})
.factory("TeamMember", function($resource) {
return $resource("/api/teams/:teamId/members", { teamId: '@id' }, {
'save': {method: 'PUT'},
@ -1498,29 +1501,12 @@ angular.module("FICApp")
}
}
})
.controller("TeamController", function($scope, $rootScope, $location, Team, TeamMember, TeamCertificate, $routeParams, $http) {
.controller("TeamController", function($scope, $rootScope, $location, Team, TeamMember, $routeParams) {
if ($scope.team && $scope.team.id)
$routeParams.teamId = $scope.team.id;
$scope.team = Team.get({ teamId: $routeParams.teamId });
$scope.fields = ["name", "color"];
$scope.certificates = TeamCertificate.query({ teamId: $routeParams.teamId });
$scope.dissociateCertificate = function(certificate) {
$http({
url: "/api/certs/" + certificate.id,
method: "PUT",
data: {
id_team: null
}
}).then(function(response) {
$scope.certificates = TeamCertificate.query({ teamId: $routeParams.teamId });
$rootScope.newBox('success', 'Certificate successfully dissociated!');
}, function(response) {
$rootScope.newBox('danger', 'An error occurs when dissociating certiticate:', response.data.errmsg);
});
}
$scope.saveTeam = function() {
if (this.team.id) {
this.team.$update();
@ -1544,6 +1530,50 @@ angular.module("FICApp")
$location.url("/teams/" + $scope.team.id + "/score");
}
})
.controller("TeamCertificatesController", function($scope, $rootScope, TeamCertificate, $routeParams, $http) {
$scope.certificates = TeamCertificate.query({ teamId: $routeParams.teamId });
$scope.dissociateCertificate = function(certificate) {
$http({
url: "/api/certs/" + certificate.id,
method: "PUT",
data: {
id_team: null
}
}).then(function(response) {
$scope.certificates = TeamCertificate.query({ teamId: $routeParams.teamId });
$rootScope.newBox('success', 'Certificate successfully dissociated!');
}, function(response) {
$rootScope.newBox('danger', 'An error occurs when dissociating certiticate:', response.data.errmsg);
});
}
})
.controller("TeamAssociationsController", function($scope, $rootScope, TeamAssociation, $routeParams, $http) {
$scope.associations = TeamAssociation.query({ teamId: $routeParams.teamId });
$scope.form = { "newassoc": "" };
$scope.addAssociation = function() {
if ($scope.form.newassoc) {
TeamAssociation.save({ teamId: $scope.team.id, assoc: $scope.form.newassoc }).$promise.then(
function() {
$scope.form.newassoc = "";
$scope.associations = TeamAssociation.query({ teamId: $routeParams.teamId });
}, function(response) {
if (response.data)
$rootScope.newBox('danger', 'An error occurs when creating user association: ', response.data.errmsg);
});
}
}
$scope.dropAssociation = function(assoc) {
TeamAssociation.delete({ teamId: $routeParams.teamId, assoc: assoc }).$promise.then(
function() {
$scope.associations = TeamAssociation.query({ teamId: $routeParams.teamId });
}, function(response) {
$rootScope.newBox('danger', 'An error occurs when removing user association: ', response.data.errmsg);
});
}
})
.controller("TeamHistoryController", function($scope, TeamHistory, $routeParams, $http, $rootScope) {
$scope.history = TeamHistory.query({ teamId: $routeParams.teamId });
$scope.delHistory = function(row) {