admin: control settings
This commit is contained in:
parent
a25e2edfd7
commit
9d3afcba53
7 changed files with 180 additions and 0 deletions
|
|
@ -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"];
|
||||
|
|
|
|||
Reference in a new issue