feat: add Control Room with containers and stacks management
- Add Control Room page with stacks sidebar and containers list - Implement container actions (start/stop/restart) with snackbars - Add container logs viewer dialog - Add search/filter for both stacks and containers lists - Add external links for Portainer and Netdata (url_launcher) - Add VS Code launch configuration for Flutter web debugging 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.5
parent
dd6bcbdbda
commit
3b89ed8c18
@@ -0,0 +1,73 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../../../../../core/api/api_client.dart';
|
||||
import '../models/container_model.dart';
|
||||
|
||||
part 'containers_datasource.g.dart';
|
||||
|
||||
/// Remote data source for container operations.
|
||||
class ContainersDatasource {
|
||||
ContainersDatasource(this._dio);
|
||||
|
||||
final Dio _dio;
|
||||
|
||||
/// Gets all containers from the API.
|
||||
Future<List<ContainerModel>> getContainers({bool all = true}) async {
|
||||
final response = await _dio.get<List<dynamic>>(
|
||||
'/infrastructure/containers',
|
||||
queryParameters: {'all': all},
|
||||
);
|
||||
|
||||
return response.data!
|
||||
.map((json) => ContainerModel.fromJson(json as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
|
||||
/// Gets a single container by ID.
|
||||
Future<ContainerModel> getContainer(String id) async {
|
||||
final response = await _dio.get<Map<String, dynamic>>(
|
||||
'/infrastructure/containers/$id',
|
||||
);
|
||||
|
||||
return ContainerModel.fromJson(response.data!);
|
||||
}
|
||||
|
||||
/// Performs an action on a container.
|
||||
Future<void> containerAction(String id, String action) async {
|
||||
await _dio.post<void>('/infrastructure/containers/$id/$action');
|
||||
}
|
||||
|
||||
/// Gets container logs.
|
||||
Future<String> getContainerLogs(
|
||||
String id, {
|
||||
int? tail,
|
||||
bool timestamps = false,
|
||||
}) async {
|
||||
final response = await _dio.get<String>(
|
||||
'/infrastructure/containers/$id/logs',
|
||||
queryParameters: {
|
||||
if (tail != null) 'tail': tail,
|
||||
'timestamps': timestamps,
|
||||
},
|
||||
);
|
||||
|
||||
return response.data ?? '';
|
||||
}
|
||||
|
||||
/// Removes a container.
|
||||
Future<void> removeContainer(String id, {bool force = false}) async {
|
||||
await _dio.delete<void>(
|
||||
'/infrastructure/containers/$id',
|
||||
queryParameters: {'force': force},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Provides the containers datasource.
|
||||
@riverpod
|
||||
ContainersDatasource containersDatasource(Ref ref) {
|
||||
final dio = ref.watch(coreApiClientProvider);
|
||||
return ContainersDatasource(dio);
|
||||
}
|
||||
Reference in New Issue
Block a user