Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix #10] Fixed an issue showing only up to 100 alarms. Reason is that the core implementation has 100 as hard maximum for the count operation. #11

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading