diff --git a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.html b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.html index 2e650935e..ee4b3fb00 100644 --- a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.html +++ b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.html @@ -31,7 +31,7 @@
-
@@ -59,7 +59,7 @@
-
+
× @@ -146,7 +146,7 @@ - {{'REPOSITORY.ARTIFACTS_COUNT' | translate}} + {{'REPOSITORY.ARTIFACTS_COUNT' | translate}} {{'REPOSITORY.PLATFORM' | translate}} {{'REPOSITORY.TAGS_COUNT' | translate}} diff --git a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.spec.ts b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.spec.ts index c0c805bea..efc26934c 100644 --- a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.spec.ts +++ b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.spec.ts @@ -366,7 +366,7 @@ describe("ArtifactListTabComponent (inline template)", () => { fixture.detectChanges(); await fixture.whenStable(); filtereName = 'sha256:3e33e3e3'; - comp.doSearchArtifactNames('sha256:3e33e3e3'); + comp.doSearchArtifactByFilter('sha256:3e33e3e3'); fixture.detectChanges(); await fixture.whenStable(); fixture.detectChanges(); diff --git a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts index 14a505208..8831265cf 100644 --- a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts +++ b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts @@ -144,7 +144,7 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { pageSize: number = DEFAULT_PAGE_SIZE; currentPage = 1; totalCount = 0; - currentState: State; + currentState: ClrDatagridStateInterface; hasAddLabelImagePermission: boolean; hasRetagImagePermission: boolean; @@ -163,7 +163,8 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { mutipleFilter = clone(mutipleFilter); filterByType: string = this.mutipleFilter[0].filterBy; openSelectFilterPiece = false; - + // could Pagination filter + filters: string[]; constructor( private errorHandlerService: ErrorHandler, private userPermissionService: UserPermissionService, @@ -282,32 +283,16 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { this.lastFilteredTagName = filterWords; this.currentPage = 1; - let st: State = this.currentState; + let st: ClrDatagridStateInterface = this.currentState; if (!st) { st = { page: {} }; } st.page.size = this.pageSize; st.page.from = 0; st.page.to = this.pageSize - 1; - - st.filters = [{ property: this.filterByType, value: this.lastFilteredTagName }]; - this.clrLoad(st); - } - doSearchArtifactNames(artifactName: string) { - this.lastFilteredTagName = artifactName; - this.currentPage = 1; - - let st: State = this.currentState; - if (!st) { - st = { page: {} }; - } - st.page.size = this.pageSize; - st.page.from = 0; - st.page.to = this.pageSize - 1; - st.filters = [{ property: this.filterByType, value: this.lastFilteredTagName }]; - let selectedLab = this.imageFilterLabels.find(label => label.iconsShow === true); - if (selectedLab) { - st.filters.push({ property: this.filterByType, value: selectedLab.label.id }); + this.filters = []; + if (this.lastFilteredTagName) { + this.filters.push(`${this.filterByType}=~${this.lastFilteredTagName}`); } this.clrLoad(st); } @@ -345,10 +330,12 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { if (sortBy) { params.sort = sortBy; } - if (state.filters && state.filters.length) { - state.filters.forEach(item => { - params[item.property] = item.value; + if (this.filters && this.filters.length) { + let q = ""; + this.filters.forEach(item => { + q += item; }); + params.q = encodeURIComponent(q); } if (this.artifactDigest) { const artifactParam: NewArtifactService.GetArtifactParams = { @@ -424,7 +411,15 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { } refresh() { - this.doSearchArtifactNames(this.lastFilteredTagName); + this.currentPage = 1; + let st: ClrDatagridStateInterface = this.currentState; + if (!st) { + st = { page: {} }; + st.page.size = this.pageSize; + st.page.from = 0; + st.page.to = this.pageSize - 1; + } + this.clrLoad(st); } getArtifactAnnotationsArray(artifactList: Artifact[]) { artifactList.forEach(artifact => { @@ -581,18 +576,15 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { // reload data this.currentPage = 1; - let st: State = this.currentState; + let st: ClrDatagridStateInterface = this.currentState; if (!st) { st = { page: {} }; } st.page.size = this.pageSize; st.page.from = 0; st.page.to = this.pageSize - 1; - if (this.lastFilteredTagName) { - st.filters = [{ property: 'name', value: this.lastFilteredTagName }, { property: 'labels.id', value: labelId }]; - } else { - st.filters = [{ property: 'labels.id', value: labelId }]; - } + + this.filters = [`${this.filterByType}=(${labelId})`]; this.clrLoad(st); } @@ -606,18 +598,15 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { // reload data this.currentPage = 1; - let st: State = this.currentState; + let st: ClrDatagridStateInterface = this.currentState; if (!st) { st = { page: {} }; } st.page.size = this.pageSize; st.page.from = 0; st.page.to = this.pageSize - 1; - if (this.lastFilteredTagName) { - st.filters = [{ property: 'name', value: this.lastFilteredTagName }]; - } else { - st.filters = []; - } + + this.filters = []; this.clrLoad(st); } @@ -922,7 +911,7 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { } selectFilterType() { this.lastFilteredTagName = ''; - if (this.filterByType === 'label.id') { + if (this.filterByType === 'labels') { this.openLabelFilterPanel = true; this.openLabelFilterPiece = true; } else { @@ -933,26 +922,38 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { data.iconsShow = false; }); } - this.doSearchArtifactNames(""); - } - - selectFilter(showItem: string, filterItem: string) { - this.lastFilteredTagName = filterItem; this.currentPage = 1; - - let st: State = this.currentState; + let st: ClrDatagridStateInterface = this.currentState; if (!st) { st = { page: {} }; } st.page.size = this.pageSize; st.page.from = 0; st.page.to = this.pageSize - 1; - st.filters = [{ property: this.filterByType, value: filterItem }]; + this.filters = []; + this.clrLoad(st); + } + + selectFilter(showItem: string, filterItem: string) { + this.lastFilteredTagName = filterItem; + this.currentPage = 1; + + let st: ClrDatagridStateInterface = this.currentState; + if (!st) { + st = { page: {} }; + } + st.page.size = this.pageSize; + st.page.from = 0; + st.page.to = this.pageSize - 1; + this.filters = []; + if (filterItem) { + this.filters.push(`${this.filterByType}=${filterItem}`); + } this.clrLoad(st); } get isFilterReadonly() { - return this.filterByType === 'label.id' ? 'readonly' : null; + return this.filterByType === 'labels' ? 'readonly' : null; } getArtifactIcon(artifacts: ArtifactFront[]) { for (const artifact of artifacts) { diff --git a/src/portal/src/app/project/repository/artifact/artifact.ts b/src/portal/src/app/project/repository/artifact/artifact.ts index cb3a59449..dd6a1e465 100644 --- a/src/portal/src/app/project/repository/artifact/artifact.ts +++ b/src/portal/src/app/project/repository/artifact/artifact.ts @@ -43,7 +43,7 @@ export const mutipleFilter = [ ] }, { - filterBy: 'label.id', + filterBy: 'labels', filterByShowText: 'Label', listItem: [] }, diff --git a/src/portal/src/app/project/repository/repository-gridview.component.ts b/src/portal/src/app/project/repository/repository-gridview.component.ts index 87106a431..9e7599c6d 100644 --- a/src/portal/src/app/project/repository/repository-gridview.component.ts +++ b/src/portal/src/app/project/repository/repository-gridview.component.ts @@ -156,8 +156,10 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit, OnDestroy projectName: this.projectName, page: this.currentPage, pageSize: this.pageSize, - name: this.lastFilteredRepoName }; + if (this.lastFilteredRepoName) { + params.q = encodeURIComponent(`name=~${this.lastFilteredRepoName}`); + } this.loading = true; return this.newRepoService.listRepositoriesResponse(params); })