diff --git a/admin/index.go b/admin/index.go index 384d7d67..d0a334e4 100644 --- a/admin/index.go +++ b/admin/index.go @@ -51,6 +51,7 @@ const indextpl = ` + Démarrage dans : {{"{{ startIn }}"}}" diff --git a/admin/static/index.html b/admin/static/index.html index e19ef421..3ea5b0a9 100644 --- a/admin/static/index.html +++ b/admin/static/index.html @@ -49,6 +49,7 @@ + Démarrage dans : {{ startIn }}" diff --git a/admin/static/js/app.js b/admin/static/js/app.js index d46d1cb0..e98bec1d 100644 --- a/admin/static/js/app.js +++ b/admin/static/js/app.js @@ -314,7 +314,7 @@ angular.module("FICApp") }; }) - .run(function($rootScope, $http, $interval) { + .run(function($rootScope, $http, $interval, Settings) { function refresh() { $http.get("/api/settings.json").then(function(response) { response.data.start = new Date(response.data.start); @@ -326,6 +326,19 @@ angular.module("FICApp") } refresh(); $interval(refresh, 10000); + + $rootScope.staticFilesNeedUpdate = 0; + $rootScope.regenerateStaticFiles = function() { + Settings.get().$promise.then(function(config) { + config.generation = (new Date()).toISOString(); + config.$update(function() { + $rootScope.staticFilesNeedUpdate = 0; + $rootScope.newBox('success', "Regeneration in progress..."); + }, function (response) { + $rootScope.newBox('success', 'An error occurs when saving settings:', response.data.errmsg); + }) + }) + } }) .controller("VersionController", function($scope, Version) { @@ -686,6 +699,7 @@ angular.module("FICApp") $scope.clearFiles = function(id) { File.delete(function() { + $rootScope.staticFilesNeedUpdate++; $scope.files = []; }); }; @@ -897,6 +911,7 @@ angular.module("FICApp") }).then(function(response) { $scope.inSync = false; $scope.themes = Theme.query(); + $rootScope.staticFilesNeedUpdate++; if (response.data) $rootScope.newBox('danger', response.data); else @@ -919,9 +934,11 @@ angular.module("FICApp") $location.url("/themes/" + $scope.theme.id); }); } + $rootScope.staticFilesNeedUpdate++; } $scope.deleteTheme = function() { this.theme.$remove(function() { + $rootScope.staticFilesNeedUpdate++; $location.url("/themes/"); }, function(response) { $rootScope.newBox('danger', 'An error occurs when trying to delete theme:', response.data.errmsg); @@ -947,6 +964,7 @@ angular.module("FICApp") } }) $scope.exercice = {}; + $rootScope.staticFilesNeedUpdate++; $rootScope.newBox('success', 'Édition de masse terminée avec succès'); } @@ -971,6 +989,7 @@ angular.module("FICApp") url: u, method: "GET" }).then(function(response) { + $rootScope.staticFilesNeedUpdate++; $scope.done += 1; go(); }, function(response) { @@ -1012,6 +1031,7 @@ angular.module("FICApp") }).then(function(response) { $scope.inSync = false; $scope.exercices = ThemedExercice.query({ themeId: $routeParams.themeId }); + $rootScope.staticFilesNeedUpdate++; if (response.data) $rootScope.newBox('warning', null, response.data, -1); else @@ -1065,6 +1085,7 @@ angular.module("FICApp") }).then(function(response) { $scope.inSync = false; $scope.exercice = Exercice.get({ exerciceId: $routeParams.exerciceId }); + $rootScope.staticFilesNeedUpdate++; if (response.data) $rootScope.newBox('danger', response.data); else @@ -1077,6 +1098,7 @@ angular.module("FICApp") $scope.deleteExercice = function() { this.exercice.$remove(function() { + $rootScope.staticFilesNeedUpdate++; $location.url("/themes/" + $routeParams.themeId); }, function(response) { $rootScope.newBox('danger', 'An error occurs when trying to delete exercice:', response.data); @@ -1085,8 +1107,10 @@ angular.module("FICApp") $scope.saveExercice = function() { if (this.exercice.id) { this.exercice.$update(); + $rootScope.staticFilesNeedUpdate++; } else if ($routeParams.themeId) { this.exercice.$save({ themeId: $routeParams.themeId }, function() { + $rootScope.staticFilesNeedUpdate++; $location.url("/themes/" + $scope.exercice.idTheme + "/exercices/" + $scope.exercice.id); }, function(response) { $rootScope.newBox('danger', 'An error occurs when trying to save exercice:', response.data.errmsg); @@ -1108,6 +1132,7 @@ angular.module("FICApp") } $scope.saveTags = function() { ExerciceTags.update({ exerciceId: $routeParams.exerciceId }, this.tags); + $rootScope.staticFilesNeedUpdate++; } }) @@ -1118,10 +1143,12 @@ angular.module("FICApp") this.file.$delete(function() { $scope.files.splice($scope.files.indexOf(this.file), 1); }); + $rootScope.staticFilesNeedUpdate++; return false; } $scope.saveFile = function() { this.file.$update(); + $rootScope.staticFilesNeedUpdate++; } $scope.inSync = false; $scope.syncFiles = function() { @@ -1131,6 +1158,7 @@ angular.module("FICApp") method: "POST" }).then(function(response) { $scope.inSync = false; + $rootScope.staticFilesNeedUpdate++; $scope.files = ExerciceFile.query({ exerciceId: $routeParams.exerciceId }); if (response.data) $rootScope.newBox('danger', response.data); @@ -1147,12 +1175,12 @@ angular.module("FICApp") $scope.hints = ExerciceHint.query({ exerciceId: $routeParams.exerciceId }); $scope.addHint = function() { - $scope.toggleHints(true); $scope.hints.push(new ExerciceHint()); } $scope.deleteHint = function() { this.hint.$delete(function() { $scope.hints.splice($scope.hints.indexOf(this.hint), 1); + $rootScope.staticFilesNeedUpdate++; }, function(response) { $rootScope.newBox('danger', 'An error occurs when trying to delete hint:', response.data); }); @@ -1163,6 +1191,7 @@ angular.module("FICApp") } else { this.hint.$save({ exerciceId: $routeParams.exerciceId }); } + $rootScope.staticFilesNeedUpdate++; } $scope.inSync = false; $scope.syncHints = function() { @@ -1173,6 +1202,7 @@ angular.module("FICApp") }).then(function(response) { $scope.inSync = false; $scope.hints = ExerciceHint.query({ exerciceId: $routeParams.exerciceId }); + $rootScope.staticFilesNeedUpdate++; if (response.data) $rootScope.newBox('danger', response.data); else @@ -1188,12 +1218,12 @@ angular.module("FICApp") $scope.flags = ExerciceFlag.query({ exerciceId: $routeParams.exerciceId }); $scope.addFlag = function() { - $scope.toggleFlags(true); $scope.flags.push(new ExerciceFlag()); } $scope.deleteFlag = function() { this.flag.$delete(function() { $scope.flags.splice($scope.flags.indexOf(this.flag), 1); + $rootScope.staticFilesNeedUpdate++; }, function(response) { $rootScope.newBox('danger', 'An error occurs when trying to delete flag:', response.data); }); @@ -1204,6 +1234,7 @@ angular.module("FICApp") } else { this.flag.$save({ exerciceId: $routeParams.exerciceId }); } + $rootScope.staticFilesNeedUpdate++; } $scope.inSync = false; $scope.syncFlags = function() { @@ -1214,6 +1245,7 @@ angular.module("FICApp") }).then(function(response) { $scope.inSync = false; $scope.flags = ExerciceFlag.query({ exerciceId: $routeParams.exerciceId }); + $rootScope.staticFilesNeedUpdate++; if (response.data) $rootScope.newBox('danger', response.data); else @@ -1229,12 +1261,12 @@ angular.module("FICApp") $scope.quiz = ExerciceMCQFlag.query({ exerciceId: $routeParams.exerciceId }); $scope.addQuiz = function() { - $scope.toggleQuizz(true); $scope.quiz.push(new ExerciceMCQFlag()); } $scope.deleteQuiz = function() { this.q.$delete(function() { $scope.quiz.splice($scope.quiz.indexOf(this.q), 1); + $rootScope.staticFilesNeedUpdate++; }, function(response) { $rootScope.newBox('danger', 'An error occurs when trying to delete flag:', response.data); }); @@ -1245,6 +1277,7 @@ angular.module("FICApp") } else { this.q.$save({ exerciceId: $routeParams.exerciceId }); } + $rootScope.staticFilesNeedUpdate++; } $scope.addChoice = function() { @@ -1310,15 +1343,17 @@ angular.module("FICApp") $scope.saveTeam = function() { if (this.team.id) { this.team.$update(); + $rootScope.staticFilesNeedUpdate++; } else { this.team.$save(function() { + $rootScope.staticFilesNeedUpdate++; $location.url("/teams/" + $scope.team.id); }); } } $scope.deleteTeam = function() { backName = this.team.name; - this.team.$remove(function() { $rootScope.newBox('success', 'Team ' + backName + ' successfully removed.'); $location.url("/teams/"); }, + this.team.$remove(function() { $rootScope.newBox('success', 'Team ' + backName + ' successfully removed.'); $location.url("/teams/"); $rootScope.staticFilesNeedUpdate++; }, function(response) { $rootScope.newBox('danger', 'An error occurs during suppression of the team:', response.data); }); } $scope.showStats = function() { @@ -1333,6 +1368,7 @@ angular.module("FICApp") method: "DELETE", data: row }).then(function(response) { + $rootScope.staticFilesNeedUpdate++; $scope.history = TeamHistory.query({ teamId: $routeParams.teamId }); }, function(response) { $rootScope.newBox('danger', 'An error occurs when removing history item: ', response.data);