Files
geutebruck/geutebruck_app/lib/main.dart
Administrator 14893e62a5 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>
2025-12-31 18:10:54 +01:00

198 lines
6.0 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'injection.dart' as di;
import 'presentation/blocs/auth/auth_bloc.dart';
import 'presentation/blocs/auth/auth_event.dart';
import 'presentation/blocs/auth/auth_state.dart';
import 'presentation/blocs/server/server_bloc.dart';
import 'presentation/blocs/server/server_event.dart';
import 'presentation/blocs/action_mapping/action_mapping_bloc.dart';
import 'presentation/blocs/action_mapping/action_mapping_event.dart';
import 'presentation/screens/auth/login_screen.dart';
import 'presentation/screens/servers/server_list_screen.dart';
import 'presentation/screens/servers/servers_management_screen.dart';
import 'presentation/screens/servers/server_form_screen.dart';
import 'presentation/screens/action_mappings/action_mappings_list_screen.dart';
import 'presentation/screens/action_mappings/action_mapping_form_screen.dart';
import 'domain/entities/server.dart';
import 'domain/entities/action_mapping.dart';
import 'data/models/server_hive_model.dart';
import 'data/models/action_mapping_hive_model.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize Hive for local storage
await Hive.initFlutter();
// Register Hive adapters
Hive.registerAdapter(ServerHiveModelAdapter());
Hive.registerAdapter(ActionMappingHiveModelAdapter());
// Initialize dependency injection
await di.init();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (_) => di.sl<AuthBloc>()..add(const CheckAuthStatus()),
child: MaterialApp.router(
title: 'GeViAPI - Video Management System',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.blue,
brightness: Brightness.light,
),
useMaterial3: true,
appBarTheme: const AppBarTheme(
centerTitle: false,
elevation: 2,
),
cardTheme: CardThemeData(
elevation: 4,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ElevatedButton.styleFrom(
elevation: 2,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
inputDecorationTheme: InputDecorationTheme(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
routerConfig: _router,
),
);
}
}
final _router = GoRouter(
routes: [
GoRoute(
path: '/login',
builder: (context, state) => BlocProvider.value(
value: context.read<AuthBloc>(),
child: const LoginScreen(),
),
),
GoRoute(
path: '/',
builder: (context, state) => BlocProvider.value(
value: context.read<AuthBloc>(),
child: const ServerListScreen(),
),
),
ShellRoute(
builder: (context, state, child) => BlocProvider(
create: (_) => di.sl<ServerBloc>()..add(const LoadServers()),
child: child,
),
routes: [
GoRoute(
path: '/servers',
builder: (context, state) => const ServersManagementScreen(),
),
GoRoute(
path: '/servers/create',
builder: (context, state) {
final serverType = state.uri.queryParameters['type'] == 'geviscope'
? ServerType.geviscope
: ServerType.gcore;
return ServerFormScreen(serverType: serverType);
},
),
GoRoute(
path: '/servers/edit/:id',
builder: (context, state) {
final server = state.extra as Server;
return ServerFormScreen(server: server, serverType: server.type);
},
),
],
),
ShellRoute(
builder: (context, state, child) => BlocProvider(
create: (_) => di.sl<ActionMappingBloc>()..add(const LoadActionMappings()),
child: child,
),
routes: [
GoRoute(
path: '/action-mappings',
builder: (context, state) => const ActionMappingsListScreen(),
),
GoRoute(
path: '/action-mappings/create',
builder: (context, state) => const ActionMappingFormScreen(),
),
GoRoute(
path: '/action-mappings/edit/:id',
builder: (context, state) {
final mapping = state.extra as ActionMapping;
return ActionMappingFormScreen(mapping: mapping);
},
),
],
),
],
redirect: (context, state) {
final authBloc = context.read<AuthBloc>();
final authState = authBloc.state;
final isLoginRoute = state.matchedLocation == '/login';
if (authState is Authenticated) {
// If authenticated and trying to access login, redirect to home
if (isLoginRoute) {
return '/';
}
} else {
// If not authenticated and not on login page, redirect to login
if (!isLoginRoute) {
return '/login';
}
}
// No redirect needed
return null;
},
refreshListenable: GoRouterRefreshStream(
di.sl<AuthBloc>().stream,
),
);
class GoRouterRefreshStream extends ChangeNotifier {
GoRouterRefreshStream(Stream<dynamic> stream) {
notifyListeners();
_subscription = stream.asBroadcastStream().listen(
(dynamic _) => notifyListeners(),
);
}
late final StreamSubscription<dynamic> _subscription;
@override
void dispose() {
_subscription.cancel();
super.dispose();
}
}