From a1cdd6b116f5baed1d9a9053612ac47552c907ff Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 26 Aug 2022 17:37:41 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B4=20=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + client/components/Api/Api.vue | 96 ++++++++++++++++++- client/components/Search/Search.vue | 4 +- .../components/Search/authorBooksStorage.js | 2 +- client/components/share/DivBtn.vue | 3 +- client/quasar.js | 2 + server/core/DbCreator.js | 68 +++++++++---- server/core/InpxParser.js | 2 +- 8 files changed, 155 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index bec7510..121c230 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /node_modules /server/.inpx-web +/server/.inpx-web-bak /dist diff --git a/client/components/Api/Api.vue b/client/components/Api/Api.vue index 8244677..ade4a3d 100644 --- a/client/components/Api/Api.vue +++ b/client/components/Api/Api.vue @@ -1,5 +1,28 @@ @@ -7,9 +30,27 @@ //----------------------------------------------------------------------------- import vueComponent from '../vueComponent.js'; -import wsc from './webSocketConnection'; //import _ from 'lodash'; +import wsc from './webSocketConnection'; +import * as utils from '../../share/utils'; + +const rotor = '|/-\\'; +const stepBound = [ + 0, + 0,//1 + 18,//2 + 20,//3 + 70,//4 + 82,//5 + 84,//6 + 88,//7 + 90,//8 + 98,//9 + 99,//10 + 100,//11 +]; + const componentOptions = { components: { }, @@ -18,6 +59,11 @@ const componentOptions = { }; class Api { _options = componentOptions; + busyDialogVisible = false; + mainMessage = ''; + jobMessage = ''; + //jsonMessage = ''; + progress = 0; created() { this.commit = this.$store.commit; @@ -40,8 +86,54 @@ class Api { return this.$store.state.config; } + async showBusyDialog() { + this.mainMessage = ''; + this.jobMessage = ''; + this.busyDialogVisible = true; + try { + let ri = 0; + while (1) {// eslint-disable-line + const server = await wsc.message(await wsc.send({action: 'get-worker-state', workerId: 'server_state'})); + + if (server.state != 'normal') { + this.mainMessage = `${server.serverMessage} ${rotor[ri]}`; + if (server.job == 'load inpx') { + this.jobMessage = `${server.jobMessage} (${server.recsLoaded}): ${server.fileName}`; + } else { + this.jobMessage = server.jobMessage; + } + + //this.jsonMessage = server; + + const jStep = server.jobStep; + + if (jStep && stepBound[jStep] !== undefined) { + const sp = server.progress || 0; + const delta = stepBound[jStep + 1] - stepBound[jStep]; + this.progress = (stepBound[jStep] + sp*delta)/100; + } + } else { + break; + } + + await utils.sleep(300); + ri = (ri < rotor.length - 1 ? ri + 1 : 0); + } + } finally { + this.busyDialogVisible = false; + } + } + async request(params) { - return await wsc.message(await wsc.send(params)); + while (1) {// eslint-disable-line + const response = await wsc.message(await wsc.send(params)); + + if (response && response.error == 'server_busy') { + await this.showBusyDialog(); + } else { + return response; + } + } } async search(query) { diff --git a/client/components/Search/Search.vue b/client/components/Search/Search.vue index 9405510..524229f 100644 --- a/client/components/Search/Search.vue +++ b/client/components/Search/Search.vue @@ -32,7 +32,7 @@ - +
- +
diff --git a/client/components/Search/authorBooksStorage.js b/client/components/Search/authorBooksStorage.js index b7a85bc..6e6be34 100644 --- a/client/components/Search/authorBooksStorage.js +++ b/client/components/Search/authorBooksStorage.js @@ -2,7 +2,7 @@ import localForage from 'localforage'; //import _ from 'lodash'; import * as utils from '../../share/utils'; -const maxDataSize = 100*1024*1024; +const maxDataSize = 100*1024*1024;//100 Mb const abStore = localForage.createInstance({ name: 'authorBooksStorage' diff --git a/client/components/share/DivBtn.vue b/client/components/share/DivBtn.vue index 84f916c..f558039 100644 --- a/client/components/share/DivBtn.vue +++ b/client/components/share/DivBtn.vue @@ -1,7 +1,7 @@