From dee5ab71db886cf3cf0a939dafde30ac758a3ecb Mon Sep 17 00:00:00 2001 From: zhangxiquan Date: Sun, 1 Dec 2024 17:34:58 +0000 Subject: [PATCH] * [task#133247,done,2h] Adjust the viewing cne event style. --- module/instance/js/events.ui.js | 2 +- module/instance/js/logs.ui.js | 13 ++++++++++--- module/instance/ui/events.html.php | 2 +- module/instance/ui/logs.html.php | 10 +++++----- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/module/instance/js/events.ui.js b/module/instance/js/events.ui.js index 2e281ce609..da8f59c786 100644 --- a/module/instance/js/events.ui.js +++ b/module/instance/js/events.ui.js @@ -24,7 +24,7 @@ window.showEvents = function (instanceID,noEventTip) { toggleLoading('#events-panel', false); $('#events-content').removeClass('dtable-empty-tip flex'); - if (resp.data.length === 0) + if (resp.code !== 200 || resp.data.length === 0) { $('#events-content').html(noEventTip); $('#events-content').addClass('dtable-empty-tip flex'); diff --git a/module/instance/js/logs.ui.js b/module/instance/js/logs.ui.js index 898368900e..b1a1faae8e 100644 --- a/module/instance/js/logs.ui.js +++ b/module/instance/js/logs.ui.js @@ -33,7 +33,7 @@ window.changeComponent = function (instanceID) }); }; -window.showLogs = function (instanceID) +window.showLogs = function (instanceID, noLogsTip) { const headerHeight = document.getElementById('logs-header').offsetHeight; document.getElementById('logs-content').style.height = `calc(100vh - ${headerHeight}px - 16px)`; @@ -43,6 +43,13 @@ window.showLogs = function (instanceID) const target = $.createLink('instance', 'showlogs', 'id=' + instanceID + "&component=" + instanceComponent + "&pod=" + instancePod + "&previous=" + previous); $.getJSON(target, function (resp) { + $('#logs-content').removeClass('dtable-empty-tip flex'); + if (resp.code !== 200 || resp.data.length === 0) + { + $('#logs-content').html(noLogsTip); + $('#logs-content').addClass('dtable-empty-tip flex'); + return; + } $('#logs-content').html(resp.data.map(item => item.timestamp + ' ' + item.content).join('\n')); $('#logs-content')[0].scrollTop = $('#logs-content')[0].scrollHeight; }); @@ -50,10 +57,10 @@ window.showLogs = function (instanceID) let logsTimer = null; -window.startAutoRefreshLogs = function(instanceID) { +window.startAutoRefreshLogs = function(instanceID, noLogsTip) { if(logsTimer) clearInterval(logsTimer); logsTimer = setInterval(function() { - showLogs(instanceID); + showLogs(instanceID,noLogsTip); }, 5000); } diff --git a/module/instance/ui/events.html.php b/module/instance/ui/events.html.php index fbec9235e8..31a2f70f02 100644 --- a/module/instance/ui/events.html.php +++ b/module/instance/ui/events.html.php @@ -41,7 +41,7 @@ formPanel set::label($lang->instance->component), set::inline(true), on::inited()->call('initComponent', $instance->id), - on::change()->call('showEvents', $instance->id,$lang->instance->event->noEvents) + on::change()->call('showEvents', $instance->id, $lang->instance->event->noEvents) ) ) ), diff --git a/module/instance/ui/logs.html.php b/module/instance/ui/logs.html.php index f457029501..f56690c1b8 100644 --- a/module/instance/ui/logs.html.php +++ b/module/instance/ui/logs.html.php @@ -29,10 +29,10 @@ div setClass('btn primary'), $lang->instance->log->autoRefresh, span( - setID('autoRefreshBtn'), - icon(setClass('icon icon-pause')) - ), - on::click()->call('toggleAutoRefresh', $instance->id) + setID('autoRefreshBtn'), + icon(setClass('icon icon-pause')) + ), + on::click()->call('toggleAutoRefresh', $instance->id, $lang->instance->log->noLog) ), $lang->instance->name, input @@ -75,7 +75,7 @@ div set::items($lang->instance->isPreviousList), set::value(0), set::inline(true), - on::change()->call('showLogs', $instance->id) + on::change()->call('showLogs', $instance->id, $lang->instance->log->noLog) ), formGroup( setClass('flex mx-2 text-sm text-gray-500'),