Files
geutebruck/geutebruck_app/lib/data/models/action_template.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

175 lines
4.8 KiB
Dart

import 'package:equatable/equatable.dart';
/// Model representing an action template from the API
/// Used for dynamic form generation when selecting action types
class ActionTemplate extends Equatable {
final String actionName;
final List<String> parameters;
final String description;
final String category;
final bool requiredCaption;
final bool supportsDelay;
final Map<String, String>? parameterTypes;
const ActionTemplate({
required this.actionName,
required this.parameters,
required this.description,
required this.category,
this.requiredCaption = true,
this.supportsDelay = true,
this.parameterTypes,
});
factory ActionTemplate.fromJson(Map<String, dynamic> json) {
return ActionTemplate(
actionName: json['action_name'] as String,
parameters: (json['parameters'] as List<dynamic>)
.map((e) => e.toString())
.toList(),
description: json['description'] as String,
category: json['category'] as String,
requiredCaption: json['required_caption'] as bool? ?? true,
supportsDelay: json['supports_delay'] as bool? ?? true,
parameterTypes: json['parameter_types'] != null
? Map<String, String>.from(json['parameter_types'] as Map)
: null,
);
}
Map<String, dynamic> toJson() {
return {
'action_name': actionName,
'parameters': parameters,
'description': description,
'category': category,
'required_caption': requiredCaption,
'supports_delay': supportsDelay,
if (parameterTypes != null) 'parameter_types': parameterTypes,
};
}
@override
List<Object?> get props => [
actionName,
parameters,
description,
category,
requiredCaption,
supportsDelay,
parameterTypes,
];
}
/// Model representing a server (G-Core or GeViScope)
class ServerInfo extends Equatable {
final String id;
final String alias;
final bool enabled;
const ServerInfo({
required this.id,
required this.alias,
required this.enabled,
});
factory ServerInfo.fromJson(Map<String, dynamic> json) {
return ServerInfo(
id: json['id'].toString(),
alias: json['alias'] as String,
enabled: json['enabled'] as bool,
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'alias': alias,
'enabled': enabled,
};
}
@override
List<Object?> get props => [id, alias, enabled];
}
/// Model for servers information
class ServersInfo extends Equatable {
final List<ServerInfo> gcoreServers;
final List<ServerInfo> gscServers;
const ServersInfo({
required this.gcoreServers,
required this.gscServers,
});
factory ServersInfo.fromJson(Map<String, dynamic> json) {
return ServersInfo(
gcoreServers: (json['gcore_servers'] as List<dynamic>?)
?.map((e) => ServerInfo.fromJson(e as Map<String, dynamic>))
.toList() ??
[],
gscServers: (json['gsc_servers'] as List<dynamic>?)
?.map((e) => ServerInfo.fromJson(e as Map<String, dynamic>))
.toList() ??
[],
);
}
@override
List<Object?> get props => [gcoreServers, gscServers];
}
/// Model for action categories response
class ActionCategoriesResponse extends Equatable {
final Map<String, List<String>> categories;
final int totalCategories;
final int totalActions;
final ServersInfo servers;
final List<String> gscSpecificCategories;
const ActionCategoriesResponse({
required this.categories,
required this.totalCategories,
required this.totalActions,
required this.servers,
this.gscSpecificCategories = const [],
});
factory ActionCategoriesResponse.fromJson(Map<String, dynamic> json) {
final categoriesMap = json['categories'] as Map<String, dynamic>;
final categories = categoriesMap.map(
(key, value) => MapEntry(
key,
(value as List<dynamic>).map((e) => e.toString()).toList(),
),
);
return ActionCategoriesResponse(
categories: categories,
totalCategories: json['total_categories'] as int,
totalActions: json['total_actions'] as int,
servers: ServersInfo.fromJson(json['servers'] as Map<String, dynamic>? ?? {}),
gscSpecificCategories: (json['gsc_specific_categories'] as List<dynamic>?)
?.map((e) => e.toString())
.toList() ??
[],
);
}
/// Get all action names sorted by category
List<String> getActionsForCategory(String category) {
return categories[category] ?? [];
}
/// Get list of all category names sorted
List<String> get categoryNames {
final names = categories.keys.toList();
names.sort();
return names;
}
@override
List<Object?> get props => [categories, totalCategories, totalActions, servers, gscSpecificCategories];
}