From 0ba96230060a8a150117fb2984cb2d19cd5bf52e Mon Sep 17 00:00:00 2001 From: Sebastien Bousquet Date: Tue, 17 Dec 2024 16:24:54 +0100 Subject: [PATCH 1/2] feat: remove collection filter - Fix #224 --- .../dashboard-search.component.ts | 2 +- .../dynamic-hub/dynamic-hub.component.html | 17 ---- .../dynamic-hub/dynamic-hub.component.scss | 55 ------------ .../dynamic-hub/dynamic-hub.component.ts | 85 ++++--------------- 4 files changed, 17 insertions(+), 142 deletions(-) diff --git a/src/app/components/dashboard-search/dashboard-search.component.ts b/src/app/components/dashboard-search/dashboard-search.component.ts index 1f5fda1..14d1922 100644 --- a/src/app/components/dashboard-search/dashboard-search.component.ts +++ b/src/app/components/dashboard-search/dashboard-search.component.ts @@ -48,7 +48,7 @@ export class DashboardSearchComponent implements OnInit, OnDestroy{ public ngOnInit(): void { this._searchSub = this.searchCtrl.valueChanges.pipe( - debounceTime(400), + debounceTime(300), filter(v => v !== null ), map((v: string) => this.search(v)) ).subscribe(); diff --git a/src/app/components/dynamic-hub/dynamic-hub.component.html b/src/app/components/dynamic-hub/dynamic-hub.component.html index f4806af..4fa75dd 100644 --- a/src/app/components/dynamic-hub/dynamic-hub.component.html +++ b/src/app/components/dynamic-hub/dynamic-hub.component.html @@ -38,22 +38,5 @@

{{ 'No dashboard available' | translate}} - - -
-
-

{{'Collections' | translate}}

