From 7b22b38c5cf2b4b4810ece8baa5f0c0c1c4f4645 Mon Sep 17 00:00:00 2001 From: Yogi_Wang Date: Fri, 17 Jul 2020 13:25:46 +0800 Subject: [PATCH] [fix][ui] Operation unified processing session expired fix #11268 includes the following functions: delete group delete chart version delete project delete member add group delete repo delete artifact delete tag delete robot delete user delete registry delete label delete replication list replication Signed-off-by: Yogi_Wang --- .../distribution-instances.component.ts | 5 ++++- .../distribution-setup-modal.component.ts | 2 ++ src/portal/src/app/group/group.component.ts | 2 +- .../helm-chart-version.component.ts | 8 +++++--- .../list-charts-detail/helm-chart.component.ts | 12 +++++++----- .../project/list-project/list-project.component.ts | 6 ++---- .../project/member/add-group/add-group.component.ts | 8 +++++--- .../src/app/project/member/member.component.ts | 4 +++- .../artifact-list-tab/artifact-list-tab.component.ts | 4 ++-- .../artifact/artifact-tag/artifact-tag.component.ts | 4 ++-- .../repository/repository-gridview.component.ts | 2 +- .../project/robot-account/robot-account.component.ts | 8 +++++--- src/portal/src/app/user/user.component.ts | 4 +++- src/portal/src/app/user/user.service.ts | 2 +- .../lib/components/endpoint/endpoint.component.ts | 9 +++++++-- .../src/lib/components/label/label.component.ts | 4 +++- .../list-replication-rule.component.ts | 4 +++- .../components/replication/replication.component.ts | 12 ++++++++---- 18 files changed, 64 insertions(+), 36 deletions(-) diff --git a/src/portal/src/app/distribution/distribution-instances/distribution-instances.component.ts b/src/portal/src/app/distribution/distribution-instances/distribution-instances.component.ts index 46e6f8174..012ef5e3b 100644 --- a/src/portal/src/app/distribution/distribution-instances/distribution-instances.component.ts +++ b/src/portal/src/app/distribution/distribution-instances/distribution-instances.component.ts @@ -186,6 +186,7 @@ export class DistributionInstancesComponent implements OnInit, OnDestroy { this.translate.get(message).subscribe(errMsg => { this.msgHandler.error(msg + ': ' + errMsg); }); + this.msgHandler.handleErrorPopupUnauthorized(error); }); } ); @@ -262,6 +263,8 @@ export class DistributionInstancesComponent implements OnInit, OnDestroy { forkJoin(...observableLists).subscribe(item => { this.selectedRow = []; this.refresh(); + }, error => { + this.msgHandler.handleErrorPopupUnauthorized(error); }); } } @@ -288,7 +291,7 @@ export class DistributionInstancesComponent implements OnInit, OnDestroy { this.msgHandler.error(msg + ': ' + errMsg); }); }); - return observableThrowError(message); + return observableThrowError(error); }) ); } diff --git a/src/portal/src/app/distribution/distribution-setup-modal/distribution-setup-modal.component.ts b/src/portal/src/app/distribution/distribution-setup-modal/distribution-setup-modal.component.ts index 99c1d7f48..4ecf54f51 100644 --- a/src/portal/src/app/distribution/distribution-setup-modal/distribution-setup-modal.component.ts +++ b/src/portal/src/app/distribution/distribution-setup-modal/distribution-setup-modal.component.ts @@ -139,6 +139,7 @@ export class DistributionSetupModalComponent implements OnInit { this.saveBtnState = ClrLoadingState.ERROR; }); }); + this.msgHandler.handleErrorPopupUnauthorized(err); } ); } else { @@ -172,6 +173,7 @@ export class DistributionSetupModalComponent implements OnInit { this.saveBtnState = ClrLoadingState.ERROR; }); }); + this.msgHandler.handleErrorPopupUnauthorized(err); } ); } diff --git a/src/portal/src/app/group/group.component.ts b/src/portal/src/app/group/group.component.ts index e2e864e01..804484ada 100644 --- a/src/portal/src/app/group/group.component.ts +++ b/src/portal/src/app/group/group.component.ts @@ -143,7 +143,7 @@ export class GroupComponent implements OnInit, OnDestroy { this.translateService.get(message).subscribe(res => operateChanges(operMessage, OperationState.failure, res) ); - return observableThrowError(message); + return observableThrowError(error); })); }); diff --git a/src/portal/src/app/project/helm-chart/list-chart-versions/helm-chart-versions-detail/helm-chart-version.component.ts b/src/portal/src/app/project/helm-chart/list-chart-versions/helm-chart-versions-detail/helm-chart-version.component.ts index 9117440a0..9f67ddff3 100644 --- a/src/portal/src/app/project/helm-chart/list-chart-versions/helm-chart-versions-detail/helm-chart-version.component.ts +++ b/src/portal/src/app/project/helm-chart/list-chart-versions/helm-chart-versions-detail/helm-chart-version.component.ts @@ -166,15 +166,15 @@ export class ChartVersionComponent implements OnInit { return this.helmChartService .deleteChartVersion(this.projectName, this.chartName, version.version) .pipe(map( - () => operateChanges(operateMsg, OperationState.success), + () => operateChanges(operateMsg, OperationState.success)), catchError( error => { const message = errorHandlerFn(error); this.translateService.get(message).subscribe(res => operateChanges(operateMsg, OperationState.failure, res) ); - return observableThrowError(message); + return observableThrowError(error); } - ))); + )); } deleteVersions(versions: HelmChartVersion[]) { @@ -191,6 +191,8 @@ export class ChartVersionComponent implements OnInit { if (totalCount === successCount) { this.backEvt.emit(); } + }, error => { + this.errorHandler.error(error); }); } diff --git a/src/portal/src/app/project/helm-chart/list-charts-detail/helm-chart.component.ts b/src/portal/src/app/project/helm-chart/list-charts-detail/helm-chart.component.ts index 19ad0fee8..e5a9f9d46 100644 --- a/src/portal/src/app/project/helm-chart/list-charts-detail/helm-chart.component.ts +++ b/src/portal/src/app/project/helm-chart/list-charts-detail/helm-chart.component.ts @@ -204,15 +204,15 @@ export class HelmChartComponent implements OnInit { return this.helmChartService.deleteHelmChart(this.projectName, chartName) .pipe(map( - () => operateChanges(operateMsg, OperationState.success), + () => operateChanges(operateMsg, OperationState.success)), catchError( error => { const message = errorHandlerFn(error); this.translateService.get(message).subscribe(res => operateChanges(operateMsg, OperationState.failure, res) ); - return observableThrowError(message); + return observableThrowError(error); } - ))); + )); } deleteCharts(charts: HelmChartItem[]) { @@ -220,12 +220,14 @@ export class HelmChartComponent implements OnInit { let chartsDelete$ = charts.map(chart => this.deleteChart(chart.name)); forkJoin(chartsDelete$) .pipe( - catchError(err => observableThrowError(err)), finalize(() => { this.refresh(); this.selectedRows = []; })) - .subscribe(() => { }); + .subscribe(() => { } + , error => { + this.errorHandler.error(error); + }); } downloadLatestVersion(evt?: Event, item?: HelmChartItem) { diff --git a/src/portal/src/app/project/list-project/list-project.component.ts b/src/portal/src/app/project/list-project/list-project.component.ts index dfcfaad27..8c2744cc6 100644 --- a/src/portal/src/app/project/list-project/list-project.component.ts +++ b/src/portal/src/app/project/list-project/list-project.component.ts @@ -217,9 +217,7 @@ export class ListProjectComponent implements OnDestroy { this.statisticHandler.refresh(); } }, error => { - this.translate.get("BATCH.DELETED_FAILURE").subscribe(res => { - this.msgHandler.handleError(res); - }); + this.msgHandler.handleError(error); }); } } @@ -242,7 +240,7 @@ export class ListProjectComponent implements OnDestroy { this.translateService.get(message).subscribe(res => operateChanges(operMessage, OperationState.failure, res) ); - return observableThrowError(message); + return observableThrowError(error); })); } diff --git a/src/portal/src/app/project/member/add-group/add-group.component.ts b/src/portal/src/app/project/member/add-group/add-group.component.ts index 63e5989fa..0788c1bba 100644 --- a/src/portal/src/app/project/member/add-group/add-group.component.ts +++ b/src/portal/src/app/project/member/add-group/add-group.component.ts @@ -1,4 +1,4 @@ -import {of as observableOf, forkJoin} from "rxjs"; +import {of as observableOf, forkJoin, throwError} from "rxjs"; import {mergeMap, catchError} from 'rxjs/operators'; import { ChangeDetectorRef, ChangeDetectionStrategy, ViewChild } from "@angular/core"; import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core"; @@ -139,9 +139,9 @@ export class AddGroupComponent implements OnInit { this.translateService.get(message).subscribe(res => operateChanges(operMessage, OperationState.failure, res) ); - return observableThrowError(message); + return observableThrowError(error); }), - catchError(error => observableOf(error.status)), ); + catchError(error => observableThrowError(error)), ); }); forkJoin(GroupAdders$) .subscribe(results => { @@ -150,6 +150,8 @@ export class AddGroupComponent implements OnInit { } else { this.added.emit(true); } + }, error => { + this.msgHandler.handleError(error); }); this.opened = false; } diff --git a/src/portal/src/app/project/member/member.component.ts b/src/portal/src/app/project/member/member.component.ts index 22671a287..287851257 100644 --- a/src/portal/src/app/project/member/member.component.ts +++ b/src/portal/src/app/project/member/member.component.ts @@ -278,7 +278,7 @@ export class MemberComponent implements OnInit, OnDestroy { this.translate.get(message).subscribe(res => operateChanges(operMessage, OperationState.failure, res) ); - return observableThrowError(message); + return observableThrowError(error); })); }; @@ -289,6 +289,8 @@ export class MemberComponent implements OnInit, OnDestroy { this.selectedRow = []; this.batchOps = 'idle'; this.retrieve(this.projectId, ""); + }, error => { + this.errorHandler.error(error); }); } getMemberPermissionRule(projectId: number): void { 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 0afd86876..cd99941f1 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 @@ -748,10 +748,10 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { } else if (deleteErrorList.length === deleteResult.length) { // all is error this.loading = false; - this.errorHandlerService.error(deleteResult[deleteResult.length - 1].error); + this.errorHandlerService.error(deleteResult[deleteResult.length - 1]); } else { // some artifact delete success but it has error delete things - this.errorHandlerService.error(deleteErrorList[deleteErrorList.length - 1].error); + this.errorHandlerService.error(deleteErrorList[deleteErrorList.length - 1]); // if delete one success refresh list let st: ClrDatagridStateInterface = { page: {from: 0, to: this.pageSize - 1, size: this.pageSize} }; this.clrLoad(st); diff --git a/src/portal/src/app/project/repository/artifact/artifact-tag/artifact-tag.component.ts b/src/portal/src/app/project/repository/artifact/artifact-tag/artifact-tag.component.ts index 0abdb2c67..de2d0efb1 100644 --- a/src/portal/src/app/project/repository/artifact/artifact-tag/artifact-tag.component.ts +++ b/src/portal/src/app/project/repository/artifact/artifact-tag/artifact-tag.component.ts @@ -242,10 +242,10 @@ export class ArtifactTagComponent implements OnInit, OnDestroy { } else if (deleteErrorList.length === deleteResult.length) { // all is error this.loading = false; - this.errorHandlerService.error(deleteResult[deleteResult.length - 1].error); + this.errorHandlerService.error(deleteResult[deleteResult.length - 1]); } else { // some artifact delete success but it has error delete things - this.errorHandlerService.error(deleteErrorList[deleteErrorList.length - 1].error); + this.errorHandlerService.error(deleteErrorList[deleteErrorList.length - 1]); // if delete one success refresh list this.currentPage = 1; let st: ClrDatagridStateInterface = { page: {from: 0, to: this.pageSize - 1, size: this.pageSize} }; 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 c0428b19d..bb32d4bdd 100644 --- a/src/portal/src/app/project/repository/repository-gridview.component.ts +++ b/src/portal/src/app/project/repository/repository-gridview.component.ts @@ -242,7 +242,7 @@ export class RepositoryGridviewComponent implements OnChanges, OnInit, OnDestroy this.translateService.get(message).subscribe(res => operateChanges(operMessage, OperationState.failure, res) ); - return observableThrowError(message); + return observableThrowError(error); })); } diff --git a/src/portal/src/app/project/robot-account/robot-account.component.ts b/src/portal/src/app/project/robot-account/robot-account.component.ts index daedaf929..2de636c68 100644 --- a/src/portal/src/app/project/robot-account/robot-account.component.ts +++ b/src/portal/src/app/project/robot-account/robot-account.component.ts @@ -136,13 +136,15 @@ export class RobotAccountComponent implements OnInit, OnDestroy { let robotsDelete$ = robots.map(robot => this.delOperate(robot)); forkJoin(robotsDelete$) .pipe( - catchError(err => observableThrowError(err)), finalize(() => { this.retrieve(); this.selectedRow = []; }) ) - .subscribe(() => { }); + .subscribe(() => { } + , error => { + this.errorHandler.error(error); + }); } delOperate(robot: Robot) { @@ -164,7 +166,7 @@ export class RobotAccountComponent implements OnInit, OnDestroy { this.translate.get(errorMsg).subscribe(res => operateChanges(operMessage, OperationState.failure, res) ); - return observableThrowError(errorMsg); + return observableThrowError(error); } ) )); diff --git a/src/portal/src/app/user/user.component.ts b/src/portal/src/app/user/user.component.ts index 7f2501bac..cd726d4bb 100644 --- a/src/portal/src/app/user/user.component.ts +++ b/src/portal/src/app/user/user.component.ts @@ -259,6 +259,8 @@ export class UserComponent implements OnInit, OnDestroy { this.selectedRow = []; this.currentTerm = ''; this.refresh(); + }, error => { + this.msgHandler.handleError(error); }); } } @@ -287,7 +289,7 @@ export class UserComponent implements OnInit, OnDestroy { this.translate.get(message).subscribe(res => operateChanges(operMessage, OperationState.failure, res) ); - return observableThrowError(message); + return observableThrowError(error); })); } diff --git a/src/portal/src/app/user/user.service.ts b/src/portal/src/app/user/user.service.ts index 59a9b7f8a..4dccfc3c6 100644 --- a/src/portal/src/app/user/user.service.ts +++ b/src/portal/src/app/user/user.service.ts @@ -54,7 +54,7 @@ export class UserService { } // Handle the related exceptions handleError(error: any): Observable { - return observableThrowError(error.error || error); + return observableThrowError(error); } // Get the user list diff --git a/src/portal/src/lib/components/endpoint/endpoint.component.ts b/src/portal/src/lib/components/endpoint/endpoint.component.ts index 983a8880b..f2ae2b7bd 100644 --- a/src/portal/src/lib/components/endpoint/endpoint.component.ts +++ b/src/portal/src/lib/components/endpoint/endpoint.component.ts @@ -184,10 +184,15 @@ export class EndpointComponent implements OnInit, OnDestroy { targetLists.forEach(target => { observableLists.push(this.delOperate(target)); }); - forkJoin(...observableLists).subscribe((item) => { + forkJoin(...observableLists) + .pipe(finalize(() => { this.selectedRow = []; this.reload(true); this.forceRefreshView(2000); + })) + .subscribe((item) => { + }, error => { + this.errorHandler.error(error); }); } } @@ -215,7 +220,7 @@ export class EndpointComponent implements OnInit, OnDestroy { this.translateService.get(message).subscribe(res => operateChanges(operMessage, OperationState.failure, res) ); - return observableThrowError(message); + return observableThrowError(error); } )); } diff --git a/src/portal/src/lib/components/label/label.component.ts b/src/portal/src/lib/components/label/label.component.ts index fc793e55e..1da434027 100644 --- a/src/portal/src/lib/components/label/label.component.ts +++ b/src/portal/src/lib/components/label/label.component.ts @@ -141,6 +141,8 @@ export class LabelComponent implements OnInit { forkJoin(...observableLists).subscribe((item) => { this.selectedRow = []; this.retrieve(this.scope); + }, error => { + this.errorHandler.error(error); }); } } @@ -168,7 +170,7 @@ export class LabelComponent implements OnInit { this.translateService.get(message).subscribe(res => operateChanges(operMessage, OperationState.failure, res) ); - return observableThrowError(message); + return observableThrowError(error); })); } diff --git a/src/portal/src/lib/components/list-replication-rule/list-replication-rule.component.ts b/src/portal/src/lib/components/list-replication-rule/list-replication-rule.component.ts index 061ec01e0..81b109b14 100644 --- a/src/portal/src/lib/components/list-replication-rule/list-replication-rule.component.ts +++ b/src/portal/src/lib/components/list-replication-rule/list-replication-rule.component.ts @@ -203,6 +203,8 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges { this.reload.emit(true); let hnd = setInterval(() => this.ref.markForCheck(), 200); setTimeout(() => clearInterval(hnd), 2000); + }, error => { + this.errorHandler.error(error); }); } } @@ -227,7 +229,7 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges { this.translateService.get(message).subscribe(res => operateChanges(operMessage, OperationState.failure, res) ); - return observableThrowError(message); + return observableThrowError(error); })); } } diff --git a/src/portal/src/lib/components/replication/replication.component.ts b/src/portal/src/lib/components/replication/replication.component.ts index 969f1c271..bf4a1309e 100644 --- a/src/portal/src/lib/components/replication/replication.component.ts +++ b/src/portal/src/lib/components/replication/replication.component.ts @@ -329,6 +329,8 @@ export class ReplicationComponent implements OnInit, OnDestroy { if (rule) { forkJoin(this.replicationOperate(rule)).subscribe(item => { this.selectOneRule(rule); + }, error => { + this.errorHandler.error(error); }); } } @@ -356,7 +358,7 @@ export class ReplicationComponent implements OnInit, OnDestroy { this.translateService.get(message).subscribe(res => operateChanges(operMessage, OperationState.failure, res) ); - return observableThrowError(message); + return observableThrowError(error); }) ); } @@ -423,14 +425,16 @@ export class ReplicationComponent implements OnInit, OnDestroy { let ExecutionsStop$ = targets.map(target => this.StopOperate(target)); forkJoin(ExecutionsStop$) .pipe( - catchError(err => observableThrowError(err)), finalize(() => { this.refreshJobs(); this.isStopOnGoing = false; this.selectedRow = []; }) ) - .subscribe(() => { }); + .subscribe(() => { } + , error => { + this.errorHandler.error(error); + }); } } @@ -457,7 +461,7 @@ export class ReplicationComponent implements OnInit, OnDestroy { this.translateService.get(message).subscribe(res => operateChanges(operMessage, OperationState.failure, res) ); - return observableThrowError(message); + return observableThrowError(error); }) ); }