[Libreoffice-commits] online.git: 2 commits - loleaflet/dist loleaflet/main.js loleaflet/src

Pranav Kant pranavk at collabora.co.uk
Fri Sep 30 09:54:04 UTC 2016


 loleaflet/dist/errormessages.js  |    1 +
 loleaflet/main.js                |    1 +
 loleaflet/src/control/Toolbar.js |    4 ++++
 loleaflet/src/core/Socket.js     |   23 +++++++++++++++++------
 loleaflet/src/map/Map.js         |    1 +
 5 files changed, 24 insertions(+), 6 deletions(-)

New commits:
commit 7b60a9e3f6d5b65dabfaecc097b848a7184f29da
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Sep 30 15:20:06 2016 +0530

    loleaflet: Show error message dialog on diskfull
    
    Set the mode to viewonly after the error so that user can still
    see the tiles downloaded from the server, but cannot interact
    anymore before server administrator fixes the disk space.
    
    Change-Id: If03f4fabe93458672a631c020d09dcebecbb955c

diff --git a/loleaflet/dist/errormessages.js b/loleaflet/dist/errormessages.js
index 0a2003c..dc99714 100644
--- a/loleaflet/dist/errormessages.js
+++ b/loleaflet/dist/errormessages.js
@@ -1,2 +1,3 @@
 exports.wrongwopisrc = _('Wrong WOPISrc, usage: WOPISrc=valid encoded URI, or file_path, usage: file_path=/path/to/doc/');
 exports.emptyhosturl = _('The host URL is empty. The loolwsd server is probably misconfigured, please contact the administrator.');
+exports.diskfull = _('No disk space left on server, please contact the server administrator to continue.');
diff --git a/loleaflet/main.js b/loleaflet/main.js
index cb53fb7..c2851d6 100644
--- a/loleaflet/main.js
+++ b/loleaflet/main.js
@@ -75,6 +75,7 @@ if (host === '') {
 global.closebutton = closebutton;
 global.revHistoryEnabled = revHistoryEnabled;
 global.title = title;
+global.errorMessages = errorMessages;
 var docURL, docParams;
 if (wopiSrc != '') {
     docURL = wopiSrc;
diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index 54a1d95..19eeaa9 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -48,6 +48,10 @@ L.Map.include({
 	},
 
 	downloadAs: function (name, format, options, id) {
+		if (this._fatal) {
+			return;
+		}
+
 		if (format === undefined || format === null) {
 			format = '';
 		}
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 53598fc..0ce132c 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -2,7 +2,7 @@
  * L.Socket contains methods for the communication with the server
  */
 
-/* global _ vex $ */
+/* global _ vex $ errorMessages */
 L.Socket = L.Class.extend({
 	ProtocolVersionNumber: '0.1',
 
@@ -37,7 +37,8 @@ L.Socket = L.Class.extend({
 	},
 
 	sendMessage: function (msg, coords) {
-		if (!msg.startsWith('useractive') && !msg.startsWith('userinactive') && !this._map._active) {
+		if ((!msg.startsWith('useractive') && !msg.startsWith('userinactive') && !this._map._active) ||
+		    this._map._fatal) {
 			// Avoid communicating when we're inactive.
 			return;
 		}
@@ -143,6 +144,19 @@ L.Socket = L.Class.extend({
 			                         lokitVersionObj.ProductVersion + lokitVersionObj.ProductExtension.replace('.10.','-') +
 			                         ' (git hash: ' + lokitVersionObj.BuildId.substring(0, 7) + ')');
 		}
+		else if (textMsg.startsWith('error:') && command.errorCmd === 'internal') {
+			this._map._fatal = true;
+			if (command.errorKind === 'diskfull') {
+				this._map.fire('error', {msg: errorMessages.diskfull});
+			}
+
+			if (this._map._docLayer) {
+				this._map._docLayer.removeAllViews();
+			}
+			this.close();
+
+			return;
+		}
 		else if (textMsg.startsWith('error:') && command.errorCmd === 'load') {
 			this.close();
 
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 5110c60..7d2dfac 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -65,6 +65,7 @@ L.Map = L.Evented.extend({
 		this._sizeChanged = true;
 		this._bDisableKeyboard = false;
 		this._active = true;
+		this._fatal = false;
 		this._enabled = true;
 
 		vex.dialogID = -1;
commit 42fbfa936ce2007686b5f9931a20b6a31a66d1fe
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Sep 30 13:44:11 2016 +0530

    loleaflet: Use 'error' event to open the alert dialog
    
    Change-Id: I8f1ca3d896027755fe1291cb227ded102e57e112

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 9a6579e..53598fc 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -187,10 +187,7 @@ L.Socket = L.Class.extend({
 		}
 		else if (textMsg.startsWith('error:') && !this._map._docLayer) {
 			textMsg = textMsg.substring(6);
-			vex.dialog.alert({
-				message: textMsg,
-				css: {'font-size': 'small'}
-			});
+			this._map.fire('error', {msg: textMsg});
 		}
 		else if (textMsg === 'pong' && this._map._docLayer && this._map._docLayer._debug) {
 			var times = this._map._docLayer._debugTimePING;


More information about the Libreoffice-commits mailing list