update: log history
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
/* global angular:false */
|
||||
/* global $:false */
|
||||
/* global $:false, TASK_TYPES */
|
||||
|
||||
angular.module('Application').controller('SettingsController', ['$scope', '$location', '$translate', '$rootScope', '$timeout', 'Client', function ($scope, $location, $translate, $rootScope, $timeout, Client) {
|
||||
Client.onReady(function () { if (!Client.getUserInfo().isAtLeastAdmin) $location.path('/'); });
|
||||
@@ -87,8 +87,16 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
percent: 0,
|
||||
message: 'Downloading',
|
||||
errorMessage: '', // this shows inline
|
||||
taskId: '',
|
||||
skipBackup: false,
|
||||
tasks: [],
|
||||
|
||||
refreshTasks: function () {
|
||||
Client.getTasksByType(TASK_TYPES.TASK_UPDATE, function (error, tasks) {
|
||||
if (error) return console.error(error);
|
||||
$scope.update.tasks = tasks.slice(0, 10);
|
||||
if ($scope.update.tasks.length && $scope.update.tasks[0].active) $scope.update.updateStatus();
|
||||
});
|
||||
},
|
||||
|
||||
checkNow: function () {
|
||||
$scope.update.checking = true;
|
||||
@@ -108,7 +116,9 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
},
|
||||
|
||||
stopUpdate: function () {
|
||||
Client.stopTask($scope.update.taskId, function (error) {
|
||||
var taskId = $scope.update.tasks[0].id;
|
||||
|
||||
Client.stopTask(taskId, function (error) {
|
||||
if (error) {
|
||||
if (error.statusCode === 409) {
|
||||
$scope.update.errorMessage = 'No update is currently in progress';
|
||||
@@ -124,16 +134,6 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
});
|
||||
},
|
||||
|
||||
checkStatus: function () {
|
||||
Client.getLatestTaskByType('update', function (error, task) {
|
||||
if (error) return console.error(error);
|
||||
if (!task) return;
|
||||
|
||||
$scope.update.taskId = task.id;
|
||||
$scope.update.updateStatus();
|
||||
});
|
||||
},
|
||||
|
||||
reloadIfNeeded: function () {
|
||||
Client.getStatus(function (error, status) {
|
||||
if (error) return $scope.error(error);
|
||||
@@ -143,7 +143,9 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
},
|
||||
|
||||
updateStatus: function () {
|
||||
Client.getTask($scope.update.taskId, function (error, data) {
|
||||
var taskId = $scope.update.tasks[0].id;
|
||||
|
||||
Client.getTask(taskId, function (error, data) {
|
||||
if (error) return window.setTimeout($scope.update.updateStatus, 5000);
|
||||
|
||||
if (!data.active) {
|
||||
@@ -154,6 +156,8 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
|
||||
if (!data.errorMessage) $scope.update.reloadIfNeeded(); // assume success
|
||||
|
||||
$scope.update.refreshTasks(); // redundant... update the tasks list dropdown
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -172,7 +176,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
$scope.update.message = '';
|
||||
$scope.update.errorMessage = '';
|
||||
|
||||
Client.update({ skipBackup: $scope.update.skipBackup }, function (error, taskId) {
|
||||
Client.update({ skipBackup: $scope.update.skipBackup }, function (error /*, taskId */) {
|
||||
if (error) {
|
||||
$scope.update.error.generic = error.message;
|
||||
$scope.update.busy = false;
|
||||
@@ -181,8 +185,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
|
||||
$('#updateModal').modal('hide');
|
||||
|
||||
$scope.update.taskId = taskId;
|
||||
$scope.update.updateStatus();
|
||||
$scope.update.refreshTasks();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -430,7 +433,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
});
|
||||
});
|
||||
|
||||
$scope.update.checkStatus();
|
||||
$scope.update.refreshTasks();
|
||||
|
||||
if ($scope.user.isAtLeastOwner) getSubscription();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user