From 259351cdd2e1448826552cfe52473f98abb3590e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A6=E8=8D=A3=E8=B6=85?= <302645122@qq.com> Date: Mon, 14 Feb 2022 18:13:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=80=90=E6=96=87=E4=BB=B6=E3=80=91?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=9B=BE=E5=8E=BB=E6=8E=89ctr+s=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/drawio/js/diagramly/App.js | 4 +- public/js/drawio/js/diagramly/DriveFile.js | 118 +++++++++--------- public/js/drawio/js/diagramly/LocalFile.js | 52 ++++---- public/js/drawio/js/diagramly/StorageFile.js | 76 +++++------ .../public/js/drawio/js/diagramly/App.js | 4 +- .../js/drawio/js/diagramly/DriveFile.js | 118 +++++++++--------- .../js/drawio/js/diagramly/LocalFile.js | 52 ++++---- .../js/drawio/js/diagramly/StorageFile.js | 76 +++++------ 8 files changed, 250 insertions(+), 250 deletions(-) diff --git a/public/js/drawio/js/diagramly/App.js b/public/js/drawio/js/diagramly/App.js index 325e4635..97eb8071 100644 --- a/public/js/drawio/js/diagramly/App.js +++ b/public/js/drawio/js/diagramly/App.js @@ -3769,6 +3769,7 @@ App.prototype.loadFileSystemEntry = function(fileHandle, success, error) reader.onload = mxUtils.bind(this, function(e) { + try { if (success != null) @@ -3912,7 +3913,6 @@ App.prototype.pickFile = function(mode) else { var peer = this.getPeerForMode(mode); - if (peer != null) { peer.pickFile(); @@ -4548,7 +4548,7 @@ App.prototype.saveFile = function(forceDialog, success) this.hideDialog(); }), mxResources.get('saveAs'), mxResources.get('download'), null, null, allowTab, null, true, rowLimit, null, null, null, this.editor.fileExtensions, false); - this.showDialog(dlg.container, 420, (serviceCount > rowLimit) ? 390 : 280, true, true); + // this.showDialog(dlg.container, 420, (serviceCount > rowLimit) ? 390 : 280, true, true); dlg.init(); } } diff --git a/public/js/drawio/js/diagramly/DriveFile.js b/public/js/drawio/js/diagramly/DriveFile.js index 13f58248..d19d2128 100644 --- a/public/js/drawio/js/diagramly/DriveFile.js +++ b/public/js/drawio/js/diagramly/DriveFile.js @@ -5,7 +5,7 @@ DriveFile = function(ui, data, desc) { DrawioFile.call(this, ui, data); - + this.desc = desc; }; @@ -57,7 +57,7 @@ DriveFile.prototype.getCurrentUser = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -73,7 +73,7 @@ DriveFile.prototype.getPublicUrl = function(fn) { this.ui.drive.executeRequest({ url: '/files/' + this.desc.id + '/permissions?supportsAllDrives=true' - }, + }, mxUtils.bind(this, function(resp) { if (resp != null && resp.items != null) @@ -84,12 +84,12 @@ DriveFile.prototype.getPublicUrl = function(fn) resp.items[i].id === 'anyone') { fn(this.desc.webContentLink); - + return; } } } - + fn(null); }), mxUtils.bind(this, function() { @@ -108,7 +108,7 @@ DriveFile.prototype.isAutosaveOptional = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -119,7 +119,7 @@ DriveFile.prototype.isRenamable = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -130,7 +130,7 @@ DriveFile.prototype.isMovable = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -141,7 +141,7 @@ DriveFile.prototype.isTrashed = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -155,7 +155,7 @@ DriveFile.prototype.save = function(revision, success, error, unloading, overwri /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -184,31 +184,31 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi try { var lastDesc = this.desc; - + this.ui.drive.saveFile(this, realRevision, mxUtils.bind(this, function(resp, savedData) { try { this.savingFile = false; - + // Handles special case where resp is false eg // if the old file was converted to realtime if (resp != false) { // Checks for changes during save this.setModified(this.getShadowModified()); - + if (revision) { this.lastAutosaveRevision = new Date().getTime(); } - + // Adaptive autosave delay this.autosaveDelay = Math.round(Math.min(10000, Math.max(DriveFile.prototype.autosaveDelay, this.saveDelay))); this.desc = resp; - + // Shows possible errors but keeps the modified flag as the // file was saved but the cache entry could not be written if (token != null) @@ -216,7 +216,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi this.fileSaved(savedData, lastDesc, mxUtils.bind(this, function() { this.contentChanged(); - + if (success != null) { success(resp); @@ -236,7 +236,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi catch (e) { this.savingFile = false; - + if (error != null) { error(e); @@ -251,15 +251,15 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi try { this.savingFile = false; - + if (this.isConflict(err)) { this.inConflictState = true; - + if (this.sync != null) { this.savingFile = true; - + this.sync.fileConflict(desc, mxUtils.bind(this, function() { // Adds random cool-off @@ -272,7 +272,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi }), mxUtils.bind(this, function() { this.savingFile = false; - + if (error != null) { error(); @@ -292,7 +292,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi catch (e) { this.savingFile = false; - + if (error != null) { error(e); @@ -307,7 +307,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi catch (e) { this.savingFile = false; - + if (error != null) { error(e); @@ -318,8 +318,8 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi } } }); - - doSave(overwrite, revision); + + doSave(overwrite, revision); })); } } @@ -361,7 +361,7 @@ DriveFile.prototype.copyFile = function(success, error) else { DrawioFile.prototype.copyFile.apply(this, arguments); - } + } }; /** @@ -379,17 +379,17 @@ DriveFile.prototype.makeCopy = function(success, error, timestamp) this.desc = resp; this.ui.spinner.stop(); this.setModified(false); - + this.backupPatch = null; this.invalidChecksum = false; this.inConflictState = false; - + this.descriptorChanged(); success(); }), mxUtils.bind(this, function() { this.ui.spinner.stop(); - + if (error != null) { error(); @@ -400,7 +400,7 @@ DriveFile.prototype.makeCopy = function(success, error, timestamp) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -411,14 +411,14 @@ DriveFile.prototype.saveAs = function(filename, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ DriveFile.prototype.rename = function(title, success, error) { var etag = this.getCurrentEtag(); - + this.ui.drive.renameFile(this.getId(), title, mxUtils.bind(this, function(desc) { if (!this.hasSameExtension(title, this.getTitle())) @@ -429,19 +429,19 @@ DriveFile.prototype.rename = function(title, success, error) { this.sync.descriptorChanged(etag); } - + this.save(true, success, error); } else { this.desc = desc; this.descriptorChanged(); - + if (this.sync != null) { this.sync.descriptorChanged(etag); } - + if (success != null) { success(desc); @@ -452,7 +452,7 @@ DriveFile.prototype.rename = function(title, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -462,7 +462,7 @@ DriveFile.prototype.move = function(folderId, success, error) { this.desc = resp; this.descriptorChanged(); - + if (success != null) { success(resp); @@ -472,7 +472,7 @@ DriveFile.prototype.move = function(folderId, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -483,7 +483,7 @@ DriveFile.prototype.share = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -494,7 +494,7 @@ DriveFile.prototype.getTitle = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -505,7 +505,7 @@ DriveFile.prototype.getHash = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -516,7 +516,7 @@ DriveFile.prototype.getId = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -560,7 +560,7 @@ DriveFile.prototype.getRevisions = function(success, error) // Redirects title to originalFilename to // match expected descriptor interface item.title = item.originalFilename; - + item.getXml = mxUtils.bind(this, function(itemSuccess, itemError) { this.ui.drive.getXmlFile(item, mxUtils.bind(this, function(file) @@ -568,7 +568,7 @@ DriveFile.prototype.getRevisions = function(success, error) itemSuccess(file.getData()); }), itemError); }); - + item.getUrl = mxUtils.bind(this, function(page) { return this.ui.getUrl(window.location.pathname + '?rev=' + item.id + @@ -577,7 +577,7 @@ DriveFile.prototype.getRevisions = function(success, error) }); }))(resp.items[i]); } - + success(resp.items); }), error); }; @@ -596,12 +596,12 @@ DriveFile.prototype.getLatestVersion = function(success, error) DriveFile.prototype.getChannelId = function() { var chan = this.ui.drive.getCustomProperty(this.desc, 'channel'); - + if (chan != null) { chan = 'G-' + this.getId() + '.' + chan; } - + return chan; }; @@ -683,7 +683,7 @@ DriveFile.prototype.setDescriptorEtag = function(desc, etag) DriveFile.prototype.loadPatchDescriptor = function(success, error) { this.ui.drive.executeRequest( - { + { url: '/files/' + this.getId() + '?supportsAllDrives=true&fields=' + this.ui.drive.catchupFields }, mxUtils.bind(this, function(desc) @@ -699,7 +699,7 @@ DriveFile.prototype.patchDescriptor = function(desc, patch) { desc.headRevisionId = patch.headRevisionId; desc.modifiedDate = patch.modifiedDate; - + DrawioFile.prototype.patchDescriptor.apply(this, arguments); }; @@ -725,25 +725,25 @@ DriveFile.prototype.commentsSupported = function() DriveFile.prototype.getComments = function(success, error) { var currentUser = this.ui.getCurrentUser(); - + function driveCommentToDrawio(file, gComment, pCommentId) { if (gComment.deleted) return null; //skip deleted comments - - var comment = new DriveComment(file, gComment.commentId || gComment.replyId, gComment.content, + + var comment = new DriveComment(file, gComment.commentId || gComment.replyId, gComment.content, gComment.modifiedDate, gComment.createdDate, gComment.status == 'resolved', gComment.author.isAuthenticatedUser? currentUser : new DrawioUser(gComment.author.permissionId, gComment.author.emailAddress, gComment.author.displayName, gComment.author.picture.url), pCommentId); - + for (var i = 0; gComment.replies != null && i < gComment.replies.length; i++) { comment.addReplyDirect(driveCommentToDrawio(file, gComment.replies[i], gComment.commentId)); } - + return comment; }; - + this.ui.drive.executeRequest( { url: '/files/' + this.getId() + '/comments' @@ -751,14 +751,14 @@ DriveFile.prototype.getComments = function(success, error) mxUtils.bind(this, function(resp) { var comments = []; - + for (var i = 0; i < resp.items.length; i++) { var comment = driveCommentToDrawio(this, resp.items[i]); - + if (comment != null) comments.push(comment); } - + success(comments); }), error); }; @@ -769,7 +769,7 @@ DriveFile.prototype.getComments = function(success, error) DriveFile.prototype.addComment = function(comment, success, error) { var body = {'content': comment.content}; - + this.ui.drive.executeRequest( { url: '/files/' + this.getId() + '/comments', diff --git a/public/js/drawio/js/diagramly/LocalFile.js b/public/js/drawio/js/diagramly/LocalFile.js index 3b646203..e61957f3 100644 --- a/public/js/drawio/js/diagramly/LocalFile.js +++ b/public/js/drawio/js/diagramly/LocalFile.js @@ -11,7 +11,7 @@ LocalFile = function(ui, data, title, temp, fileHandle, desc) { DrawioFile.call(this, ui, data); - + this.title = title; this.mode = (temp) ? null : App.MODE_DEVICE; this.fileHandle = fileHandle; @@ -23,7 +23,7 @@ mxUtils.extend(LocalFile, DrawioFile); /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -43,7 +43,7 @@ LocalFile.prototype.isAutosaveOptional = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -54,7 +54,7 @@ LocalFile.prototype.getMode = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -65,7 +65,7 @@ LocalFile.prototype.getTitle = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -76,7 +76,7 @@ LocalFile.prototype.isRenamable = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -87,7 +87,7 @@ LocalFile.prototype.save = function(revision, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -98,7 +98,7 @@ LocalFile.prototype.saveAs = function(title, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -125,7 +125,7 @@ LocalFile.prototype.setDescriptor = function(desc) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -143,7 +143,7 @@ LocalFile.prototype.getLatestVersion = function(success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -154,7 +154,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr this.fileHandle = null; this.desc = null; } - + this.title = title; // Updates data after changing file name @@ -162,22 +162,22 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr { this.updateFileData(); } - + var binary = this.ui.useCanvasForExport && /(\.png)$/i.test(this.getTitle()); this.setShadowModified(false); var savedData = this.getData(); - + var done = mxUtils.bind(this, function() { this.setModified(this.getShadowModified()); this.contentChanged(); - + if (success != null) { success(); } }); - + var doSave = mxUtils.bind(this, function(data) { if (this.fileHandle != null) @@ -187,27 +187,27 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr { this.savingFileTime = new Date(); this.savingFile = true; - + var errorWrapper = mxUtils.bind(this, function(e) { this.savingFile = false; - + if (error != null) { // Wraps error object to offer save status option error({error: e}); } }); - + // Saves a copy as a draft while saving this.saveDraft(); - + this.fileHandle.createWritable().then(mxUtils.bind(this, function(writable) { this.fileHandle.getFile().then(mxUtils.bind(this, function(newDesc) { this.invalidFileHandle = null; - + if (this.desc.lastModified == newDesc.lastModified) { writable.write((binary) ? this.ui.base64ToBlob(data, 'image/png') : data).then(mxUtils.bind(this, function() @@ -222,7 +222,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr this.savingFile = false; this.desc = desc; this.fileSaved(savedData, lastDesc, done, errorWrapper); - + // Deletes draft after saving this.removeDraft(); } @@ -260,7 +260,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr { var dot = title.lastIndexOf('.'); var format = (dot > 0) ? title.substring(dot + 1) : 'xml'; - + // Do not update modified flag new mxXmlRequest(SAVE_URL, 'format=' + format + '&xml=' + encodeURIComponent(data) + @@ -276,11 +276,11 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr })); } } - + done(); } }); - + if (binary) { var p = this.ui.getPngFileProperties(this.ui.fileNode); @@ -299,7 +299,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -307,7 +307,7 @@ LocalFile.prototype.rename = function(title, success, error) { this.title = title; this.descriptorChanged(); - + if (success != null) { success(); diff --git a/public/js/drawio/js/diagramly/StorageFile.js b/public/js/drawio/js/diagramly/StorageFile.js index a9dde880..f0da7b75 100644 --- a/public/js/drawio/js/diagramly/StorageFile.js +++ b/public/js/drawio/js/diagramly/StorageFile.js @@ -13,7 +13,7 @@ StorageFile = function(ui, data, title) { DrawioFile.call(this, ui, data); - + this.title = title; }; @@ -37,7 +37,7 @@ StorageFile.prototype.type = 'F'; /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -56,7 +56,7 @@ StorageFile.prototype.isAutosaveOptional = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -67,7 +67,7 @@ StorageFile.prototype.getHash = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -78,7 +78,7 @@ StorageFile.prototype.getTitle = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -89,7 +89,7 @@ StorageFile.prototype.isRenamable = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -100,7 +100,7 @@ StorageFile.prototype.save = function(revision, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -112,7 +112,7 @@ StorageFile.prototype.saveAs = function(title, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -123,7 +123,7 @@ StorageFile.insertFile = function(ui, title, data, success, error) var fn = function() { var file = new StorageFile(ui, data, title); - + // Inserts data into local storage file.saveFile(title, false, function() { @@ -140,7 +140,7 @@ StorageFile.insertFile = function(ui, title, data, success, error) fn(); } }); - + StorageFile.getFileContent(ui, title, function(data) { createStorageFile(data != null); @@ -152,7 +152,7 @@ StorageFile.insertFile = function(ui, title, data, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -161,7 +161,7 @@ StorageFile.getFileContent = function(ui, title, success, error) ui.getDatabaseItem(title, function(obj) { success(obj != null? obj.data : null); - }, + }, mxUtils.bind(this, function() { if (ui.database == null) //fallback to localstorage @@ -177,7 +177,7 @@ StorageFile.getFileContent = function(ui, title, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -186,7 +186,7 @@ StorageFile.getFileInfo = function(ui, title, success, error) ui.getDatabaseItem(title, function(obj) { success(obj); - }, + }, mxUtils.bind(this, function() { if (ui.database == null) //fallback to localstorage @@ -205,7 +205,7 @@ StorageFile.getFileInfo = function(ui, title, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -226,23 +226,23 @@ StorageFile.prototype.saveFile = function(title, revision, success, error) { this.title = title; } - + try { var saveDone = mxUtils.bind(this, function() { this.setModified(this.getShadowModified()); this.contentChanged(); - + if (success != null) { success(); } }); - + this.setShadowModified(false); var data = this.getData(); - + this.ui.setDatabaseItem(null, [{ title: this.title, size: data.length, @@ -271,7 +271,7 @@ StorageFile.prototype.saveFile = function(title, revision, success, error) } } }); - + // Checks for trailing dots if (this.isRenamable() && title.charAt(0) == '.' && error != null) { @@ -296,7 +296,7 @@ StorageFile.prototype.saveFile = function(title, revision, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -311,19 +311,19 @@ StorageFile.prototype.rename = function(title, success, error) var fn = mxUtils.bind(this, function() { this.title = title; - + // Updates the data if the extension has changed if (!this.hasSameExtension(oldTitle, title)) { this.setData(this.ui.getFileData()); } - + this.saveFile(title, false, mxUtils.bind(this, function() { this.ui.removeLocalData(oldTitle, success); }), error); }); - + if (data != null) { this.ui.confirm(mxResources.get('replaceIt', [title]), fn, error); @@ -369,7 +369,7 @@ StorageFile.prototype.getLatestVersion = function(success, error) StorageFile.prototype.destroy = function() { DrawioFile.prototype.destroy.apply(this, arguments); - + if (this.storageListener != null) { mxEvent.removeListener(window, 'storage', this.storageListener); @@ -379,19 +379,19 @@ StorageFile.prototype.destroy = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ StorageFile.listLocalStorageFiles = function(type) { var filesInfo = []; - + for (var i = 0; i < localStorage.length; i++) { var key = localStorage.key(i); var value = localStorage.getItem(key); - + if (key.length > 0 && key.charAt(0) != '.' && value.length > 0) { var isFile = (type == null || type == 'F') && (value.substring(0, 8) === ' rowLimit) ? 390 : 280, true, true); + // this.showDialog(dlg.container, 420, (serviceCount > rowLimit) ? 390 : 280, true, true); dlg.init(); } } diff --git a/resources/assets/statics/public/js/drawio/js/diagramly/DriveFile.js b/resources/assets/statics/public/js/drawio/js/diagramly/DriveFile.js index 13f58248..d19d2128 100644 --- a/resources/assets/statics/public/js/drawio/js/diagramly/DriveFile.js +++ b/resources/assets/statics/public/js/drawio/js/diagramly/DriveFile.js @@ -5,7 +5,7 @@ DriveFile = function(ui, data, desc) { DrawioFile.call(this, ui, data); - + this.desc = desc; }; @@ -57,7 +57,7 @@ DriveFile.prototype.getCurrentUser = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -73,7 +73,7 @@ DriveFile.prototype.getPublicUrl = function(fn) { this.ui.drive.executeRequest({ url: '/files/' + this.desc.id + '/permissions?supportsAllDrives=true' - }, + }, mxUtils.bind(this, function(resp) { if (resp != null && resp.items != null) @@ -84,12 +84,12 @@ DriveFile.prototype.getPublicUrl = function(fn) resp.items[i].id === 'anyone') { fn(this.desc.webContentLink); - + return; } } } - + fn(null); }), mxUtils.bind(this, function() { @@ -108,7 +108,7 @@ DriveFile.prototype.isAutosaveOptional = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -119,7 +119,7 @@ DriveFile.prototype.isRenamable = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -130,7 +130,7 @@ DriveFile.prototype.isMovable = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -141,7 +141,7 @@ DriveFile.prototype.isTrashed = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -155,7 +155,7 @@ DriveFile.prototype.save = function(revision, success, error, unloading, overwri /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -184,31 +184,31 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi try { var lastDesc = this.desc; - + this.ui.drive.saveFile(this, realRevision, mxUtils.bind(this, function(resp, savedData) { try { this.savingFile = false; - + // Handles special case where resp is false eg // if the old file was converted to realtime if (resp != false) { // Checks for changes during save this.setModified(this.getShadowModified()); - + if (revision) { this.lastAutosaveRevision = new Date().getTime(); } - + // Adaptive autosave delay this.autosaveDelay = Math.round(Math.min(10000, Math.max(DriveFile.prototype.autosaveDelay, this.saveDelay))); this.desc = resp; - + // Shows possible errors but keeps the modified flag as the // file was saved but the cache entry could not be written if (token != null) @@ -216,7 +216,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi this.fileSaved(savedData, lastDesc, mxUtils.bind(this, function() { this.contentChanged(); - + if (success != null) { success(resp); @@ -236,7 +236,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi catch (e) { this.savingFile = false; - + if (error != null) { error(e); @@ -251,15 +251,15 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi try { this.savingFile = false; - + if (this.isConflict(err)) { this.inConflictState = true; - + if (this.sync != null) { this.savingFile = true; - + this.sync.fileConflict(desc, mxUtils.bind(this, function() { // Adds random cool-off @@ -272,7 +272,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi }), mxUtils.bind(this, function() { this.savingFile = false; - + if (error != null) { error(); @@ -292,7 +292,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi catch (e) { this.savingFile = false; - + if (error != null) { error(e); @@ -307,7 +307,7 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi catch (e) { this.savingFile = false; - + if (error != null) { error(e); @@ -318,8 +318,8 @@ DriveFile.prototype.saveFile = function(title, revision, success, error, unloadi } } }); - - doSave(overwrite, revision); + + doSave(overwrite, revision); })); } } @@ -361,7 +361,7 @@ DriveFile.prototype.copyFile = function(success, error) else { DrawioFile.prototype.copyFile.apply(this, arguments); - } + } }; /** @@ -379,17 +379,17 @@ DriveFile.prototype.makeCopy = function(success, error, timestamp) this.desc = resp; this.ui.spinner.stop(); this.setModified(false); - + this.backupPatch = null; this.invalidChecksum = false; this.inConflictState = false; - + this.descriptorChanged(); success(); }), mxUtils.bind(this, function() { this.ui.spinner.stop(); - + if (error != null) { error(); @@ -400,7 +400,7 @@ DriveFile.prototype.makeCopy = function(success, error, timestamp) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -411,14 +411,14 @@ DriveFile.prototype.saveAs = function(filename, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ DriveFile.prototype.rename = function(title, success, error) { var etag = this.getCurrentEtag(); - + this.ui.drive.renameFile(this.getId(), title, mxUtils.bind(this, function(desc) { if (!this.hasSameExtension(title, this.getTitle())) @@ -429,19 +429,19 @@ DriveFile.prototype.rename = function(title, success, error) { this.sync.descriptorChanged(etag); } - + this.save(true, success, error); } else { this.desc = desc; this.descriptorChanged(); - + if (this.sync != null) { this.sync.descriptorChanged(etag); } - + if (success != null) { success(desc); @@ -452,7 +452,7 @@ DriveFile.prototype.rename = function(title, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -462,7 +462,7 @@ DriveFile.prototype.move = function(folderId, success, error) { this.desc = resp; this.descriptorChanged(); - + if (success != null) { success(resp); @@ -472,7 +472,7 @@ DriveFile.prototype.move = function(folderId, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -483,7 +483,7 @@ DriveFile.prototype.share = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -494,7 +494,7 @@ DriveFile.prototype.getTitle = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -505,7 +505,7 @@ DriveFile.prototype.getHash = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -516,7 +516,7 @@ DriveFile.prototype.getId = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -560,7 +560,7 @@ DriveFile.prototype.getRevisions = function(success, error) // Redirects title to originalFilename to // match expected descriptor interface item.title = item.originalFilename; - + item.getXml = mxUtils.bind(this, function(itemSuccess, itemError) { this.ui.drive.getXmlFile(item, mxUtils.bind(this, function(file) @@ -568,7 +568,7 @@ DriveFile.prototype.getRevisions = function(success, error) itemSuccess(file.getData()); }), itemError); }); - + item.getUrl = mxUtils.bind(this, function(page) { return this.ui.getUrl(window.location.pathname + '?rev=' + item.id + @@ -577,7 +577,7 @@ DriveFile.prototype.getRevisions = function(success, error) }); }))(resp.items[i]); } - + success(resp.items); }), error); }; @@ -596,12 +596,12 @@ DriveFile.prototype.getLatestVersion = function(success, error) DriveFile.prototype.getChannelId = function() { var chan = this.ui.drive.getCustomProperty(this.desc, 'channel'); - + if (chan != null) { chan = 'G-' + this.getId() + '.' + chan; } - + return chan; }; @@ -683,7 +683,7 @@ DriveFile.prototype.setDescriptorEtag = function(desc, etag) DriveFile.prototype.loadPatchDescriptor = function(success, error) { this.ui.drive.executeRequest( - { + { url: '/files/' + this.getId() + '?supportsAllDrives=true&fields=' + this.ui.drive.catchupFields }, mxUtils.bind(this, function(desc) @@ -699,7 +699,7 @@ DriveFile.prototype.patchDescriptor = function(desc, patch) { desc.headRevisionId = patch.headRevisionId; desc.modifiedDate = patch.modifiedDate; - + DrawioFile.prototype.patchDescriptor.apply(this, arguments); }; @@ -725,25 +725,25 @@ DriveFile.prototype.commentsSupported = function() DriveFile.prototype.getComments = function(success, error) { var currentUser = this.ui.getCurrentUser(); - + function driveCommentToDrawio(file, gComment, pCommentId) { if (gComment.deleted) return null; //skip deleted comments - - var comment = new DriveComment(file, gComment.commentId || gComment.replyId, gComment.content, + + var comment = new DriveComment(file, gComment.commentId || gComment.replyId, gComment.content, gComment.modifiedDate, gComment.createdDate, gComment.status == 'resolved', gComment.author.isAuthenticatedUser? currentUser : new DrawioUser(gComment.author.permissionId, gComment.author.emailAddress, gComment.author.displayName, gComment.author.picture.url), pCommentId); - + for (var i = 0; gComment.replies != null && i < gComment.replies.length; i++) { comment.addReplyDirect(driveCommentToDrawio(file, gComment.replies[i], gComment.commentId)); } - + return comment; }; - + this.ui.drive.executeRequest( { url: '/files/' + this.getId() + '/comments' @@ -751,14 +751,14 @@ DriveFile.prototype.getComments = function(success, error) mxUtils.bind(this, function(resp) { var comments = []; - + for (var i = 0; i < resp.items.length; i++) { var comment = driveCommentToDrawio(this, resp.items[i]); - + if (comment != null) comments.push(comment); } - + success(comments); }), error); }; @@ -769,7 +769,7 @@ DriveFile.prototype.getComments = function(success, error) DriveFile.prototype.addComment = function(comment, success, error) { var body = {'content': comment.content}; - + this.ui.drive.executeRequest( { url: '/files/' + this.getId() + '/comments', diff --git a/resources/assets/statics/public/js/drawio/js/diagramly/LocalFile.js b/resources/assets/statics/public/js/drawio/js/diagramly/LocalFile.js index 3b646203..e61957f3 100644 --- a/resources/assets/statics/public/js/drawio/js/diagramly/LocalFile.js +++ b/resources/assets/statics/public/js/drawio/js/diagramly/LocalFile.js @@ -11,7 +11,7 @@ LocalFile = function(ui, data, title, temp, fileHandle, desc) { DrawioFile.call(this, ui, data); - + this.title = title; this.mode = (temp) ? null : App.MODE_DEVICE; this.fileHandle = fileHandle; @@ -23,7 +23,7 @@ mxUtils.extend(LocalFile, DrawioFile); /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -43,7 +43,7 @@ LocalFile.prototype.isAutosaveOptional = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -54,7 +54,7 @@ LocalFile.prototype.getMode = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -65,7 +65,7 @@ LocalFile.prototype.getTitle = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -76,7 +76,7 @@ LocalFile.prototype.isRenamable = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -87,7 +87,7 @@ LocalFile.prototype.save = function(revision, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -98,7 +98,7 @@ LocalFile.prototype.saveAs = function(title, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -125,7 +125,7 @@ LocalFile.prototype.setDescriptor = function(desc) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -143,7 +143,7 @@ LocalFile.prototype.getLatestVersion = function(success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -154,7 +154,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr this.fileHandle = null; this.desc = null; } - + this.title = title; // Updates data after changing file name @@ -162,22 +162,22 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr { this.updateFileData(); } - + var binary = this.ui.useCanvasForExport && /(\.png)$/i.test(this.getTitle()); this.setShadowModified(false); var savedData = this.getData(); - + var done = mxUtils.bind(this, function() { this.setModified(this.getShadowModified()); this.contentChanged(); - + if (success != null) { success(); } }); - + var doSave = mxUtils.bind(this, function(data) { if (this.fileHandle != null) @@ -187,27 +187,27 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr { this.savingFileTime = new Date(); this.savingFile = true; - + var errorWrapper = mxUtils.bind(this, function(e) { this.savingFile = false; - + if (error != null) { // Wraps error object to offer save status option error({error: e}); } }); - + // Saves a copy as a draft while saving this.saveDraft(); - + this.fileHandle.createWritable().then(mxUtils.bind(this, function(writable) { this.fileHandle.getFile().then(mxUtils.bind(this, function(newDesc) { this.invalidFileHandle = null; - + if (this.desc.lastModified == newDesc.lastModified) { writable.write((binary) ? this.ui.base64ToBlob(data, 'image/png') : data).then(mxUtils.bind(this, function() @@ -222,7 +222,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr this.savingFile = false; this.desc = desc; this.fileSaved(savedData, lastDesc, done, errorWrapper); - + // Deletes draft after saving this.removeDraft(); } @@ -260,7 +260,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr { var dot = title.lastIndexOf('.'); var format = (dot > 0) ? title.substring(dot + 1) : 'xml'; - + // Do not update modified flag new mxXmlRequest(SAVE_URL, 'format=' + format + '&xml=' + encodeURIComponent(data) + @@ -276,11 +276,11 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr })); } } - + done(); } }); - + if (binary) { var p = this.ui.getPngFileProperties(this.ui.fileNode); @@ -299,7 +299,7 @@ LocalFile.prototype.saveFile = function(title, revision, success, error, useCurr /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -307,7 +307,7 @@ LocalFile.prototype.rename = function(title, success, error) { this.title = title; this.descriptorChanged(); - + if (success != null) { success(); diff --git a/resources/assets/statics/public/js/drawio/js/diagramly/StorageFile.js b/resources/assets/statics/public/js/drawio/js/diagramly/StorageFile.js index a9dde880..f0da7b75 100644 --- a/resources/assets/statics/public/js/drawio/js/diagramly/StorageFile.js +++ b/resources/assets/statics/public/js/drawio/js/diagramly/StorageFile.js @@ -13,7 +13,7 @@ StorageFile = function(ui, data, title) { DrawioFile.call(this, ui, data); - + this.title = title; }; @@ -37,7 +37,7 @@ StorageFile.prototype.type = 'F'; /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -56,7 +56,7 @@ StorageFile.prototype.isAutosaveOptional = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -67,7 +67,7 @@ StorageFile.prototype.getHash = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -78,7 +78,7 @@ StorageFile.prototype.getTitle = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -89,7 +89,7 @@ StorageFile.prototype.isRenamable = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -100,7 +100,7 @@ StorageFile.prototype.save = function(revision, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -112,7 +112,7 @@ StorageFile.prototype.saveAs = function(title, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -123,7 +123,7 @@ StorageFile.insertFile = function(ui, title, data, success, error) var fn = function() { var file = new StorageFile(ui, data, title); - + // Inserts data into local storage file.saveFile(title, false, function() { @@ -140,7 +140,7 @@ StorageFile.insertFile = function(ui, title, data, success, error) fn(); } }); - + StorageFile.getFileContent(ui, title, function(data) { createStorageFile(data != null); @@ -152,7 +152,7 @@ StorageFile.insertFile = function(ui, title, data, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -161,7 +161,7 @@ StorageFile.getFileContent = function(ui, title, success, error) ui.getDatabaseItem(title, function(obj) { success(obj != null? obj.data : null); - }, + }, mxUtils.bind(this, function() { if (ui.database == null) //fallback to localstorage @@ -177,7 +177,7 @@ StorageFile.getFileContent = function(ui, title, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -186,7 +186,7 @@ StorageFile.getFileInfo = function(ui, title, success, error) ui.getDatabaseItem(title, function(obj) { success(obj); - }, + }, mxUtils.bind(this, function() { if (ui.database == null) //fallback to localstorage @@ -205,7 +205,7 @@ StorageFile.getFileInfo = function(ui, title, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -226,23 +226,23 @@ StorageFile.prototype.saveFile = function(title, revision, success, error) { this.title = title; } - + try { var saveDone = mxUtils.bind(this, function() { this.setModified(this.getShadowModified()); this.contentChanged(); - + if (success != null) { success(); } }); - + this.setShadowModified(false); var data = this.getData(); - + this.ui.setDatabaseItem(null, [{ title: this.title, size: data.length, @@ -271,7 +271,7 @@ StorageFile.prototype.saveFile = function(title, revision, success, error) } } }); - + // Checks for trailing dots if (this.isRenamable() && title.charAt(0) == '.' && error != null) { @@ -296,7 +296,7 @@ StorageFile.prototype.saveFile = function(title, revision, success, error) /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ @@ -311,19 +311,19 @@ StorageFile.prototype.rename = function(title, success, error) var fn = mxUtils.bind(this, function() { this.title = title; - + // Updates the data if the extension has changed if (!this.hasSameExtension(oldTitle, title)) { this.setData(this.ui.getFileData()); } - + this.saveFile(title, false, mxUtils.bind(this, function() { this.ui.removeLocalData(oldTitle, success); }), error); }); - + if (data != null) { this.ui.confirm(mxResources.get('replaceIt', [title]), fn, error); @@ -369,7 +369,7 @@ StorageFile.prototype.getLatestVersion = function(success, error) StorageFile.prototype.destroy = function() { DrawioFile.prototype.destroy.apply(this, arguments); - + if (this.storageListener != null) { mxEvent.removeListener(window, 'storage', this.storageListener); @@ -379,19 +379,19 @@ StorageFile.prototype.destroy = function() /** * Translates this point by the given vector. - * + * * @param {number} dx X-coordinate of the translation. * @param {number} dy Y-coordinate of the translation. */ StorageFile.listLocalStorageFiles = function(type) { var filesInfo = []; - + for (var i = 0; i < localStorage.length; i++) { var key = localStorage.key(i); var value = localStorage.getItem(key); - + if (key.length > 0 && key.charAt(0) != '.' && value.length > 0) { var isFile = (type == null || type == 'F') && (value.substring(0, 8) === '