feat: Geutebruck GeViScope/GeViSoft Action Mapping System - MVP

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>
This commit is contained in:
Administrator
2025-12-31 18:10:54 +01:00
commit 14893e62a5
4189 changed files with 1395076 additions and 0 deletions

View File

@@ -0,0 +1,141 @@
import 'package:hive_flutter/hive_flutter.dart';
import '../../models/action_mapping_hive_model.dart';
import '../../models/action_mapping_model.dart';
/// Abstract interface for local action mapping data operations
abstract class ActionMappingLocalDataSource {
Future<List<ActionMappingHiveModel>> getAllActionMappings();
Future<ActionMappingHiveModel?> getActionMappingById(String id);
Future<void> saveActionMapping(ActionMappingHiveModel mapping);
Future<void> deleteActionMapping(String id);
Future<List<ActionMappingHiveModel>> getDirtyActionMappings();
Future<void> markActionMappingAsSynced(String id);
Future<void> replaceAllActionMappings(List<ActionMappingModel> mappings, {bool force = false});
Future<List<ActionMappingHiveModel>> searchActionMappings(String query);
Future<void> clearAll();
}
/// Implementation of local action mapping data source using Hive
class ActionMappingLocalDataSourceImpl implements ActionMappingLocalDataSource {
static const String _boxName = 'action_mappings';
Future<Box<ActionMappingHiveModel>> get _box async =>
await Hive.openBox<ActionMappingHiveModel>(_boxName);
@override
Future<List<ActionMappingHiveModel>> getAllActionMappings() async {
final box = await _box;
return box.values
.where((mapping) => mapping.syncOperation != 'delete')
.toList();
}
@override
Future<ActionMappingHiveModel?> getActionMappingById(String id) async {
final box = await _box;
final mapping = box.get(id);
// Don't return deleted items
if (mapping?.syncOperation == 'delete') {
return null;
}
return mapping;
}
@override
Future<void> saveActionMapping(ActionMappingHiveModel mapping) async {
final box = await _box;
await box.put(mapping.id, mapping);
}
@override
Future<void> deleteActionMapping(String id) async {
final box = await _box;
final existing = box.get(id);
if (existing != null) {
// Soft delete: mark as dirty with delete operation
final deleted = existing.copyWith(
isDirty: true,
syncOperation: 'delete',
lastModified: DateTime.now(),
);
await box.put(id, deleted);
}
}
@override
Future<List<ActionMappingHiveModel>> getDirtyActionMappings() async {
final box = await _box;
return box.values.where((mapping) => mapping.isDirty).toList();
}
@override
Future<void> markActionMappingAsSynced(String id) async {
final box = await _box;
final mapping = box.get(id);
if (mapping != null) {
if (mapping.syncOperation == 'delete') {
// Actually delete after successful sync
await box.delete(id);
} else {
// Clear dirty flag and sync operation
final synced = mapping.copyWith(
isDirty: false,
syncOperation: null,
);
await box.put(id, synced);
}
}
}
@override
Future<void> replaceAllActionMappings(List<ActionMappingModel> mappings, {bool force = false}) async {
final box = await _box;
if (force) {
// Force mode: Clear ALL items (including dirty) to get fresh server data
await box.clear();
} else {
// Normal mode: Clear existing non-dirty items
final keysToDelete = box.values
.where((mapping) => !mapping.isDirty)
.map((mapping) => mapping.id)
.toList();
for (final key in keysToDelete) {
await box.delete(key);
}
}
// Add new items from server
for (final model in mappings) {
final hiveModel = ActionMappingHiveModel.fromActionMappingModel(
model,
isDirty: false,
);
await box.put(hiveModel.id, hiveModel);
}
}
@override
Future<List<ActionMappingHiveModel>> searchActionMappings(String query) async {
final box = await _box;
final lowerQuery = query.toLowerCase();
return box.values
.where((mapping) =>
mapping.syncOperation != 'delete' &&
(mapping.name.toLowerCase().contains(lowerQuery) ||
(mapping.description?.toLowerCase().contains(lowerQuery) ?? false)))
.toList();
}
@override
Future<void> clearAll() async {
final box = await _box;
await box.clear();
}
}

View File

