Files
tatlock-ui/lib/features/front_hall/data/models/quick_link_model.dart
T
Jeroen SchweitzerandClaude Opus 4.5 bdced8739c
Build and Push / build (release) Successful in 3m6s
chore: release v0.3.3
Features:
- Health check endpoint for Portainer monitoring
- Local search filtering in DataGrid
- Container status badges reflect health (green/orange/blue)

Improvements:
- Standardized 56px header heights across panels
- Container grid parses Docker API format correctly
- Search bar styling improvements
- Status badges have consistent width

Fixes:
- Quick links persistence (link type, form refresh)
- Iframe switching closes existing content first
- ContainerState type conflict resolved

Branding:
- Updated favicon and icons with Tatlock bucket logo

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 16:12:18 +01:00

80 lines
2.3 KiB
Dart

import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:tatlock_ui/features/front_hall/domain/entities/quick_link.dart';
part 'quick_link_model.freezed.dart';
part 'quick_link_model.g.dart';
/// Quick link data model matching Core API dashboard/quick-links endpoint.
///
/// Field mapping:
/// - title (API) ↔ name (Flutter entity)
/// - icon (API) ↔ iconName (Flutter entity)
/// - position (API) ↔ sortOrder (Flutter entity)
/// - is_visible (API) ↔ isActive (Flutter entity)
/// - link_type (API) ↔ type (Flutter entity)
@freezed
sealed class QuickLinkModel with _$QuickLinkModel {
const factory QuickLinkModel({
@Default(0) int id,
required String title,
required String url,
String? icon,
String? description,
String? category,
@Default(0) int position,
@JsonKey(name: 'is_visible') @Default(true) bool isVisible,
@JsonKey(name: 'link_type') @Default('iframe') String linkType,
String? color,
@JsonKey(name: 'background_color') String? backgroundColor,
}) = _QuickLinkModel;
const QuickLinkModel._();
factory QuickLinkModel.fromJson(Map<String, dynamic> json) =>
_$QuickLinkModelFromJson(json);
/// Converts to domain entity.
QuickLink toEntity() {
return QuickLink(
id: id.toString(),
name: title,
url: url,
iconName: icon ?? 'link',
category: category,
type: _parseQuickLinkType(linkType),
sortOrder: position,
isActive: isVisible,
);
}
/// Creates model from domain entity.
factory QuickLinkModel.fromEntity(QuickLink entity) {
return QuickLinkModel(
id: int.tryParse(entity.id) ?? 0,
title: entity.name,
url: entity.url,
icon: entity.iconName,
category: entity.category,
position: entity.sortOrder,
isVisible: entity.isActive,
linkType: _formatQuickLinkType(entity.type),
);
}
}
/// Parses API link_type string to QuickLinkType enum.
QuickLinkType _parseQuickLinkType(String linkType) {
return switch (linkType) {
'new_tab' => QuickLinkType.newTab,
_ => QuickLinkType.iframe,
};
}
/// Formats QuickLinkType enum to API link_type string.
String _formatQuickLinkType(QuickLinkType type) {
return switch (type) {
QuickLinkType.newTab => 'new_tab',
QuickLinkType.iframe => 'iframe',
};
}