| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496 |
- <?php
- /**
- * The view view file of zanode module of ZenTaoPMS.
- * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
- * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
- * @author Zeng Gang<zenggang@easycorp.ltd>
- * @package zanode
- * @link https://www.zentao.net
- */
- namespace zin;
- jsVar('nodeID', $zanode->id);
- jsVar('zanodeLang', $lang->zanode);
- jsVar('nodeStatus', $zanode->status);
- jsVar('hostType', $zanode->hostType);
- jsVar('webRoot', getWebRoot());
- $account = strpos(strtolower($zanode->osName), "windows") !== false ? $config->zanode->defaultWinAccount : $config->zanode->defaultAccount;
- $ssh = $zanode->hostType == 'physics' ? ('ssh ' . $zanode->extranet) : ($zanode->ssh ? 'ssh ' . $account . '@' . $zanode->ip . ' -p ' . $zanode->ssh : '');
- $snapshotUrl = helper::createLink('zanode', 'browseSnapshot', "nodeID={$zanode->id}");
- $mainActions = array();
- $commonActions = array();
- foreach($config->zanode->view->operateList as $operate)
- {
- if(strpos($operate, '|') !== false)
- {
- $operates = explode('|', $operate);
- foreach($operates as $operate)
- {
- if($this->zanode->isClickable($zanode, $operate)) break;
- }
- }
- if(!common::hasPriv('zanode', $operate)) continue;
- $action = $config->zanode->dtable->fieldList['actions']['list'][$operate];
- if(!$this->zanode->isClickable($zanode, $operate))
- {
- unset($action);
- continue;
- }
- if($operate === 'edit' || $operate === 'destroy')
- {
- $commonActions[] = $action;
- continue;
- }
- $mainActions[] = $action;
- }
- $baseInfo = array();
- if($zanode->hostType == 'physics')
- {
- $baseInfo[] = div
- (
- setClass('w-1/3'),
- span
- (
- setClass('text-gray'),
- $lang->zanode->osName
- ),
- span
- (
- setClass('ml-2'),
- zget($config->zanode->linuxList, $zanode->osName, zget($config->zanode->windowsList, $zanode->osName))
- )
- );
- $baseInfo[] = div
- (
- setClass('w-1/2'),
- span
- (
- setClass('text-gray'),
- $lang->zanode->sshAddress
- ),
- span
- (
- setClass('ml-2'),
- $ssh,
- $ssh ? h::button
- (
- setClass('ghost btn btn-info size-sm btn-ssh-copy'),
- icon
- (
- setClass('icon-common-copy icon-copy'),
- set::title($lang->zanode->copy),
- set::name('')
- ),
- on::click('sshCopy')
- ) : null,
- h::input
- (
- set::type('hidden'),
- setID('ssh-copy'),
- set::value($ssh)
- )
- )
- );
- $hiddenHost || $zanode->cpuCores == 0 ? null : $baseInfo[] = div
- (
- setClass('w-1/6'),
- span
- (
- setClass('text-gray'),
- $lang->zanode->cpuCores
- ),
- span
- (
- setClass('ml-2'),
- $zanode->cpuCores . ' ' . $lang->zanode->cpuUnit
- )
- );
- $baseInfo[] = div
- (
- $hiddenHost || $zanode->cpuCores == 0 ? setClass('w-1/6') : setClass('w-1/3 mt-2'),
- span
- (
- setClass('text-gray'),
- $lang->zanode->status
- ),
- span
- (
- setClass('ml-2'),
- zget($lang->zanode->statusList, $zanode->status)
- )
- );
- $hiddenHost || $zanode->memory == 0 ? null : $baseInfo[] = div
- (
- setClass('w-1/2 mt-4'),
- span
- (
- setClass('text-gray'),
- $lang->zanode->memory
- ),
- span
- (
- setClass('ml-2'),
- $zanode->memory . 'GB'
- )
- );
- $hiddenHost || $zanode->diskSize == 0 ? null : $baseInfo[] = div
- (
- setClass('w-1/6 mt-4'),
- span
- (
- setClass('text-gray'),
- $lang->zanode->diskSize
- ),
- span
- (
- setClass('ml-2'),
- $zanode->diskSize . 'GB'
- )
- );
- }
- else
- {
- $baseInfo[] = div
- (
- setClass('w-1/3'),
- span
- (
- setClass('text-gray'),
- $lang->zanode->osName
- ),
- span
- (
- setClass('ml-2'),
- $zanode->osName
- )
- );
- $baseInfo[] = div
- (
- setClass('w-1/2'),
- span
- (
- setClass('text-gray'),
- $lang->zanode->sshCommand
- ),
- span
- (
- setClass('ml-2'),
- $ssh,
- $ssh ? h::button
- (
- setClass('ghost btn btn-info size-sm btn-ssh-copy'),
- icon
- (
- setClass('icon-common-copy icon-copy'),
- set::title($lang->zanode->copy),
- set::name('')
- ),
- on::click('sshCopy')
- ) : null,
- h::textarea
- (
- setClass('hidden'),
- setID('ssh-copy'),
- $ssh
- )
- )
- );
- $baseInfo[] = div
- (
- setClass('w-1/6'),
- span
- (
- setClass('text-gray'),
- $lang->zanode->cpuCores
- ),
- span
- (
- setClass('ml-2'),
- $zanode->cpuCores . '' . $lang->zanode->cpuUnit
- )
- );
- $baseInfo[] = div
- (
- setClass('w-1/3 mt-4'),
- span
- (
- setClass('text-gray'),
- $lang->zanode->status
- ),
- span
- (
- setClass('ml-2'),
- zget($lang->zanode->statusList, $zanode->status)
- )
- );
- $baseInfo[] = div
- (
- setClass('w-1/2 mt-4'),
- span
- (
- setClass('text-gray'),
- $lang->zanode->defaultUser
- ),
- span
- (
- setClass('ml-2'),
- $account
- )
- );
- $baseInfo[] = div
- (
- setClass('w-1/6 mt-4'),
- span
- (
- setClass('text-gray'),
- $lang->zanode->memory
- ),
- span
- (
- setClass('ml-2'),
- $zanode->memory . ' GB'
- )
- );
- $baseInfo[] = div
- (
- setClass('w-1/3 mt-4'),
- span
- (
- setClass('text-gray'),
- $lang->zanode->hostName
- ),
- span
- (
- setClass('ml-2 clip w-36 inline-flex'),
- set::title($zanode->hostName),
- $zanode->hostName
- )
- );
- $baseInfo[] = div
- (
- setClass('w-1/2 mt-4'),
- span
- (
- setClass('text-gray'),
- $lang->zanode->defaultPwd
- ),
- span
- (
- setClass('ml-2'),
- span
- (
- setID('pwd-text'),
- str_repeat('*', strlen($config->zanode->defaultPwd))
- ),
- h::button
- (
- setClass('ghost btn btn-info size-sm btn-pwd-copy'),
- icon
- (
- setClass('icon-common-copy icon-copy'),
- set::title($lang->zanode->copy),
- set::name('')
- ),
- on::click('pwdCopy')
- ),
- h::button
- (
- setClass('ghost btn btn-info size-sm btn-pwd-show'),
- icon
- (
- setClass('icon-common-eye icon-eye'),
- set::title($lang->zanode->showPwd),
- set::name('')
- ),
- on::click('pwdShow')
- ),
- h::input
- (
- setID('pwd-copy'),
- set::type('hidden'),
- set::value($config->zanode->defaultPwd)
- )
- )
- );
- }
- detailHeader
- (
- to::title
- (
- entityLabel
- (
- set::entityID($zanode->id),
- set::level(1),
- set::text($zanode->name)
- ),
- $zanode->deleted ? span(setClass('label danger'), $lang->zanode->deleted) : null
- )
- );
- detailBody
- (
- sectionList
- (
- setID('baseInfoContent'),
- section
- (
- set::title($lang->zanode->baseInfo),
- h::table
- (
- setClass('w-full'),
- h::tr
- (
- h::td
- (
- div
- (
- setClass('flex flex-wrap pt-2 mx-4'),
- $baseInfo
- )
- )
- )
- )
- ),
- section
- (
- set::title($lang->zanode->desc),
- !empty($zanode->desc) ? html(htmlspecialchars_decode($zanode->desc)) : $lang->noData
- )
- ),
- sectionList
- (
- setID('serviceContent'),
- div
- (
- setClass('text-lg font-bold'),
- $lang->zanode->init->statusTitle,
- button
- (
- setClass('ghost btn'),
- icon('refresh', setClass('text-primary')),
- $lang->zanode->init->checkStatus,
- on::click()->call('window.checkServiceStatus')
- )
- ),
- div
- (
- setClass('service-status hidden'),
- span
- (
- setClass('dot-symbol dot-zenagent text-danger'),
- '●'
- ),
- span
- (
- ' ZAgent ',
- span
- (
- setClass('zenagent-status'),
- $lang->zanode->initializing
- )
- )
- ),
- div
- (
- setClass('service-status hidden'),
- span
- (
- setClass('dot-symbol dot-ztf text-danger'),
- '●'
- ),
- span
- (
- ' ZTF ',
- span
- (
- setClass('ztf-status'),
- $lang->zanode->initializing
- )
- )
- ),
- div
- (
- setID('statusContainer')
- ),
- div
- (
- setClass('status-notice'),
- span
- (
- setClass('init-success hidden'),
- html(sprintf($lang->zanode->init->initSuccessNoticeTitle, "<a href='https://www.zentao.net/book/zentaopms/974.html?fullScreen=zentao'>{$lang->zanode->manual}</a>", html::a(createLink('testcase', 'automation'), $lang->zanode->automation, '', "data-toggle='modal'")))
- ),
- $zanode->hostType == 'physics' ? div
- (
- setClass('init-fail hidden'),
- html($lang->zanode->init->initFailNoticeOnPhysics),
- textarea
- (
- setID('initBash'),
- setClass('hidden'),
- $initBash
- ),
- div
- (
- setClass('zanode-init'),
- $initBash,
- h::button
- (
- setClass('ghost btn btn-info size-sm btn-init-copy text-primary'),
- icon
- (
- setClass('icon-common-copy icon-copy'),
- set::title($lang->zanode->copy),
- set::name('')
- ),
- on::click('onCopy')
- )
- )
- ) : null
- )
- ),
- common::hasPriv('zanode', 'browseSnapshot') && $zanode->hostType == '' ? sectionList
- (
- section
- (
- set::title($lang->zanode->browseSnapshot),
- to::actions
- (
- div
- (
- setClass('ml-auto'),
- btn
- (
- setClass('btn primary'),
- $lang->zanode->createSnapshot,
- set::url(createLink('zanode', 'createSnapshot', "zanodeID={$zanode->id}")),
- set::icon('plus'),
- setData(array('toggle' => 'modal')),
- set::disabled($zanode->status != 'running' ? true : false)
- )
- )
- )
- ),
- !empty($snapshotList) ? div(setID('snapshotList'), on::init()->do("$('#snapshotList').load('{$snapshotUrl}');")) : $lang->noData
- ) : null,
- floatToolbar
- (
- to::prefix(backBtn(set::icon('back'), $lang->goback)),
- set::main($mainActions),
- set::suffix($commonActions),
- set::object($zanode)
- ),
- detailSide
- (
- history()
- )
- );
- render();
|