Skip to content

Commit

Permalink
filter inactive devices from widget; fix #SNRGY-3029
Browse files Browse the repository at this point in the history
  • Loading branch information
hahahannes committed Dec 22, 2023
1 parent 7351512 commit 2b60d6b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* limitations under the License.
*/

import { Attribute } from "./device-instances.model";


export interface DeviceInstancesHistoryModel {
creator: string;
date: number;
Expand All @@ -22,6 +25,7 @@ export interface DeviceInstancesHistoryModel {
log_state: string;
log_history: { values: LogHistoryValues[] | null };
log_edge: (string | boolean)[] | null;
attributes?: Attribute[];
}

interface LogHistoryValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ export class DeviceDowntimeListService {
getDevicesDowntime(): Observable<DeviceDowntimeListModel[]> {
return this.deviceInstancesService.getDeviceHistory7d().pipe(
map(d => d || []),
map(devices => devices.filter((device) => {
var active = true
if(device.attributes) {
device.attributes.forEach(attribute => {
if(attribute.key == "inactive" && attribute.value == "true") {
active = false
}
});
}
return active
})),
map((devices: DeviceInstancesHistoryModel[]) => this.calcDevicesConnectionTime(devices))
);
}
Expand Down
11 changes: 11 additions & 0 deletions src/app/widgets/devices-state/shared/devices-state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ export class DevicesStateService {
getDevicesStatus(): Observable<DevicesStateModel> {
return this.deviceInstancesService.getDeviceHistory1h().pipe(
map(devices => devices || []),
map(devices => devices.filter((device) => {
var active = true
if(device.attributes) {
device.attributes.forEach(attribute => {
if(attribute.key == "inactive" && attribute.value == "true") {
active = false
}
});
}
return active
})),
map((devices: DeviceInstancesHistoryModel[]) => this.sumDevicesStatus(devices))
);
}
Expand Down

0 comments on commit 2b60d6b

Please sign in to comment.