[pve-devel] [PATCH pve-flutter-frontend 8/9] task logs: use separate color for warnings

Dominik Csapak d.csapak at proxmox.com
Fri Apr 12 10:04:57 CEST 2024


orange instead of red, so one can differentiate between error and
warnings better.

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 .../pve_task_log_expansiontile_widget.dart        | 15 +++++++++++----
 lib/widgets/pve_task_log_widget.dart              |  5 ++++-
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/lib/widgets/pve_task_log_expansiontile_widget.dart b/lib/widgets/pve_task_log_expansiontile_widget.dart
index 2073840..2ff5eb2 100644
--- a/lib/widgets/pve_task_log_expansiontile_widget.dart
+++ b/lib/widgets/pve_task_log_expansiontile_widget.dart
@@ -36,8 +36,10 @@ class _PveTaskExpansionTileState extends State<PveTaskExpansionTile> {
 
   @override
   Widget build(BuildContext context) {
-    final hasError =
-        widget.task.status != 'RUNNING' && widget.task.status != "OK";
+    final hasWarnings = widget.task.status.startsWith('WARNINGS:');
+    final hasError = widget.task.status != 'RUNNING' &&
+        widget.task.status != "OK" &&
+        !hasWarnings;
     final isFinished = widget.task.endTime != null;
     final taskLogBloc = Provider.of<PveTaskLogBloc>(context);
     Duration duration;
@@ -48,6 +50,7 @@ class _PveTaskExpansionTileState extends State<PveTaskExpansionTile> {
     }
     final colorScheme = Theme.of(context).colorScheme;
     final errorColor = widget.errorColor ?? colorScheme.error;
+    final warningColor = Colors.orange.shade200;
     final headerColor = isExpanded
         ? (widget.headerColorExpanded ?? colorScheme.onSurface)
         : (widget.headerColor ?? colorScheme.onBackground);
@@ -64,8 +67,12 @@ class _PveTaskExpansionTileState extends State<PveTaskExpansionTile> {
       collapsedBackgroundColor: Theme.of(context).colorScheme.background,
       key: PageStorageKey<PveClusterTasksModel>(widget.task),
       leading: Icon(
-        hasError ? Icons.warning : Icons.info,
-        color: hasError ? errorColor : headerColor,
+        hasError || hasWarnings ? Icons.warning : Icons.info,
+        color: hasError
+            ? errorColor
+            : hasWarnings
+                ? warningColor
+                : headerColor,
       ),
       title: Text(
         '$taskText: ${widget.task.type}',
diff --git a/lib/widgets/pve_task_log_widget.dart b/lib/widgets/pve_task_log_widget.dart
index 97cbf03..5a12676 100644
--- a/lib/widgets/pve_task_log_widget.dart
+++ b/lib/widgets/pve_task_log_widget.dart
@@ -198,12 +198,15 @@ class _PveTaskLogScrollViewState extends State<PveTaskLogScrollView> {
       child: ProxmoxStreamBuilder<PveTaskLogViewerBloc, PveTaskLogViewerState>(
           bloc: Provider.of<PveTaskLogViewerBloc>(context),
           builder: (context, state) {
-            // TODO: fix color (for dark theme) and better handle warnings
             var indicatorColor = Colors.teal.shade500;
             var statusChipColor = Colors.teal.shade100;
             if (state.status?.failed ?? false) {
               indicatorColor = Colors.red;
               statusChipColor = Colors.red.shade100;
+            } else if ((state.status?.exitStatus ?? '')
+                .startsWith('WARNINGS:')) {
+              indicatorColor = Colors.orange;
+              statusChipColor = Colors.orange.shade100;
             }
             return SizedBox(
               height: MediaQuery.of(context).size.height * 0.5,
-- 
2.39.2





More information about the pve-devel mailing list