Fix repo list sorting and filtering bug

Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
AllForNothing 2020-04-13 11:26:03 +08:00
parent 93f316ccfe
commit e5e39c03c5
3 changed files with 22 additions and 6 deletions

View File

@ -21,7 +21,13 @@ import {
UserPermissionService, USERSTATICPERMISSION
} from "../../../../../lib/services";
import { ClrDatagridStateInterface } from '@clr/angular';
import { DEFAULT_PAGE_SIZE, calculatePage, dbEncodeURIComponent } from '../../../../../lib/utils/utils';
import {
DEFAULT_PAGE_SIZE,
calculatePage,
dbEncodeURIComponent,
doFiltering,
doSorting
} from '../../../../../lib/utils/utils';
import { AppConfigService } from "../../../../services/app-config.service";
class InitTag {
@ -130,6 +136,9 @@ export class ArtifactTagComponent implements OnInit, OnDestroy {
}
}
this.currentTags = res.body;
// Do customising filtering and sorting
this.currentTags = doFiltering<Tag>(this.currentTags, state);
this.currentTags = doSorting<Tag>(this.currentTags, state);
}, error => {
this.errorHandlerService.error(error);
});

View File

@ -25,11 +25,9 @@
<div *ngIf="!isCardView" class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<clr-datagrid (clrDgRefresh)="clrLoad($event)" [clrDgLoading]="loading" [(clrDgSelected)]="selectedRow">
<clr-dg-action-bar>
<!-- <button *ngIf="withAdmiral" type="button" class="btn btn-secondary" (click)="provisionItemEvent($event, selectedRow[0])" [disabled]="!(selectedRow.length===1 && hasProjectAdminRole)"><clr-icon shape="times" size="16"></clr-icon>&nbsp;{{'REPOSITORY.DEPLOY' | translate}}</button>
<button *ngIf="withAdmiral" type="button" class="btn btn-secondary" (click)="itemAddInfoEvent($event, selectedRow[0])" [disabled]="!(selectedRow.length===1 && hasProjectAdminRole)"><clr-icon shape="times" size="16"></clr-icon>&nbsp;{{'REPOSITORY.ADDITIONAL_INFO' | translate}}</button> -->
<button type="button" class="btn btn-secondary" (click)="deleteRepos(selectedRow)" [disabled]="!(selectedRow.length)|| !hasDeleteRepositoryPermission"><clr-icon shape="times" size="16"></clr-icon>&nbsp;{{'REPOSITORY.DELETE' | translate}}</button>
</clr-dg-action-bar>
<clr-dg-column [clrDgField]="'q'" [clrDgSortBy]="'name'">{{'REPOSITORY.NAME' | translate}}</clr-dg-column>
<clr-dg-column [clrDgField]="'name'">{{'REPOSITORY.NAME' | translate}}</clr-dg-column>
<clr-dg-column>{{'REPOSITORY.ARTIFACTS_COUNT' | translate}}</clr-dg-column>
<clr-dg-column [clrDgSortBy]="'pull_count'">{{'REPOSITORY.PULL_COUNT' | translate}}</clr-dg-column>
<clr-dg-placeholder>{{'REPOSITORY.PLACEHOLDER' | translate }}</clr-dg-placeholder>

View File

@ -24,7 +24,14 @@ import {
UserPermissionService, USERSTATICPERMISSION
} from "../../../lib/services";
import { FilterComponent } from "../../../lib/components/filter/filter.component";
import { calculatePage, clone, DEFAULT_PAGE_SIZE, dbEncodeURIComponent } from "../../../lib/utils/utils";
import {
calculatePage,
clone,
DEFAULT_PAGE_SIZE,
dbEncodeURIComponent,
doFiltering,
doSorting
} from "../../../lib/utils/utils";
import { IServiceConfig, SERVICE_CONFIG } from "../../../lib/entities/service.config";
import { ErrorHandler } from "../../../lib/utils/error-handler";
import { ConfirmationButtons, ConfirmationState, ConfirmationTargets } from "../../../lib/entities/shared.const";
@ -372,7 +379,9 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit, OnDestroy
this.totalCount = +repo.headers.get('x-total-count');
this.repositories = repo.body;
// Do customising filtering and sorting
this.repositories = doFiltering<NewRepository>(this.repositories, state);
this.repositories = doSorting<NewRepository>(this.repositories, state);
this.signedCon = {};
this.loading = false;
}, error => {