You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by oe...@apache.org on 2026/04/16 10:59:24 UTC
(streampipes) branch 4380-auto-refresh-assets-after-adding-newly-created-resources updated (1100b2838a -> 4a9fcf331d)
This is an automated email from the ASF dual-hosted git repository.
oehler pushed a change to branch 4380-auto-refresh-assets-after-adding-newly-created-resources
in repository https://gitbox.apache.org/repos/asf/streampipes.git
from 1100b2838a fix: Add missing event grounding modification in debug mode (#4381)
new f40be335bf Update assets after creating resources
new 4a9fcf331d Remove unused duplicated service
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../lib/services/asset-configuration.service.ts | 79 ++---
.../adapter-asset-configuration.service.ts | 342 ---------------------
2 files changed, 43 insertions(+), 378 deletions(-)
delete mode 100644 ui/src/app/connect/services/adapter-asset-configuration.service.ts
(streampipes) 02/02: Remove unused duplicated service
Posted by oe...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
oehler pushed a commit to branch 4380-auto-refresh-assets-after-adding-newly-created-resources
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit 4a9fcf331daa2a894031f5fd8c1160dc0412baaa
Author: Sven Oehler <oe...@web.de>
AuthorDate: Thu Apr 16 12:59:14 2026 +0200
Remove unused duplicated service
---
.../adapter-asset-configuration.service.ts | 342 ---------------------
1 file changed, 342 deletions(-)
diff --git a/ui/src/app/connect/services/adapter-asset-configuration.service.ts b/ui/src/app/connect/services/adapter-asset-configuration.service.ts
deleted file mode 100644
index b242382d8d..0000000000
--- a/ui/src/app/connect/services/adapter-asset-configuration.service.ts
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-import { EventEmitter, inject, Injectable, Output } from '@angular/core';
-import {
- AssetConstants,
- AssetLink,
- AssetLinkType,
- AssetManagementService,
- GenericStorageService,
- LinkageData,
- SpAssetModel,
- SpAssetTreeNode,
-} from '@streampipes/platform-services';
-import { firstValueFrom } from 'rxjs';
-
-@Injectable({
- providedIn: 'root',
-})
-export class AssetSaveService {
- assetLinkTypes: AssetLinkType[] = [];
- currentAsset: SpAssetModel;
-
- private assetService = inject(AssetManagementService);
- private storageService = inject(GenericStorageService);
-
- constructor() {
- this.loadAssetLinkTypes();
- }
-
- @Output() adapterStartedEmitter: EventEmitter<void> =
- new EventEmitter<void>();
-
- async saveSelectedAssets(
- selectedAssets: SpAssetTreeNode[],
- linkageData: LinkageData[],
- deselectedAssets: SpAssetTreeNode[] = [],
- originalAssets: SpAssetTreeNode[] = [],
- ): Promise<void> {
- const links = this.buildLinks(linkageData);
-
- if (deselectedAssets.length > 0) {
- await this.deleteLinkOnDeselectAssets(deselectedAssets, links);
- }
- if (selectedAssets.length > 0) {
- await this.setLinkOnSelectAssets(selectedAssets, links);
- }
-
- if (originalAssets.length > 0) {
- //filter is necessary, otherwise conflicting database instances are produced
- const filteredOriginal = this.filterAssets(
- originalAssets,
- deselectedAssets,
- selectedAssets,
- );
-
- if (filteredOriginal.length > 0) {
- this.renameLinkage(filteredOriginal, links);
- }
- }
- }
- private filterAssets(
- originalAssets: SpAssetTreeNode[],
- deselectedAssets: SpAssetTreeNode[],
- selectedAssets: SpAssetTreeNode[],
- ): SpAssetTreeNode[] {
- const deselectedAssetIds = new Set(
- deselectedAssets.map(asset => asset.assetId),
- );
- const selectedAssetIds = new Set(
- selectedAssets.map(asset => asset.assetId),
- );
-
- return originalAssets.filter(
- asset =>
- !deselectedAssetIds.has(asset.assetId) &&
- !selectedAssetIds.has(asset.assetId),
- );
- }
-
- renameLinkage(originalAssets, links) {
- const uniqueAssetIDsDict = this.getAssetPaths(originalAssets);
- const uniqueAssetIDs = Object.keys(uniqueAssetIDsDict);
-
- uniqueAssetIDs.forEach(spAssetModelId => {
- this.assetService.getAsset(spAssetModelId).subscribe({
- next: current => {
- this.currentAsset = current;
-
- uniqueAssetIDsDict[spAssetModelId].forEach(path => {
- if (path.length === 2) {
- current.assetLinks = (current.assetLinks ?? []).map(
- (link: any) => {
- const matchedLink = links.find(
- l => l.resourceId === link.resourceId,
- );
- if (matchedLink) {
- link.linkLabel = matchedLink.linkLabel;
- }
- return link;
- },
- );
- }
-
- if (path.length > 2) {
- links.forEach(linkToUpdate => {
- this.updateLinkLabelInDict(
- current as unknown as SpAssetTreeNode,
- path,
- linkToUpdate,
- );
- });
- }
- });
-
- const updateObservable =
- this.assetService.updateAsset(current);
-
- updateObservable?.subscribe({
- next: () => {
- this.adapterStartedEmitter.emit();
- },
- });
- },
- });
- });
- }
-
- private updateLinkLabelInDict(
- dict: SpAssetTreeNode,
- path: (string | number)[],
- linkToUpdate: any,
- ) {
- let current = dict;
-
- for (let i = 2; i < path.length; i++) {
- const key = path[i];
- if (i === path.length - 1) {
- if (current.assets?.[key]?.assetLinks) {
- current.assets[key].assetLinks = current.assets[
- key
- ].assetLinks.map((link: any) => {
- if (link.resourceId === linkToUpdate.resourceId) {
- link.linkLabel = linkToUpdate.linkLabel;
- }
- return link;
- });
- }
- } else {
- if (Array.isArray(current.assets)) {
- current = current.assets[key as number];
- }
- }
- }
-
- return current;
- }
- async setLinkOnSelectAssets(
- selectedAssets: SpAssetTreeNode[],
- links: AssetLink[],
- ): Promise<void> {
- const uniqueAssetIDsDict = this.getAssetPaths(selectedAssets);
- const uniqueAssetIDs = Object.keys(uniqueAssetIDsDict);
-
- for (const spAssetModelId of uniqueAssetIDs) {
- const current = await firstValueFrom(
- this.assetService.getAsset(spAssetModelId),
- );
-
- uniqueAssetIDsDict[spAssetModelId].forEach(path => {
- if (path.length === 2) {
- current.assetLinks = [
- ...(current.assetLinks ?? []),
- ...links,
- ];
- }
-
- if (path.length > 2) {
- this.updateDictValue(current, path, links);
- }
- });
-
- const updateObservable = this.assetService.updateAsset(current);
- await firstValueFrom(updateObservable); // Ensure this completes before continuing
- }
- }
-
- async deleteLinkOnDeselectAssets(
- deselectedAssets: SpAssetTreeNode[],
- links: AssetLink[],
- ): Promise<void> {
- const uniqueAssetIDsDict = this.getAssetPaths(deselectedAssets);
- const uniqueAssetIDs = Object.keys(uniqueAssetIDsDict);
-
- for (const spAssetModelId of uniqueAssetIDs) {
- const current = await firstValueFrom(
- this.assetService.getAsset(spAssetModelId),
- );
-
- uniqueAssetIDsDict[spAssetModelId].forEach(path => {
- if (path.length === 2) {
- current.assetLinks = (current.assetLinks ?? []).filter(
- (link: any) =>
- !links.some(
- l =>
- JSON.stringify(l.resourceId) ===
- JSON.stringify(link.resourceId),
- ),
- );
- }
-
- if (path.length > 2) {
- links.forEach(linkToRemove => {
- this.deleteDictValue(
- current as unknown as SpAssetTreeNode,
- path,
- linkToRemove,
- );
- });
- }
- });
-
- const updateObservable = this.assetService.updateAsset(current);
- await firstValueFrom(updateObservable); // Ensure this completes before continuing
- }
- }
-
- private deleteDictValue(
- dict: SpAssetTreeNode,
- path: (string | number)[],
- linkToRemove: any,
- ) {
- let current = dict;
-
- for (let i = 2; i < path.length; i++) {
- const key = path[i];
- if (i === path.length - 1) {
- if (current.assets?.[key]?.assetLinks) {
- current.assets[key].assetLinks = current.assets[
- key
- ].assetLinks.filter(
- (link: any) =>
- JSON.stringify(link.resourceId) !==
- JSON.stringify(linkToRemove.resourceId),
- );
- }
- } else {
- if (Array.isArray(current.assets)) {
- current = current.assets[key as number];
- }
- }
- }
-
- return current;
- }
-
- private updateDictValue(
- dict: SpAssetModel,
- path: (string | number)[],
- newValue: any,
- ) {
- const result: any = { ...dict };
- let current = result;
- for (let i = 2; i < path.length; i++) {
- const key = path[i];
-
- if (i === path.length - 1) {
- current.assets[key].assetLinks = [
- ...(current.assets[key].assetLinks ?? []),
- ...newValue,
- ];
-
- break;
- }
-
- if (Array.isArray(current.assets)) {
- parent = current;
- current = { ...current.assets[key as number] };
- }
- }
-
- return result;
- }
-
- private getAssetPaths(apiAssets: SpAssetTreeNode[]): {
- [key: string]: Array<Array<string | number>>;
- } {
- const idPaths = {};
- apiAssets.forEach(item => {
- if (item.spAssetModelId && item.flattenPath) {
- if (!idPaths[item.spAssetModelId]) {
- idPaths[item.spAssetModelId] = [];
- }
- idPaths[item.spAssetModelId].push(item.flattenPath);
- }
- });
- return idPaths;
- }
-
- private buildLinks(data: LinkageData[]): AssetLink[] {
- return data.map(item => {
- const linkType = this.getAssetLinkTypeById(item.type);
- return {
- linkLabel: item.name,
- linkType: item.type,
- editingDisabled: false,
- queryHint: item.type,
- navigationActive: linkType?.navigationActive ?? false,
- resourceId: item.id,
- };
- });
- }
-
- private getAssetLinkTypeById(linkType: string): AssetLinkType | undefined {
- return this.assetLinkTypes.find(a => a.linkType === linkType);
- }
-
- private loadAssetLinkTypes(): void {
- this.storageService
- .getAllDocuments(AssetConstants.ASSET_LINK_TYPES_DOC_NAME)
- .subscribe(linkTypes => {
- this.assetLinkTypes = linkTypes.sort((a, b) =>
- a.linkLabel.localeCompare(b.linkLabel),
- );
- });
- }
-}
(streampipes) 01/02: Update assets after creating resources
Posted by oe...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
oehler pushed a commit to branch 4380-auto-refresh-assets-after-adding-newly-created-resources
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit f40be335bfc06c797ed7011242ac025b95a57c48
Author: Sven Oehler <oe...@web.de>
AuthorDate: Thu Apr 16 12:50:30 2026 +0200
Update assets after creating resources
---
.../lib/services/asset-configuration.service.ts | 79 ++++++++++++----------
1 file changed, 43 insertions(+), 36 deletions(-)
diff --git a/ui/projects/streampipes/shared-ui/src/lib/services/asset-configuration.service.ts b/ui/projects/streampipes/shared-ui/src/lib/services/asset-configuration.service.ts
index eafa6aeeca..fc0033316e 100644
--- a/ui/projects/streampipes/shared-ui/src/lib/services/asset-configuration.service.ts
+++ b/ui/projects/streampipes/shared-ui/src/lib/services/asset-configuration.service.ts
@@ -28,6 +28,7 @@ import {
SpAssetTreeNode,
} from '@streampipes/platform-services';
import { firstValueFrom } from 'rxjs';
+import { SpAssetBrowserService } from '../components/asset-browser/asset-browser.service';
@Injectable({
providedIn: 'root',
@@ -38,6 +39,7 @@ export class AssetSaveService {
private assetService = inject(AssetManagementService);
private storageService = inject(GenericStorageService);
+ private assetBrowserService = inject(SpAssetBrowserService);
constructor() {
this.loadAssetLinkTypes();
@@ -50,11 +52,15 @@ export class AssetSaveService {
originalAssets: SpAssetTreeNode[] = [],
): Promise<void> {
const links = this.buildLinks(linkageData);
+ let assetLinksChanged = false;
+
if (deselectedAssets.length > 0) {
await this.deleteLinkOnDeselectAssets(deselectedAssets, links);
+ assetLinksChanged = true;
}
if (selectedAssets.length > 0) {
await this.setLinkOnSelectAssets(selectedAssets, links);
+ assetLinksChanged = true;
}
if (originalAssets.length > 0) {
@@ -66,9 +72,14 @@ export class AssetSaveService {
);
if (filteredOriginal.length > 0) {
- this.renameLinkage(filteredOriginal, links);
+ await this.renameLinkage(filteredOriginal, links);
+ assetLinksChanged = true;
}
}
+
+ if (assetLinksChanged) {
+ this.assetBrowserService.refreshBrowserAssetData();
+ }
}
private filterAssets(
@@ -90,48 +101,44 @@ export class AssetSaveService {
);
}
- renameLinkage(originalAssets, links) {
+ async renameLinkage(originalAssets, links): Promise<void> {
const uniqueAssetIDsDict = this.getAssetPaths(originalAssets);
const uniqueAssetIDs = Object.keys(uniqueAssetIDsDict);
- uniqueAssetIDs.forEach(spAssetModelId => {
- this.assetService.getAsset(spAssetModelId).subscribe({
- next: current => {
- this.currentAsset = current;
-
- uniqueAssetIDsDict[spAssetModelId].forEach(path => {
- if (path.length === 2) {
- current.assetLinks = (current.assetLinks ?? []).map(
- (link: any) => {
- const matchedLink = links.find(
- l => l.resourceId === link.resourceId,
- );
- if (matchedLink) {
- link.linkLabel = matchedLink.linkLabel;
- }
- return link;
- },
+ for (const spAssetModelId of uniqueAssetIDs) {
+ const current = await firstValueFrom(
+ this.assetService.getAsset(spAssetModelId),
+ );
+ this.currentAsset = current;
+
+ uniqueAssetIDsDict[spAssetModelId].forEach(path => {
+ if (path.length === 2) {
+ current.assetLinks = (current.assetLinks ?? []).map(
+ (link: any) => {
+ const matchedLink = links.find(
+ l => l.resourceId === link.resourceId,
);
- }
+ if (matchedLink) {
+ link.linkLabel = matchedLink.linkLabel;
+ }
+ return link;
+ },
+ );
+ }
- if (path.length > 2) {
- links.forEach(linkToUpdate => {
- this.updateLinkLabelInDict(
- current as unknown as SpAssetTreeNode,
- path,
- linkToUpdate,
- );
- });
- }
+ if (path.length > 2) {
+ links.forEach(linkToUpdate => {
+ this.updateLinkLabelInDict(
+ current as unknown as SpAssetTreeNode,
+ path,
+ linkToUpdate,
+ );
});
-
- const updateObservable =
- this.assetService.updateAsset(current);
-
- updateObservable?.subscribe();
- },
+ }
});
- });
+
+ await firstValueFrom(this.assetService.updateAsset(current));
+ }
}
private updateLinkLabelInDict(