feat: 대시보드에 라이선스 만료 요약 및 Lookup 데이터 캐싱 시스템 구현
- License Expiry Summary API 연동 완료 - 30/60/90일 내 만료 예정 라이선스 요약 표시 - 대시보드 상단에 알림 카드로 통합 - 만료 임박 순서로 색상 구분 (빨강/주황/노랑) - Lookup 데이터 전역 캐싱 시스템 구축 - LookupService 및 RemoteDataSource 생성 - 전체 lookup 데이터 일괄 로드 및 캐싱 - 타입별 필터링 지원 - 새로운 모델 추가 - LicenseExpirySummary (Freezed) - LookupData, LookupCategory, LookupItem 모델 - CLAUDE.md 문서 업데이트 - 미사용 API 활용 계획 추가 - 구현 우선순위 정의 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:superport/data/models/dashboard/equipment_status_distribution.dart';
|
||||
import 'package:superport/data/models/dashboard/expiring_license.dart';
|
||||
import 'package:superport/data/models/dashboard/license_expiry_summary.dart';
|
||||
import 'package:superport/data/models/dashboard/overview_stats.dart';
|
||||
import 'package:superport/data/models/dashboard/recent_activity.dart';
|
||||
import 'package:superport/services/dashboard_service.dart';
|
||||
@@ -17,35 +18,53 @@ class OverviewController extends ChangeNotifier {
|
||||
List<RecentActivity> _recentActivities = [];
|
||||
EquipmentStatusDistribution? _equipmentStatus;
|
||||
List<ExpiringLicense> _expiringLicenses = [];
|
||||
LicenseExpirySummary? _licenseExpirySummary;
|
||||
|
||||
// 로딩 상태
|
||||
bool _isLoadingStats = false;
|
||||
bool _isLoadingActivities = false;
|
||||
bool _isLoadingEquipmentStatus = false;
|
||||
bool _isLoadingLicenses = false;
|
||||
bool _isLoadingLicenseExpiry = false;
|
||||
|
||||
// 에러 상태
|
||||
String? _statsError;
|
||||
String? _activitiesError;
|
||||
String? _equipmentStatusError;
|
||||
String? _licensesError;
|
||||
String? _licenseExpiryError;
|
||||
|
||||
// Getters
|
||||
OverviewStats? get overviewStats => _overviewStats;
|
||||
List<RecentActivity> get recentActivities => _recentActivities;
|
||||
EquipmentStatusDistribution? get equipmentStatus => _equipmentStatus;
|
||||
List<ExpiringLicense> get expiringLicenses => _expiringLicenses;
|
||||
LicenseExpirySummary? get licenseExpirySummary => _licenseExpirySummary;
|
||||
|
||||
// 추가 getter
|
||||
int get totalCompanies => _overviewStats?.totalCompanies ?? 0;
|
||||
int get totalUsers => _overviewStats?.totalUsers ?? 0;
|
||||
|
||||
bool get isLoading => _isLoadingStats || _isLoadingActivities ||
|
||||
_isLoadingEquipmentStatus || _isLoadingLicenses;
|
||||
_isLoadingEquipmentStatus || _isLoadingLicenses ||
|
||||
_isLoadingLicenseExpiry;
|
||||
|
||||
String? get error {
|
||||
return _statsError ?? _activitiesError ??
|
||||
_equipmentStatusError ?? _licensesError;
|
||||
_equipmentStatusError ?? _licensesError ?? _licenseExpiryError;
|
||||
}
|
||||
|
||||
// 라이선스 만료 알림 여부
|
||||
bool get hasExpiringLicenses {
|
||||
if (_licenseExpirySummary == null) return false;
|
||||
return (_licenseExpirySummary!.within30Days > 0 ||
|
||||
_licenseExpirySummary!.expired > 0);
|
||||
}
|
||||
|
||||
// 긴급 라이선스 수 (30일 이내 또는 만료)
|
||||
int get urgentLicenseCount {
|
||||
if (_licenseExpirySummary == null) return 0;
|
||||
return _licenseExpirySummary!.within30Days + _licenseExpirySummary!.expired;
|
||||
}
|
||||
|
||||
OverviewController();
|
||||
@@ -58,6 +77,7 @@ class OverviewController extends ChangeNotifier {
|
||||
_loadRecentActivities(),
|
||||
_loadEquipmentStatus(),
|
||||
_loadExpiringLicenses(),
|
||||
_loadLicenseExpirySummary(),
|
||||
], eagerError: false); // 하나의 작업이 실패해도 다른 작업 계속 진행
|
||||
} catch (e) {
|
||||
DebugLogger.logError('대시보드 데이터 로드 중 오류', error: e);
|
||||
@@ -233,6 +253,38 @@ class OverviewController extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> _loadLicenseExpirySummary() async {
|
||||
_isLoadingLicenseExpiry = true;
|
||||
_licenseExpiryError = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
final result = await _dashboardService.getLicenseExpirySummary();
|
||||
|
||||
result.fold(
|
||||
(failure) {
|
||||
_licenseExpiryError = failure.message;
|
||||
DebugLogger.logError('라이선스 만료 요약 로드 실패', error: failure.message);
|
||||
},
|
||||
(summary) {
|
||||
_licenseExpirySummary = summary;
|
||||
DebugLogger.log('라이선스 만료 요약 로드 성공', tag: 'DASHBOARD', data: {
|
||||
'within30Days': summary.within30Days,
|
||||
'within60Days': summary.within60Days,
|
||||
'within90Days': summary.within90Days,
|
||||
'expired': summary.expired,
|
||||
});
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
_licenseExpiryError = '라이선스 만료 요약을 불러올 수 없습니다';
|
||||
DebugLogger.logError('라이선스 만료 요약 로드 예외', error: e);
|
||||
}
|
||||
|
||||
_isLoadingLicenseExpiry = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// 활동 타입별 아이콘과 색상 가져오기
|
||||
IconData getActivityIcon(String activityType) {
|
||||
switch (activityType.toLowerCase()) {
|
||||
|
||||
@@ -55,6 +55,12 @@ class _OverviewScreenRedesignState extends State<OverviewScreenRedesign> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 라이선스 만료 알림 배너 (조건부 표시)
|
||||
if (controller.hasExpiringLicenses) ...[
|
||||
_buildLicenseExpiryBanner(controller),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
|
||||
// 환영 섹션
|
||||
ShadcnCard(
|
||||
padding: const EdgeInsets.all(32),
|
||||
@@ -375,6 +381,82 @@ class _OverviewScreenRedesignState extends State<OverviewScreenRedesign> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLicenseExpiryBanner(OverviewController controller) {
|
||||
final summary = controller.licenseExpirySummary;
|
||||
if (summary == null) return const SizedBox.shrink();
|
||||
|
||||
Color bannerColor = ShadcnTheme.warning;
|
||||
String bannerText = '';
|
||||
IconData bannerIcon = Icons.warning_amber_rounded;
|
||||
|
||||
if (summary.expired > 0) {
|
||||
bannerColor = ShadcnTheme.destructive;
|
||||
bannerText = '${summary.expired}개 라이선스 만료';
|
||||
bannerIcon = Icons.error_outline;
|
||||
} else if (summary.within30Days > 0) {
|
||||
bannerColor = ShadcnTheme.warning;
|
||||
bannerText = '${summary.within30Days}개 라이선스 30일 내 만료 예정';
|
||||
bannerIcon = Icons.warning_amber_rounded;
|
||||
} else if (summary.within60Days > 0) {
|
||||
bannerColor = ShadcnTheme.primary;
|
||||
bannerText = '${summary.within60Days}개 라이선스 60일 내 만료 예정';
|
||||
bannerIcon = Icons.info_outline;
|
||||
}
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: bannerColor.withValues(alpha: 0.1),
|
||||
border: Border.all(color: bannerColor.withValues(alpha: 0.3)),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(bannerIcon, color: bannerColor, size: 24),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'라이선스 관리 필요',
|
||||
style: ShadcnTheme.bodyMedium.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: bannerColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
bannerText,
|
||||
style: ShadcnTheme.bodySmall.copyWith(
|
||||
color: ShadcnTheme.foreground,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
// 라이선스 목록 페이지로 이동
|
||||
Navigator.pushNamed(context, '/licenses');
|
||||
},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'상세 보기',
|
||||
style: TextStyle(color: bannerColor),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Icon(Icons.arrow_forward, color: bannerColor, size: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatCard(
|
||||
String title,
|
||||
String value,
|
||||
|
||||
Reference in New Issue
Block a user