Skip to content

Commit

Permalink
[Fix #10] Fixed an issue showing only up to 100 alarms. Reason is tha…
Browse files Browse the repository at this point in the history
…t the core implementation has 100 as hard maximum for the count operation. (#11)

(cherry picked from commit 191c3d7)
  • Loading branch information
joerghartmann committed Dec 10, 2024
1 parent 5151fd2 commit ac9b9a7
Showing 1 changed file with 21 additions and 50 deletions.
71 changes: 21 additions & 50 deletions ios/AlarmApp/AlarmApp/Controller/DashboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,58 +64,29 @@ class DashboardViewController: UIViewController, AlarmListReloadDelegate, EmptyA

private func fetchAlarmCount() {
let alarmsApi = Cumulocity.Core.shared.alarms.alarmsApi
alarmsApi.getNumberOfAlarms(
severity: [C8yAlarm.C8ySeverity.critical.rawValue],
status: [C8yAlarm.C8yStatus.active.rawValue]
)
.receive(on: DispatchQueue.main)
.sink(
receiveCompletion: { _ in
},
receiveValue: { value in
self.criticalCountItem.countLabel.text = String(value)
}
)
.store(in: &self.cancellableSet)
alarmsApi.getNumberOfAlarms(
severity: [C8yAlarm.C8ySeverity.major.rawValue],
status: [C8yAlarm.C8yStatus.active.rawValue]
)
.receive(on: DispatchQueue.main)
.sink(
receiveCompletion: { _ in
},
receiveValue: { value in
self.majorCountItem.countLabel.text = String(value)
}
)
.store(in: &self.cancellableSet)
alarmsApi.getNumberOfAlarms(
severity: [C8yAlarm.C8ySeverity.minor.rawValue],
status: [C8yAlarm.C8yStatus.active.rawValue]
)
.receive(on: DispatchQueue.main)
.sink(
receiveCompletion: { _ in
},
receiveValue: { value in
self.minorCountItem.countLabel.text = String(value)
let arguments = [
C8yAlarm.C8ySeverity.critical, C8yAlarm.C8ySeverity.major, C8yAlarm.C8ySeverity.minor,
C8yAlarm.C8ySeverity.warning,
]
let textfields = [self.criticalCountItem, self.majorCountItem, self.minorCountItem, self.warningCountItem]
arguments.enumerated().publisher
.flatMap { index, arg in
return alarmsApi.getAlarms(
pageSize: 1,
severity: [arg.rawValue],
status: [C8yAlarm.C8yStatus.active.rawValue],
withTotalElements: true
)
.map { $0.statistics?.totalElements ?? 0 }
.receive(on: DispatchQueue.main)
.catch { _ in Just(0) }
.map { (index, $0) }
.eraseToAnyPublisher()
}
)
.store(in: &self.cancellableSet)
alarmsApi.getNumberOfAlarms(
severity: [C8yAlarm.C8ySeverity.warning.rawValue],
status: [C8yAlarm.C8yStatus.active.rawValue]
)
.receive(on: DispatchQueue.main)
.sink(
receiveCompletion: { _ in
},
receiveValue: { value in
self.warningCountItem.countLabel.text = String(value)
.sink { index, result in
textfields[index]?.countLabel.text = String(result ?? 0)
}
)
.store(in: &self.cancellableSet)
.store(in: &self.cancellableSet)
}

/// update tag list for receiving push notifications
Expand Down

0 comments on commit ac9b9a7

Please sign in to comment.