web: migrate health notifications to js_interop; add browser hook
- Replace dart:js with package:js in health_check_service_web.dart\n- Implement showHealthCheckNotification in web/index.html\n- Pin js dependency to ^0.6.7 for flutter_secure_storage_web compatibility auth: harden AuthInterceptor + tests - Allow overrideAuthRepository injection for testing\n- Normalize imports to package: paths\n- Add unit test covering token attach, 401→refresh→retry, and failure path\n- Add integration test skeleton gated by env vars ui/data: map User.companyName to list column - Add companyName to domain User\n- Map UserDto.company?.name\n- Render companyName in user_list cleanup: remove legacy equipment table + unused code; minor warnings - Remove _buildFlexibleTable and unused helpers\n- Remove unused zipcode details and cache retry constant\n- Fix null-aware and non-null assertions\n- Address child-last warnings in administrator dialog docs: update AGENTS.md session context
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:superport/screens/model/controllers/model_controller.dart';
|
||||
import 'package:superport/screens/model/model_form_dialog.dart';
|
||||
import 'package:superport/screens/common/layouts/base_list_screen.dart';
|
||||
import 'package:superport/screens/common/widgets/standard_action_bar.dart';
|
||||
import 'package:superport/screens/common/widgets/pagination.dart';
|
||||
import 'package:superport/screens/common/theme_shadcn.dart';
|
||||
import 'package:superport/injection_container.dart' as di;
|
||||
|
||||
@@ -18,6 +19,10 @@ class ModelListScreen extends StatefulWidget {
|
||||
|
||||
class _ModelListScreenState extends State<ModelListScreen> {
|
||||
late final ModelController _controller;
|
||||
|
||||
// 클라이언트 사이드 페이지네이션
|
||||
int _currentPage = 1;
|
||||
static const int _pageSize = 10;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -28,6 +33,33 @@ class _ModelListScreenState extends State<ModelListScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
// 현재 페이지의 모델 목록 반환
|
||||
List<ModelDto> _getCurrentPageModels() {
|
||||
final allModels = _controller.models;
|
||||
final startIndex = (_currentPage - 1) * _pageSize;
|
||||
final endIndex = startIndex + _pageSize;
|
||||
|
||||
if (startIndex >= allModels.length) return [];
|
||||
if (endIndex >= allModels.length) return allModels.sublist(startIndex);
|
||||
|
||||
return allModels.sublist(startIndex, endIndex);
|
||||
}
|
||||
|
||||
// 총 페이지 수 계산
|
||||
int _getTotalPages() {
|
||||
return (_controller.models.length / _pageSize).ceil();
|
||||
}
|
||||
|
||||
// 페이지 이동
|
||||
void _goToPage(int page) {
|
||||
final totalPages = _getTotalPages();
|
||||
if (page < 1 || page > totalPages) return;
|
||||
|
||||
setState(() {
|
||||
_currentPage = page;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChangeNotifierProvider.value(
|
||||
@@ -78,21 +110,21 @@ class _ModelListScreenState extends State<ModelListScreen> {
|
||||
'전체 모델',
|
||||
controller.models.length.toString(),
|
||||
Icons.category,
|
||||
ShadcnTheme.primary,
|
||||
ShadcnTheme.companyCustomer,
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing4),
|
||||
_buildStatCard(
|
||||
'제조사',
|
||||
controller.vendors.length.toString(),
|
||||
Icons.business,
|
||||
ShadcnTheme.success,
|
||||
ShadcnTheme.companyPartner,
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing4),
|
||||
_buildStatCard(
|
||||
'활성 모델',
|
||||
controller.models.where((m) => !m.isDeleted).length.toString(),
|
||||
Icons.check_circle,
|
||||
ShadcnTheme.info,
|
||||
ShadcnTheme.equipmentIn,
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -105,7 +137,12 @@ class _ModelListScreenState extends State<ModelListScreen> {
|
||||
flex: 2,
|
||||
child: ShadInput(
|
||||
placeholder: const Text('모델명 검색...'),
|
||||
onChanged: controller.setSearchQuery,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_currentPage = 1; // 검색 시 첫 페이지로 리셋
|
||||
});
|
||||
controller.setSearchQuery(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing4),
|
||||
@@ -135,7 +172,12 @@ class _ModelListScreenState extends State<ModelListScreen> {
|
||||
return const Text('전체');
|
||||
}
|
||||
},
|
||||
onChanged: controller.setVendorFilter,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_currentPage = 1; // 필터 변경 시 첫 페이지로 리셋
|
||||
});
|
||||
controller.setVendorFilter(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -169,200 +211,121 @@ class _ModelListScreenState extends State<ModelListScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
/// 헤더 셀 빌더
|
||||
Widget _buildHeaderCell(
|
||||
String text, {
|
||||
required int flex,
|
||||
required bool useExpanded,
|
||||
required double minWidth,
|
||||
}) {
|
||||
final child = Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
text,
|
||||
style: ShadcnTheme.bodyMedium.copyWith(fontWeight: FontWeight.w500),
|
||||
),
|
||||
);
|
||||
|
||||
if (useExpanded) {
|
||||
return Expanded(flex: flex, child: child);
|
||||
} else {
|
||||
return SizedBox(width: minWidth, child: child);
|
||||
}
|
||||
}
|
||||
|
||||
/// 데이터 셀 빌더
|
||||
Widget _buildDataCell(
|
||||
Widget child, {
|
||||
required int flex,
|
||||
required bool useExpanded,
|
||||
required double minWidth,
|
||||
}) {
|
||||
final container = Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: child,
|
||||
);
|
||||
|
||||
if (useExpanded) {
|
||||
return Expanded(flex: flex, child: container);
|
||||
} else {
|
||||
return SizedBox(width: minWidth, child: container);
|
||||
}
|
||||
}
|
||||
|
||||
/// 헤더 셀 리스트
|
||||
List<Widget> _buildHeaderCells() {
|
||||
return [
|
||||
_buildHeaderCell('ID', flex: 0, useExpanded: false, minWidth: 60),
|
||||
_buildHeaderCell('제조사', flex: 2, useExpanded: true, minWidth: 100),
|
||||
_buildHeaderCell('모델명', flex: 3, useExpanded: true, minWidth: 120),
|
||||
_buildHeaderCell('등록일', flex: 2, useExpanded: true, minWidth: 100),
|
||||
_buildHeaderCell('상태', flex: 0, useExpanded: false, minWidth: 80),
|
||||
_buildHeaderCell('작업', flex: 0, useExpanded: false, minWidth: 100),
|
||||
];
|
||||
}
|
||||
|
||||
/// 테이블 행 빌더
|
||||
Widget _buildTableRow(ModelDto model, int index) {
|
||||
final vendor = _controller.getVendorById(model.vendorsId);
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: index.isEven
|
||||
? ShadcnTheme.muted.withValues(alpha: 0.1)
|
||||
: null,
|
||||
border: const Border(
|
||||
bottom: BorderSide(color: Colors.black),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildDataCell(
|
||||
Text(
|
||||
model.id.toString(),
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
flex: 0,
|
||||
useExpanded: false,
|
||||
minWidth: 60,
|
||||
),
|
||||
_buildDataCell(
|
||||
Text(
|
||||
vendor?.name ?? '알 수 없음',
|
||||
style: ShadcnTheme.bodyMedium,
|
||||
),
|
||||
flex: 2,
|
||||
useExpanded: true,
|
||||
minWidth: 100,
|
||||
),
|
||||
_buildDataCell(
|
||||
Text(
|
||||
model.name,
|
||||
style: ShadcnTheme.bodyMedium.copyWith(
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
flex: 3,
|
||||
useExpanded: true,
|
||||
minWidth: 120,
|
||||
),
|
||||
_buildDataCell(
|
||||
Text(
|
||||
model.registeredAt != null
|
||||
? DateFormat('yyyy-MM-dd').format(model.registeredAt)
|
||||
: '-',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
flex: 2,
|
||||
useExpanded: true,
|
||||
minWidth: 100,
|
||||
),
|
||||
_buildDataCell(
|
||||
_buildStatusChip(model.isDeleted),
|
||||
flex: 0,
|
||||
useExpanded: false,
|
||||
minWidth: 80,
|
||||
),
|
||||
_buildDataCell(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _showEditDialog(model),
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _showDeleteConfirmDialog(model),
|
||||
child: const Icon(Icons.delete, size: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
flex: 0,
|
||||
useExpanded: false,
|
||||
minWidth: 100,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDataTable(ModelController controller) {
|
||||
final models = controller.models;
|
||||
final allModels = controller.models;
|
||||
final currentPageModels = _getCurrentPageModels();
|
||||
|
||||
if (allModels.isEmpty) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.category_outlined,
|
||||
size: 64,
|
||||
color: ShadcnTheme.mutedForeground,
|
||||
),
|
||||
const SizedBox(height: ShadcnTheme.spacing4),
|
||||
Text(
|
||||
'등록된 모델이 없습니다',
|
||||
style: ShadcnTheme.bodyMedium.copyWith(
|
||||
color: ShadcnTheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.black),
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// 고정 헤더
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.muted.withValues(alpha: 0.3),
|
||||
border: Border(bottom: BorderSide(color: Colors.black)),
|
||||
),
|
||||
child: Row(children: _buildHeaderCells()),
|
||||
),
|
||||
// 스크롤 바디
|
||||
Expanded(
|
||||
child: models.isEmpty
|
||||
? Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.category_outlined,
|
||||
size: 64,
|
||||
color: ShadcnTheme.mutedForeground,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'등록된 모델이 없습니다',
|
||||
style: ShadcnTheme.bodyMedium.copyWith(
|
||||
color: ShadcnTheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
],
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: ShadTable.list(
|
||||
header: const [
|
||||
ShadTableCell.header(child: Text('ID')),
|
||||
ShadTableCell.header(child: Text('제조사')),
|
||||
ShadTableCell.header(child: Text('모델명')),
|
||||
ShadTableCell.header(child: Text('등록일')),
|
||||
ShadTableCell.header(child: Text('상태')),
|
||||
ShadTableCell.header(child: Text('작업')),
|
||||
],
|
||||
children: currentPageModels.map((model) {
|
||||
final vendor = _controller.getVendorById(model.vendorsId);
|
||||
return [
|
||||
ShadTableCell(child: Text(model.id.toString(), style: ShadcnTheme.bodySmall)),
|
||||
ShadTableCell(child: Text(vendor?.name ?? '알 수 없음', overflow: TextOverflow.ellipsis)),
|
||||
ShadTableCell(child: Text(model.name, overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodyMedium.copyWith(fontWeight: FontWeight.w500))),
|
||||
ShadTableCell(child: Text(model.registeredAt != null ? DateFormat('yyyy-MM-dd').format(model.registeredAt) : '-', style: ShadcnTheme.bodySmall)),
|
||||
ShadTableCell(child: _buildStatusChip(model.isDeleted)),
|
||||
ShadTableCell(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _showEditDialog(model),
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: models.length,
|
||||
itemBuilder: (context, index) => _buildTableRow(models[index], index),
|
||||
),
|
||||
),
|
||||
],
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _showDeleteConfirmDialog(model),
|
||||
child: Icon(Icons.delete, size: 16, color: ShadcnTheme.destructive),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
];
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget _buildPagination(ModelController controller) {
|
||||
// 모델 목록은 현재 페이지네이션이 없는 것 같으니 빈 위젯 반환
|
||||
return const SizedBox();
|
||||
final totalCount = controller.models.length;
|
||||
final totalPages = _getTotalPages();
|
||||
|
||||
if (totalCount <= _pageSize) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(ShadcnTheme.spacing3),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.card,
|
||||
border: Border(
|
||||
top: BorderSide(color: ShadcnTheme.border),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'총 $totalCount개 모델',
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(ShadcnTheme.spacing3),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.card,
|
||||
border: Border(
|
||||
top: BorderSide(color: ShadcnTheme.border),
|
||||
),
|
||||
),
|
||||
child: Pagination(
|
||||
totalCount: totalCount,
|
||||
currentPage: _currentPage,
|
||||
pageSize: _pageSize,
|
||||
onPageChanged: _goToPage,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatCard(
|
||||
@@ -416,11 +379,15 @@ class _ModelListScreenState extends State<ModelListScreen> {
|
||||
|
||||
Widget _buildStatusChip(bool isDeleted) {
|
||||
if (isDeleted) {
|
||||
return ShadBadge.destructive(
|
||||
return ShadBadge(
|
||||
backgroundColor: ShadcnTheme.equipmentDisposal.withValues(alpha: 0.1),
|
||||
foregroundColor: ShadcnTheme.equipmentDisposal,
|
||||
child: const Text('비활성'),
|
||||
);
|
||||
} else {
|
||||
return ShadBadge.secondary(
|
||||
return ShadBadge(
|
||||
backgroundColor: ShadcnTheme.equipmentIn.withValues(alpha: 0.1),
|
||||
foregroundColor: ShadcnTheme.equipmentIn,
|
||||
child: const Text('활성'),
|
||||
);
|
||||
}
|
||||
@@ -467,4 +434,4 @@ class _ModelListScreenState extends State<ModelListScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user