Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

UI enhancement: Reduced amount of requested HTTP data for assets page (#2293)

Martin Peetersb0e642001d2a
diff --git a/ui/component/or-asset-tree/src/index.ts b/ui/component/or-asset-tree/src/index.ts
index b4b7efa67..414531f65 100644
--- a/ui/component/or-asset-tree/src/index.ts
+++ b/ui/component/or-asset-tree/src/index.ts
@@ -1267,9 +1267,9 @@ export class OrAssetTree extends subscribe(manager)(LitElement) {
try {
console.debug(`Querying assets using filter '${this._filterInput.nativeValue}'...`);
- const promises = assetQueries.map(q => manager.rest.api.AssetResource.queryAssets(q));
+ const promises = assetQueries.map(q => manager.rest.api.AssetResource.queryAssetTree(q));
const responses = await Promise.all(promises);
- foundAssets = responses.flatMap(r => r.data);
+ foundAssets = responses.flatMap(r => r.data.assets ?? []);
foundAssetIds = foundAssets.map(a => a.id!);
console.debug(`The filter query found ${foundAssets.length} assets!`);
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index 69df8f93f..78a108928 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -940,6 +940,7 @@ async function getAssetChildren(parentId: string, childAssetType: string): Promi
try {
response = await manager.rest.api.AssetResource.queryAssets({
+ types: [childAssetType],
parents: [
{
id: parentId
@@ -955,7 +956,7 @@ async function getAssetChildren(parentId: string, childAssetType: string): Promi
return [];
}
- return response.data.filter((asset) => asset.type === childAssetType);
+ return response.data;
}
async function getLinkedUserInfo(userAssetLink: UserAssetLink): Promise<UserAssetLinkInfo> {