Fix some issues of replication

Signed-off-by: FangyuanCheng <fangyuanc@vmware.com>
This commit is contained in:
FangyuanCheng 2019-04-25 14:39:20 +08:00
parent 66087aac82
commit 5e34cd3cf9
10 changed files with 90 additions and 103 deletions

View File

@ -66,12 +66,12 @@
</div> </div>
<label *ngIf="supportedFilters[i]?.style==='input'" aria-haspopup="true" role="tooltip" class="tooltip tooltip-validation tooltip-md tooltip-bottom-left" <label *ngIf="supportedFilters[i]?.style==='input'" aria-haspopup="true" role="tooltip" class="tooltip tooltip-validation tooltip-md tooltip-bottom-left"
[class.invalid]='(filter.value.dirty || filter.value.touched) && filter.value.invalid'> [class.invalid]='(filter.value.dirty || filter.value.touched) && filter.value.invalid'>
<input type="text" #filterValue required size="14" formControlName="value"> <input type="text" #filterValue required size="14" formControlName="value" id="{{'filter_'+ supportedFilters[i]?.type}}">
<span class="tooltip-content">{{'TOOLTIP.EMPTY' | translate}}</span> <span class="tooltip-content">{{'TOOLTIP.EMPTY' | translate}}</span>
</label> </label>
<div class="select inline-block" *ngIf="supportedFilters[i]?.style==='radio'"> <div class="select inline-block" *ngIf="supportedFilters[i]?.style==='radio'">
<select formControlName="value" #selectedValue id="{{i}}" name="{{supportedFilters[i]?.type}}"> <select formControlName="value" #selectedValue id="{{'select_'+ supportedFilters[i]?.type}}" name="{{supportedFilters[i]?.type}}">
<option value="">-- {{'REPLICATION.PLEASE_SELECT' | translate}} --</option> <option value="">{{'REPLICATION.BOTH' | translate}}</option>
<option *ngFor="let value of supportedFilters[i]?.values;" value="{{value}}">{{value}}</option> <option *ngFor="let value of supportedFilters[i]?.values;" value="{{value}}">{{value}}</option>
</select> </select>
</div> </div>
@ -156,11 +156,11 @@
<div class="clr-form-control rule-width override-box"> <div class="clr-form-control rule-width override-box">
<clr-checkbox-wrapper> <clr-checkbox-wrapper>
<input type="checkbox" clrCheckbox [checked]="true" id="overridePolicy" formControlName="override" class="clr-checkbox"> <input type="checkbox" clrCheckbox [checked]="true" id="overridePolicy" formControlName="override" class="clr-checkbox">
<label for="overridePolicy" class="clr-control-label">{{'REPLICATION.OVERRIDE' | translate}}</label> <label for="overridePolicy" class="clr-control-label">{{'REPLICATION.OVERRIDE_INFO' | translate}}</label>
</clr-checkbox-wrapper> </clr-checkbox-wrapper>
<clr-tooltip class="override-tooltip"> <clr-tooltip class="override-tooltip">
<clr-icon clrTooltipTrigger shape="info-circle" size="24"></clr-icon> <clr-icon clrTooltipTrigger shape="info-circle" size="24"></clr-icon>
<clr-tooltip-content clrPosition="top-right" clrSize="md" *clrIfOpen> <clr-tooltip-content clrPosition="top-left" clrSize="md" *clrIfOpen>
<span>{{'TOOLTIP.OVERRIDE' | translate}}</span> <span>{{'TOOLTIP.OVERRIDE' | translate}}</span>
</clr-tooltip-content> </clr-tooltip-content>
</clr-tooltip> </clr-tooltip>

View File

