admin: Add button to switch from WIP to PROD
This commit is contained in:
parent
c34fe51641
commit
c7968fb256
|
@ -47,6 +47,19 @@ func declareSettingsRoutes(router *gin.RouterGroup) {
|
||||||
apiNextSettingsRoutes.DELETE("", deleteNextSettings)
|
apiNextSettingsRoutes.DELETE("", deleteNextSettings)
|
||||||
|
|
||||||
router.POST("/reset", reset)
|
router.POST("/reset", reset)
|
||||||
|
|
||||||
|
router.GET("/prod", func(c *gin.Context) {
|
||||||
|
c.JSON(http.StatusOK, IsProductionEnv)
|
||||||
|
})
|
||||||
|
router.PUT("/prod", func(c *gin.Context) {
|
||||||
|
err := c.ShouldBindJSON(&IsProductionEnv)
|
||||||
|
if err != nil {
|
||||||
|
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, IsProductionEnv)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func NextSettingsHandler(c *gin.Context) {
|
func NextSettingsHandler(c *gin.Context) {
|
||||||
|
|
|
@ -455,7 +455,7 @@ angular.module("FICApp")
|
||||||
$rootScope.Utils = {
|
$rootScope.Utils = {
|
||||||
keys : Object.keys
|
keys : Object.keys
|
||||||
};
|
};
|
||||||
function refresh() {
|
$rootScope.refreshSettings = function() {
|
||||||
$http.get("api/settings.json").then(function(response) {
|
$http.get("api/settings.json").then(function(response) {
|
||||||
response.data.start = new Date(response.data.start);
|
response.data.start = new Date(response.data.start);
|
||||||
response.data.end = new Date(response.data.end);
|
response.data.end = new Date(response.data.end);
|
||||||
|
@ -464,8 +464,8 @@ angular.module("FICApp")
|
||||||
$rootScope.recvTime(response);
|
$rootScope.recvTime(response);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
refresh();
|
$rootScope.refreshSettings();
|
||||||
$interval(refresh, 10000);
|
$interval($rootScope.refreshSettings, 10000);
|
||||||
|
|
||||||
$rootScope.toasts = [];
|
$rootScope.toasts = [];
|
||||||
$rootScope.addToast = function(kind, title, msg, yesFunc, noFunc, tmout) {
|
$rootScope.addToast = function(kind, title, msg, yesFunc, noFunc, tmout) {
|
||||||
|
@ -655,6 +655,17 @@ angular.module("FICApp")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
$scope.switchToProd = function() {
|
||||||
|
$scope.addToast('warning', "Activer le mode challenge ?", "L'activation du mode challenge est temporaire (vous devriez plutôt relancer le daemon avec l'option `-4real`). Ce mode permet d'éviter les mauvaises manipulations et désactive le hook git de synchronisation automatique. Êtes-vous sûr de vouloir continuer ?",
|
||||||
|
function() {
|
||||||
|
$http.put("api/prod", true).then(function(time) {
|
||||||
|
$rootScope.refreshSettings()
|
||||||
|
$scope.addToast('success', 'Mode challenge activé');
|
||||||
|
}, function(response) {
|
||||||
|
$scope.addToast('danger', 'An error occurs when activating challenge mode:', response.data.errmsg);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
.controller("SyncController", function($scope, $rootScope, ROSettings, $location, $http, $interval) {
|
.controller("SyncController", function($scope, $rootScope, ROSettings, $location, $http, $interval) {
|
||||||
|
|
|
@ -359,6 +359,7 @@
|
||||||
<div>
|
<div>
|
||||||
<div class="d-flex flex-column">
|
<div class="d-flex flex-column">
|
||||||
<button ng-click="regenerate()" class="btn btn-info my-1" type="button"><span class="glyphicon glyphicon-share" aria-hidden="true"></span> Regénérer les fichiers statiques</button>
|
<button ng-click="regenerate()" class="btn btn-info my-1" type="button"><span class="glyphicon glyphicon-share" aria-hidden="true"></span> Regénérer les fichiers statiques</button>
|
||||||
|
<button ng-if="settings.wip" ng-click="switchToProd()" class="btn btn-danger my-1" type="button"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span> Activer le mode challenge</button>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<h4>Changements anticipés</h4>
|
<h4>Changements anticipés</h4>
|
||||||
|
@ -402,7 +403,7 @@
|
||||||
|
|
||||||
<div class="row mb-2" ng-show="settings.wip || !timeProgression || displayDangerousActions">
|
<div class="row mb-2" ng-show="settings.wip || !timeProgression || displayDangerousActions">
|
||||||
<div class="d-flex flex-column">
|
<div class="d-flex flex-column">
|
||||||
<a href="sync" class="btn btn-secondary my-1" type="button"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Paramètres de synchronisation</a>
|
<a href="sync" class="btn btn-primary my-1" type="button"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> Paramètres de synchronisation</a>
|
||||||
<button ng-click="reset('settings');" class="btn btn-secondary mt-2 mb-1" type="button"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Revenir aux paramètres par défaut</button>
|
<button ng-click="reset('settings');" class="btn btn-secondary mt-2 mb-1" type="button"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Revenir aux paramètres par défaut</button>
|
||||||
<button ng-click="reset('challenges')" class="btn btn-secondary mt-2 mb-1" type="button"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Effacer les challenges et les thèmes</button>
|
<button ng-click="reset('challenges')" class="btn btn-secondary mt-2 mb-1" type="button"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Effacer les challenges et les thèmes</button>
|
||||||
<button ng-click="reset('teams');" class="btn btn-secondary mt-1 mb-1" type="button"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Effacer les équipes</button>
|
<button ng-click="reset('teams');" class="btn btn-secondary mt-1 mb-1" type="button"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Effacer les équipes</button>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user