admin: Handle challenge info on settings page

This commit is contained in:
nemunaire 2022-05-02 10:59:43 +02:00
parent c713a0a25d
commit 48ee5321a8
2 changed files with 286 additions and 210 deletions

View file

@ -223,6 +223,11 @@ angular.module("FICApp")
'update': {method: 'PUT'},
})
})
.factory("SettingsChallenge", function($resource) {
return $resource("api/challenge.json", null, {
'update': {method: 'PUT'},
})
})
.factory("Scene", function($resource) {
return $resource("api/public/:screenId", { screenId: '@id' }, {
'update': {method: 'PUT'},
@ -494,7 +499,7 @@ angular.module("FICApp")
$scope.monitor = Monitor.get();
})
.controller("SettingsController", function($scope, $rootScope, Settings, ROSettings, $location, $http, $interval) {
.controller("SettingsController", function($scope, $rootScope, Settings, SettingsChallenge, ROSettings, $location, $http, $interval) {
$scope.displayDangerousActions = false;
$scope.config = Settings.get();
$scope.config.$promise.then(function(response) {
@ -505,6 +510,7 @@ angular.module("FICApp")
$rootScope.settings.activateTime = new Date(response.activateTime);
})
$scope.configro = ROSettings.get();
$scope.challenge = SettingsChallenge.get();
$scope.duration = 360;
$scope.exerciceDependChange = function() {
@ -542,6 +548,13 @@ angular.module("FICApp")
}, 1500);
$scope.$on('$destroy', function () { $interval.cancel(progressInterval); });
$scope.saveChallengeInfo = function() {
this.challenge.$update(function(response) {
$scope.addToast('success', 'Infos du challenge mises à jour avec succès !');
}, function(response) {
$scope.addToast('danger', 'An error occurs when saving challenge info:', response.data.errmsg);
});
}
$scope.saveSettings = function(msg) {
if (msg === undefined) { msg = 'New settings saved!'; }
var nStart = this.config.start;