@ -19,7 +19,7 @@ import {
ChangeDetectionStrategy, ChangeDetectionStrategy,
ChangeDetectorRef ChangeDetectorRef
} from "@angular/core"; } from "@angular/core";
import { Subscription, Observable, forkJoin } from "rxjs"; import { Subscription, Observable, forkJoin, throwError as observableThrowError } from "rxjs";
import { TranslateService } from "@ngx-translate/core"; import { TranslateService } from "@ngx-translate/core";
import { Comparator } from "../service/interface"; import { Comparator } from "../service/interface";
@ -210,19 +210,17 @@ export class EndpointComponent implements OnInit, OnDestroy {
}); });
}) })
, catchError(error => { , catchError(error => {
if (error && error.status === 412) { if (error && error._body) {
return forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'), const message = JSON.parse(error._body).message;
this.translateService.get('DESTINATION.FAILED_TO_DELETE_TARGET_IN_USED')).pipe(map(res => { operateChanges(operMessage, OperationState.failure, message);
operateChanges(operMessage, OperationState.failure, res[1]); return observableThrowError(message);
}));
} else { } else {
return this.translateService.get('BATCH.DELETED_FAILURE').pipe(map(res => { return this.translateService.get('BATCH.DELETED_FAILURE').pipe(map(res => {
operateChanges(operMessage, OperationState.failure, res); operateChanges(operMessage, OperationState.failure, res);
})); }));
} }
} }
)); ));
} }
// Forcely refresh the view // Forcely refresh the view

View File

