fix2552 connect button grayed out

This commit is contained in:
pengpengshui 2017-07-14 09:28:20 -07:00
parent be6e265890
commit 8ec00c479e
2 changed files with 13 additions and 2 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;
});
}
}