it0/it0_app/lib/features/dashboard/domain/entities/server_status.dart

35 lines
854 B
Dart

/// Represents the status of a single server in the inventory.
class ServerStatus {
final String id;
final String hostname;
final String status;
final String? ipAddress;
final double? cpuUsage;
final double? memoryUsage;
final double? diskUsage;
final DateTime? lastChecked;
const ServerStatus({
required this.id,
required this.hostname,
required this.status,
this.ipAddress,
this.cpuUsage,
this.memoryUsage,
this.diskUsage,
this.lastChecked,
});
bool get isOnline =>
status.toLowerCase() == 'online' ||
status.toLowerCase() == 'healthy' ||
status.toLowerCase() == 'running' ||
status.toLowerCase() == 'active';
bool get isWarning =>
status.toLowerCase() == 'warning' ||
status.toLowerCase() == 'degraded';
bool get isOffline => !isOnline && !isWarning;
}