diff --git a/ui/src/app/assets/components/asset-overview/asset-overview.component.ts b/ui/src/app/assets/components/asset-overview/asset-overview.component.ts index 0afcbf7033..88a5b3f79f 100644 --- a/ui/src/app/assets/components/asset-overview/asset-overview.component.ts +++ b/ui/src/app/assets/components/asset-overview/asset-overview.component.ts @@ -72,21 +72,19 @@ export class SpAssetOverviewComponent implements OnInit { }); } - createNewAsset(assetModel?: SpAssetModel) { - if (!assetModel) { - assetModel = { - assetName: 'New Asset', - assetDescription: '', - assetLinks: [], - assetId: this.idGeneratorService.generate(6), - _id: this.idGeneratorService.generate(24), - appDocType: 'asset-management', - removable: true, - _rev: undefined, - assets: [], - assetType: undefined, - }; - } + createNewAsset() { + const assetModel = { + assetName: 'New Asset', + assetDescription: '', + assetLinks: [], + assetId: this.idGeneratorService.generate(6), + _id: this.idGeneratorService.generate(24), + appDocType: 'asset-management', + removable: true, + _rev: undefined, + assets: [], + assetType: undefined, + }; const dialogRef = this.dialogService.open( SpCreateAssetDialogComponent, { @@ -94,14 +92,15 @@ export class SpAssetOverviewComponent implements OnInit { title: 'Create asset', width: '50vw', data: { - createMode: true, assetModel: assetModel, }, }, ); - dialogRef.afterClosed().subscribe(() => { - this.goToDetailsView(assetModel, true); + dialogRef.afterClosed().subscribe(ev => { + if (ev) { + this.goToDetailsView(assetModel, true); + } }); } @@ -117,7 +116,7 @@ export class SpAssetOverviewComponent implements OnInit { asset._id, asset._rev, ) - .subscribe(result => { + .subscribe(() => { this.loadAssets(); this.assetBrowserService.loadAssetData(); }); diff --git a/ui/src/app/assets/dialog/create-asset/create-asset-dialog.component.html b/ui/src/app/assets/dialog/create-asset/create-asset-dialog.component.html index e4acc1423f..c1778d43af 100644 --- a/ui/src/app/assets/dialog/create-asset/create-asset-dialog.component.html +++ b/ui/src/app/assets/dialog/create-asset/create-asset-dialog.component.html @@ -57,7 +57,7 @@ data-cy="save-data-view" (click)="onSave()" > - {{ createMode ? 'Create' : 'Save' }} + Create diff --git a/ui/src/app/assets/dialog/create-asset/create-asset-dialog.component.ts b/ui/src/app/assets/dialog/create-asset/create-asset-dialog.component.ts index e4a6aad67a..41c22f343c 100644 --- a/ui/src/app/assets/dialog/create-asset/create-asset-dialog.component.ts +++ b/ui/src/app/assets/dialog/create-asset/create-asset-dialog.component.ts @@ -30,7 +30,6 @@ import { DialogRef } from '@streampipes/shared-ui'; styleUrls: ['./create-asset-dialog.component.scss'], }) export class SpCreateAssetDialogComponent { - @Input() createMode: boolean; @Input() assetModel: SpAssetModel; constructor( @@ -43,18 +42,10 @@ export class SpCreateAssetDialogComponent { } onSave(): void { - if (this.createMode) { - this.assetManagementService - .createAsset(this.assetModel) - .subscribe(() => { - this.dialogRef.close(); - }); - } else { - this.assetManagementService - .updateAsset(this.assetModel) - .subscribe(() => { - this.dialogRef.close(); - }); - } + this.assetManagementService + .createAsset(this.assetModel) + .subscribe(() => { + this.dialogRef.close(true); + }); } } diff --git a/ui/src/app/dashboard/components/overview/dashboard-overview.component.html b/ui/src/app/dashboard/components/overview/dashboard-overview.component.html index c58a094634..e51199a6cd 100644 --- a/ui/src/app/dashboard/components/overview/dashboard-overview.component.html +++ b/ui/src/app/dashboard/components/overview/dashboard-overview.component.html @@ -16,144 +16,151 @@ ~ --> - - - + + - add - New Dashboard - - - - - - - - - - Dashboard - - - - {{ element.name }} - - - {{ element.description }} - - - + add + New Dashboard + + - - - - + + + + + - - visibility - - - open_in_new - - - settings - - - edit - - - share - - + + + {{ element.name }} + + + {{ element.description }} + + + + + + + + - delete - - - - - + + visibility + + + open_in_new + + + settings + + + edit + + + share + + + delete + + + + + + - - + + diff --git a/ui/src/app/dashboard/components/overview/dashboard-overview.component.ts b/ui/src/app/dashboard/components/overview/dashboard-overview.component.ts index 946812af5c..d32eb11261 100644 --- a/ui/src/app/dashboard/components/overview/dashboard-overview.component.ts +++ b/ui/src/app/dashboard/components/overview/dashboard-overview.component.ts @@ -42,6 +42,7 @@ import { zip } from 'rxjs'; }) export class DashboardOverviewComponent implements OnInit { dashboards: Dashboard[] = []; + filteredDashboards: Dashboard[] = []; dataSource = new MatTableDataSource(); displayedColumns: string[] = []; @@ -76,7 +77,7 @@ export class DashboardOverviewComponent implements OnInit { getDashboards() { this.dashboardService.getDashboards().subscribe(data => { this.dashboards = data.sort((a, b) => a.name.localeCompare(b.name)); - this.dataSource.data = this.dashboards; + this.applyDashboardFilters(); }); } @@ -164,4 +165,15 @@ export class DashboardOverviewComponent implements OnInit { } }); } + + applyDashboardFilters(elementIds: Set = new Set()): void { + this.filteredDashboards = this.dashboards.filter(a => { + if (elementIds.size === 0) { + return true; + } else { + return elementIds.has(a.elementId); + } + }); + this.dataSource.data = this.filteredDashboards; + } } diff --git a/ui/src/app/data-explorer/components/overview/data-explorer-dashboard-overview/data-explorer-dashboard-overview.component.ts b/ui/src/app/data-explorer/components/overview/data-explorer-dashboard-overview/data-explorer-dashboard-overview.component.ts index 11dbce196c..bdd1775596 100644 --- a/ui/src/app/data-explorer/components/overview/data-explorer-dashboard-overview/data-explorer-dashboard-overview.component.ts +++ b/ui/src/app/data-explorer/components/overview/data-explorer-dashboard-overview/data-explorer-dashboard-overview.component.ts @@ -16,13 +16,12 @@ * */ -import { Component } from '@angular/core'; +import { Component, EventEmitter, Output } from '@angular/core'; import { MatTableDataSource } from '@angular/material/table'; import { Dashboard, DataViewDataExplorerService, } from '@streampipes/platform-services'; -import { ObjectPermissionDialogComponent } from '../../../../core-ui/object-permission-dialog/object-permission-dialog.component'; import { CurrentUserService, ConfirmDialogComponent, @@ -43,6 +42,10 @@ export class SpDataExplorerDashboardOverviewComponent extends SpDataExplorerOver dataSource = new MatTableDataSource(); displayedColumns: string[] = []; dashboards: Dashboard[] = []; + filteredDashboards: Dashboard[] = []; + + @Output() + resourceCountEmitter: EventEmitter = new EventEmitter(); constructor( private dataViewService: DataViewDataExplorerService, @@ -121,7 +124,19 @@ export class SpDataExplorerDashboardOverviewComponent extends SpDataExplorerOver getDashboards() { this.dataViewService.getDataViews().subscribe(data => { this.dashboards = data.sort((a, b) => a.name.localeCompare(b.name)); - this.dataSource.data = this.dashboards; + this.resourceCountEmitter.emit(this.dashboards.length); + this.applyDashboardFilters(); + }); + } + + applyDashboardFilters(elementIds: Set = new Set()): void { + this.filteredDashboards = this.dashboards.filter(a => { + if (elementIds.size === 0) { + return true; + } else { + return elementIds.has(a.elementId); + } }); + this.dataSource.data = this.filteredDashboards; } } diff --git a/ui/src/app/data-explorer/components/overview/data-explorer-overview.component.html b/ui/src/app/data-explorer/components/overview/data-explorer-overview.component.html index 81b53324b8..ac0c0b090f 100644 --- a/ui/src/app/data-explorer/components/overview/data-explorer-overview.component.html +++ b/ui/src/app/data-explorer/components/overview/data-explorer-overview.component.html @@ -16,41 +16,50 @@ ~ --> - - - + + - add - New Dashboard - - - add - New Data View - - - - - - - + + add + New Dashboard + + + add + New Data View + + + + + + + + diff --git a/ui/src/app/data-explorer/components/overview/data-explorer-overview.component.ts b/ui/src/app/data-explorer/components/overview/data-explorer-overview.component.ts index 176399a5fb..5c265b096e 100644 --- a/ui/src/app/data-explorer/components/overview/data-explorer-overview.component.ts +++ b/ui/src/app/data-explorer/components/overview/data-explorer-overview.component.ts @@ -39,6 +39,8 @@ export class DataExplorerOverviewComponent extends SpDataExplorerOverviewDirecti @ViewChild(SpDataExplorerDashboardOverviewComponent) dashboardOverview: SpDataExplorerDashboardOverviewComponent; + resourceCount = 0; + constructor( public dialogService: DialogService, private breadcrumbService: SpBreadcrumbService, @@ -86,4 +88,8 @@ export class DataExplorerOverviewComponent extends SpDataExplorerOverviewDirecti this.dashboardOverview.getDashboards(); }); } + + applyDashboardFilters(elementIds: Set = new Set()): void { + this.dashboardOverview.applyDashboardFilters(elementIds); + } }