diff --git a/admin/api/theme.go b/admin/api/theme.go index e95f0993..e7803963 100644 --- a/admin/api/theme.go +++ b/admin/api/theme.go @@ -44,6 +44,14 @@ func init() { router.GET("/api/remote/themes/:thid/exercices", apiHandler(themeHandler(sync.ApiListRemoteExercices))) // Synchronize + router.GET("/api/sync/deep", apiHandler( + func(_ httprouter.Params, _ []byte) (interface{}, error) { + if sync.DeepSyncProgress == 0 { + return nil, errors.New("Pas de synchronisation en cours") + } else { + return map[string]interface{}{"progress": sync.DeepSyncProgress}, nil + } + })) router.POST("/api/sync/deep", apiHandler( func(_ httprouter.Params, _ []byte) (interface{}, error) { return sync.SyncDeep(sync.GlobalImporter), nil diff --git a/admin/static/js/app.js b/admin/static/js/app.js index d725b113..b30c97cb 100644 --- a/admin/static/js/app.js +++ b/admin/static/js/app.js @@ -422,7 +422,7 @@ angular.module("FICApp") $interval(updBox, 750); }) - .controller("SettingsController", function($scope, $rootScope, Settings, ROSettings, $location, $http) { + .controller("SettingsController", function($scope, $rootScope, Settings, ROSettings, $location, $http, $interval) { $scope.config = Settings.get(); $scope.config.$promise.then(function(response) { $rootScope.settings.start = new Date(response.start); @@ -433,6 +433,21 @@ angular.module("FICApp") $scope.configro = ROSettings.get(); $scope.duration = 240; + var progressInterval = $interval(function() { + $http.get("/api/sync/deep").then(function(response) { + if (response.data && response.data.progress) + $scope.syncProgress = Math.floor(response.data.progress * 100 / 255) + " %"; + else + $scope.syncProgress = response.data; + }, function(response) { + if (response.data && response.data.errmsg) + $scope.syncProgress = response.data.errmsg; + else + $scope.syncProgress = response.data; + }) + }, 1500); + $scope.$on('$destroy', function () { $interval.cancel(progressInterval); }); + $scope.saveSettings = function(msg) { if (msg === undefined) { msg = 'New settings saved!'; } var nStart = this.config.start; diff --git a/admin/static/views/settings.html b/admin/static/views/settings.html index 192d4573..01cfdb58 100644 --- a/admin/static/views/settings.html +++ b/admin/static/views/settings.html @@ -161,6 +161,9 @@
+