gui: New rest endpoint to get errors when web UI is opened
Since #4340 pulls aren't happening every 10s anymore and may be delayed up to 1h. This means that no folder error event reaches the web UI for a long time, thus no failed items will show up for a long time. Now errors are populated when the web UI is opened. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4650 LGTM: AudriusButkevicius
This commit is contained in:
committed by
Audrius Butkevicius
parent
89a021609b
commit
fecb21cdb1
@@ -48,8 +48,6 @@ angular.module('syncthing.core')
|
||||
$scope.neededCurrentPage = 1;
|
||||
$scope.neededPageSize = 10;
|
||||
$scope.failed = {};
|
||||
$scope.failedCurrentPage = 1;
|
||||
$scope.failedPageSize = 10;
|
||||
$scope.scanProgress = {};
|
||||
$scope.themes = [];
|
||||
$scope.globalChangeEvents = {};
|
||||
@@ -198,13 +196,6 @@ angular.module('syncthing.core')
|
||||
$scope.model[data.folder].state = data.to;
|
||||
$scope.model[data.folder].error = data.error;
|
||||
|
||||
// If a folder has started syncing, then any old list of
|
||||
// errors is obsolete. We may get a new list of errors very
|
||||
// shortly though.
|
||||
if (data.to === 'syncing') {
|
||||
$scope.failed[data.folder] = [];
|
||||
}
|
||||
|
||||
// If a folder has started scanning, then any scan progress is
|
||||
// also obsolete.
|
||||
if (data.to === 'scanning') {
|
||||
@@ -344,8 +335,7 @@ angular.module('syncthing.core')
|
||||
});
|
||||
|
||||
$scope.$on(Events.FOLDER_ERRORS, function (event, arg) {
|
||||
var data = arg.data;
|
||||
$scope.failed[data.folder] = data.errors;
|
||||
$scope.model[arg.data.folder].pullErrors = arg.data.errors.length;
|
||||
});
|
||||
|
||||
$scope.$on(Events.FOLDER_SCAN_PROGRESS, function (event, arg) {
|
||||
@@ -657,12 +647,12 @@ angular.module('syncthing.core')
|
||||
refreshNeed($scope.neededFolder);
|
||||
};
|
||||
|
||||
$scope.failedPageChanged = function (page) {
|
||||
$scope.failedCurrentPage = page;
|
||||
};
|
||||
|
||||
$scope.failedChangePageSize = function (perpage) {
|
||||
$scope.failedPageSize = perpage;
|
||||
$scope.refreshFailed = function (page, perpage) {
|
||||
var url = urlbase + '/folder/pullerrors?folder=' + encodeURIComponent($scope.failed.folder);
|
||||
url += "&page=" + page + "&perpage=" + perpage;
|
||||
$http.get(url).success(function (data) {
|
||||
$scope.failed = data;
|
||||
}).error($scope.emitHTTPError);
|
||||
};
|
||||
|
||||
$scope.refreshRemoteNeed = function (folder, page, perpage) {
|
||||
@@ -1018,14 +1008,6 @@ angular.module('syncthing.core')
|
||||
return '?';
|
||||
};
|
||||
|
||||
$scope.deviceCompletion = function (deviceCfg) {
|
||||
var conn = $scope.connections[deviceCfg.deviceID];
|
||||
if (conn) {
|
||||
return conn.completion + '%';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
$scope.friendlyNameFromShort = function (shortID) {
|
||||
var matches = $scope.devices.filter(function (n) {
|
||||
return n.deviceID.substr(0, 7) === shortID;
|
||||
@@ -2067,24 +2049,18 @@ angular.module('syncthing.core')
|
||||
};
|
||||
|
||||
$scope.showFailed = function (folder) {
|
||||
$scope.failedCurrent = $scope.failed[folder];
|
||||
$scope.failedFolderPath = $scope.folders[folder].path;
|
||||
if ($scope.failedFolderPath[$scope.failedFolderPath.length - 1] !== $scope.system.pathSeparator) {
|
||||
$scope.failedFolderPath += $scope.system.pathSeparator;
|
||||
}
|
||||
$scope.failed.folder = folder;
|
||||
$scope.failed = $scope.refreshFailed(1, 10);
|
||||
$('#failed').modal().on('hidden.bs.modal', function () {
|
||||
$scope.failedCurrent = undefined;
|
||||
$scope.failed = {};
|
||||
});
|
||||
};
|
||||
|
||||
$scope.hasFailedFiles = function (folder) {
|
||||
if (!$scope.failed[folder]) {
|
||||
if (!$scope.model[folder]) {
|
||||
return false;
|
||||
}
|
||||
if ($scope.failed[folder].length === 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return $scope.model[folder].pullErrors !== 0;
|
||||
};
|
||||
|
||||
$scope.override = function (folder) {
|
||||
|
||||
Reference in New Issue
Block a user