Update for restriction check.

This commit is contained in:
kunw 2017-05-12 17:00:34 +08:00
parent 900854128a
commit 3b0bd2e700
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,7 +269,9 @@ export class CreateEditEndpointComponent implements AfterViewChecked {
username: this.initVal.username,
password: this.initVal.password
};
this.targetForm.valueChanges.subscribe(data=>{
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];
@ -283,5 +287,6 @@ export class CreateEditEndpointComponent implements AfterViewChecked {
});
}
}
}
}

View File

@ -145,14 +145,18 @@ export class EndpointComponent implements OnInit {
editTarget(target: Endpoint) {
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