generator: Can perform synchronous generation

This commit is contained in:
nemunaire 2023-07-10 12:10:03 +02:00
commit 1769938205
13 changed files with 214 additions and 81 deletions

View file

@ -480,15 +480,16 @@ angular.module("FICApp")
}
$rootScope.staticFilesNeedUpdate = 0;
$rootScope.staticRegenerationInProgress = false;
$rootScope.regenerateStaticFiles = function() {
Settings.get().$promise.then(function(config) {
config.generation = (new Date()).toISOString();
config.$update(function() {
$rootScope.staticFilesNeedUpdate = 0;
$rootScope.addToast('success', "Regeneration in progress...");
}, function (response) {
$rootScope.addToast('success', 'An error occurs when saving settings:', response.data.errmsg);
})
$rootScope.staticRegenerationInProgress = true;
$http.post("api/full-generation").then(function(response) {
$rootScope.staticFilesNeedUpdate = 0;
$rootScope.staticRegenerationInProgress = false;
$rootScope.addToast('success', 'Regeneration ended');
}, function (response) {
$rootScope.staticRegenerationInProgress = false;
$rootScope.addToast('error', 'An error occurs when saving settings:', response.data.errmsg);
})
}
@ -633,11 +634,6 @@ angular.module("FICApp")
$scope.addToast('danger', 'An error occurs when saving settings:', response.data.errmsg);
});
}
$scope.regenerate = function() {
this.config.generation = (new Date()).toISOString();
$rootScope.settings.generation = new Date(this.config.generation);
$scope.saveSettings("Regeneration in progress...");
}
$scope.launchChallenge = function() {
var ts = Date.now() - Date.now() % 60000;
var d = new Date(ts + 120000);

View file

@ -31,8 +31,6 @@
</h2>
</div>
<div class="card-body pb-1">
<input type="hidden" class="form-control form-control-sm" id="lastRegeneration" ng-model="config.generation">
<div class="form-group row">
<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">
@ -382,7 +380,13 @@
<div class="col-3 pt-2 d-flex flex-column justify-content-between">
<div>
<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="regenerateStaticFiles()" class="btn btn-info my-1" type="button" ng-disabled="staticRegenerationInProgress">
<span class="glyphicon glyphicon-share" aria-hidden="true" ng-show="!staticRegenerationInProgress"></span>
<div class="spinner-border spinner-border-sm" role="status" ng-show="staticRegenerationInProgress">
<span class="sr-only">Loading...</span>
</div>
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>
<hr>