admin: control settings
This commit is contained in:
parent
eab92973e8
commit
61bde6d31e
7 changed files with 180 additions and 0 deletions
|
|
@ -22,6 +22,7 @@
|
|||
<li><a href="/themes">Thèmes</a></li>
|
||||
<li><a href="/exercices">Exercices</a></li>
|
||||
<li><a href="/events">Événements</a></li>
|
||||
<li><a href="/settings">Paramètres</a></li>
|
||||
</ul>
|
||||
|
||||
<p id="clock" class="navbar-text navbar-right" ng-controller="CountdownController">
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ angular.module("FICApp", ["ngRoute", "ngResource", "ngSanitize"])
|
|||
controller: "ExerciceController",
|
||||
templateUrl: "views/exercice.html"
|
||||
})
|
||||
.when("/settings", {
|
||||
controller: "SettingsController",
|
||||
templateUrl: "views/settings.html"
|
||||
})
|
||||
.when("/exercices", {
|
||||
controller: "AllExercicesListController",
|
||||
templateUrl: "views/exercice-list.html"
|
||||
|
|
@ -56,6 +60,11 @@ angular.module("FICApp")
|
|||
'update': {method: 'PUT'},
|
||||
})
|
||||
})
|
||||
.factory("Settings", function($resource) {
|
||||
return $resource("/api/settings.json", null, {
|
||||
'update': {method: 'PUT'},
|
||||
})
|
||||
})
|
||||
.factory("Team", function($resource) {
|
||||
return $resource("/api/teams/:teamId", { teamId: '@id' }, {
|
||||
'update': {method: 'PUT'},
|
||||
|
|
@ -186,10 +195,39 @@ angular.module("FICApp")
|
|||
};
|
||||
})
|
||||
|
||||
.directive('float', function() {
|
||||
return {
|
||||
require: 'ngModel',
|
||||
link: function(scope, ele, attr, ctrl){
|
||||
ctrl.$parsers.unshift(function(viewValue){
|
||||
return parseFloat(viewValue, 10);
|
||||
});
|
||||
}
|
||||
};
|
||||
})
|
||||
|
||||
.controller("VersionController", function($scope, Version) {
|
||||
$scope.v = Version.get();
|
||||
})
|
||||
|
||||
.controller("SettingsController", function($scope, Settings, $location, $http) {
|
||||
$scope.config = Settings.get();
|
||||
$scope.duration = 240;
|
||||
|
||||
$scope.saveSettings = function() {
|
||||
this.config.$update(function() {
|
||||
$location.url("/");
|
||||
});
|
||||
}
|
||||
$scope.launchChallenge = function() {
|
||||
var ts = Date.now() - Date.now() % 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();
|
||||
}
|
||||
})
|
||||
|
||||
.controller("EventsListController", function($scope, Event, $location) {
|
||||
$scope.events = Event.query();
|
||||
$scope.fields = ["id", "kind", "txt", "time"];
|
||||
|
|
|
|||
102
admin/static/views/settings.html
Normal file
102
admin/static/views/settings.html
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
<h2>Paramètres</h2>
|
||||
|
||||
<form ng-submit="saveSettings()" class="form-horizontal well">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="startTime" class="col-sm-2 control-label">Début du challenge</label>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" class="form-control" id="startTime" ng-model="config.start">
|
||||
</div>
|
||||
<div class="col-sm-2 text-right">
|
||||
<a ng-click="launchChallenge()" class="btn btn-warning" role="button"><span class="glyphicon glyphicon-play" aria-hidden="true"></span> Lancer le challenge</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="endTime" class="col-sm-2 control-label">Fin du challenge</label>
|
||||
<div class="col-sm-7">
|
||||
<input type="text" class="form-control" id="endTime" ng-model="config.end">
|
||||
</div>
|
||||
<div class="col-sm-1 text-right">
|
||||
<label for="duration" class="control-label">Durée</label>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="duration" ng-model="duration" integer>
|
||||
<div class="input-group-addon">min</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="firstBlood" class="col-sm-2 control-label">Bonus premier sang</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="firstBlood" ng-model="config.firstBlood" float>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="submissionCostBase" class="col-sm-2 control-label">Coût de base d'une soumission</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="submissionCostBase" ng-model="config.submissionCostBase" float>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" ng-model="config.allowRegistration"> Activer les inscriptions
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" ng-model="config.denyNameChange"> Interdire les changements de nom d'équipe
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" ng-model="config.enableResolutionRoute"> Activer la route montrant les solutions
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" ng-model="config.partialValidation"> Activer la validation partielle des challenges
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" ng-model="config.enableExerciceDepend"> Activer les dépendances des exercices
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-right">
|
||||
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-save" aria-hidden="true"></span> Propager ces paramètres</button>
|
||||
</div>
|
||||
</form>
|
||||
Reference in a new issue