Skip to content

Commit

Permalink
browser: use 'Error_Messages' postmessage call to
Browse files Browse the repository at this point in the history
override error messages
- send App_LoadingStatus msg with Intialized status once map is
  initialized so that integrator can start to send postmessages

Signed-off-by: Rash419 <[email protected]>
Change-Id: I96e0c1471cbabe15b0e61711defe15f4e5298ab3
  • Loading branch information
Rash419 authored and timar committed Oct 25, 2023
1 parent 294c2da commit 2485dab
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
4 changes: 3 additions & 1 deletion browser/src/core/Socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -1522,8 +1522,10 @@ app.definitions.Socket = L.Class.extend({
window.app.console.debug('_onSocketClose:');
if (!this._map._docLoadedOnce) {
var postMessageObj = {
errorType: 'websocketconnectionfailed',
success: false,
errorMsg: errorMessages.websocketconnectionfailed
errorMsg: errorMessages.websocketconnectionfailed,
result: '',
};
this._map.fire('postMessage', {msgId: 'Action_Load_Resp', args: postMessageObj});
this._map.fire('error', {msg: errorMessages.websocketconnectionfailed, cmd: 'socket', kind: 'closed', id: 4});
Expand Down
2 changes: 1 addition & 1 deletion browser/src/errormessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ errorMessages.docloadtimeout = _('Failed to load the document. This document is
errorMessages.docunloadingretry = _('Cleaning up the document from the last session.');
errorMessages.docunloadinggiveup = _('We are in the process of cleaning up this document from the last session, please try again later.');
errorMessages.clusterconfiguration = _('Your %productName cluster appear to be mis-configured or scaling rapidly - please contact your system administrator. Continuing with editing may result in multiple users not seeing each other, conflicts in the document storage and/or copy/paste problems. Expected serverId %0 for routeToken %1 but connected to serverId %2');
errorMessages.websocketconnectionfailed = _('Failed to establish socket connection or socket connection closed unexpectedly. The reverse proxy is probably misconfigured, please contact the administrator. For more info on proxy conifguration please checkout https://sdk.collaboraonline.com/docs/installation/Proxy_settings.html');
errorMessages.websocketconnectionfailed = _('Failed to establish socket connection or socket connection closed unexpectedly. The reverse proxy might be misconfigured, please contact the administrator. For more info on proxy configuration please checkout https://sdk.collaboraonline.com/docs/installation/Proxy_settings.html');
if (window.ThisIsAMobileApp) {
errorMessages.storage = {
loadfailed: _('Failed to load document.'),
Expand Down
7 changes: 7 additions & 0 deletions browser/src/map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,13 @@ L.Map = L.Evented.extend({
this._docLoadedOnce = this._docLoaded;
}
}, this);

this.fire('postMessage', {
msgId: 'App_LoadingStatus',
args: {
Status: 'Initialized',
}
});
},

initTextInput: function(docType) {
Expand Down
15 changes: 14 additions & 1 deletion browser/src/map/handler/Map.WOPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* L.WOPI contains WOPI related logic
*/

/* global w2ui _ app */
/* global w2ui _ app errorMessages */
L.Map.WOPI = L.Handler.extend({
// If the CheckFileInfo call fails on server side, we won't have any PostMessageOrigin.
// So use '*' because we still needs to send 'close' message to the parent frame which
Expand Down Expand Up @@ -337,6 +337,19 @@ L.Map.WOPI = L.Handler.extend({
this._map._disableDefaultAction[msg.Values.action] = msg.Values.disable;
}
}
else if (msg.MessageId === 'Error_Messages') {
if (msg.Values && msg.Values.list) {
msg.Values.list.forEach(function (item) {
if (Object.prototype.hasOwnProperty.call(errorMessages.storage, item.type)) {
errorMessages.storage[item.type] = item.msg;
} else if (Object.prototype.hasOwnProperty.call(errorMessages.uploadfile, item.type)) {
errorMessages.uploadfile[item.type] = item.msg;
} else if (Object.prototype.hasOwnProperty.call(errorMessages, item.type)) {
errorMessages[item.type] = item.msg;
}
});
}
}

// All following actions must be done after initialization is completed.
if (!window.WOPIPostmessageReady) {
Expand Down

0 comments on commit 2485dab

Please sign in to comment.