* [misc] Open a new window outside the frame.

This commit is contained in:
zhangxiquan
2024-12-02 10:56:48 +08:00
committed by 翟晓剑
parent 523ac03c52
commit 9d4fea8dd6
6 changed files with 120 additions and 85 deletions
+2 -2
View File
@@ -1321,9 +1321,9 @@ eof;
* The following pages can be allowed to open in non-iframe, so ignore these pages.
*/
$module = $this->app->getModuleName();
$whitelist = is_string($whitelist) ? $whitelist : '|index|tutorial|install|upgrade|sso|cron|misc|user-login|user-deny|user-logout|user-reset|user-forgetpassword|user-resetpassword|my-changepassword|my-preference|file-read|file-download|file-preview|file-uploadimages|file-ajaxwopifiles|report-annualdata|misc-captcha|execution-printkanban|traincourse-ajaxuploadlargefile|traincourse-playvideo|screen-view|zanode-create|screen-ajaxgetchart|ai-chat|integration-wopi|instance-terminal|conference-getconferencepermissions|';
$whitelist = is_string($whitelist) ? $whitelist : '|index|tutorial|install|upgrade|sso|cron|misc|user-login|user-deny|user-logout|user-reset|user-forgetpassword|user-resetpassword|my-changepassword|my-preference|file-read|file-download|file-preview|file-uploadimages|file-ajaxwopifiles|report-annualdata|misc-captcha|execution-printkanban|traincourse-ajaxuploadlargefile|traincourse-playvideo|screen-view|zanode-create|screen-ajaxgetchart|ai-chat|integration-wopi|instance-terminal|conference-getconferencepermissions|instance-logs|';
$iframeList = '|cron-index|zanode-create|';
//var_dump($whitelist);die;
if(strpos($iframeList, "|{$module}-{$method}|") === false && (strpos($whitelist, "|{$module}|") !== false || strpos($whitelist, "|{$module}-{$method}|") !== false)) return true;
/**
+3 -5
View File
@@ -24,16 +24,14 @@ $app->loadLang('space');
$config->instance->actionList['showLogs']['icon'] = 'time';
$config->instance->actionList['showLogs']['hint'] = $lang->instance->log->viewButton;
$config->instance->actionList['showLogs']['text'] = $lang->instance->log->viewButton;
$config->instance->actionList['showLogs']['url'] = array('module' => 'instance', 'method' => 'logs', 'params' => 'id={id}&zin=1');
$config->instance->actionList['showLogs']['data-toggle'] = 'modal';
$config->instance->actionList['showLogs']['class'] = 'task-record-btn';
$config->instance->actionList['showLogs']['url'] = array('module' => 'instance', 'method' => 'logs', 'params' => 'id={id}');
$config->instance->actionList['showLogs']['target'] = '_blank';
$config->instance->actionList['showEvents']['icon'] = 'magic';
$config->instance->actionList['showEvents']['icon'] = 'summary';
$config->instance->actionList['showEvents']['hint'] = $lang->instance->event->viewButton;
$config->instance->actionList['showEvents']['text'] = $lang->instance->event->viewButton;
$config->instance->actionList['showEvents']['url'] = array('module' => 'instance', 'method' => 'events', 'params' => 'id={id}');
$config->instance->actionList['showEvents']['data-toggle'] = 'modal';
$config->instance->actionList['showEvents']['class'] = 'task-record-btn';
$config->instance->actionList['ajaxStart']['icon'] = 'play';
$config->instance->actionList['ajaxStart']['className'] = 'ajax-submit';
+37 -6
View File
@@ -29,20 +29,51 @@ window.changeComponent = function (instanceID)
$picker.$.setValue(items.pod);
}
toggleLoading('#logs-panel', false);
showLogs(instanceID);
startAutoRefreshLogs(instanceID);
});
};
window.showLogs = function (instanceID)
{
const headerHeight = document.getElementById('logs-header').offsetHeight;
document.getElementById('logs-content').style.height = `calc(100vh - ${headerHeight}px - 16px)`;
const instanceComponent = $('[name=component]').val();
const instancePod = $('[name=pod]').val();
const previous = $('[name=previous]').val();
const previous = $('[name=previous]:checked').val();
const target = $.createLink('instance', 'showlogs', 'id=' + instanceID + "&component=" + instanceComponent + "&pod=" + instancePod + "&previous=" + previous);
toggleLoading('#logs-panel', true);
$.getJSON(target, function (data)
$.getJSON(target, function (resp)
{
toggleLoading('#logs-panel', false);
$('#logs-content').html(data.data.map(item => item.timestamp + ' ' + item.content).join('\n'));
$('#logs-content').html(resp.data.map(item => item.timestamp + ' ' + item.content).join('\n'));
$('#logs-content')[0].scrollTop = $('#logs-content')[0].scrollHeight;
});
};
let logsTimer = null;
window.startAutoRefreshLogs = function(instanceID) {
if(logsTimer) clearInterval(logsTimer);
logsTimer = setInterval(function() {
showLogs(instanceID);
}, 5000);
}
$(window).on('unload', function() {
if(logsTimer) clearInterval(logsTimer);
});
$(document).ready(function() {
const instanceID = $('#logs-panel').data('id');
if(instanceID) startAutoRefreshLogs(instanceID);
});
window.toggleAutoRefresh = function(instanceID) {
const $toggleBtn = $('#autoRefreshBtn');
if(logsTimer) {
clearInterval(logsTimer);
logsTimer = null;
$toggleBtn.html('<i class="icon icon-play"></i>');
} else {
startAutoRefreshLogs(instanceID);
$toggleBtn.html('<i class="icon icon-pause"></i>');
}
}
+11 -7
View File
@@ -187,24 +187,28 @@ $lang->instance->management = '管理';
$lang->instance->dbReady = '正常';
$lang->instance->dbWaiting = '等待就绪';
$lang->instance->log = new stdclass;
$lang->instance->log = new stdClass;
$lang->instance->log->date = '日期';
$lang->instance->log->message = '内容';
$lang->instance->log->viewButton = '日志';
$lang->instance->log->title = '查看日志';
$lang->instance->log->button = '立即查看';
$lang->instance->log->viewButton = '日志';
$lang->instance->log->title = '查看日志';
$lang->instance->log->button = '立即查看';
$lang->instance->log->autoRefresh = '切换刷新状态';
$lang->instance->log->tips = '日志默认自动刷新,可点切换按钮切换';
$lang->instance->log->noLog = '暂无日志';
$lang->instance->component = '组件';
$lang->instance->pod = 'Pod';
$lang->instance->isPrevious = '是否上个退出容器';
$lang->instance->isPreviousList[0] = '否';
$lang->instance->isPreviousList[1] = '是';
$lang->instance->isPreviousList[0] = '当前容器';
$lang->instance->isPreviousList[1] = '上个容器';
$lang->instance->event = new stdClass;
$lang->instance->event->viewButton = '事件';
$lang->instance->event->title = '查看事件';
$lang->instance->event->button = '立即查看';
$lang->instance->event->noEvents = '暂无事件';
$lang->instance->actionList = array();
$lang->instance->actionList['install'] = '安装了%s';
+66 -64
View File
@@ -11,83 +11,85 @@ declare(strict_types=1);
*/
namespace zin;
set::zui(true);
formPanel
div
(
set::title($lang->instance->log->title),
set::actions(array(
array(
'text' => $lang->instance->log->button,
'type' => 'primary',
'onclick' => 'window.showLogs('.$instance->id.')',
)
)),
setID('logs-panel'),
setClass('w-full'),
formRow
(
formGroup
(
set::name('name'),
set::labelWidth('160px'),
set::required(true),
set::label($lang->instance->name),
set::value($instance->name),
set::disabled(true)
)
),
formRow
(
formGroup
(
setID('component-logs'),
set::name('component'),
set::labelWidth('160px'),
set::control('picker'),
set::required(true),
set::label($lang->instance->component),
on::change()->call('changeComponent', $instance->id)
)
),
formRow
(
formGroup
(
setID('pod-logs'),
set::name('pod'),
set::labelWidth('160px'),
set::control('picker'),
set::required(true),
set::label($lang->instance->pod),
set::items(array())
)
),
setClass('px-1 mt-2 w-full'),
formRow
(
setID('logs-header'),
setClass('flex px-1 top-0 bg-white'),
formGroup(
inputGroup
(
h::button
(
setClass('btn primary'),
$lang->instance->log->autoRefresh,
span(
setID('autoRefreshBtn'),
icon(setClass('icon icon-pause'))
),
on::click()->call('toggleAutoRefresh', $instance->id)
),
$lang->instance->name,
input
(
set::class('input-group-addon'),
set::name('name'),
set::required(true),
set::value($instance->name),
set::disabled(true)
),
$lang->instance->component,
picker
(
setClass('input-group-addon w-48'),
setID('component-logs'),
set::name('component'),
set::control('picker'),
set::required(true),
on::change()->call('changeComponent', $instance->id)
),
$lang->instance->pod,
picker
(
setClass('input-group-addon w-72'),
setID('pod-logs'),
set::name('pod'),
set::required(true),
set::items(array()),
set::inline(true),
on::inited()->call('initComponent', $instance->id)
)
)
),
formGroup
(
setClass('flex mx-2'),
setID('is-previous'),
set::name('previous'),
set::labelWidth('160px'),
set::control('picker'),
set::label($lang->instance->isPrevious),
set::control('radioListInline'),
set::items($lang->instance->isPreviousList),
set::value(0),
on::change()->call('showLogs', $instance->id),
on::inited()->call('initComponent', $instance->id)
set::inline(true),
on::change()->call('showLogs', $instance->id)
),
formGroup(
setClass('flex mx-2 text-sm text-gray-500'),
set::label( setClass('text-danger'), $lang->instance->log->tips)
)
),
div
(
setClass('px-1 mt-2 w-full'),
panel
(
setClass('py-2'),
form
(
h::pre(setID('logs-content'), setClass('bg-gray-800 text-white progress block h-96')),
set::actions(false)
)
)
setClass('px-1 mt-2 w-full h-full'),
h::pre(
setID('logs-content'),
setClass('bg-gray-800 text-white block h-screen scrollbar-thin')
),
set::actions(false)
)
);
);
render('pagebase');
+1 -1
View File
@@ -8,7 +8,7 @@
const isIndexPage = currentModule === 'index' && currentMethod === 'index';
const moduleMethod = `${currentModule}-${currentMethod}`;
const selfOpenList = new Set('index|tutorial|install|upgrade|sso|cron|misc|user-login|user-deny|user-logout|user-reset|user-forgetpassword|user-resetpassword|my-changepassword|my-preference|file-read|file-download|file-preview|file-uploadimages|file-ajaxwopifiles|report-annualdata|misc-captcha|execution-printkanban|traincourse-ajaxuploadlargefile|traincourse-playvideo|screen-view|zanode-create|screen-ajaxgetchart|instance-terminal|ai-chat'.split('|'));
const selfOpenList = new Set('index|tutorial|install|upgrade|sso|cron|misc|user-login|user-deny|user-logout|user-reset|user-forgetpassword|user-resetpassword|my-changepassword|my-preference|file-read|file-download|file-preview|file-uploadimages|file-ajaxwopifiles|report-annualdata|misc-captcha|execution-printkanban|traincourse-ajaxuploadlargefile|traincourse-playvideo|screen-view|zanode-create|screen-ajaxgetchart|instance-terminal|ai-chat|instance-logs'.split('|'));
const iframeList = new Set(['cron-index', 'zanode-create']);
const isAllowSelfOpen = !iframeList.has(moduleMethod) &&
(isIndexPage