ekangularbase
Version:
Authentication service for usermanagement(oidc client)
98 lines (87 loc) • 3.77 kB
text/typescript
import { OnInit } from "@angular/core";
import { WebNotificationService } from '../auth/webNotification.service';
import { Http } from '@angular/http';
import { BaseService } from './BaseService';
import { BaseComponent } from './BaseComponent';
import { ConnectionIndicationService } from '../auth/ConnectionIndication.service';
import { MessageService } from 'node_modules/primeng/api';
import { ConfirmationService } from 'node_modules/primeng/api';
import { AuthService } from '../auth/auth.service';
import { RequireInteractiveControl } from '../interface/Interactive Component/RequireInteractiveControl';
import { LocalContainerObject } from '../interface/Interactive Component/LocalContainerObject';
import { Router } from '@angular/router';
export class BaseComponentSubObj<T extends RequireInteractiveControl,
U extends RequireInteractiveControl> extends
BaseComponent<T> {
// public mode: string;
// public baseu: string;
// public generalhttp: Http;
// public selectedObject:T;
// public objectlist:T[];
// public isnewobject : boolean;
// public actionitems:string[] =["Insert","Delete","Update"];
public selectedSubObject: U;
constructor(
public webNotificationservice: WebNotificationService,
public confirmationService: ConfirmationService
, public messageService: MessageService
, public objectservice: BaseService<T>
, public objectname: string
, public authService: AuthService
, public subobjectservice: BaseService<T>
, public subobjectname: string
, public actionitems: string[] = ["Insert", "Delete", "Update"]
, public router: Router
) {
super(confirmationService, webNotificationservice
, messageService
, objectservice
, objectname
, authService
, router
, actionitems)
}
ngOnInit(): void {
let callback = (data: any, typestr: string): void => { this.OnReceiveUpdate(data); };
this.webNotificationservice.on(callback, this.objectname);
this.ngOnInitLocal();
this.list();
let callbackSubObj = (data: any, typestr: string): void => { this.OnReceiveUpdateSubObj(data); };
this.webNotificationservice.on(callbackSubObj, this.subobjectname);
}
// ngOnDestroy()
// {
// this.webNotificationservice.off();
// }
// ngOnInitLocal()
// {
// }
// list()
// {
// this.objectservice.Get().subscribe(obj =>
// {
// // alert('sss');
// this.objectlist = obj;
// },error=>{console.error(error)}
// );
// }
OnReceiveUpdateSubObj(lco: LocalContainerObject) {
// this.messageService.add({severity:'Info', summary:'Info', detail:lco.objectUniqueId});
if (this.selectedSubObject != null && lco.objectUniqueId == this.selectedSubObject.id) {
// var actionitems:string[] =["Insert","Delete","Update"];
if (this.actionitems.includes(lco.action)) {
this.messageService.add({ severity: 'Info', summary: 'Info', detail: 'The object is updated' });
this.selectedSubObject.isLocked = true;
}
}
// else
// {
// // var actionitems:string[] =["Insert","Delete","Update"];
// if(this.actionitems.includes(lco.action))
// {
// this.messageService.add({severity:'Info', summary:'Info', detail:'The list is updated, system will now refresh'});
// this.list();
// }
// }
}
}