-
- - - {{col.key | getCollectionDisplayName | translate}} - - -
-
-
-
diff --git a/src/app/components/dynamic-hub/dynamic-hub.component.scss b/src/app/components/dynamic-hub/dynamic-hub.component.scss index 5b9ffb5..c56877f 100644 --- a/src/app/components/dynamic-hub/dynamic-hub.component.scss +++ b/src/app/components/dynamic-hub/dynamic-hub.component.scss @@ -88,61 +88,6 @@ h2 { color: rgba(0, 0, 0, 0.7); } } - .collection { - flex: 1; - - &-wrapper { - height: calc(100vh - ($top-menu-height + $header-height)); - position: sticky; - width: 100%; - top: $header-height; - } - - &--without-edit-header { - top: $header-height - 10px; - } - - .cards { - padding-top: 1px; - height: calc(100% - 90px); // top menu height + dynamic hub header height + collection h2 height - overflow-x: hidden; - overflow-y: auto; - & .scroll-hider { - position: absolute; - background: #F5F5F5; - height: 100%; - top: 0; - right: 0; - width: 6px; - -webkit-transition: all .5s; - transition: all .5s; - opacity: 1; - } - &:hover .scroll-hider { - opacity: 0; - -webkit-transition: all .5s; - transition: all .5s; - } - - .card { - margin: 4px 0px; - border-left: 3px solid; - border-radius: 0px; - padding: 8px 15px; - cursor: pointer; - box-shadow: none; - - .mat-mdc-card-header { - padding: 0; - } - - &.disabled { - border-color: whitesmoke !important; - color: rgba(0, 0, 0, 0.54); - } - } - } - } } } diff --git a/src/app/components/dynamic-hub/dynamic-hub.component.ts b/src/app/components/dynamic-hub/dynamic-hub.component.ts index f388d6b..3e41ac5 100644 --- a/src/app/components/dynamic-hub/dynamic-hub.component.ts +++ b/src/app/components/dynamic-hub/dynamic-hub.component.ts @@ -50,13 +50,10 @@ export class DynamicHubComponent implements OnInit { public canCreateDashboardByOrg: Map; public allowedOrganisations: string[] = []; - public cardCollections = new Map(); public canCreateDashboard = false; public userGroups: string[] = []; - public selectedCollection: string[] = []; - public connected = false; public isAuthentActivated: boolean; public authentMode: 'openid' | 'iam'; @@ -88,7 +85,6 @@ export class DynamicHubComponent implements OnInit { } public ngOnInit(): void { - this.cardCollections.clear(); if (!this.isAuthentActivated) { this.fetchCards(); @@ -131,17 +127,17 @@ export class DynamicHubComponent implements OnInit { this.initSearch(); } - public initSearch(){ + public initSearch() { this.dashboardSearch.valueChanged$ .pipe( - tap(() => this.isLoading = true), + tap(() => this.isLoading = true), debounceTime(500), map((v) => { this.filterDashboard(v); this.isLoading = false; }) ) - .subscribe({error: () => this.isLoading = false}); + .subscribe({ error: () => this.isLoading = false }); } public add(org?: string) { @@ -237,7 +233,7 @@ export class DynamicHubComponent implements OnInit { } public publicAtTheEnd = (a: KeyValue, b: KeyValue): number => { - if (a.key !== this.PUBLIC_ORG && b.key === this.PUBLIC_ORG ) { + if (a.key !== this.PUBLIC_ORG && b.key === this.PUBLIC_ORG) { return -1; } if (a.key === this.PUBLIC_ORG && b.key !== this.PUBLIC_ORG) { @@ -275,7 +271,7 @@ export class DynamicHubComponent implements OnInit { )); this.cardsRef.set(o, cards); i++; - this.applyCollectionFilter(); + this.initFilter(); if (i === this.orgs.length) { this.isLoading = false; } @@ -294,7 +290,7 @@ export class DynamicHubComponent implements OnInit { next: (cards) => { this.storeExternalOrganisationsCards(cards); this.isLoading = false; - this.applyCollectionFilter(); + this.initFilter(); } }); } @@ -320,8 +316,8 @@ export class DynamicHubComponent implements OnInit { if (!publicCards) { publicCards = []; } - this.registerCollection(c); - c.preview$ = this.getPreview$(c.previewId,{}); + + c.preview$ = this.getPreview$(c.previewId, {}); this.addCard(c, publicCards); this.cardsRef.set(publicOrg, publicCards); } @@ -336,11 +332,7 @@ export class DynamicHubComponent implements OnInit { } - private registerCollection(c: Card) { - if (!this.cardCollections.has(c.collection)) { - this.cardCollections.set(c.collection, { color: c.color, selected: true }); - } - } + private enrichCards(cards: Card[], fetchOptions?): Card[] { cards.forEach(c => { @@ -349,7 +341,7 @@ export class DynamicHubComponent implements OnInit { .forEach(a => a.url = this.arlasSettingsService.getArlasWuiUrl()); c.actions.filter(a => a.type === ConfigActionEnum.EDIT) .forEach(a => a.url = this.arlasSettingsService.getArlasBuilderUrl().concat('/load/')); - this.registerCollection(c); + c.preview$ = this.getPreview$(c.previewId, fetchOptions); c.isPublic = c.readers.find(g => g.name === 'public') !== undefined; }); @@ -378,30 +370,21 @@ export class DynamicHubComponent implements OnInit { } } - public applyCollectionFilter() { - if (this.selectedCollection.length > 0) { - const filteredMap = new Map(); - this.cardsRef.forEach((values: Card[], key: string) => { - filteredMap.set(key, values.filter(c => this.selectedCollection.includes(c.collection))); - }); - this.cards = filteredMap; - } else { - this.cards = this.cardsRef; - } - + public initFilter() { + this.cards = this.cardsRef; this.dashboardSearch.buildSearchIndex(this.cards); this.filterDashboard(this.dashboardSearch.currentFilter); } - public filterDashboard(searchValue: string, preserveEmptyCardList = false){ + public filterDashboard(searchValue: string, preserveEmptyCardList = false) { let previous; - if(searchValue){ + if (searchValue) { previous = this.cardsFiltered; this.cardsFiltered = new Map(); this.dashboardSearch .getMatchingSearchIndices() .forEach(searchIndex => { - if(this.cardsFiltered.has(searchIndex.key)){ + if (this.cardsFiltered.has(searchIndex.key)) { this.cardsFiltered.get(searchIndex.key).push(this.cards.get(searchIndex.key)[searchIndex.cardIndex]); } else { this.cardsFiltered.set(searchIndex.key, [this.cards.get(searchIndex.key)[searchIndex.cardIndex]]); @@ -411,49 +394,13 @@ export class DynamicHubComponent implements OnInit { this.cardsFiltered = this.cards; } - if(preserveEmptyCardList && this.cardsFiltered.size === 0){ + if (preserveEmptyCardList && this.cardsFiltered.size === 0) { previous.forEach((v, k) => { this.cardsFiltered.set(k, []); }); } } - public getCheckbox(state: boolean, collectionKey: string) { - if (this.selectedCollection.length === 0) { - this.cardCollections.forEach(v => v.selected = false); - this.selectedCollection.push(collectionKey); - this.cardCollections.get(collectionKey).selected = true; - } else { - if (state) { - this.cardCollections.get(collectionKey).selected = true; - if (!this.selectedCollection.includes(collectionKey)) { - this.selectedCollection.push(collectionKey); - } - if (this.selectedCollection.length === this.cardCollections.size) { - this.selectedCollection = []; - } - } else { - this.selectedCollection = this.selectedCollection.filter(c => c !== collectionKey); - this.cardCollections.get(collectionKey).selected = false; - if (this.selectedCollection.length === 0) { - this.cardCollections.forEach(v => { - v.selected = true; - }); - } - } - } - this.cards = this.cardsRef; - if (this.selectedCollection.length > 0) { - const filteredMap = new Map(); - this.cards.forEach((values: Card[], key: string) => { - filteredMap.set(key, values.filter(c => this.selectedCollection.includes(c.collection))); - }); - this.cards = filteredMap; - } - this.dashboardSearch.buildSearchIndex(this.cards); - this.filterDashboard(this.dashboardSearch.currentFilter, true); - } - public getAllowedOrganisations(): string[] { return [...this.canCreateDashboardByOrg.entries()].filter(m => !!m[1]).map(m => m[0]); } From 2c8a32249b8c12a5b38e29dfba3fa8f36152e73f Mon Sep 17 00:00:00 2001 From: Sebastien Bousquet Date: Wed, 18 Dec 2024 09:24:14 +0100 Subject: [PATCH 2/2] ci: set ubuntu version to 22.04 in trivy workflow --- .github/workflows/trivy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index d1e247c..7c1a6c6 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -8,7 +8,7 @@ on: jobs: scan: name: Vulnerability Scan - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Checkout code uses: actions/checkout@v4.1.4