Show files remaining in library in sync button tooltip
This commit is contained in:
parent
0df967418b
commit
4c13d51f24
3 changed files with 31 additions and 3 deletions
|
@ -34,6 +34,7 @@ if (!Zotero.Sync.Storage) {
|
||||||
* @param {Object} options
|
* @param {Object} options
|
||||||
* @param {Integer} options.libraryID
|
* @param {Integer} options.libraryID
|
||||||
* @param {Object} options.controller - Storage controller instance (ZFS_Controller/WebDAV_Controller)
|
* @param {Object} options.controller - Storage controller instance (ZFS_Controller/WebDAV_Controller)
|
||||||
|
* @param {Function} [onProgress] - Function to run when a request finishes: f(progress, progressMax)
|
||||||
* @param {Function} [onError] - Function to run on error
|
* @param {Function} [onError] - Function to run on error
|
||||||
* @param {Boolean} [stopOnError]
|
* @param {Boolean} [stopOnError]
|
||||||
*/
|
*/
|
||||||
|
@ -52,11 +53,15 @@ Zotero.Sync.Storage.Engine = function (options) {
|
||||||
this.library = Zotero.Libraries.get(options.libraryID);
|
this.library = Zotero.Libraries.get(options.libraryID);
|
||||||
this.controller = options.controller;
|
this.controller = options.controller;
|
||||||
|
|
||||||
|
this.numRequests = 0;
|
||||||
|
this.requestsRemaining = 0;
|
||||||
|
|
||||||
this.local = Zotero.Sync.Storage.Local;
|
this.local = Zotero.Sync.Storage.Local;
|
||||||
this.utils = Zotero.Sync.Storage.Utilities;
|
this.utils = Zotero.Sync.Storage.Utilities;
|
||||||
|
|
||||||
this.setStatus = options.setStatus || function () {};
|
this.setStatus = options.setStatus || function () {};
|
||||||
this.onError = options.onError || function (e) {};
|
this.onError = options.onError || function (e) {};
|
||||||
|
this.onProgress = options.onProgress || function (progress, progressMax) {};
|
||||||
this.stopOnError = options.stopOnError || false;
|
this.stopOnError = options.stopOnError || false;
|
||||||
|
|
||||||
this.queues = [];
|
this.queues = [];
|
||||||
|
@ -136,6 +141,7 @@ Zotero.Sync.Storage.Engine.prototype.start = Zotero.Promise.coroutine(function*
|
||||||
}
|
}
|
||||||
|
|
||||||
var filesEditable = Zotero.Libraries.get(libraryID).filesEditable;
|
var filesEditable = Zotero.Libraries.get(libraryID).filesEditable;
|
||||||
|
this.requestsRemaining = 0;
|
||||||
|
|
||||||
// Check for updated files to upload
|
// Check for updated files to upload
|
||||||
if (!filesEditable) {
|
if (!filesEditable) {
|
||||||
|
@ -322,8 +328,13 @@ Zotero.Sync.Storage.Engine.prototype.queueItem = Zotero.Promise.coroutine(functi
|
||||||
libraryID: this.libraryID,
|
libraryID: this.libraryID,
|
||||||
name: item.libraryKey,
|
name: item.libraryKey,
|
||||||
onStart: request => this.controller[fn](request),
|
onStart: request => this.controller[fn](request),
|
||||||
onProgress: this.onProgress
|
onStop: () => {
|
||||||
|
this.requestsRemaining--;
|
||||||
|
this.onProgress(this.numRequests - this.requestsRemaining, this.numRequests);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return request.start();
|
return request.start();
|
||||||
});
|
});
|
||||||
|
this.numRequests++;
|
||||||
|
this.requestsRemaining++;
|
||||||
})
|
})
|
||||||
|
|
|
@ -609,12 +609,27 @@ Zotero.Sync.Runner_Module = function (options = {}) {
|
||||||
*/
|
*/
|
||||||
var _doFileSync = Zotero.Promise.coroutine(function* (libraries, options) {
|
var _doFileSync = Zotero.Promise.coroutine(function* (libraries, options) {
|
||||||
Zotero.debug("Starting file syncing");
|
Zotero.debug("Starting file syncing");
|
||||||
this.setSyncStatus(Zotero.getString('sync.status.syncingFiles'));
|
|
||||||
var resyncLibraries = []
|
var resyncLibraries = []
|
||||||
for (let libraryID of libraries) {
|
for (let libraryID of libraries) {
|
||||||
_stopCheck();
|
_stopCheck();
|
||||||
|
this.setSyncStatus(
|
||||||
|
Zotero.getString(
|
||||||
|
'sync.status.syncingFilesInLibrary', Zotero.Libraries.get(libraryID).name
|
||||||
|
)
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
let opts = {};
|
let opts = {
|
||||||
|
onProgress: (progress, progressMax) => {
|
||||||
|
var remaining = progressMax - progress;
|
||||||
|
this.setSyncStatus(
|
||||||
|
Zotero.getString(
|
||||||
|
'sync.status.syncingFilesInLibraryWithRemaining',
|
||||||
|
[Zotero.Libraries.get(libraryID).name, remaining],
|
||||||
|
remaining
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
Object.assign(opts, options);
|
Object.assign(opts, options);
|
||||||
opts.libraryID = libraryID;
|
opts.libraryID = libraryID;
|
||||||
|
|
||||||
|
|
|
@ -967,6 +967,8 @@ sync.status.processingUpdatedData = Processing updated data from sync server
|
||||||
sync.status.uploadingData = Uploading data to sync server
|
sync.status.uploadingData = Uploading data to sync server
|
||||||
sync.status.uploadAccepted = Upload accepted \u2014 waiting for sync server
|
sync.status.uploadAccepted = Upload accepted \u2014 waiting for sync server
|
||||||
sync.status.syncingFiles = Syncing files
|
sync.status.syncingFiles = Syncing files
|
||||||
|
sync.status.syncingFilesInLibrary = Syncing files in %S
|
||||||
|
sync.status.syncingFilesInLibraryWithRemaining = Syncing files in %1$S (%2$S remaining);Syncing files in %1$S (%2$S remaining)
|
||||||
sync.status.syncingFullText = Syncing full-text content
|
sync.status.syncingFullText = Syncing full-text content
|
||||||
|
|
||||||
sync.storage.mbRemaining = %SMB remaining
|
sync.storage.mbRemaining = %SMB remaining
|
||||||
|
|
Loading…
Add table
Reference in a new issue