settings: Can disable all submission button for maintenance

This commit is contained in:
nemunaire 2022-06-08 04:39:20 +02:00
parent 329bd246c7
commit e9dd35f8ac
9 changed files with 41 additions and 10 deletions

View File

@ -529,6 +529,7 @@ angular.module("FICApp")
$scope.config[k] = ns.values[k]; $scope.config[k] = ns.values[k];
}); });
$scope.config.enableExerciceDepend = $scope.config.unlockedChallengeDepth >= 0; $scope.config.enableExerciceDepend = $scope.config.unlockedChallengeDepth >= 0;
$scope.config.disabledsubmitbutton = $scope.config.disablesubmitbutton && $scope.config.disablesubmitbutton.length > 0;
} }
$scope.deleteNextSettings = function(ns) { $scope.deleteNextSettings = function(ns) {
ns.$delete().then(function() { ns.$delete().then(function() {
@ -542,6 +543,7 @@ angular.module("FICApp")
$scope.config.$promise.then(function(response) { $scope.config.$promise.then(function(response) {
$scope.dist_config = Object.assign({}, response); $scope.dist_config = Object.assign({}, response);
response.enableExerciceDepend = response.unlockedChallengeDepth >= 0; response.enableExerciceDepend = response.unlockedChallengeDepth >= 0;
response.disabledsubmitbutton = response.disablesubmitbutton && response.disablesubmitbutton.length > 0;
$rootScope.settings.start = new Date(response.start); $rootScope.settings.start = new Date(response.start);
$rootScope.settings.end = new Date(response.end); $rootScope.settings.end = new Date(response.end);
$rootScope.settings.generation = new Date(response.generation); $rootScope.settings.generation = new Date(response.generation);
@ -562,6 +564,13 @@ angular.module("FICApp")
$scope.config.unlockedChallengeDepth = -1; $scope.config.unlockedChallengeDepth = -1;
}; };
$scope.submitButtonStateChange = function() {
if ($scope.config.disabledsubmitbutton)
$scope.config.disablesubmitbutton = "Mise à jour en cours...";
else
$scope.config.disablesubmitbutton = "";
};
$scope.saveChallengeInfo = function() { $scope.saveChallengeInfo = function() {
this.challenge.duration = $scope.duration; this.challenge.duration = $scope.duration;
this.challenge.$update(function(response) { this.challenge.$update(function(response) {
@ -577,6 +586,7 @@ angular.module("FICApp")
var nGen = this.config.generation; var nGen = this.config.generation;
var state = this.config.enableExerciceDepend; var state = this.config.enableExerciceDepend;
this.config.unlockedChallengeDepth = (this.config.enableExerciceDepend?this.config.unlockedChallengeDepth:-1) this.config.unlockedChallengeDepth = (this.config.enableExerciceDepend?this.config.unlockedChallengeDepth:-1)
this.config.disablesubmitbutton = (this.config.disabledsubmitbutton?this.config.disablesubmitbutton:'')
var updateQuery = {}; var updateQuery = {};
if (this.activateTime && this.activateTime != '0001-01-01T00:00:00Z') { if (this.activateTime && this.activateTime != '0001-01-01T00:00:00Z') {
updateQuery['t'] = this.activateTime; updateQuery['t'] = this.activateTime;
@ -590,6 +600,7 @@ angular.module("FICApp")
$scope.addToast('success', msg); $scope.addToast('success', msg);
$scope.nextsettings = NextSettings.query(); $scope.nextsettings = NextSettings.query();
response.enableExerciceDepend = response.unlockedChallengeDepth >= 0; response.enableExerciceDepend = response.unlockedChallengeDepth >= 0;
response.disabledsubmitbutton = response.disablesubmitbutton && response.disablesubmitbutton.length > 0;
$rootScope.settings.start = new Date(nStart); $rootScope.settings.start = new Date(nStart);
$rootScope.settings.end = new Date(nEnd); $rootScope.settings.end = new Date(nEnd);
$rootScope.settings.generation = new Date(nGen); $rootScope.settings.generation = new Date(nGen);

View File

@ -158,16 +158,16 @@
<div class="form-check"> <div class="form-check">
<label class="custom-control custom-checkbox"> <label class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" ng-model="config.partialValidation"> <input class="custom-control-input" type="checkbox" ng-model="config.enableExerciceDepend" ng-change="exerciceDependChange()">
<span class="custom-control-label" ng-class="{'text-primary font-weight-bold': !config.partialValidation != !dist_config.partialValidation}">Activer la validation partielle des challenges</span> <span class="custom-control-label" ng-class="{'text-primary font-weight-bold': config.unlockedChallengeDepth != dist_config.unlockedChallengeDepth}">Activer les dépendances des exercices</span>
<input type="number" class="form-control form-control-sm" ng-model="config.unlockedChallengeDepth" ng-disabled="!config.enableExerciceDepend" title="-1 : Désactivé ; 0: activé ; 1,2,3 : débloque 1,2,3,... exercices supplémentaires après un challenge validé" min="0" integer ng-class="{'border-primary': config.unlockedChallengeDepth != dist_config.unlockedChallengeDepth}">
</label> </label>
</div> </div>
<div class="form-check"> <div class="form-check">
<label class="custom-control custom-checkbox"> <label class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox" ng-model="config.enableExerciceDepend" ng-change="exerciceDependChange()"> <input class="custom-control-input" type="checkbox" ng-model="config.partialValidation">
<span class="custom-control-label" ng-class="{'text-primary font-weight-bold': config.unlockedChallengeDepth != dist_config.unlockedChallengeDepth}">Activer les dépendances des exercices</span> <span class="custom-control-label" ng-class="{'text-primary font-weight-bold': !config.partialValidation != !dist_config.partialValidation}">Activer la validation partielle des challenges</span>
<input type="number" class="form-control form-control-sm" ng-model="config.unlockedChallengeDepth" ng-disabled="!config.enableExerciceDepend" title="-1 : Désactivé ; 0: activé ; 1,2,3 : débloque 1,2,3,... exercices supplémentaires après un challenge validé" min="0" integer ng-class="{'border-primary': config.unlockedChallengeDepth != dist_config.unlockedChallengeDepth}">
</label> </label>
</div> </div>
@ -206,6 +206,14 @@
</label> </label>
</div> </div>
<div class="form-check">
<label class="custom-control custom-checkbox">
<input class="custom-control-input" type="checkbox"ng-model="config.disabledsubmitbutton" ng-change="submitButtonStateChange()">
<span class="custom-control-label" ng-class="{'text-primary font-weight-bold': !config.disablesubmitbutton != !dist_config.disablesubmitbutton}">Désactiver les boutons de soumission (pour indiquer une indisponibilité)</span>
<input class="form-control form-control-sm" ng-model="config.disablesubmitbutton" ng-disabled="!config.disabledsubmitbutton" title="Message qui sera indiqué aux participants" ng-class="{'border-primary': !config.disablesubmitbutton != !dist_config.disablesubmitbutton}">
</label>
</div>
</div> </div>
</form> </form>

View File

@ -10,11 +10,13 @@
ListGroupItem, ListGroupItem,
Progress, Progress,
Spinner, Spinner,
Tooltip,
} from 'sveltestrap'; } from 'sveltestrap';
import { blake2b } from 'hash-wasm'; import { blake2b } from 'hash-wasm';
import { my } from '../stores/my.js'; import { my } from '../stores/my.js';
import { settings } from '../stores/settings.js';
import DateFormat from './DateFormat.svelte'; import DateFormat from './DateFormat.svelte';
import FlagKey from './FlagKey.svelte'; import FlagKey from './FlagKey.svelte';
@ -224,13 +226,17 @@
<Button <Button
type="submit" type="submit"
color="danger" color="danger"
disabled={submitInProgress} id="submission-{exercice.id}"
disabled={submitInProgress || $settings.disablesubmitbutton}
> >
{#if submitInProgress} {#if submitInProgress}
<Spinner size="sm" class="me-2" /> <Spinner size="sm" class="me-2" />
{/if} {/if}
Soumettre Soumettre
</Button> </Button>
{#if $settings.disablesubmitbutton}
<span class="text-muted">{$settings.disablesubmitbutton}</span>
{/if}
</div> </div>
</form> </form>
</CardBody> </CardBody>

View File

@ -117,7 +117,7 @@
{#if !(hint.content || hint.file) || (!hint.file && hint.hidden)} {#if !(hint.content || hint.file) || (!hint.file && hint.hidden)}
<div> <div>
{#if !(hint.content || hint.file)} {#if !(hint.content || hint.file)}
<button type="button" on:click={openHint(hint)} class="btn btn-info" class:disabled={hints_submitted[hint.id]}> <button type="button" on:click={openHint(hint)} class="btn btn-info" class:disabled={hints_submitted[hint.id]} disabled={$settings.disablesubmitbutton}>
{#if hints_submitted[hint.id]} {#if hints_submitted[hint.id]}
<Spinner size="sm" class="me-2" /> <Spinner size="sm" class="me-2" />
{:else} {:else}

View File

@ -155,7 +155,7 @@
color="success" color="success"
type="button" type="button"
on:click={wantchoices} on:click={wantchoices}
disabled={wcsubmitted} disabled={wcsubmitted || $settings.disablesubmitbutton}
title="Cliquez pour échanger ce champ de texte par une liste de choix. L'opération vous coûtera {flag.choices_cost * $settings.wchoiceCurrentCoefficient} points." title="Cliquez pour échanger ce champ de texte par une liste de choix. L'opération vous coûtera {flag.choices_cost * $settings.wchoiceCurrentCoefficient} points."
> >
{#if wcsubmitted} {#if wcsubmitted}

View File

@ -5,6 +5,7 @@
} from 'sveltestrap'; } from 'sveltestrap';
import { issues, issues_idx } from '../stores/issues.js'; import { issues, issues_idx } from '../stores/issues.js';
import { settings } from '../stores/settings.js';
export let exercice = null; export let exercice = null;
export let issue = { }; export let issue = { };
@ -41,7 +42,7 @@
</div> </div>
</div> </div>
<Button type="submit" color="warning" class="float-end"> <Button type="submit" color="warning" class="float-end" disabled={$settings.disablesubmitbutton}>
Envoyer le rapport Envoyer le rapport
</Button> </Button>
</form> </form>

View File

@ -8,6 +8,7 @@
} from 'sveltestrap'; } from 'sveltestrap';
import { my } from '../stores/my.js'; import { my } from '../stores/my.js';
import { settings } from '../stores/settings.js';
export let refresh_my; export let refresh_my;
@ -101,7 +102,7 @@
<div class="col-sm-10"> <div class="col-sm-10">
<div class="input-group"> <div class="input-group">
<input type="text" class="form-control" id="newName" bind:value={newTeamName} placeholder="{$my.name}"> <input type="text" class="form-control" id="newName" bind:value={newTeamName} placeholder="{$my.name}">
<Button type="submit" class="btn btn-info">Valider</Button> <Button type="submit" class="btn btn-info" disabled={$settings.disablesubmitbutton}>Valider</Button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -18,6 +18,8 @@ function createSettingsStore() {
settings.generation = new Date(settings.generation); settings.generation = new Date(settings.generation);
if (settings.activateTime) if (settings.activateTime)
settings.activateTime = new Date(settings.activateTime); settings.activateTime = new Date(settings.activateTime);
if (!settings.disablesubmitbutton)
settings.disablesubmitbutton = null;
settings.recvTime = recvTime; settings.recvTime = recvTime;
const x_fic_time = res_settings.headers.get("x-fic-time"); const x_fic_time = res_settings.headers.get("x-fic-time");

View File

@ -77,6 +77,8 @@ type Settings struct {
DisplayMCQBadCount bool `json:"displayMCQBadCount,omitempty"` DisplayMCQBadCount bool `json:"displayMCQBadCount,omitempty"`
// EventKindness will ask browsers to delay notification interval. // EventKindness will ask browsers to delay notification interval.
EventKindness bool `json:"eventKindness,omitempty"` EventKindness bool `json:"eventKindness,omitempty"`
// DisableSubmitButton replace button by this text (eg. scheduled updates, ...).
DisableSubmitButton string `json:"disablesubmitbutton,omitempty"`
} }
// ExistsSettings checks if the settings file can by found at the given path. // ExistsSettings checks if the settings file can by found at the given path.