Skip to content

Commit

Permalink
dynamic child and measurement lists display was done
Browse files Browse the repository at this point in the history
  • Loading branch information
Mukkamalla committed Jul 20, 2023
1 parent 1f9928d commit 04e4b15
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ <h4 class="modal-title text-normal text-center" translate="">Configure Device</h
placeholder="Search Device"
type="search"
formControlName="devicename"
(change)="invokeParentDevice($event)"
/>
<span class="input-group-addon" style="margin-right: 20px">
<i c8yIcon="search" *ngIf="!value || value.length === 0"></i>
Expand All @@ -628,7 +629,7 @@ <h4 class="modal-title text-normal text-center" translate="">Configure Device</h
<div class="row col-sm-12">
<div class="btn-group device-list-switch-toggle ">
<label class="c8y-switch ">
<input type="checkbox" [checked]="includeChildDevice" (change)="includeChildDevice = !includeChildDevice">
<input type="checkbox" (change)="onCheckboxChange($event)" [checked]="includeChildDevice">
<span></span> <label translate="">Include child Devices</label>
</label>
</div>
Expand All @@ -650,7 +651,7 @@ <h4 class="modal-title text-normal text-center" translate="">Configure Device</h
[searchable]="true"
placeholder="Select Child Devices"
[(ngModel)]="selectedChildDevices"
(change)="invokechildDevices()"
(change)="invokeChildDevices($event)"
>
</ng-select>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class GpBoonlogicComponent implements OnInit, DoCheck, OnDestroy {
observableMeasurements$ = new BehaviorSubject<any>(this.measurementList);
configDevice: any;
measurementType: any;
measurementTypeList: any;
measurementTypeList: any = [];
allSubscriptions: any = [];
realtimeState = true;
page = 1;
Expand Down Expand Up @@ -138,6 +138,7 @@ export class GpBoonlogicComponent implements OnInit, DoCheck, OnDestroy {
userHasAdminRights!: boolean;
submitted!: any;
childDevicesLength:number =0;
includeChildDevice: any = false;

constructor(
private microserviceBoonLogic: GpBoonlogicService,
Expand Down Expand Up @@ -349,17 +350,17 @@ export class GpBoonlogicComponent implements OnInit, DoCheck, OnDestroy {
*/
async deviceSelected(device: DeviceConfig): Promise<string | -1> {
this.childDevicesLength=0;
this.selectedChildDevices=[];
if (device) {
//console.log("Device",device)
console.log("Device",device)
this.childDevices=[...device.childDevices.references];
this.childDevicesLength=device.childDevices.references.length;
//console.log(this.childDevicesLength)
//console.log("ChildDevices",this.childDevices)
//this.sel = true;
this.Selecteddevice = { name: '', id: '' };
this.Selecteddevice.name = device.name;
this.Selecteddevice.id = device.id;
this.measurementList = [];
this.measurementTypeList = [];
this.selectedMeasurements = [];
this.getcombinemeasurement(device);
return device.name;
} else {
Expand Down Expand Up @@ -587,21 +588,28 @@ export class GpBoonlogicComponent implements OnInit, DoCheck, OnDestroy {
}
}

async invokechildDevices(): Promise<void> {
//console.log("selected child list",this.selectedChildDevices)
if(this.selectedChildDevices)
async invokeChildDevices(chDevice: ChildDeviceConfig[]): Promise<void> {
if(chDevice.length > 0 && this.includeChildDevice)
{
this.selectedMeasurements = [];
for(let ch of this.selectedChildDevices)
{
//console.log("ch",ch)
const response = await this.cmonSvc.getTargetObject(ch);
//console.log("response",response)
this.configDevice = ch;
this.getcombinemeasurement(response)
}
}
else{
const response = await this.cmonSvc.getTargetObject(this.Selecteddevice.id);
this.measurementList = [];
this.measurementTypeList = [];
this.selectedMeasurements = [];
this.getcombinemeasurement(response)
}
}

}

async invokeParentDevice(e: DeviceConfig){
this.deviceSelected(e)
}

invokeUpdateSetValue(): void {
Expand Down Expand Up @@ -929,10 +937,30 @@ export class GpBoonlogicComponent implements OnInit, DoCheck, OnDestroy {
);
}
}

async onCheckboxChange(event: any): Promise<void> {
this.includeChildDevice=event.target.checked;
if(!this.includeChildDevice)
{
const response = await this.cmonSvc.getTargetObject(this.Selecteddevice.id);
this.measurementList = [];
this.measurementTypeList = [];
this.selectedMeasurements = [];
this.selectedChildDevices = [];
this.getcombinemeasurement(response)
}
}
}

export interface DeviceConfig {
id: string;
name: string;
childDevices:any;
}

export interface ChildDeviceConfig{
managedObject:{
id:string;
name:string;
}
}

0 comments on commit 04e4b15

Please sign in to comment.