[DE mobile] Add error controller
This commit is contained in:
parent
bc7713368a
commit
3bcd2a55a7
|
@ -78,7 +78,50 @@
|
||||||
"txtEditingMode": "Set editing mode...",
|
"txtEditingMode": "Set editing mode...",
|
||||||
"loadingDocumentTitleText": "Loading document",
|
"loadingDocumentTitleText": "Loading document",
|
||||||
"loadingDocumentTextText": "Loading document...",
|
"loadingDocumentTextText": "Loading document...",
|
||||||
"textLoadingDocument": "Loading document"
|
"textLoadingDocument": "Loading document",
|
||||||
|
|
||||||
|
"errorProcessSaveResult": "Saving is failed.",
|
||||||
|
"criticalErrorTitle": "Error",
|
||||||
|
"warnProcessRightsChange": "You have been denied the right to edit the file.",
|
||||||
|
"errorAccessDeny": "You are trying to perform an action you do not have rights for.<br>Please contact your Document Server administrator."
|
||||||
|
},
|
||||||
|
"Error": {
|
||||||
|
"criticalErrorTitle": "Error",
|
||||||
|
"unknownErrorText": "Unknown error.",
|
||||||
|
"convertationTimeoutText": "Convertation timeout exceeded.",
|
||||||
|
"openErrorText": "An error has occurred while opening the file",
|
||||||
|
"saveErrorText": "An error has occurred while saving the file",
|
||||||
|
"downloadErrorText": "Download failed.",
|
||||||
|
"uploadImageSizeMessage": "Maximium image size limit exceeded.",
|
||||||
|
"uploadImageExtMessage": "Unknown image format.",
|
||||||
|
"uploadImageFileCountMessage": "No images uploaded.",
|
||||||
|
"splitMaxRowsErrorText": "The number of rows must be less than %1",
|
||||||
|
"splitMaxColsErrorText": "The number of columns must be less than %1",
|
||||||
|
"splitDividerErrorText": "The number of rows must be a divisor of %1",
|
||||||
|
"errorKeyEncrypt": "Unknown key descriptor",
|
||||||
|
"errorKeyExpire": "Key descriptor expired",
|
||||||
|
"errorUsersExceed": "Count of users was exceed",
|
||||||
|
"errorViewerDisconnect": "Connection is lost. You can still view the document,<br>but will not be able to download until the connection is restored and page is reloaded.",
|
||||||
|
"errorFilePassProtect": "The file is password protected and could not be opened.",
|
||||||
|
"errorStockChart": "Incorrect row order. To build a stock chart place the data on the sheet in the following order:<br> opening price, max price, min price, closing price.",
|
||||||
|
"errorDataRange": "Incorrect data range.",
|
||||||
|
"errorDatabaseConnection": "External error.<br>Database connection error. Please, contact support.",
|
||||||
|
"errorUserDrop": "The file cannot be accessed right now.",
|
||||||
|
"errorMailMergeLoadFile": "Loading failed",
|
||||||
|
"errorMailMergeSaveFile": "Merge failed.",
|
||||||
|
"errorConnectToServer": " The document could not be saved. Please check connection settings or contact your administrator.<br>When you click the 'OK' button, you will be prompted to download the document.",
|
||||||
|
"errorBadImageUrl": "Image url is incorrect",
|
||||||
|
"errorSessionAbsolute": "The document editing session has expired. Please reload the page.",
|
||||||
|
"errorSessionIdle": "The document has not been edited for quite a long time. Please reload the page.",
|
||||||
|
"errorSessionToken": "The connection to the server has been interrupted. Please reload the page.",
|
||||||
|
"errorDataEncrypted": "Encrypted changes have been received, they cannot be deciphered.",
|
||||||
|
"errorAccessDeny": "You are trying to perform an action you do not have rights for.<br>Please contact your Document Server administrator.",
|
||||||
|
"errorEditingDownloadas": "An error occurred during the work with the document.<br>Use the 'Download' option to save the file backup copy to your computer hard drive.",
|
||||||
|
"errorFileSizeExceed": "The file size exceeds the limitation set for your server.<br>Please contact your Document Server administrator for details.",
|
||||||
|
"errorUpdateVersionOnDisconnect": "Internet connection has been restored, and the file version has been changed.<br>Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.",
|
||||||
|
"errorDefaultMessage": "Error code: %1",
|
||||||
|
"criticalErrorExtText": "Press 'OK' to back to document list.",
|
||||||
|
"notcriticalErrorTitle": "Warning"
|
||||||
},
|
},
|
||||||
"Toolbar": {
|
"Toolbar": {
|
||||||
"dlgLeaveTitleText": "You leave the application",
|
"dlgLeaveTitleText": "You leave the application",
|
||||||
|
|
227
apps/documenteditor/mobile/src/controller/Error.jsx
Normal file
227
apps/documenteditor/mobile/src/controller/Error.jsx
Normal file
|
@ -0,0 +1,227 @@
|
||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { inject } from 'mobx-react';
|
||||||
|
import { f7 } from 'framework7-react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
const ErrorController = inject('storeAppOptions')(({storeAppOptions}) => {
|
||||||
|
const {t} = useTranslation();
|
||||||
|
const _t = t("Error", { returnObjects: true });
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
Common.Notifications.on('engineCreated', (api) => {
|
||||||
|
api.asc_registerCallback('asc_onError', onError);
|
||||||
|
});
|
||||||
|
return () => {
|
||||||
|
const api = Common.EditorApi.get();
|
||||||
|
api.asc_unregisterCallback('asc_onError', onError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const onError = (id, level, errData) => {
|
||||||
|
if (id === Asc.c_oAscError.ID.LoadingScriptError) {
|
||||||
|
f7.notification.create({
|
||||||
|
title: _t.criticalErrorTitle,
|
||||||
|
text: _t.criticalErrorTitle,
|
||||||
|
closeButton: true
|
||||||
|
}).open();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//this.hidePreloader();
|
||||||
|
//this.onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument);
|
||||||
|
|
||||||
|
const api = Common.EditorApi.get();
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
closable: false
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case Asc.c_oAscError.ID.Unknown:
|
||||||
|
config.msg = _t.unknownErrorText;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.ConvertationTimeout:
|
||||||
|
config.msg = _t.convertationTimeoutText;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.ConvertationOpenError:
|
||||||
|
config.msg = _t.openErrorText;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.ConvertationSaveError:
|
||||||
|
config.msg = _t.saveErrorText;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.DownloadError:
|
||||||
|
config.msg = _t.downloadErrorText;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.UplImageSize:
|
||||||
|
config.msg = _t.uploadImageSizeMessage;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.UplImageExt:
|
||||||
|
config.msg = _t.uploadImageExtMessage;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.UplImageFileCount:
|
||||||
|
config.msg = _t.uploadImageFileCountMessage;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.SplitCellMaxRows:
|
||||||
|
config.msg = _t.splitMaxRowsErrorText.replace('%1', errData.get_Value());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.SplitCellMaxCols:
|
||||||
|
config.msg = _t.splitMaxColsErrorText.replace('%1', errData.get_Value());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.SplitCellRowsDivider:
|
||||||
|
config.msg = _t.splitDividerErrorText.replace('%1', errData.get_Value());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.VKeyEncrypt:
|
||||||
|
config.msg = _t.errorKeyEncrypt;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.KeyExpire:
|
||||||
|
config.msg = _t.errorKeyExpire;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.UserCountExceed:
|
||||||
|
config.msg = _t.errorUsersExceed;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.CoAuthoringDisconnect:
|
||||||
|
config.msg = _t.errorViewerDisconnect;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.ConvertationPassword:
|
||||||
|
config.msg = _t.errorFilePassProtect;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.StockChartError:
|
||||||
|
config.msg = _t.errorStockChart;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.DataRangeError:
|
||||||
|
config.msg = _t.errorDataRange;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.Database:
|
||||||
|
config.msg = _t.errorDatabaseConnection;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.UserDrop:
|
||||||
|
const lostEditingRights = storeAppOptions.lostEditingRights;
|
||||||
|
if (lostEditingRights) {
|
||||||
|
storeAppOptions.changeEditingRights(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
storeAppOptions.changeEditingRights(true);
|
||||||
|
config.msg = _t.errorUserDrop;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.MailMergeLoadFile:
|
||||||
|
config.msg = _t.errorMailMergeLoadFile;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.MailMergeSaveFile:
|
||||||
|
config.msg = _t.errorMailMergeSaveFile;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.Warning:
|
||||||
|
config.msg = _t.errorConnectToServer;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.UplImageUrl:
|
||||||
|
config.msg = _t.errorBadImageUrl;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.SessionAbsolute:
|
||||||
|
config.msg = _t.errorSessionAbsolute;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.SessionIdle:
|
||||||
|
config.msg = _t.errorSessionIdle;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.SessionToken:
|
||||||
|
config.msg = _t.errorSessionToken;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.DataEncrypted:
|
||||||
|
config.msg = _t.errorDataEncrypted;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.AccessDeny:
|
||||||
|
config.msg = _t.errorAccessDeny;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.EditingError:
|
||||||
|
config.msg = _t.errorEditingDownloadas;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.ConvertationOpenLimitError:
|
||||||
|
config.msg = _t.errorFileSizeExceed;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscError.ID.UpdateVersion:
|
||||||
|
config.msg = _t.errorUpdateVersionOnDisconnect;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
config.msg = _t.errorDefaultMessage.replace('%1', id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level === Asc.c_oAscError.Level.Critical) {
|
||||||
|
|
||||||
|
// report only critical errors
|
||||||
|
Common.Gateway.reportError(id, config.msg);
|
||||||
|
|
||||||
|
config.title = this.criticalErrorTitle;
|
||||||
|
|
||||||
|
if (storeAppOptions.canBackToFolder && !storeAppOptions.isDesktopApp) {
|
||||||
|
config.msg += '</br></br>' + _t.criticalErrorExtText;
|
||||||
|
config.callback = function() {
|
||||||
|
Common.Notifications.trigger('goback', true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (id === Asc.c_oAscError.ID.DataEncrypted) {
|
||||||
|
api.asc_coAuthoringDisconnect();
|
||||||
|
Common.Notifications.trigger('api:disconnect');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Common.Gateway.reportWarning(id, config.msg);
|
||||||
|
|
||||||
|
config.title = _t.notcriticalErrorTitle;
|
||||||
|
config.callback = (btn) => {
|
||||||
|
if (id === Asc.c_oAscError.ID.Warning && btn === 'ok' && (storeAppOptions.canDownload || storeAppOptions.canDownloadOrigin)) {
|
||||||
|
api.asc_DownloadOrigin();
|
||||||
|
}
|
||||||
|
storeAppOptions.changeEditingRights(false);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
f7.dialog.create({
|
||||||
|
title : config.title,
|
||||||
|
text : config.msg,
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
text: 'OK',
|
||||||
|
onClick: config.callback
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}).open();
|
||||||
|
|
||||||
|
Common.component.Analytics.trackEvent('Internal Error', id.toString());
|
||||||
|
};
|
||||||
|
|
||||||
|
return null
|
||||||
|
});
|
||||||
|
|
||||||
|
export default ErrorController;
|
|
@ -16,6 +16,7 @@ import {
|
||||||
} from "../../../../common/mobile/lib/controller/collaboration/Comments";
|
} from "../../../../common/mobile/lib/controller/collaboration/Comments";
|
||||||
import About from '../../../../common/mobile/lib/view/About';
|
import About from '../../../../common/mobile/lib/view/About';
|
||||||
import EditorUIController from '../lib/patch';
|
import EditorUIController from '../lib/patch';
|
||||||
|
import ErrorController from "./Error";
|
||||||
|
|
||||||
@inject(
|
@inject(
|
||||||
"storeAppOptions",
|
"storeAppOptions",
|
||||||
|
@ -33,7 +34,8 @@ class MainController extends Component {
|
||||||
window.editorType = 'de';
|
window.editorType = 'de';
|
||||||
|
|
||||||
this._state = {
|
this._state = {
|
||||||
licenseType: false
|
licenseType: false,
|
||||||
|
isFromGatewayDownloadAs: false
|
||||||
};
|
};
|
||||||
|
|
||||||
this.stackLongActions = new IrregularStack({
|
this.stackLongActions = new IrregularStack({
|
||||||
|
@ -192,6 +194,11 @@ class MainController extends Component {
|
||||||
|
|
||||||
f7.dialog.close(this.loadMask.el);
|
f7.dialog.close(this.loadMask.el);
|
||||||
this.onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], this.LoadingDocument);
|
this.onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], this.LoadingDocument);
|
||||||
|
|
||||||
|
Common.Gateway.on('processsaveresult', this.onProcessSaveResult.bind(this));
|
||||||
|
Common.Gateway.on('processrightschange', this.onProcessRightsChange.bind(this));
|
||||||
|
Common.Gateway.on('downloadas', this.onDownloadAs.bind(this));
|
||||||
|
Common.Gateway.on('requestclose', this.onRequestClose.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
const _process_array = (array, fn) => {
|
const _process_array = (array, fn) => {
|
||||||
|
@ -407,6 +414,8 @@ class MainController extends Component {
|
||||||
Common.Utils.ThemeColor.setColors(colors, standart_colors);
|
Common.Utils.ThemeColor.setColors(colors, standart_colors);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.api.asc_registerCallback('asc_onDownloadUrl', this.onDownloadUrl.bind(this));
|
||||||
|
|
||||||
const storeDocumentSettings = this.props.storeDocumentSettings;
|
const storeDocumentSettings = this.props.storeDocumentSettings;
|
||||||
this.api.asc_registerCallback('asc_onPageOrient', isPortrait => {
|
this.api.asc_registerCallback('asc_onPageOrient', isPortrait => {
|
||||||
storeDocumentSettings.resetPortrait(isPortrait);
|
storeDocumentSettings.resetPortrait(isPortrait);
|
||||||
|
@ -681,9 +690,70 @@ class MainController extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onProcessSaveResult (data) {
|
||||||
|
this.api.asc_OnSaveEnd(data.result);
|
||||||
|
|
||||||
|
if (data && data.result === false) {
|
||||||
|
const _t = this._t;
|
||||||
|
f7.dialog.alert(
|
||||||
|
(!data.message) ? _t.errorProcessSaveResult : data.message,
|
||||||
|
_t.criticalErrorTitle
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onProcessRightsChange (data) {
|
||||||
|
if (data && data.enabled === false) {
|
||||||
|
const appOptions = this.props.storeAppOptions;
|
||||||
|
const old_rights = appOptions.lostEditingRights;
|
||||||
|
appOptions.changeEditingRights(!old_rights);
|
||||||
|
this.api.asc_coAuthoringDisconnect();
|
||||||
|
Common.Notifications.trigger('api:disconnect');
|
||||||
|
|
||||||
|
if (!old_rights) {
|
||||||
|
const _t = this._t;
|
||||||
|
f7.dialog.alert(
|
||||||
|
(!data.message) ? _t.warnProcessRightsChange : data.message,
|
||||||
|
_t.notcriticalErrorTitle,
|
||||||
|
() => { appOptions.changeEditingRights(false); }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onDownloadAs () {
|
||||||
|
const appOptions = this.props.storeAppOptions;
|
||||||
|
if ( !appOptions.canDownload && !appOptions.canDownloadOrigin) {
|
||||||
|
Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, this._t.errorAccessDeny);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._state.isFromGatewayDownloadAs = true;
|
||||||
|
const type = /^(?:(pdf|djvu|xps))$/.exec(this.document.fileType);
|
||||||
|
|
||||||
|
if (type && typeof type[1] === 'string') {
|
||||||
|
this.api.asc_DownloadOrigin(true);
|
||||||
|
} else {
|
||||||
|
this.api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.DOCX, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onDownloadUrl () {
|
||||||
|
if (this._state.isFromGatewayDownloadAs) {
|
||||||
|
Common.Gateway.downloadAs(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._state.isFromGatewayDownloadAs = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
onRequestClose () {
|
||||||
|
Common.Gateway.requestClose();
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
<ErrorController />
|
||||||
<CollaborationController />
|
<CollaborationController />
|
||||||
<ReviewController />
|
<ReviewController />
|
||||||
<CommentsController />
|
<CommentsController />
|
||||||
|
|
|
@ -8,7 +8,10 @@ export class storeAppOptions {
|
||||||
canReview: observable,
|
canReview: observable,
|
||||||
setConfigOptions: action,
|
setConfigOptions: action,
|
||||||
setPermissionOptions: action,
|
setPermissionOptions: action,
|
||||||
setCanViewReview: action
|
setCanViewReview: action,
|
||||||
|
|
||||||
|
lostEditingRights: observable,
|
||||||
|
changeEditingRights: action
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +19,11 @@ export class storeAppOptions {
|
||||||
canViewComments = false;
|
canViewComments = false;
|
||||||
canReview = false;
|
canReview = false;
|
||||||
|
|
||||||
|
lostEditingRights = false;
|
||||||
|
changeEditingRights (value) {
|
||||||
|
this.lostEditingRights = value;
|
||||||
|
}
|
||||||
|
|
||||||
config = {};
|
config = {};
|
||||||
setConfigOptions (config) {
|
setConfigOptions (config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
|
@ -3,6 +3,8 @@ import React from 'react';
|
||||||
import {App,Panel,Views,View,Popup,Page,Navbar,Toolbar,NavRight,Link,Block,BlockTitle,List,ListItem,ListInput,ListButton,BlockFooter} from 'framework7-react';
|
import {App,Panel,Views,View,Popup,Page,Navbar,Toolbar,NavRight,Link,Block,BlockTitle,List,ListItem,ListInput,ListButton,BlockFooter} from 'framework7-react';
|
||||||
import { f7, f7ready } from 'framework7-react';
|
import { f7, f7ready } from 'framework7-react';
|
||||||
|
|
||||||
|
import '../../../../common/Analytics.js';
|
||||||
|
|
||||||
import '../../../../common/Gateway.js';
|
import '../../../../common/Gateway.js';
|
||||||
import '../../../../common/main/lib/util/utils.js';
|
import '../../../../common/main/lib/util/utils.js';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue