Files
manager/lib/core/models/severity_mapping.dart
T
2026-07-27 14:42:23 +02:00

17 lines
805 B
Dart

import '../theme/status_colors.dart';
/// Maps the API's untyped status strings to a [Severity] for [StatusPill]
/// rendering. Centralized here (not per-screen) since `Service.status` is
/// rendered on both the Services table and Fleet's aggregated card grid.
Severity severityForServiceStatus(String status) => switch (status) {
'up' => Severity.good,
'down' => Severity.critical,
_ => Severity.warning, // "unknown" or anything this client doesn't recognize yet
};
/// Maps a backup/update execution's `success` flag to a [Severity].
Severity severityForSuccess(bool success) => success ? Severity.good : Severity.critical;
/// Maps a [RemoteNode.status]/reachability signal to a [Severity].
Severity severityForNodeReachable(bool reachable) => reachable ? Severity.good : Severity.critical;