Add app source and tests

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
alvocool
2026-10-11 10:15:30 +03:00
parent 7e246255c2
commit 38881d1fe1
135 changed files with 21057 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
import '../../about/external/data/Health.dart';
import '../../about/internal/application/ServerProfile.dart';
import '../parent/ParentViewModel.dart';
import 'ConnectHealth.dart';
class ViewHealth extends ParentViewModel {
ConnectHealth connection;
ViewHealth(super.context, this.connection);
bool _running = false;
bool get isRunning => _running;
/// Checks every service on every server, reporting each result as it lands.
/// A server that can't be reached marks its own services unhealthy and the
/// sweep moves on, so one dead box doesn't stall the whole dashboard.
void runSweep(List<ServerProfile> servers) async {
if (_running) return;
_running = true;
notifyListeners();
connection.onSweepStarted();
for (final server in servers) {
for (final service in server.services) {
try {
final result = await getDataManager().checkHealth(server, service);
connection.onServiceChecked(service.id, result);
} catch (error) {
connection.onServiceChecked(
service.id,
HealthResult(HealthStatus.unhealthy, _describe(error)),
);
}
}
}
getDataManager().disconnect();
_running = false;
notifyListeners();
connection.onSweepFinished();
}
String _describe(Object error) {
final text = error.toString();
return text.length > 80 ? '${text.substring(0, 77)}…' : text;
}
}