Skip to content

Commit

Permalink
Merge pull request #2 from SoftwareAG/feature/support-assets
Browse files Browse the repository at this point in the history
Handled realtime unsubscribe and child assets radio button issue
  • Loading branch information
DarpanLalani committed Nov 10, 2021
2 parents 9c5296a + f810182 commit 7f8ceef
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gp-device-chart",
"version": "1.0.0",
"version": "1.0.1",
"description": "This is an Angular 8 widget, which is designed to display the chart based on the device specific inventory data.",
"author": "Khushi Khanna - Software AG, Global Presales",
"license": "Apache 2.0",
Expand Down
2 changes: 1 addition & 1 deletion projects/gp-lib-device-chart/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gp-lib-device-chart",
"version": "1.1.0",
"version": "1.0.1",
"description": "This is an Angular 8 widget, which is designed to display the chart based on the device specific inventory data.",
"author": "Khushi Khanna - Software AG, Global Presales",
"license": "Apache 2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class GpLibDeviceChartComponent implements OnInit, OnDestroy {
dataValues: [];
deviceList = [];
oldDataset = {};
realTimeDeviceSub;
realTimeDeviceSub: any[] = [];
realtimeState = true;
@Input() config;

Expand Down Expand Up @@ -86,11 +86,12 @@ export class GpLibDeviceChartComponent implements OnInit, OnDestroy {

this.deviceList.map(singleDevice => {
const deviceUrl = '/managedobjects/' + singleDevice;
this.realTimeDeviceSub = this.realtimeService.subscribe(deviceUrl, () => {
const realtimeData = this.realtimeService.subscribe(deviceUrl, () => {
if (this.realtimeState) {
this.createChart();
}
});
this.realTimeDeviceSub.push(realtimeData);
});
}

Expand Down Expand Up @@ -216,6 +217,10 @@ export class GpLibDeviceChartComponent implements OnInit, OnDestroy {
}
/** unsubscribes the realtime subscription subject */
ngOnDestroy() {
this.realtimeService.unsubscribe(this.realTimeDeviceSub);

this.realTimeDeviceSub.forEach(realtimeElem => {
this.realtimeService.unsubscribe(realtimeElem);

});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
</select>
</div>
<div class="form-group">
<mat-slide-toggle class="example-margin" name="innerChild" [(ngModel)]="config.innerChild" ngDefaultControl>Include child devices</mat-slide-toggle>
<label class="c8y-switch">
<input type="checkbox" checked="config.innerChild" [(ngModel)]="config.innerChild" />
<span></span> Include child devices
</label>
</div>
<div style="display: flex;">
<div style="flex-grow:1 ; margin-right: 5px;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export class GpDeviceChartWidgetConfig implements OnInit {
constructor() { }

ngOnInit() {

if (this.config.innerChild === undefined) {

this.config.innerChild = false;

}

}

/** Opens the color picker if it is not already open */
Expand Down
26 changes: 15 additions & 11 deletions projects/gp-lib-device-chart/src/lib/gp-lib-device-chart.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,22 @@ export class GpLibDeviceChartService {

if (config.groupby === 'versionIssuesName') {
let versionIssues = 0;
versionIssues = it.c8y_Firmware.version - this.latestFirmwareVersion;
if (it.c8y_Firmware && versionIssues >= 0) {
dataSet['No Risk'] = dataSet['No Risk'] + 1 || 1;
} else if (it.c8y_Firmware && versionIssues === -1) {
dataSet['Low Risk'] = dataSet['Low Risk'] + 1 || 1;
} else if (it.c8y_Firmware && versionIssues === -2) {
dataSet['Medium Risk'] = dataSet['Medium Risk'] + 1 || 1;
} else if (it.c8y_Firmware && versionIssues <= -3) {
dataSet['High Risk'] = dataSet['High Risk'] + 1 || 1;
} else {
dataSet['Not Available'] = dataSet['Not Available'] + 1 || 1;
if (it.c8y_Firmware) {
versionIssues = it.c8y_Firmware.version - this.latestFirmwareVersion;
if (it.c8y_Firmware && versionIssues >= 0) {
dataSet['No Risk'] = dataSet['No Risk'] + 1 || 1;
} else if (it.c8y_Firmware && versionIssues === -1) {
dataSet['Low Risk'] = dataSet['Low Risk'] + 1 || 1;
} else if (it.c8y_Firmware && versionIssues === -2) {
dataSet['Medium Risk'] = dataSet['Medium Risk'] + 1 || 1;
} else if (it.c8y_Firmware && versionIssues <= -3) {
dataSet['High Risk'] = dataSet['High Risk'] + 1 || 1;
} else {
dataSet['Not Available'] = dataSet['Not Available'] + 1 || 1;
}

}

}
if (typeof recordValue === 'object') {
Object.keys(recordValue).map((key) => {
Expand Down
2 changes: 1 addition & 1 deletion runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"dist\\bundle-src\\custom-widget.js": "device-chart-runtime-widget-CustomWidget",
"dist/bundle-src/custom-widget.js": "device-chart-runtime-widget-CustomWidget"
},
"version": "1.0.0",
"version": "1.0.1",
"description": "Runtime package.json for library widget (written by Software AG Global Presales)",
"author": "Darpankumar Lalani - Software AG, Global Presales",
"license": "Apache 2.0"
Expand Down

0 comments on commit 7f8ceef

Please sign in to comment.