From d4480c366d808d43b646bd6c0de5e6ef3ba85659 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Fri, 4 Apr 2025 17:53:09 -0700 Subject: [PATCH] Refactor: Update getArrayStatus function to return an associative array for better data handling and improve footer rendering logic. --- .../dynamix/include/DefaultPageLayout.php | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/emhttp/plugins/dynamix/include/DefaultPageLayout.php b/emhttp/plugins/dynamix/include/DefaultPageLayout.php index 09781b99f..492c3016e 100644 --- a/emhttp/plugins/dynamix/include/DefaultPageLayout.php +++ b/emhttp/plugins/dynamix/include/DefaultPageLayout.php @@ -863,40 +863,47 @@ unset($pages,$page,$pgs,$pg,$icon,$nchan,$running,$start,$stop,$row,$script,$opt annotate('Footer'); function getArrayStatus($var) { - $progress = (_var($var,'fsProgress')!='') ? "•{$var['fsProgress']}" : ""; - + $progress = (_var($var,'fsProgress')!='') ? $var['fsProgress'] : ""; + $statusMap = [ 'Stopped' => ['class' => 'red', 'icon' => 'stop-circle', 'text' => _('Array Stopped')], 'Starting' => ['class' => 'orange', 'icon' => 'pause-circle', 'text' => _('Array Starting')], 'Stopping' => ['class' => 'orange', 'icon' => 'pause-circle', 'text' => _('Array Stopping')], 'default' => ['class' => 'green', 'icon' => 'play-circle', 'text' => _('Array Started')] ]; - + $state = _var($var,'fsState'); $status = $statusMap[$state] ?? $statusMap['default']; - - return sprintf( - " %s%s", - $status['class'], - $status['icon'], - $status['text'], - $progress - ); + + return [ + 'class' => $status['class'], + 'icon' => $status['icon'], + 'text' => $status['text'], + 'progress' => $progress + ]; } ?>