This is an automated email from the ASF dual-hosted git repository.
riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to refs/heads/dev by this push:
new 1d58e08e7b fix: Display location for sites in asset management (#3291)
1d58e08e7b is described below
commit 1d58e08e7b5dcab5da9aaa7bcdf487887841978a
Author: Marcel Früholz <[email protected]>
AuthorDate: Tue Oct 8 22:28:44 2024 +0200
fix: Display location for sites in asset management (#3291)
* fixed location for sites in asset management
* add indication for label configuration
---
.../asset-details/base-asset-details.directive.ts | 10 +++
.../asset-details-labels.component.html | 93 ++++++++++++++--------
.../asset-details-labels.component.ts | 4 +
.../asset-details-site.component.html | 43 +++++++---
4 files changed, 103 insertions(+), 47 deletions(-)
diff --git
a/ui/src/app/assets/components/asset-details/base-asset-details.directive.ts
b/ui/src/app/assets/components/asset-details/base-asset-details.directive.ts
index c0a11cc3a7..3bc6761f6c 100644
--- a/ui/src/app/assets/components/asset-details/base-asset-details.directive.ts
+++ b/ui/src/app/assets/components/asset-details/base-asset-details.directive.ts
@@ -68,6 +68,16 @@ export abstract class BaseAssetDetailsDirective implements
OnInit {
SpAssetRoutes.BASE,
{ label: this.asset.assetName },
]);
+
+ if (!this.asset.assetSite.hasExactLocation) {
+ const matchingSite = this.sites.find(
+ site => site._id === this.asset.assetSite.siteId,
+ );
+ if (matchingSite) {
+ this.asset.assetSite.location = matchingSite.location;
+ }
+ }
+
this.onAssetAvailable();
});
}
diff --git
a/ui/src/app/assets/components/asset-details/edit-asset/asset-details-panel/asset-details-basics/asset-details-labels/asset-details-labels.component.html
b/ui/src/app/assets/components/asset-details/edit-asset/asset-details-panel/asset-details-basics/asset-details-labels/asset-details-labels.component.html
index acbf7daf51..b1a955ee65 100644
---
a/ui/src/app/assets/components/asset-details/edit-asset/asset-details-panel/asset-details-basics/asset-details-labels/asset-details-labels.component.html
+++
b/ui/src/app/assets/components/asset-details/edit-asset/asset-details-panel/asset-details-basics/asset-details-labels/asset-details-labels.component.html
@@ -17,42 +17,67 @@
-->
<div *ngIf="editMode">
- <mat-form-field class="w-100" *ngIf="labelsAvailable" color="accent">
- <mat-chip-grid #chipGrid aria-label="Labels">
- <mat-chip-row
- (removed)="remove(label)"
- *ngFor="let label of labels"
- [ngStyle]="{ background: label.color }"
+ <div fxLayout="row" fxLayoutGap="15px" fxLayoutAlign="start center">
+ <div fxFlex fxLayoutAlign="start center">
+ <mat-form-field
+ class="w-100"
+ *ngIf="labelsAvailable"
+ color="accent"
+ subscriptSizing="dynamic"
+ [disabled]="allLabels.length === 0"
>
- <span [ngStyle]="{ color: labelTextColors[label._id] }">{{
- label.label
- }}</span>
- <button
- matChipRemove
- [ngStyle]="{ color: labelTextColors[label._id] }"
+ <mat-chip-grid #chipGrid aria-label="Labels">
+ <mat-chip-row
+ (removed)="remove(label)"
+ *ngFor="let label of labels"
+ [ngStyle]="{ background: label.color }"
+ >
+ <span
+ [ngStyle]="{ color: labelTextColors[label._id] }"
+ >{{ label.label }}</span
+ >
+ <button
+ matChipRemove
+ [ngStyle]="{ color: labelTextColors[label._id] }"
+ >
+ <mat-icon>cancel</mat-icon>
+ </button>
+ </mat-chip-row>
+ </mat-chip-grid>
+ <input
+ [placeholder]="
+ allLabels.length === 0
+ ? 'No labels available - Click \'Manage Labels\''
+ : 'Click to add label'
+ "
+ #labelInput
+ [formControl]="labelCtrl"
+ [matChipInputFor]="chipGrid"
+ [matAutocomplete]="auto"
+ [matChipInputSeparatorKeyCodes]="separatorKeysCodes"
+ (matChipInputTokenEnd)="add($event)"
+ [disabled]="allLabels.length === 0"
+ />
+ <mat-autocomplete
+ #auto="matAutocomplete"
+ (optionSelected)="selected($event)"
>
- <mat-icon>cancel</mat-icon>
- </button>
- </mat-chip-row>
- </mat-chip-grid>
- <input
- placeholder="Click to add label"
- #labelInput
- [formControl]="labelCtrl"
- [matChipInputFor]="chipGrid"
- [matAutocomplete]="auto"
- [matChipInputSeparatorKeyCodes]="separatorKeysCodes"
- (matChipInputTokenEnd)="add($event)"
- />
- <mat-autocomplete
- #auto="matAutocomplete"
- (optionSelected)="selected($event)"
- >
- @for (label of filteredLabels | async; track label) {
- <mat-option [value]="label">{{ label }}</mat-option>
- }
- </mat-autocomplete>
- </mat-form-field>
+ @for (label of filteredLabels | async; track label) {
+ <mat-option [value]="label">{{ label }}</mat-option>
+ }
+ </mat-autocomplete>
+ </mat-form-field>
+ </div>
+ <div fxLayoutAlign="start center">
+ <button
+ mat-raised-button
+ color="accent"
+ [routerLink]="['/configuration/labels']"
+ >
+ Manage Labels
+ </button>
+ </div>
+ </div>
</div>
<div
*ngIf="!editMode && labelsAvailable"
diff --git
a/ui/src/app/assets/components/asset-details/edit-asset/asset-details-panel/asset-details-basics/asset-details-labels/asset-details-labels.component.ts
b/ui/src/app/assets/components/asset-details/edit-asset/asset-details-panel/asset-details-basics/asset-details-labels/asset-details-labels.component.ts
index b26fbcde6a..db75fcfbcf 100644
---
a/ui/src/app/assets/components/asset-details/edit-asset/asset-details-panel/asset-details-basics/asset-details-labels/asset-details-labels.component.ts
+++
b/ui/src/app/assets/components/asset-details/edit-asset/asset-details-panel/asset-details-basics/asset-details-labels/asset-details-labels.component.ts
@@ -75,6 +75,10 @@ export class AssetDetailsLabelsComponent implements OnInit,
OnChanges {
label.color,
)),
);
+ this.asset.labelIds =
+ this.asset.labelIds?.filter(
+ id => this.allLabels.find(l => l._id === id) !== undefined,
+ ) || [];
this.refreshCurrentLabels();
this.labelsAvailable = true;
});
diff --git
a/ui/src/app/assets/components/asset-details/edit-asset/asset-details-panel/asset-details-basics/asset-details-site/asset-details-site.component.html
b/ui/src/app/assets/components/asset-details/edit-asset/asset-details-panel/asset-details-basics/asset-details-site/asset-details-site.component.html
index 5b0c819560..5d2363eafd 100644
---
a/ui/src/app/assets/components/asset-details/edit-asset/asset-details-panel/asset-details-basics/asset-details-site/asset-details-site.component.html
+++
b/ui/src/app/assets/components/asset-details/edit-asset/asset-details-panel/asset-details-basics/asset-details-site/asset-details-site.component.html
@@ -17,19 +17,36 @@
-->
<div fxLayout="column">
- <mat-form-field color="accent" class="w-100">
- <mat-label>Site</mat-label>
- <mat-select
- [disabled]="!editMode"
- [(ngModel)]="asset.assetSite.siteId"
- (selectionChange)="handleLocationChange($event)"
- >
- <mat-option *ngFor="let site of sites" [value]="site._id">
- {{ site.label }}
- </mat-option>
- </mat-select>
- </mat-form-field>
- <mat-form-field color="accent" class="w-100" *ngIf="currentSite">
+ <div fxLayout="row" fxLayoutGap="15px" fxLayoutAlign="start center">
+ <div fxFlex fxLayoutAlign="start center">
+ <mat-form-field
+ color="accent"
+ class="w-100"
+ subscriptSizing="dynamic"
+ >
+ <mat-select
+ [disabled]="!editMode"
+ [(ngModel)]="asset.assetSite.siteId"
+ (selectionChange)="handleLocationChange($event)"
+ >
+ <mat-option *ngFor="let site of sites" [value]="site._id">
+ {{ site.label }}
+ </mat-option>
+ </mat-select>
+ </mat-form-field>
+ </div>
+ <div fxLayoutAlign="start center">
+ <button
+ mat-raised-button
+ color="accent"
+ [routerLink]="['/configuration/sites']"
+ >
+ Manage Sites
+ </button>
+ </div>
+ </div>
+
+ <mat-form-field color="accent" class="mt-10 w-100" *ngIf="currentSite">
<mat-label>Area</mat-label>
<mat-select [disabled]="!editMode" [(ngModel)]="asset.assetSite.area">
<mat-option *ngFor="let area of currentSite.areas" [value]="area">