@ -80,7 +80,6 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges {
rules: ReplicationRule[]; rules: ReplicationRule[];
changedRules: ReplicationRule[]; changedRules: ReplicationRule[];
ruleName: string; ruleName: string;
canDeleteRule: boolean;
selectedRow: ReplicationRule; selectedRow: ReplicationRule;
@ -149,21 +148,6 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges {
this.replicateManual.emit(rule); this.replicateManual.emit(rule);
} }
hasDeletedLabel(rule: any) {
if (rule.filters) {
let count = 0;
rule.filters.forEach((data: any) => {
if (data.kind === 'label' && data.value.deleted) {
count++;
}
});
if (count === 0) {
return 'enabled';
} else { return 'disabled'; }
}
return 'enabled';
}
deletionConfirm(message: ConfirmationAcknowledgement) { deletionConfirm(message: ConfirmationAcknowledgement) {
if ( if (
message && message &&
@ -193,27 +177,6 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges {
this.editOne.emit(rule); this.editOne.emit(rule);
} }
jobList(id: string | number): Observable<void> {
let ruleData: ReplicationJobItem[];
this.canDeleteRule = true;
let count = 0;
return this.replicationService.getExecutions(id)
.pipe(map(response => {
ruleData = response.data;
if (ruleData.length) {
ruleData.forEach(job => {
if (
job.status === jobstatus
) {
count++;
}
});
}
this.canDeleteRule = count > 0 ? false : true;
}), catchError(error => observableThrowError(error)));
}
deleteRule(rule: ReplicationRule) { deleteRule(rule: ReplicationRule) {
if (rule) { if (rule) {
let deletionMessage = new ConfirmationMessage( let deletionMessage = new ConfirmationMessage(
@ -231,15 +194,13 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges {
deleteOpe(rule: ReplicationRule) { deleteOpe(rule: ReplicationRule) {
if (rule) { if (rule) {
let observableLists: any[] = []; let observableLists: any[] = [];
this.jobList(rule.id).subscribe(items => { observableLists.push(this.delOperate(rule));
observableLists.push(this.delOperate(rule));
forkJoin(...observableLists).subscribe(item => { forkJoin(...observableLists).subscribe(item => {
this.selectedRow = null; this.selectedRow = null;
this.reload.emit(true); this.reload.emit(true);
let hnd = setInterval(() => this.ref.markForCheck(), 200); let hnd = setInterval(() => this.ref.markForCheck(), 200);
setTimeout(() => clearInterval(hnd), 2000); setTimeout(() => clearInterval(hnd), 2000);
});
}); });
} }
} }
@ -253,13 +214,6 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges {
operMessage.data.name = rule.name; operMessage.data.name = rule.name;
this.operationService.publishInfo(operMessage); this.operationService.publishInfo(operMessage);
if (!this.canDeleteRule) {
return forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'),
this.translateService.get('REPLICATION.DELETION_SUMMARY_FAILURE')).pipe(map(res => {
operateChanges(operMessage, OperationState.failure, res[1]);
}));
}
return this.replicationService return this.replicationService
.deleteReplicationRule(+rule.id) .deleteReplicationRule(+rule.id)
.pipe(map(() => { .pipe(map(() => {
@ -267,15 +221,16 @@ export class ListReplicationRuleComponent implements OnInit, OnChanges {
.subscribe(res => operateChanges(operMessage, OperationState.success)); .subscribe(res => operateChanges(operMessage, OperationState.success));
}) })
, catchError(error => { , catchError(error => {
if (error && error.status === 412) { if (error && error._body) {
return forkJoin(this.translateService.get('BATCH.DELETED_FAILURE'), const message = JSON.parse(error._body).message;
this.translateService.get('REPLICATION.FAILED_TO_DELETE_POLICY_ENABLED')).pipe(map(res => { operateChanges(operMessage, OperationState.failure, message);
operateChanges(operMessage, OperationState.failure, res[1]); return observableThrowError(message);
}));
} else { } else {
return this.translateService.get('BATCH.DELETED_FAILURE').pipe(map(res => { return this.translateService.get("BATCH.DELETED_FAILURE").pipe(
map(res => {
operateChanges(operMessage, OperationState.failure, res); operateChanges(operMessage, OperationState.failure, res);
})); })
);
} }
})); }));
} }

View File

@ -111,13 +111,9 @@
<clr-dg-cell>{{t.start_time | date: 'short'}}</clr-dg-cell> <clr-dg-cell>{{t.start_time | date: 'short'}}</clr-dg-cell>
<clr-dg-cell>{{t.end_time | date: 'short'}}</clr-dg-cell> <clr-dg-cell>{{t.end_time | date: 'short'}}</clr-dg-cell>
<clr-dg-cell> <clr-dg-cell>
<span *ngIf="t.status=='InProgress'; else elseBlock" class="label">{{'REPLICATION.NO_LOGS' <a target="_blank" [href]="viewLog(t.id)">
| translate}}</span> <clr-icon shape="list"></clr-icon>
<ng-template #elseBlock> </a>
<a target="_blank" [href]="viewLog(t.id)">
<clr-icon shape="list"></clr-icon>
</a>
</ng-template>
</clr-dg-cell> </clr-dg-cell>
</clr-dg-row> </clr-dg-row>
<clr-dg-footer> <clr-dg-footer>

View File

@ -22,7 +22,7 @@ import {
} from "@angular/core"; } from "@angular/core";
import { Comparator, State } from "../service/interface"; import { Comparator, State } from "../service/interface";
import { finalize, catchError, map } from "rxjs/operators"; import { finalize, catchError, map } from "rxjs/operators";
import { Subscription, forkJoin, timer, Observable, throwError } from "rxjs"; import { Subscription, forkJoin, timer, Observable, throwError as observableThrowError, observable } from "rxjs";
import { TranslateService } from "@ngx-translate/core"; import { TranslateService } from "@ngx-translate/core";
import { ListReplicationRuleComponent } from "../list-replication-rule/list-replication-rule.component"; import { ListReplicationRuleComponent } from "../list-replication-rule/list-replication-rule.component";
@ -327,19 +327,14 @@ export class ReplicationComponent implements OnInit, OnDestroy {
); );
}), }),
catchError(error => { catchError(error => {
if (error && error.status === 412) { if (error && error._body) {
return forkJoin( const message = JSON.parse(error._body).message;
this.translateService.get("BATCH.REPLICATE_FAILURE"), operateChanges(operMessage, OperationState.failure, message);
this.translateService.get("REPLICATION.REPLICATE_SUMMARY_FAILURE") return observableThrowError(message);
).pipe(
map(function(res) {
operateChanges(operMessage, OperationState.failure, res[1]);
})
);
} else { } else {
return this.translateService.get("BATCH.REPLICATE_FAILURE").pipe( return this.translateService.get("BATCH.REPLICATE_FAILURE").pipe(
map(res => { map(res => {
operateChanges(operMessage, OperationState.failure, res); operateChanges(operMessage, OperationState.failure, res);
}) })
); );
} }
@ -409,7 +404,7 @@ export class ReplicationComponent implements OnInit, OnDestroy {
let ExecutionsStop$ = targets.map(target => this.StopOperate(target)); let ExecutionsStop$ = targets.map(target => this.StopOperate(target));
forkJoin(ExecutionsStop$) forkJoin(ExecutionsStop$)
.pipe( .pipe(
catchError(err => throwError(err)), catchError(err => observableThrowError(err)),
finalize(() => { finalize(() => {
this.refreshJobs(); this.refreshJobs();
this.isStopOnGoing = false; this.isStopOnGoing = false;
@ -431,10 +426,26 @@ export class ReplicationComponent implements OnInit, OnDestroy {
return this.replicationService return this.replicationService
.stopJobs(targets.id) .stopJobs(targets.id)
.pipe( .pipe(
map( map(response => {
() => operateChanges(operMessage, OperationState.success), this.translateService
err => operateChanges(operMessage, OperationState.failure, err) .get("BATCH.STOP_SUCCESS")
) .subscribe(res =>
operateChanges(operMessage, OperationState.success)
);
}),
catchError(error => {
if (error && error._body) {
const message = JSON.parse(error._body).message;
operateChanges(operMessage, OperationState.failure, message);
return observableThrowError(message);
} else {
return this.translateService.get("BATCH.STOP_FAILURE").pipe(
map(res => {
operateChanges(operMessage, OperationState.failure, res);
})
);
}
})
); );
} }

View File

@ -50,7 +50,9 @@
"SWITCH_SUCCESS": "Switch successfully", "SWITCH_SUCCESS": "Switch successfully",
"SWITCH_FAILURE": "Switch failed", "SWITCH_FAILURE": "Switch failed",
"REPLICATE_SUCCESS": "Started successfully", "REPLICATE_SUCCESS": "Started successfully",
"REPLICATE_FAILURE": "Started failed" "REPLICATE_FAILURE": "Started failed",
"STOP_SUCCESS": "Stop successfully",
"STOP_FAILURE": "Stop execution failed"
}, },
"TOOLTIP": { "TOOLTIP": {
"NAME_FILTER": "Filter the name part of the resources. Leaving empty or '**' matches all; 'library/**' only matches the resources under 'library'. For more patterns please refer to the user guide.", "NAME_FILTER": "Filter the name part of the resources. Leaving empty or '**' matches all; 'library/**' only matches the resources under 'library'. For more patterns please refer to the user guide.",
@ -358,11 +360,12 @@
"REPLICATION": { "REPLICATION": {
"TOTAL": "Total", "TOTAL": "Total",
"OVERRIDE": "Override", "OVERRIDE": "Override",
"OVERRIDE_INFO": "Override the destination resources if name conflicts",
"OPERATION": "Operation", "OPERATION": "Operation",
"CURRENT": "current", "CURRENT": "current",
"FILTER_PLACEHOLDER": "Filter Tasks", "FILTER_PLACEHOLDER": "Filter Tasks",
"STOP_TITLE": "Confirm Stop Executions", "STOP_TITLE": "Confirm Stop Executions",
"PLEASE_SELECT": "select an option", "BOTH": "both",
"STOP_SUCCESS": "Stop Execution {{param}} Successful", "STOP_SUCCESS": "Stop Execution {{param}} Successful",
"STOP_SUMMARY": "Do you want to stop the executions {{param}}?", "STOP_SUMMARY": "Do you want to stop the executions {{param}}?",
"TASK_ID":"Task ID", "TASK_ID":"Task ID",

View File

@ -50,7 +50,9 @@
"SWITCH_SUCCESS": "Switch successfully", "SWITCH_SUCCESS": "Switch successfully",
"SWITCH_FAILURE": "Switch failed", "SWITCH_FAILURE": "Switch failed",
"REPLICATE_SUCCESS": "Started successfully", "REPLICATE_SUCCESS": "Started successfully",
"REPLICATE_FAILURE": "Started failed" "REPLICATE_FAILURE": "Started failed",
"STOP_SUCCESS": "Stop successfully",
"STOP_FAILURE": "Stop execution failed"
}, },
"TOOLTIP": { "TOOLTIP": {
"NAME_FILTER": "Filter the name part of the resources. Leaving empty or '**' matches all; 'library/**' only matches the resources under 'library'. For more patterns please refer to the user guide.", "NAME_FILTER": "Filter the name part of the resources. Leaving empty or '**' matches all; 'library/**' only matches the resources under 'library'. For more patterns please refer to the user guide.",
@ -356,10 +358,12 @@
}, },
"REPLICATION": { "REPLICATION": {
"TOTAL": "Total", "TOTAL": "Total",
"OVERRIDE": "Anular", "OVERRIDE": "Override",
"OVERRIDE_INFO": "Override the destination resources if name conflicts",
"CURRENT": "current", "CURRENT": "current",
"FILTER_PLACEHOLDER": "Filter Tasks", "FILTER_PLACEHOLDER": "Filter Tasks",
"STOP_TITLE": "Confirme Stop Executions", "STOP_TITLE": "Confirme Stop Executions",
"BOTH": "both",
"PLEASE_SELECT": "select an option", "PLEASE_SELECT": "select an option",
"STOP_SUCCESS": "Stop Execution {{param}} Successful", "STOP_SUCCESS": "Stop Execution {{param}} Successful",
"STOP_SUMMARY": "De que desea detener las ejecuciones {{param}}?", "STOP_SUMMARY": "De que desea detener las ejecuciones {{param}}?",

View File

@ -41,6 +41,16 @@
"UPLOAD": "Upload", "UPLOAD": "Upload",
"NO_FILE": "No file selected" "NO_FILE": "No file selected"
}, },
"BATCH": {
"DELETED_SUCCESS": "Deleted successfully",
"DELETED_FAILURE": "Deleted failed",
"SWITCH_SUCCESS": "Switch successfully",
"SWITCH_FAILURE": "Switch failed",
"REPLICATE_SUCCESS": "Started successfully",
"REPLICATE_FAILURE": "Started failed",
"STOP_SUCCESS": "Stop successfully",
"STOP_FAILURE": "Stop execution failed"
},
"TOOLTIP": { "TOOLTIP": {
"NAME_FILTER": "Filter the name part of the resources. Leaving empty or '**' matches all; 'library/**' only matches the resources under 'library'. For more patterns please refer to the user guide.", "NAME_FILTER": "Filter the name part of the resources. Leaving empty or '**' matches all; 'library/**' only matches the resources under 'library'. For more patterns please refer to the user guide.",
"TAG_FILTER": "Filter the tag/version part of the resources. Leaving empty or '**' matches all; '1.0*' only matches the tags that starts with '1.0'. For more patterns please refer to the user guide.", "TAG_FILTER": "Filter the tag/version part of the resources. Leaving empty or '**' matches all; '1.0*' only matches the tags that starts with '1.0'. For more patterns please refer to the user guide.",
@ -341,10 +351,12 @@
}, },
"REPLICATION": { "REPLICATION": {
"TOTAL": "Total", "TOTAL": "Total",
"OVERRIDE": "Passer outre", "OVERRIDE": "Override",
"OVERRIDE_INFO": "Override the destination resources if name conflicts",
"CURRENT": "current", "CURRENT": "current",
"FILTER_PLACEHOLDER": "Filter Tasks", "FILTER_PLACEHOLDER": "Filter Tasks",
"STOP_TITLE": "Confirmer arrêter les exécutions", "STOP_TITLE": "Confirmer arrêter les exécutions",
"BOTH": "both",
"PLEASE_SELECT": "select an option", "PLEASE_SELECT": "select an option",
"STOP_SUCCESS": "Stop Execution {{param}} Successful", "STOP_SUCCESS": "Stop Execution {{param}} Successful",
"STOP_SUMMARY": "Voulez-vous arrêter les exécutions {{param}}?", "STOP_SUMMARY": "Voulez-vous arrêter les exécutions {{param}}?",

View File

@ -50,7 +50,9 @@
"SWITCH_SUCCESS": "Alterado com sucesso", "SWITCH_SUCCESS": "Alterado com sucesso",
"SWITCH_FAILURE": "Falha ao alterar", "SWITCH_FAILURE": "Falha ao alterar",
"REPLICATE_SUCCESS": "Iniciado com sucesso", "REPLICATE_SUCCESS": "Iniciado com sucesso",
"REPLICATE_FAILURE": "Falha ao iniciar" "REPLICATE_FAILURE": "Falha ao iniciar",
"STOP_SUCCESS": "Stop successfully",
"STOP_FAILURE": "Stop execution failed"
}, },
"TOOLTIP": { "TOOLTIP": {
"NAME_FILTER": "Filter the name part of the resources. Leaving empty or '**' matches all; 'library/**' only matches the resources under 'library'. For more patterns please refer to the user guide.", "NAME_FILTER": "Filter the name part of the resources. Leaving empty or '**' matches all; 'library/**' only matches the resources under 'library'. For more patterns please refer to the user guide.",
@ -355,10 +357,12 @@
}, },
"REPLICATION": { "REPLICATION": {
"TOTAL": "Total", "TOTAL": "Total",
"OVERRIDE": "Substituir", "OVERRIDE": "Override",
"OVERRIDE_INFO": "Override the destination resources if name conflicts",
"CURRENT": "current", "CURRENT": "current",
"FILTER_PLACEHOLDER": "Filter Tasks", "FILTER_PLACEHOLDER": "Filter Tasks",
"STOP_TITLE": "Confirme as execuções de parada", "STOP_TITLE": "Confirme as execuções de parada",
"BOTH": "both",
"PLEASE_SELECT": "select an option", "PLEASE_SELECT": "select an option",
"STOP_SUCCESS": "Stop Execution {{param}} Successful", "STOP_SUCCESS": "Stop Execution {{param}} Successful",
"STOP_SUMMARY": "Você quer parar as execuções? {{param}}?", "STOP_SUMMARY": "Você quer parar as execuções? {{param}}?",

View File

@ -50,7 +50,9 @@
"SWITCH_SUCCESS": "切换成功", "SWITCH_SUCCESS": "切换成功",
"SWITCH_FAILURE": "切换失败", "SWITCH_FAILURE": "切换失败",
"REPLICATE_SUCCESS": "开始成功", "REPLICATE_SUCCESS": "开始成功",
"REPLICATE_FAILURE": "开始失败" "REPLICATE_FAILURE": "开始失败",
"STOP_SUCCESS": "停止任务成功",
"STOP_FAILURE": "停止任务失败"
}, },
"TOOLTIP": { "TOOLTIP": {
"NAME_FILTER": "过滤资源的名字。不填或者“”匹配所有资源“library/”只匹配“library”下的资源。更多的匹配模式请参考用户手册。", "NAME_FILTER": "过滤资源的名字。不填或者“”匹配所有资源“library/”只匹配“library”下的资源。更多的匹配模式请参考用户手册。",
@ -357,9 +359,11 @@
"REPLICATION": { "REPLICATION": {
"TOTAL": "总数", "TOTAL": "总数",
"OVERRIDE": "覆盖", "OVERRIDE": "覆盖",
"OVERRIDE_INFO": "如果名称冲突则覆盖目标资源",
"CURRENT": "当前仓库", "CURRENT": "当前仓库",
"FILTER_PLACEHOLDER": "过滤任务", "FILTER_PLACEHOLDER": "过滤任务",
"STOP_TITLE": "确认停止任务", "STOP_TITLE": "确认停止任务",
"BOTH": "全部",
"PLEASE_SELECT": "请选择", "PLEASE_SELECT": "请选择",
"STOP_SUCCESS": "停止任务 {{param}} 成功", "STOP_SUCCESS": "停止任务 {{param}} 成功",
"STOP_SUMMARY": "确认停止任务{{param}}?", "STOP_SUMMARY": "确认停止任务{{param}}?",