Merge pull request #2779 from pengpengshui/master

Fix the issue #2564,#2552 and #2758
This commit is contained in:
Steven Zou 2017-07-14 16:01:22 +08:00 committed by GitHub
commit b69083ecd1
4 changed files with 24 additions and 6 deletions

View File

@ -81,8 +81,8 @@ export const CREATE_EDIT_RULE_TEMPLATE: string = `
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline" (click)="testConnection()" [disabled]="testOngoing">{{'REPLICATION.TEST_CONNECTION' | translate}}</button>
<button type="button" class="btn btn-outline" (click)="onCancel()">{{'BUTTON.CANCEL' | translate }}</button>
<button type="button" class="btn btn-outline" (click)="testConnection()" [disabled]="testOngoing || endpointUrl.errors || connectAbled">{{'REPLICATION.TEST_CONNECTION' | translate}}</button>
<button type="button" class="btn btn-outline" [disabled]="btnAbled" (click)="onCancel()">{{'BUTTON.CANCEL' | translate }}</button>
<button type="submit" class="btn btn-primary" [disabled]="!ruleForm.form.valid || testOngoing || !editable" (click)="onSubmit()">{{'BUTTON.OK' | translate}}</button>
</div>
</clr-modal>`;

View File

@ -75,6 +75,9 @@ export class CreateEditRuleComponent implements AfterViewChecked {
testOngoing: boolean;
pingStatus: boolean;
btnAbled:boolean;
ruleForm: NgForm;
staticBackdrop: boolean = true;
@ -135,9 +138,14 @@ export class CreateEditRuleComponent implements AfterViewChecked {
return this.actionType === ActionType.EDIT && (this.initVal.enable || false);
}
get showNewDestination(): boolean {
return this.actionType === ActionType.ADD_NEW || (!this.createEditRule.enable || false);
}
get connectAbled():boolean{
return !this.createEditRule.endpointId && !this.isCreateEndpoint;
}
constructor(
private replicationService: ReplicationService,
@ -393,6 +401,7 @@ export class CreateEditRuleComponent implements AfterViewChecked {
testConnection() {
this.pingStatus = true;
this.btnAbled=true;
this.translateService.get('REPLICATION.TESTING_CONNECTION').subscribe(res=>this.pingTestMessage=res);
this.testOngoing = !this.testOngoing;
let pingTarget: Endpoint = this.initEndpoint;
@ -409,11 +418,13 @@ export class CreateEditRuleComponent implements AfterViewChecked {
this.testOngoing = !this.testOngoing;
this.translateService.get('REPLICATION.TEST_CONNECTION_SUCCESS').subscribe(res=>this.pingTestMessage=res);
this.pingStatus = true;
this.btnAbled=false;
})
.catch(error=>{
this.testOngoing = !this.testOngoing;
this.translateService.get('REPLICATION.TEST_CONNECTION_FAILURE').subscribe(res=>this.pingTestMessage=res);
this.pingStatus = false;
this.btnAbled=false;
});
}
}

View File

@ -54,6 +54,7 @@ export class CreateProjectComponent implements AfterViewChecked, OnInit, OnDestr
createProjectOpened: boolean;
hasChanged: boolean;
btnIsOk:boolean=false;
staticBackdrop: boolean = true;
closable: boolean = false;
@ -90,6 +91,7 @@ export class CreateProjectComponent implements AfterViewChecked, OnInit, OnDestr
.checkProjectExists(cont.value).toPromise()
.then(() => {
//Project existing
this.btnIsOk=true;
this.isNameValid = false;
this.nameTooltipText = 'PROJECT.NAME_ALREADY_EXISTS';
this.checkOnGoing = false;
@ -109,6 +111,7 @@ export class CreateProjectComponent implements AfterViewChecked, OnInit, OnDestr
}
onSubmit() {
this.btnIsOk=false;
this.projectService
.createProject(this.project.name, this.project.public ? 1 : 0)
.subscribe(
@ -182,8 +185,9 @@ export class CreateProjectComponent implements AfterViewChecked, OnInit, OnDestr
}
public get isValid(): boolean {
return this.currentForm &&
this.currentForm.valid &&
return this.currentForm &&
this.currentForm.valid &&
this.btnIsOk&&
this.isNameValid &&
!this.checkOnGoing;
}

View File

@ -124,7 +124,6 @@ export class ProjectComponent implements OnInit, OnDestroy {
getProjects(name?: string, isPublic?: number, page?: number, pageSize?: number): void {
this.loading = true;
this.projectService
.listProjects(name, isPublic, page, pageSize)
.subscribe(
@ -184,7 +183,11 @@ export class ProjectComponent implements OnInit, OnDestroy {
response => {
this.messageHandlerService.showSuccess('PROJECT.TOGGLED_SUCCESS');
this.statisticHandler.refresh();
this.getProjects("", this.currentFilteredType - 1);
if (this.currentFilteredType === 0) {
this.getProjects();
} else {
this.getProjects("", this.currentFilteredType - 1);
}
},
error => this.messageHandlerService.handleError(error)
);