admin: Use datetime-local input types in settings

This commit is contained in:
nemunaire 2024-03-14 15:14:26 +01:00
parent ad72eb0b95
commit d44fc4f715
2 changed files with 12 additions and 13 deletions

View File

@ -582,14 +582,15 @@ angular.module("FICApp")
$scope.config = Settings.get();
$scope.dist_config = {};
$scope.config.$promise.then(function(response) {
response.start = new Date(response.start);
if (response.end) response.end = new Date(response.end);
else response.end = null;
response.generation = new Date(response.generation);
response.activateTime = new Date(response.activateTime);
$scope.dist_config = Object.assign({}, response);
response.enableExerciceDepend = response.unlockedChallengeDepth >= 0;
response.disabledsubmitbutton = response.disablesubmitbutton && response.disablesubmitbutton.length > 0;
$rootScope.settings.start = new Date(response.start);
if (response.end) $rootScope.settings.end = new Date(response.end);
else $rootScope.settings.end = null;
$rootScope.settings.generation = new Date(response.generation);
$rootScope.settings.activateTime = new Date(response.activateTime);
})
$scope.challenge = SettingsChallenge.get();
$scope.duration = 360;
@ -681,10 +682,8 @@ angular.module("FICApp")
}
$scope.launchChallenge = function() {
var ts = $rootScope.getSrvTime().getTime() - $rootScope.getSrvTime().getTime() % 60000;
var d = new Date(ts + 120000);
this.config.start = d.toISOString();
var f = new Date(ts + 120000 + this.duration * 60000);
this.config.end = f.toISOString();
this.config.start = new Date(ts + 120000);
this.config.end = new Date(ts + 120000 + this.duration * 60000);
$scope.addToast('info', 'Challenge ready to start,', 'propagate the changes?',
function() {
@ -697,7 +696,7 @@ angular.module("FICApp")
$scope.updActivateTime = function(modulo) {
var ts = Math.floor((new Date(this.config.end) - $rootScope.getSrvTime().getTime() - (60000 * modulo / 2)) / (60000 * modulo)) * (60000 * modulo);
var d = new Date(this.config.end) - ts;
this.activateTime = new Date(d).toISOString();
this.activateTime = new Date(d);
this.updateActivateTime();
}
$scope.reset = function(type) {

View File

@ -19,7 +19,7 @@
<a class="dropdown-item" ng-click="activateTime = '0001-01-01T00:00:00Z'" ng-show="activateTimeCountDown">annuler la propagation</a>
</div>
</div>
<input type="text" class="form-control form-control-sm" id="activateTime" ng-model="activateTime" ng-change="updateActivateTime()">
<input type="datetime-local" class="form-control form-control-sm" id="activateTime" ng-model="activateTime" ng-change="updateActivateTime()">
</div>
<small ng-if="activateTimeCountDown">
Propagation dans : {{ activateTimeCountDown | timer }}
@ -35,7 +35,7 @@
<label for="startTime" class="col-sm-3 col-form-label col-form-label-sm" ng-class="{'text-primary font-weight-bold': config.start != dist_config.start}">Début du challenge</label>
<div class="col-sm-9">
<div class="input-group">
<input type="text" class="form-control form-control-sm" id="startTime" ng-model="config.start" ng-class="{'border-primary': config.start != dist_config.start}">
<input type="datetime-local" class="form-control form-control-sm" id="startTime" ng-model="config.start" ng-class="{'border-primary': config.start != dist_config.start}">
<div class="input-group-append">
<button ng-click="launchChallenge()" class="btn btn-sm btn-secondary" type="button"><span class="glyphicon glyphicon-play" aria-hidden="true"></span> Lancer le challenge</button>
</div>
@ -46,7 +46,7 @@
<div class="form-group row">
<label for="endTime" class="col-sm-3 col-form-label col-form-label-sm" ng-class="{'text-primary font-weight-bold': config.end != dist_config.end}">Fin du challenge</label>
<div class="col-sm-6">
<input type="text" class="form-control form-control-sm" id="endTime" ng-model="config.end" ng-class="{'border-primary': config.end != dist_config.end}">
<input type="datetime-local" class="form-control form-control-sm" id="endTime" ng-model="config.end" ng-class="{'border-primary': config.end != dist_config.end}">
</div>
<div class="col-sm-1 text-right">
<label for="duration" class="col-form-label col-form-label-sm">Durée</label>