From 013bda6fc765f9c301495b9cbc339be59e41115e Mon Sep 17 00:00:00 2001 From: PhilReact Date: Thu, 28 Sep 2023 20:55:35 -0500 Subject: [PATCH] add loader to q-apps page --- plugins/plugins/core/q-app/q-apps.src.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/plugins/core/q-app/q-apps.src.js b/plugins/plugins/core/q-app/q-apps.src.js index 37b502e2..7a2b0792 100644 --- a/plugins/plugins/core/q-app/q-apps.src.js +++ b/plugins/plugins/core/q-app/q-apps.src.js @@ -4,6 +4,7 @@ import { Epml } from '../../../epml.js' import { use, get, translate, translateUnsafeHTML, registerTranslateConfig } from 'lit-translate' import { columnBodyRenderer, gridRowDetailsRenderer } from '@vaadin/grid/lit.js' import isElectron from 'is-electron' +import '@polymer/paper-spinner/paper-spinner-lite.js' registerTranslateConfig({ loader: lang => fetch(`/language/${lang}.json`).then(res => res.json()) @@ -42,7 +43,9 @@ class QApps extends LitElement { blockedResources: { type: Array }, textStatus: { type: String }, textProgress: { type: String }, - theme: { type: String, reflect: true } + theme: { type: String, reflect: true }, + hasInitiallyFetched: {type:Boolean}, + isLoading: {type: Boolean} } } @@ -369,6 +372,7 @@ class QApps extends LitElement { this.blockedNames = [] this.relayMode = null this.isLoading = false + this.hasInitiallyFetched = false this.btnDisabled = false this.searchName = '' this.searchResources = [] @@ -421,13 +425,14 @@ class QApps extends LitElement {
- ${this.pageRes == null ? html` - Loading... + ${this.isLoading ? html` +
` : ''} - ${this.isEmptyArray(this.pageRes) ? html` + ${this.isEmptyArray(this.pageRes) && this.hasInitiallyFetched ? html` ${translate("appspage.schange10")} ` : ''} ${this.renderRelayModeText()}
+
@@ -738,11 +743,16 @@ class QApps extends LitElement { const myNode = window.parent.reduxStore.getState().app.nodeConfig.knownNodes[window.parent.reduxStore.getState().app.nodeConfig.node] const nodeUrl = myNode.protocol + '://' + myNode.domain + ':' + myNode.port let jsonOffsetUrl = `${nodeUrl}/arbitrary/resources?service=APP&default=true&limit=20&offset=${offset}&reverse=false&includestatus=true&includemetadata=true&excludeblocked=true` - + this.isLoading = true + const jsonOffsetRes = await fetch(jsonOffsetUrl) const jsonOffsetData = await jsonOffsetRes.json() this.pageRes = jsonOffsetData + if(!this.hasInitiallyFetched){ + this.hasInitiallyFetched = true + } + this.isLoading = false } async updateItemsFromPage(page) {