This MVP release provides a complete full-stack solution for managing action mappings in Geutebruck's GeViScope and GeViSoft video surveillance systems. ## Features ### Flutter Web Application (Port 8081) - Modern, responsive UI for managing action mappings - Action picker dialog with full parameter configuration - Support for both GSC (GeViScope) and G-Core server actions - Consistent UI for input and output actions with edit/delete capabilities - Real-time action mapping creation, editing, and deletion - Server categorization (GSC: prefix for GeViScope, G-Core: prefix for G-Core servers) ### FastAPI REST Backend (Port 8000) - RESTful API for action mapping CRUD operations - Action template service with comprehensive action catalog (247 actions) - Server management (G-Core and GeViScope servers) - Configuration tree reading and writing - JWT authentication with role-based access control - PostgreSQL database integration ### C# SDK Bridge (gRPC, Port 50051) - Native integration with GeViSoft SDK (GeViProcAPINET_4_0.dll) - Action mapping creation with correct binary format - Support for GSC and G-Core action types - Proper Camera parameter inclusion in action strings (fixes CrossSwitch bug) - Action ID lookup table with server-specific action IDs - Configuration reading/writing via SetupClient ## Bug Fixes - **CrossSwitch Bug**: GSC and G-Core actions now correctly display camera/PTZ head parameters in GeViSet - Action strings now include Camera parameter: `@ PanLeft (Comment: "", Camera: 101028)` - Proper filter flags and VideoInput=0 for action mappings - Correct action ID assignment (4198 for GSC, 9294 for G-Core PanLeft) ## Technical Stack - **Frontend**: Flutter Web, Dart, Dio HTTP client - **Backend**: Python FastAPI, PostgreSQL, Redis - **SDK Bridge**: C# .NET 8.0, gRPC, GeViSoft SDK - **Authentication**: JWT tokens - **Configuration**: GeViSoft .set files (binary format) ## Credentials - GeViSoft/GeViScope: username=sysadmin, password=masterkey - Default admin: username=admin, password=admin123 ## Deployment All services run on localhost: - Flutter Web: http://localhost:8081 - FastAPI: http://localhost:8000 - SDK Bridge gRPC: localhost:50051 - GeViServer: localhost (default port) Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
212 lines
6.2 KiB
Dart
212 lines
6.2 KiB
Dart
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'server_event.dart';
|
|
import 'server_state.dart';
|
|
import '../../../domain/repositories/server_repository.dart';
|
|
import '../../../data/services/sync_service.dart';
|
|
|
|
class ServerBloc extends Bloc<ServerEvent, ServerState> {
|
|
final ServerRepository serverRepository;
|
|
|
|
ServerBloc({required this.serverRepository}) : super(const ServerInitial()) {
|
|
on<LoadServers>(_onLoadServers);
|
|
on<LoadGCoreServers>(_onLoadGCoreServers);
|
|
on<LoadGeViScopeServers>(_onLoadGeViScopeServers);
|
|
on<CreateServerEvent>(_onCreateServer);
|
|
on<UpdateServerEvent>(_onUpdateServer);
|
|
on<DeleteServerEvent>(_onDeleteServer);
|
|
on<SyncServersEvent>(_onSyncServers);
|
|
on<DownloadServersEvent>(_onDownloadServers);
|
|
on<CheckDirtyCountEvent>(_onCheckDirtyCount);
|
|
}
|
|
|
|
Future<void> _onLoadServers(
|
|
LoadServers event,
|
|
Emitter<ServerState> emit,
|
|
) async {
|
|
emit(const ServerLoading());
|
|
|
|
final result = await serverRepository.getAllServers();
|
|
final dirtyCountResult = await serverRepository.getDirtyCount();
|
|
|
|
result.fold(
|
|
(failure) => emit(ServerError(failure.message)),
|
|
(servers) {
|
|
final dirtyCount = dirtyCountResult.fold((_) => 0, (count) => count);
|
|
emit(ServerLoaded(servers, dirtyCount: dirtyCount));
|
|
},
|
|
);
|
|
}
|
|
|
|
Future<void> _onLoadGCoreServers(
|
|
LoadGCoreServers event,
|
|
Emitter<ServerState> emit,
|
|
) async {
|
|
emit(const ServerLoading());
|
|
|
|
final result = await serverRepository.getGCoreServers();
|
|
final dirtyCountResult = await serverRepository.getDirtyCount();
|
|
|
|
result.fold(
|
|
(failure) => emit(ServerError(failure.message)),
|
|
(servers) {
|
|
final dirtyCount = dirtyCountResult.fold((_) => 0, (count) => count);
|
|
emit(ServerLoaded(servers, dirtyCount: dirtyCount));
|
|
},
|
|
);
|
|
}
|
|
|
|
Future<void> _onLoadGeViScopeServers(
|
|
LoadGeViScopeServers event,
|
|
Emitter<ServerState> emit,
|
|
) async {
|
|
emit(const ServerLoading());
|
|
|
|
final result = await serverRepository.getGeViScopeServers();
|
|
final dirtyCountResult = await serverRepository.getDirtyCount();
|
|
|
|
result.fold(
|
|
(failure) => emit(ServerError(failure.message)),
|
|
(servers) {
|
|
final dirtyCount = dirtyCountResult.fold((_) => 0, (count) => count);
|
|
emit(ServerLoaded(servers, dirtyCount: dirtyCount));
|
|
},
|
|
);
|
|
}
|
|
|
|
Future<void> _onCreateServer(
|
|
CreateServerEvent event,
|
|
Emitter<ServerState> emit,
|
|
) async {
|
|
emit(const ServerLoading());
|
|
|
|
final result = await serverRepository.createServer(event.server);
|
|
|
|
await result.fold(
|
|
(failure) async => emit(ServerError(failure.message)),
|
|
(_) async {
|
|
// Reload servers first
|
|
final serversResult = await serverRepository.getAllServers();
|
|
final dirtyCountResult = await serverRepository.getDirtyCount();
|
|
|
|
serversResult.fold(
|
|
(failure) => emit(ServerError(failure.message)),
|
|
(servers) {
|
|
final dirtyCount = dirtyCountResult.fold((_) => 0, (count) => count);
|
|
emit(ServerLoaded(servers, dirtyCount: dirtyCount));
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Future<void> _onUpdateServer(
|
|
UpdateServerEvent event,
|
|
Emitter<ServerState> emit,
|
|
) async {
|
|
emit(const ServerLoading());
|
|
|
|
final result = await serverRepository.updateServer(event.server);
|
|
|
|
await result.fold(
|
|
(failure) async => emit(ServerError(failure.message)),
|
|
(_) async {
|
|
// Reload servers first
|
|
final serversResult = await serverRepository.getAllServers();
|
|
final dirtyCountResult = await serverRepository.getDirtyCount();
|
|
|
|
serversResult.fold(
|
|
(failure) => emit(ServerError(failure.message)),
|
|
(servers) {
|
|
final dirtyCount = dirtyCountResult.fold((_) => 0, (count) => count);
|
|
emit(ServerLoaded(servers, dirtyCount: dirtyCount));
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Future<void> _onDeleteServer(
|
|
DeleteServerEvent event,
|
|
Emitter<ServerState> emit,
|
|
) async {
|
|
emit(const ServerLoading());
|
|
|
|
final result = await serverRepository.deleteServer(event.id, event.type);
|
|
|
|
await result.fold(
|
|
(failure) async => emit(ServerError(failure.message)),
|
|
(_) async {
|
|
// Reload servers first
|
|
final serversResult = await serverRepository.getAllServers();
|
|
final dirtyCountResult = await serverRepository.getDirtyCount();
|
|
|
|
serversResult.fold(
|
|
(failure) => emit(ServerError(failure.message)),
|
|
(servers) {
|
|
final dirtyCount = dirtyCountResult.fold((_) => 0, (count) => count);
|
|
emit(ServerLoaded(servers, dirtyCount: dirtyCount));
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Future<void> _onSyncServers(
|
|
SyncServersEvent event,
|
|
Emitter<ServerState> emit,
|
|
) async {
|
|
emit(const ServerSyncing());
|
|
|
|
final result = await serverRepository.syncToServer();
|
|
|
|
result.fold(
|
|
(failure) => emit(ServerError(failure.message)),
|
|
(syncResult) {
|
|
if (syncResult.status == SyncStatus.success) {
|
|
emit(ServerSyncSuccess(
|
|
syncResult.message ?? 'Sync completed',
|
|
syncResult.syncedCount ?? 0,
|
|
));
|
|
// Reload servers after sync
|
|
add(const LoadServers());
|
|
} else if (syncResult.status == SyncStatus.error) {
|
|
emit(ServerError(syncResult.message ?? 'Sync failed'));
|
|
}
|
|
},
|
|
);
|
|
}
|
|
|
|
Future<void> _onDownloadServers(
|
|
DownloadServersEvent event,
|
|
Emitter<ServerState> emit,
|
|
) async {
|
|
emit(const ServerDownloading());
|
|
|
|
final result = await serverRepository.downloadFromServer();
|
|
|
|
result.fold(
|
|
(failure) => emit(ServerError(failure.message)),
|
|
(count) {
|
|
emit(ServerOperationSuccess('Downloaded $count servers from server'));
|
|
// Reload servers after download
|
|
add(const LoadServers());
|
|
},
|
|
);
|
|
}
|
|
|
|
Future<void> _onCheckDirtyCount(
|
|
CheckDirtyCountEvent event,
|
|
Emitter<ServerState> emit,
|
|
) async {
|
|
final result = await serverRepository.getDirtyCount();
|
|
|
|
result.fold(
|
|
(failure) => emit(ServerError(failure.message)),
|
|
(count) {
|
|
// Just trigger a reload which will include the dirty count
|
|
add(const LoadServers());
|
|
},
|
|
);
|
|
}
|
|
}
|