초기 커밋
This commit is contained in:
@@ -0,0 +1,187 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
|
||||
class MonitoringPanel extends StatelessWidget {
|
||||
const MonitoringPanel({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'시스템 모니터링',
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Gap(16),
|
||||
_MonitoringItem(
|
||||
label: 'CPU 사용률',
|
||||
value: 0.45,
|
||||
displayValue: '45%',
|
||||
color: Colors.blue,
|
||||
),
|
||||
const Gap(12),
|
||||
_MonitoringItem(
|
||||
label: '메모리 사용률',
|
||||
value: 0.62,
|
||||
displayValue: '62%',
|
||||
color: Colors.orange,
|
||||
),
|
||||
const Gap(12),
|
||||
_MonitoringItem(
|
||||
label: '디스크 사용률',
|
||||
value: 0.35,
|
||||
displayValue: '35%',
|
||||
color: Colors.green,
|
||||
),
|
||||
const Gap(12),
|
||||
_MonitoringItem(
|
||||
label: '네트워크 I/O',
|
||||
value: 0.78,
|
||||
displayValue: '78 Mbps',
|
||||
color: Colors.purple,
|
||||
),
|
||||
const Gap(16),
|
||||
const Divider(),
|
||||
const Gap(12),
|
||||
|
||||
// 서비스 상태
|
||||
Text(
|
||||
'서비스 상태',
|
||||
style: theme.textTheme.titleSmall?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const Gap(12),
|
||||
const _ServiceStatus(
|
||||
name: 'API 서버',
|
||||
status: ServiceState.running,
|
||||
),
|
||||
const _ServiceStatus(
|
||||
name: 'WebSocket',
|
||||
status: ServiceState.running,
|
||||
),
|
||||
const _ServiceStatus(
|
||||
name: '데이터베이스',
|
||||
status: ServiceState.running,
|
||||
),
|
||||
const _ServiceStatus(
|
||||
name: '캐시 서버',
|
||||
status: ServiceState.warning,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _MonitoringItem extends StatelessWidget {
|
||||
const _MonitoringItem({
|
||||
required this.label,
|
||||
required this.value,
|
||||
required this.displayValue,
|
||||
required this.color,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final double value;
|
||||
final String displayValue;
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(label, style: theme.textTheme.bodyMedium),
|
||||
Text(
|
||||
displayValue,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Gap(6),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: LinearProgressIndicator(
|
||||
value: value,
|
||||
backgroundColor: color.withValues(alpha: 0.1),
|
||||
valueColor: AlwaysStoppedAnimation(color),
|
||||
minHeight: 8,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum ServiceState { running, stopped, warning }
|
||||
|
||||
class _ServiceStatus extends StatelessWidget {
|
||||
const _ServiceStatus({
|
||||
required this.name,
|
||||
required this.status,
|
||||
});
|
||||
|
||||
final String name;
|
||||
final ServiceState status;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final (color, label) = switch (status) {
|
||||
ServiceState.running => (Colors.green, '정상'),
|
||||
ServiceState.stopped => (Colors.red, '중지'),
|
||||
ServiceState.warning => (Colors.orange, '경고'),
|
||||
};
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 10,
|
||||
height: 10,
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const Gap(10),
|
||||
Expanded(
|
||||
child: Text(name, style: theme.textTheme.bodyMedium),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: color,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
182
lib/features/dashboard/presentation/widgets/realtime_chart.dart
Normal file
182
lib/features/dashboard/presentation/widgets/realtime_chart.dart
Normal file
@@ -0,0 +1,182 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
|
||||
class RealtimeChart extends StatefulWidget {
|
||||
const RealtimeChart({
|
||||
this.title = '실시간 데이터',
|
||||
this.dataStream,
|
||||
this.maxDataPoints = 30,
|
||||
this.lineColor,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final Stream<double>? dataStream;
|
||||
final int maxDataPoints;
|
||||
final Color? lineColor;
|
||||
|
||||
@override
|
||||
State<RealtimeChart> createState() => _RealtimeChartState();
|
||||
}
|
||||
|
||||
class _RealtimeChartState extends State<RealtimeChart> {
|
||||
final List<FlSpot> _spots = [];
|
||||
StreamSubscription<double>? _subscription;
|
||||
Timer? _mockTimer;
|
||||
int _index = 0;
|
||||
final _random = Random();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.dataStream != null) {
|
||||
_subscription = widget.dataStream!.listen(_addDataPoint);
|
||||
} else {
|
||||
// Mock 데이터 생성 (WebSocket 미연결 시)
|
||||
_mockTimer = Timer.periodic(const Duration(seconds: 1), (_) {
|
||||
_addDataPoint(50 + _random.nextDouble() * 50);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _addDataPoint(double value) {
|
||||
setState(() {
|
||||
_spots.add(FlSpot(_index.toDouble(), value));
|
||||
if (_spots.length > widget.maxDataPoints) {
|
||||
_spots.removeAt(0);
|
||||
}
|
||||
_index++;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_subscription?.cancel();
|
||||
_mockTimer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final color = widget.lineColor ?? theme.colorScheme.primary;
|
||||
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
widget.title,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.green.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 8,
|
||||
height: 8,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.green,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
const Gap(4),
|
||||
Text(
|
||||
'LIVE',
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: Colors.green,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Gap(16),
|
||||
Expanded(
|
||||
child: _spots.length < 2
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: LineChart(
|
||||
LineChartData(
|
||||
gridData: FlGridData(
|
||||
show: true,
|
||||
drawVerticalLine: false,
|
||||
horizontalInterval: 25,
|
||||
getDrawingHorizontalLine: (value) => FlLine(
|
||||
color: theme.colorScheme.outlineVariant
|
||||
.withValues(alpha: 0.3),
|
||||
strokeWidth: 1,
|
||||
),
|
||||
),
|
||||
titlesData: const FlTitlesData(
|
||||
topTitles: AxisTitles(
|
||||
sideTitles: SideTitles(showTitles: false),
|
||||
),
|
||||
rightTitles: AxisTitles(
|
||||
sideTitles: SideTitles(showTitles: false),
|
||||
),
|
||||
bottomTitles: AxisTitles(
|
||||
sideTitles: SideTitles(showTitles: false),
|
||||
),
|
||||
leftTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: true,
|
||||
reservedSize: 40,
|
||||
),
|
||||
),
|
||||
),
|
||||
borderData: FlBorderData(show: false),
|
||||
minY: 0,
|
||||
maxY: 100,
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
spots: _spots,
|
||||
isCurved: true,
|
||||
color: color,
|
||||
barWidth: 2,
|
||||
isStrokeCapRound: true,
|
||||
dotData: const FlDotData(show: false),
|
||||
belowBarData: BarAreaData(
|
||||
show: true,
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
color.withValues(alpha: 0.3),
|
||||
color.withValues(alpha: 0.0),
|
||||
],
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
duration: const Duration(milliseconds: 150),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
105
lib/features/dashboard/presentation/widgets/stats_card.dart
Normal file
105
lib/features/dashboard/presentation/widgets/stats_card.dart
Normal file
@@ -0,0 +1,105 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
|
||||
class StatsCard extends StatelessWidget {
|
||||
const StatsCard({
|
||||
required this.title,
|
||||
required this.value,
|
||||
this.icon,
|
||||
this.iconColor,
|
||||
this.change,
|
||||
this.isPositive,
|
||||
this.subtitle,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String value;
|
||||
final IconData? icon;
|
||||
final Color? iconColor;
|
||||
final String? change;
|
||||
final bool? isPositive;
|
||||
final String? subtitle;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
title,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
if (icon != null)
|
||||
Icon(
|
||||
icon,
|
||||
color: iconColor ?? theme.colorScheme.primary,
|
||||
size: 24,
|
||||
),
|
||||
],
|
||||
),
|
||||
const Gap(8),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
value,
|
||||
style: theme.textTheme.headlineMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
if (change != null) ...[
|
||||
const Gap(8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 6,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: (isPositive ?? true)
|
||||
? Colors.green.withValues(alpha: 0.1)
|
||||
: Colors.red.withValues(alpha: 0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
change!,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: (isPositive ?? true)
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
if (subtitle != null) ...[
|
||||
const Gap(4),
|
||||
Text(
|
||||
subtitle!,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user