@@ -0,0 +1,110 @@
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import '../../../core/errors/exceptions.dart';
import '../../../core/storage/token_manager.dart';
class SecureStorageManager {
final FlutterSecureStorage storage;
SecureStorageManager({required this.storage});
// Token storage
Future<void> saveAccessToken(String token) async {
// Save to memory for immediate use
TokenManager().saveTokens(accessToken: token);
try {
await storage.write(key: 'access_token', value: token);
} catch (e) {
// Silently fail on web when storage is not available (HTTP context)
print('Warning: Failed to save access token to secure storage (using memory): $e');
}
}
Future<void> saveRefreshToken(String token) async {
// Save to memory for immediate use
TokenManager().saveTokens(refreshToken: token);
try {
await storage.write(key: 'refresh_token', value: token);
} catch (e) {
// Silently fail on web when storage is not available (HTTP context)
print('Warning: Failed to save refresh token to secure storage (using memory): $e');
}
}
Future<String?> getAccessToken() async {
try {
final token = await storage.read(key: 'access_token');
if (token != null) return token;
} catch (e) {
print('Warning: Failed to read access token from secure storage, using memory');
}
// Fallback to memory storage
return TokenManager().accessToken;
}
Future<String?> getRefreshToken() async {
try {
final token = await storage.read(key: 'refresh_token');
if (token != null) return token;
} catch (e) {
print('Warning: Failed to read refresh token from secure storage, using memory');
}
// Fallback to memory storage
return TokenManager().refreshToken;
}
// User data storage
Future<void> saveUsername(String username) async {
// Save to memory for immediate use
TokenManager().saveTokens(username: username);
try {
await storage.write(key: 'username', value: username);
} catch (e) {
// Silently fail on web when storage is not available (HTTP context)
print('Warning: Failed to save username to secure storage (using memory): $e');
}
}
Future<void> saveUserRole(String role) async {
// Save to memory for immediate use
TokenManager().saveTokens(userRole: role);
try {
await storage.write(key: 'user_role', value: role);
} catch (e) {
// Silently fail on web when storage is not available (HTTP context)
print('Warning: Failed to save user role to secure storage (using memory): $e');
}
}
Future<String?> getUsername() async {
try {
return await storage.read(key: 'username');
} catch (e) {
throw CacheException('Failed to read username');
}
}
Future<String?> getUserRole() async {
try {
return await storage.read(key: 'user_role');
} catch (e) {
throw CacheException('Failed to read user role');
}
}
// Clear all data
Future<void> clearAll() async {
// Clear memory storage
TokenManager().clear();
try {
await storage.deleteAll();
} catch (e) {
print('Warning: Failed to clear secure storage: $e');
// Not throwing exception since memory is already cleared
}
}
}

View File

@@ -0,0 +1,159 @@
import 'package:hive/hive.dart';
import '../../models/server_hive_model.dart';
import '../../models/server_model.dart';
abstract class ServerLocalDataSource {
/// Get all servers from local storage
Future<List<ServerHiveModel>> getAllServers();
/// Get servers by type
Future<List<ServerHiveModel>> getServersByType(String type);
/// Get server by ID and type
Future<ServerHiveModel?> getServerById(String id, String type);
/// Save server to local storage (create or update)
Future<void> saveServer(ServerHiveModel server);
/// Delete server from local storage
Future<void> deleteServer(String id, String type);
/// Get all servers with pending sync operations
Future<List<ServerHiveModel>> getDirtyServers();
/// Clear dirty flag after successful sync
Future<void> markServerAsSynced(String id, String type);
/// Replace all servers (used after fetching from API)
Future<void> replaceAllServers(List<ServerModel> servers);
/// Clear all local data
Future<void> clearAll();
}
class ServerLocalDataSourceImpl implements ServerLocalDataSource {
static const String _boxName = 'servers';
Box<ServerHiveModel>? _box;
Future<Box<ServerHiveModel>> get box async {
if (_box != null && _box!.isOpen) {
return _box!;
}
_box = await Hive.openBox<ServerHiveModel>(_boxName);
return _box!;
}
String _getKey(String id, String type) => '${type}_$id';
@override
Future<List<ServerHiveModel>> getAllServers() async {
final b = await box;
return b.values.where((s) => s.syncOperation != 'delete').toList();
}
@override
Future<List<ServerHiveModel>> getServersByType(String type) async {
final b = await box;
return b.values
.where((s) => s.serverType == type && s.syncOperation != 'delete')
.toList();
}
@override
Future<ServerHiveModel?> getServerById(String id, String type) async {
final b = await box;
final key = _getKey(id, type);
final server = b.get(key);
// Don't return deleted servers
if (server?.syncOperation == 'delete') {
return null;
}
return server;
}
@override
Future<void> saveServer(ServerHiveModel server) async {
final b = await box;
final key = _getKey(server.id, server.serverType);
await b.put(key, server);
}
@override
Future<void> deleteServer(String id, String type) async {
final b = await box;
final key = _getKey(id, type);
final existing = b.get(key);
if (existing != null) {
// Mark as deleted instead of actually deleting
// This allows us to sync the deletion to the server
final deleted = existing.copyWith(
isDirty: true,
syncOperation: 'delete',
lastModified: DateTime.now(),
);
await b.put(key, deleted);
}
}
@override
Future<List<ServerHiveModel>> getDirtyServers() async {
final b = await box;
return b.values.where((s) => s.isDirty).toList();
}
@override
Future<void> markServerAsSynced(String id, String type) async {
final b = await box;
final key = _getKey(id, type);
final server = b.get(key);
if (server != null) {
if (server.syncOperation == 'delete') {
// Actually delete after successful sync
await b.delete(key);
} else {
// Clear dirty flag
final synced = server.copyWith(
isDirty: false,
syncOperation: null,
);
await b.put(key, synced);
}
}
}
@override
Future<void> replaceAllServers(List<ServerModel> servers) async {
final b = await box;
// Don't clear dirty servers - keep them for sync
final dirtyServers = await getDirtyServers();
final dirtyKeys = dirtyServers.map((s) => _getKey(s.id, s.serverType)).toSet();
// Clear only non-dirty servers
await b.clear();
// Re-add dirty servers
for (final dirty in dirtyServers) {
await b.put(_getKey(dirty.id, dirty.serverType), dirty);
}
// Add all fetched servers (but don't overwrite dirty ones)
for (final server in servers) {
final key = _getKey(server.id, server.serverType);
if (!dirtyKeys.contains(key)) {
await b.put(key, ServerHiveModel.fromServerModel(server));
}
}
}
@override
Future<void> clearAll() async {
final b = await box;
await b.clear();
}
}