2024-07-24 14:22:12 +00:00
|
|
|
part of 'server_logs_bloc.dart';
|
|
|
|
|
|
|
|
sealed class ServerLogsState extends Equatable {
|
|
|
|
const ServerLogsState();
|
|
|
|
}
|
|
|
|
|
|
|
|
final class ServerLogsInitial extends ServerLogsState {
|
|
|
|
@override
|
|
|
|
List<Object> get props => [];
|
|
|
|
}
|
|
|
|
|
|
|
|
final class ServerLogsLoading extends ServerLogsState {
|
|
|
|
@override
|
|
|
|
List<Object> get props => [];
|
|
|
|
}
|
|
|
|
|
|
|
|
final class ServerLogsLoaded extends ServerLogsState {
|
2024-07-29 22:47:27 +00:00
|
|
|
ServerLogsLoaded({
|
|
|
|
required this.oldEntries,
|
|
|
|
required this.newEntries,
|
|
|
|
required this.meta,
|
|
|
|
required this.loadingMore,
|
|
|
|
this.slice,
|
|
|
|
}) : _lastCursor = newEntries.isEmpty ? '' : newEntries.first.cursor;
|
2024-07-24 14:22:12 +00:00
|
|
|
|
2024-07-26 19:56:40 +00:00
|
|
|
final List<ServerLogEntry> oldEntries;
|
|
|
|
final List<ServerLogEntry> newEntries;
|
2024-07-24 14:22:12 +00:00
|
|
|
final ServerLogsPageMeta meta;
|
|
|
|
final bool loadingMore;
|
2024-07-26 19:56:40 +00:00
|
|
|
final String _lastCursor;
|
2024-07-29 22:47:27 +00:00
|
|
|
final String? slice;
|
2024-07-24 14:22:12 +00:00
|
|
|
|
2024-07-26 19:56:40 +00:00
|
|
|
List<String> get systemdUnits => oldEntries
|
2024-07-24 14:22:12 +00:00
|
|
|
.map((final entry) => entry.systemdUnit ?? 'kernel')
|
|
|
|
.toSet()
|
|
|
|
.toList();
|
|
|
|
|
2024-07-26 19:56:40 +00:00
|
|
|
List<ServerLogEntry> oldEntriesForUnit(final String unit) {
|
2024-07-24 14:22:12 +00:00
|
|
|
if (unit == 'kernel') {
|
|
|
|
final filteredEntries =
|
2024-07-26 19:56:40 +00:00
|
|
|
oldEntries.where((final entry) => entry.systemdUnit == null).toList();
|
|
|
|
return filteredEntries;
|
2024-07-24 14:22:12 +00:00
|
|
|
}
|
|
|
|
final filteredEntries =
|
2024-07-26 19:56:40 +00:00
|
|
|
oldEntries.where((final entry) => entry.systemdUnit == unit).toList();
|
|
|
|
return filteredEntries;
|
|
|
|
}
|
|
|
|
|
|
|
|
List<ServerLogEntry> newEntriesForUnit(final String unit) {
|
|
|
|
if (unit == 'kernel') {
|
|
|
|
final filteredEntries =
|
|
|
|
newEntries.where((final entry) => entry.systemdUnit == null).toList();
|
|
|
|
return filteredEntries;
|
|
|
|
}
|
|
|
|
final filteredEntries =
|
|
|
|
newEntries.where((final entry) => entry.systemdUnit == unit).toList();
|
|
|
|
return filteredEntries;
|
2024-07-24 14:22:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2024-07-29 22:47:27 +00:00
|
|
|
List<Object?> get props => [oldEntries, newEntries, meta, _lastCursor, slice];
|
2024-07-24 14:22:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
final class ServerLogsError extends ServerLogsState {
|
|
|
|
const ServerLogsError(this.error);
|
|
|
|
|
|
|
|
final Object error;
|
|
|
|
|
|
|
|
@override
|
|
|
|
List<Object> get props => [error];
|
|
|
|
}
|