initial commit
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../../core/models/models.dart';
|
||||
import '../../../core/models/severity_mapping.dart';
|
||||
import '../../../core/theme/theme_x.dart';
|
||||
import '../../../core/widgets/data_table_scaffold.dart';
|
||||
import '../../../core/widgets/empty_state.dart';
|
||||
import '../../../core/widgets/mono_text.dart';
|
||||
import '../../../core/widgets/status_pill.dart';
|
||||
|
||||
class BackupHistoryTable extends StatelessWidget {
|
||||
const BackupHistoryTable({super.key, required this.history, required this.targets});
|
||||
|
||||
final List<BackupExecution> history;
|
||||
final List<BackupTarget> targets;
|
||||
|
||||
String _targetName(String? targetId) {
|
||||
if (targetId == null) return '—';
|
||||
for (final t in targets) {
|
||||
if (t.id == targetId) return t.name;
|
||||
}
|
||||
return targetId;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final sorted = [...history]..sort((a, b) => b.timestamp.compareTo(a.timestamp));
|
||||
final timeFormat = DateFormat('yyyy-MM-dd HH:mm');
|
||||
|
||||
return DataTableScaffold(
|
||||
empty: const EmptyState(
|
||||
icon: Icons.cloud_outlined,
|
||||
title: 'No backup history yet',
|
||||
message: 'Run a backup to see execution results here.',
|
||||
),
|
||||
columns: const [
|
||||
DataColumn(label: Text('Timestamp')),
|
||||
DataColumn(label: Text('Target')),
|
||||
DataColumn(label: Text('Result')),
|
||||
DataColumn(label: Text('Duration')),
|
||||
DataColumn(label: Text('Message')),
|
||||
],
|
||||
rows: [
|
||||
for (final execution in sorted)
|
||||
DataRow(
|
||||
cells: [
|
||||
DataCell(MonoText(timeFormat.format(execution.timestamp.toLocal()))),
|
||||
DataCell(Text(_targetName(execution.targetId))),
|
||||
DataCell(
|
||||
StatusPill(
|
||||
label: execution.success ? 'success' : 'failed',
|
||||
severity: severityForSuccess(execution.success),
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
Text(
|
||||
'${execution.durationSeconds}s',
|
||||
style: context.dataStyles.numericTabular,
|
||||
),
|
||||
),
|
||||
DataCell(
|
||||
ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 340),
|
||||
child: MonoText(execution.message, small: true, maxLines: 1),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user