+ [task#133164,done,0.5h] Cne container logs.

This commit is contained in:
zhangxiquan
2024-11-27 15:26:59 +08:00
committed by 翟晓剑
parent 0707ceaf2c
commit c23972f232
2 changed files with 42 additions and 40 deletions
+40 -39
View File
@@ -1,39 +1,40 @@
window.initComponent = function (instanceID) {
toggleLoading('#logs-panel', true);
const $picker = $('[name=component]').zui('picker');
$picker.$.clear();
$.getJSON($.createLink('instance', 'ajaxGetComponents', 'id=' + instanceID), function (items) {
toggleLoading('#logs-panel', false);
$picker.render({items: items});
if (typeof (items) !== 'undefined') {
$picker.$.setValue(items.component);
}
});
};
window.changeComponent = function (instanceID) {
toggleLoading('#logs-panel', true);
const $picker = $('[name=pod]').zui('picker');
$picker.$.clear();
const component = $('[name=component]').val();
$.getJSON($.createLink('instance', 'ajaxGetPods', 'id=' + instanceID + '&component=' + component), function (items) {
$picker.render({items: items});
if (typeof (items) !== 'undefined') {
$picker.$.setValue(items.pod);
}
toggleLoading('#logs-panel', false);
});
};
window.showLogs = function (instanceID) {
const instanceComponent = $('[name=component]').val();
const instancePod = $('[name=pod]').val();
const previous = $('[name=previous]').val();
const target = $.createLink('instance', 'showlogs', 'id=' + instanceID + "&component=" + instanceComponent + "&pod=" + instancePod + "&previous=" + previous);
toggleLoading('#logs-panel', true);
$.getJSON(target, function (data) {
toggleLoading('#logs-panel', false);
$('#logs-content').html(data.data.map(item => item.timestamp + ' ' + item.content).join('\n'));
});
};
window.initComponent = function (instanceID) {
toggleLoading('#logs-panel', true);
const $picker = $('[name=component]').zui('picker');
$picker.$.clear();
$.getJSON($.createLink('instance', 'ajaxGetComponents', 'id=' + instanceID), function (items) {
toggleLoading('#logs-panel', false);
$picker.render({items: items});
if (typeof (items) !== 'undefined') {
$picker.$.setValue(items.component);
}
});
};
window.changeComponent = function (instanceID) {
toggleLoading('#logs-panel', true);
const $picker = $('[name=pod]').zui('picker');
$picker.$.clear();
const component = $('[name=component]').val();
$.getJSON($.createLink('instance', 'ajaxGetPods', 'id=' + instanceID + '&component=' + component), function (items) {
$picker.render({items: items});
if (typeof (items) !== 'undefined') {
$picker.$.setValue(items.pod);
}
toggleLoading('#logs-panel', false);
showLogs(instanceID);
});
};
window.showLogs = function (instanceID) {
const instanceComponent = $('[name=component]').val();
const instancePod = $('[name=pod]').val();
const previous = $('[name=previous]').val();
const target = $.createLink('instance', 'showlogs', 'id=' + instanceID + "&component=" + instanceComponent + "&pod=" + instancePod + "&previous=" + previous);
toggleLoading('#logs-panel', true);
$.getJSON(target, function (data) {
toggleLoading('#logs-panel', false);
$('#logs-content').html(data.data.map(item => item.timestamp + ' ' + item.content).join('\n'));
});
};
+2 -1
View File
@@ -73,6 +73,7 @@ formPanel
set::label($lang->instance->isPrevious),
set::items($lang->instance->isPreviousList),
set::value(0),
on::change()->call('showLogs', $instance->id),
on::inited()->call('initComponent', $instance->id)
)
),
@@ -84,7 +85,7 @@ formPanel
setClass('py-2'),
form
(
h::pre(setID('logs-content'), setClass('progress block h-96')),
h::pre(setID('logs-content'), setClass('bg-gray-800 text-white progress block h-96')),
set::actions(false)
)
)