100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Add is_loading to get settings
Robin Dekkers4ac9cf1f7b13
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.tsindex c06e930e6..500303b9b 100644--- a/ui/component/or-asset-viewer/src/index.ts+++ b/ui/component/or-asset-viewer/src/index.ts@@ -438,12 +438,13 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem} else if (panelConfig && panelConfig.type === "chart") {let storeDataPointAttrs = attrs.filter((attr) => Util.getFirstMetaItem(attr, MetaItemType.STORE_DATA_POINTS.urn!))- let defaultAttrs = storeDataPointAttrs.filter((attr) => (defaultAttributes && defaultAttributes.indexOf(attr.name!) >= 0));+let assetAttributes;-- if(defaultAttrs.length > 0){- assetAttributes = defaultAttrs;- } else if(storeDataPointAttrs.length > 0) {+ // let defaultAttrs = storeDataPointAttrs.filter((attr) => (defaultAttributes && defaultAttributes.indexOf(attr.name!) >= 0));+ // if(defaultAttrs.length > 0){+ // assetAttributes = defaultAttrs;+ // } else+ if(storeDataPointAttrs.length > 0) {assetAttributes = storeDataPointAttrs;assetAttributes.length = 1;}diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.tsindex b3cd62308..f092a13d9 100644--- a/ui/component/or-chart/src/index.ts+++ b/ui/component/or-chart/src/index.ts@@ -402,8 +402,9 @@ export class OrChart extends translate(i18next)(LitElement) {}this._dialog = new MDCDialog(this._dialogElem);-- this.getSettings();+ if(!this.activeAssetId) {+ this.getSettings();+ }}}@@ -600,8 +601,9 @@ export class OrChart extends translate(i18next)(LitElement) {updated(changedProperties: PropertyValues) {super.updated(changedProperties);- if (changedProperties.has("activeAsset") && this.activeAsset && changedProperties.get("activeAsset") !== this.activeAsset) {+ if (!this._loading && changedProperties.has("activeAsset") && this.activeAsset && changedProperties.get("activeAsset") !== this.activeAsset) {this.getSettings();+ return;}if(changedProperties.has("assetAttributes") ) {@@ -613,7 +615,7 @@ export class OrChart extends translate(i18next)(LitElement) {let reloadData = changedProperties.has("period") || changedProperties.has("compareTimestamp") || changedProperties.has("timestamp") || changedProperties.has("assetAttributes");- if (reloadData) {+ if (reloadData && !this._loading) {this._data = [];this._loadData();}@@ -702,6 +704,7 @@ export class OrChart extends translate(i18next)(LitElement) {}getSettings() {+ this._loading = true;const configStr = window.localStorage.getItem('OrChartConfig')if(!configStr) return@@ -713,12 +716,14 @@ export class OrChart extends translate(i18next)(LitElement) {const query = {ids: view.assetIds}+ if(view.assetIds === this.assets.map(asset => asset.id)) returnmanager.rest.api.AssetResource.queryAssets(query).then((response) => {const assets = response.data;this.assets = view.assetIds.map((assetId: string) => assets.find(x => x.id === assetId));this.assetAttributes = view.attributes.map((attr: string, index: number) => Util.getAssetAttribute(this.assets[index], attr));this.period = view.period;+ this._loading = false;});}