New setting delegated_qa to store QA managers

This commit is contained in:
nemunaire 2023-07-25 09:04:31 +02:00
commit d2f409db7a
11 changed files with 148 additions and 20 deletions

View file

@ -37,6 +37,7 @@ func declareTeamsRoutes(router *gin.RouterGroup) {
c.JSON(http.StatusOK, teams)
})
router.GET("/teams-associations.json", allAssociations)
router.GET("/teams-binding", bindingTeams)
router.GET("/teams-nginx", nginxGenTeams)
router.POST("/disableinactiveteams", disableInactiveTeams)
@ -282,6 +283,31 @@ func bindingTeams(c *gin.Context) {
c.String(http.StatusOK, ret)
}
func allAssociations(c *gin.Context) {
teams, err := fic.GetTeams()
if err != nil {
log.Println("Unable to GetTeams:", err.Error())
c.AbortWithError(http.StatusInternalServerError, err)
return
}
var ret []string
for _, team := range teams {
assocs, err := pki.GetTeamAssociations(TeamsDir, team.Id)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
return
}
for _, a := range assocs {
ret = append(ret, a)
}
}
c.JSON(http.StatusOK, ret)
}
func createTeam(c *gin.Context) {
var ut fic.Team
err := c.ShouldBindJSON(&ut)

View file

@ -538,6 +538,13 @@ angular.module("FICApp")
$scope.monitor = Monitor.get();
})
.controller("AllTeamAssociationsController", function($scope, $http) {
$scope.allAssociations = [];
$http.get("api/teams-associations.json").then(function(response) {
$scope.allAssociations = response.data;
})
})
.controller("SettingsController", function($scope, $rootScope, NextSettings, Settings, SettingsChallenge, $location, $http, $interval) {
$scope.nextsettings = NextSettings.query();
$scope.erase = false;
@ -591,7 +598,30 @@ angular.module("FICApp")
$scope.config.disablesubmitbutton = "";
};
$scope.saveChallengeInfo = function() {
$scope.newdqa = "";
$scope.addDelegatedQA = function() {
if ($scope.newdqa.length) {
if (!$scope.config.delegated_qa)
$scope.config.delegated_qa = [];
$scope.config.delegated_qa.push($scope.newdqa);
$scope.saveSettings();
$scope.newdqa = "";
}
}
$scope.dropDelegatedQA = function(member) {
if ($scope.config.delegated_qa) {
$scope.config.delegated_qa = [];
angular.forEach($scope.config.delegated_qa, function(m, k) {
if (member == m)
$scope.config.delegated_qa.splice(k, 1);
});
$scope.saveSettings();
}
}
$scope.saveChallengeInfo = function() {
this.challenge.duration = $scope.duration;
this.challenge.$update(function(response) {
$scope.addToast('success', 'Infos du challenge mises à jour avec succès !');

View file

@ -264,6 +264,35 @@
</div>
</form>
<form ng-submit="addDelegatedQA()" class="card my-3">
<div class="card-header">
<h3>Managers QA</h3>
</div>
<div class="card-body">
<ul>
<li ng-repeat="m in config.delegated_qa">
{{ m }}
<button class="btn btn-sm btn-danger" type="button" ng-click="dropDelegatedQA(m)">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</button>
</li>
<li class="row">
<div class="col" ng-controller="AllTeamAssociationsController">
<select class="form-control form-control-sm" ng-model="newdqa">
<option ng-repeat="(i,m) in allAssociations" ng-value="m">{{ m }}</option>
</select>
</div>
<div class="col input-group">
<input type="text" class="form-control form-control-sm" ng-model="newdqa" placeholder="Nouveau manager QA">
<span class="input-group-append">
<button class="btn btn-sm btn-success" ng-disabled="!newdqa.length"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
</span>
</div>
</li>
</ul>
</div>
</form>
<form ng-submit="saveChallengeInfo()" class="card my-3">
<div class="card-header">
<button type="submit" class="btn btn-success float-right" title="Enregistrer les modifications aux infos du challenge"><span class="glyphicon glyphicon-ok" aria-hidden="true"></span></button>