- Upgrade flutter_riverpod to 3.1.0, riverpod_annotation to 4.0.0 - Upgrade freezed to 3.2.3, freezed_annotation to 3.1.0 - Migrate freezed classes to use sealed keyword (freezed 3.x) - Update provider naming (*NotifierProvider → *Provider) - Add legacy.dart import for StateNotifierProvider compatibility - Fix valueOrNull → value for AsyncValue - Remove unused imports and fields - Add sync from Authentik button to users/groups pages - Suppress invalid_annotation_target warning in analysis_options 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
62 lines
1.9 KiB
Dart
62 lines
1.9 KiB
Dart
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
import 'package:tatlock_ui/features/control_room/stacks/domain/entities/stack.dart';
|
|
|
|
part 'stack_model.freezed.dart';
|
|
part 'stack_model.g.dart';
|
|
|
|
/// Stack data model for API serialization.
|
|
@freezed
|
|
sealed class StackModel with _$StackModel {
|
|
const factory StackModel({
|
|
required String id,
|
|
required String name,
|
|
@JsonKey(name: 'type') String? typeString,
|
|
@JsonKey(name: 'status') String? statusString,
|
|
@JsonKey(name: 'container_count') @Default(0) int containerCount,
|
|
@JsonKey(name: 'running_count') @Default(0) int runningCount,
|
|
@JsonKey(name: 'compose_file') String? composeFile,
|
|
String? environment,
|
|
@JsonKey(name: 'created_at') String? createdAt,
|
|
@JsonKey(name: 'updated_at') String? updatedAt,
|
|
}) = _StackModel;
|
|
|
|
const StackModel._();
|
|
|
|
factory StackModel.fromJson(Map<String, dynamic> json) =>
|
|
_$StackModelFromJson(json);
|
|
|
|
/// Converts to domain entity.
|
|
Stack toEntity() {
|
|
return Stack(
|
|
id: id,
|
|
name: name,
|
|
type: _parseStackType(typeString),
|
|
status: _parseStackStatus(statusString),
|
|
containerCount: containerCount,
|
|
runningCount: runningCount,
|
|
composeFile: composeFile,
|
|
environment: environment,
|
|
createdAt: createdAt != null ? DateTime.tryParse(createdAt!) : null,
|
|
updatedAt: updatedAt != null ? DateTime.tryParse(updatedAt!) : null,
|
|
);
|
|
}
|
|
|
|
StackType _parseStackType(String? type) {
|
|
return switch (type?.toLowerCase()) {
|
|
'compose' => StackType.compose,
|
|
'swarm' => StackType.swarm,
|
|
'kubernetes' || 'k8s' => StackType.kubernetes,
|
|
_ => StackType.compose,
|
|
};
|
|
}
|
|
|
|
StackStatus _parseStackStatus(String? status) {
|
|
return switch (status?.toLowerCase()) {
|
|
'active' || 'running' => StackStatus.active,
|
|
'inactive' || 'stopped' => StackStatus.inactive,
|
|
'error' => StackStatus.error,
|
|
_ => StackStatus.unknown,
|
|
};
|
|
}
|
|
}
|