Merge pull request #2299 from wknet123/master-endpoint

Update for restriction check.
This commit is contained in:
Steven Zou 2017-05-12 22:35:52 +08:00 committed by GitHub
commit de8e0091f9
3 changed files with 27 additions and 18 deletions

View File

@ -87,7 +87,7 @@ export class CreateEditEndpointComponent implements AfterViewChecked {
private errorHandler: ErrorHandler,
private translateService: TranslateService) {}
openCreateEditTarget(editable: boolean, targetId?: number) {
openCreateEditTarget(editable: boolean, targetId?: number | string) {
this.target = this.initEndpoint;
this.editable = editable;
@ -211,6 +211,8 @@ export class CreateEditEndpointComponent implements AfterViewChecked {
payload.password = this.target.password;
delete payload.name;
}
if(!this.target.id) { return; }
toPromise<number>(this.endpointService
.updateEndpoint(this.target.id, payload))
.then(
@ -267,20 +269,23 @@ export class CreateEditEndpointComponent implements AfterViewChecked {
username: this.initVal.username,
password: this.initVal.password
};
this.targetForm.valueChanges.subscribe(data=>{
for(let key in data) {
let current = data[key];
let origin: string = comparison[key];
if(((this.actionType === ActionType.EDIT && this.editable && !current) || current) &&
current !== origin) {
this.hasChanged = true;
break;
} else {
this.hasChanged = false;
this.inlineAlert.close();
let self: CreateEditEndpointComponent | any = this;
if(self) {
self.targetForm.valueChanges.subscribe((data: any)=>{
for(let key in data) {
let current = data[key];
let origin: string = comparison[key];
if(((this.actionType === ActionType.EDIT && this.editable && !current) || current) &&
current !== origin) {
this.hasChanged = true;
break;
} else {
this.hasChanged = false;
this.inlineAlert.close();
}
}
}
});
});
}
}
}

View File

@ -143,16 +143,20 @@ export class EndpointComponent implements OnInit {
}
editTarget(target: Endpoint) {
if (target) {
if(target) {
let editable = true;
if (!target.id) {
return;
}
let id: number | string = target.id;
toPromise<ReplicationRule[]>(this.endpointService
.getEndpointWithReplicationRules(target.id))
.getEndpointWithReplicationRules(id))
.then(
rules=>{
if(rules && rules.length > 0) {
rules.forEach((rule)=>editable = (rule && rule.enabled !== 1));
}
this.createEditEndpointComponent.openCreateEditTarget(editable, +target.id);
this.createEditEndpointComponent.openCreateEditTarget(editable, id);
let hnd = setInterval(()=>this.ref.markForCheck(), 100);
setTimeout(()=>clearInterval(hnd), 1000);
})

View File

@ -120,7 +120,7 @@ export class EndpointDefaultService extends EndpointService {
queryParams = new RequestQueryParams();
}
if(endpointName) {
queryParams.set('endpointName', endpointName);
queryParams.set('name', endpointName);
}
let requestUrl: string = `${this._endpointUrl}`;
return this.http