* Zanode page

This commit is contained in:
zenggang
2023-10-18 09:41:02 +00:00
parent 84ecc814b2
commit 840bcbab14
8 changed files with 85 additions and 6 deletions
+3 -3
View File
@@ -4,11 +4,11 @@ global $lang;
$config->zahost->dtable = new stdclass();
$config->zahost->dtable->fieldList['id']['title'] = $lang->idAB;
$config->zahost->dtable->fieldList['id']['name'] = 'hostID';
$config->zahost->dtable->fieldList['id']['type'] = 'id';
$config->zahost->dtable->fieldList['id']['name'] = 'hostID';
$config->zahost->dtable->fieldList['id']['type'] = 'id';
$config->zahost->dtable->fieldList['name']['type'] = 'title';
$config->zahost->dtable->fieldList['name']['link'] = array('module' => 'zahost', 'method' => 'view', 'params' => 'id={hostID}');
$config->zahost->dtable->fieldList['name']['link'] = array('module' => 'zahost', 'method' => 'view', 'params' => 'id={hostID}');
$config->zahost->dtable->fieldList['type']['name'] = 'hostType';
$config->zahost->dtable->fieldList['type']['title'] = $lang->zahost->type;
+2 -2
View File
@@ -10,8 +10,8 @@ declare(strict_types=1);
*/
namespace zin;
jsVar('orderBy', $orderBy);
jsVar('sortLink', $sortLink);
jsVar('orderBy', $orderBy);
jsVar('sortLink', $sortLink);
jsVar('webRoot', getWebRoot());
jsVar('undeletedNotice', $lang->zahost->undeletedNotice);
jsVar('uninitNotice', $lang->zahost->uninitNotice);
+50
View File
@@ -34,3 +34,53 @@ $config->zanode->dtable->fieldList['status']['sortType'] = true;
$config->zanode->dtable->fieldList['hostName']['name'] = 'hostName';
$config->zanode->dtable->fieldList['hostName']['sortType'] = true;
$config->zanode->dtable->fieldList['actions']['name'] = 'actions';
$config->zanode->dtable->fieldList['actions']['title'] = $lang->actions;
$config->zanode->dtable->fieldList['actions']['type'] = 'actions';
$config->zanode->dtable->fieldList['actions']['menu'] = array('getVNC', 'resume|suspend', 'start|close', 'reboot', 'createSnapshot', 'more' => array('edit'));
$config->zanode->dtable->fieldList['actions']['list']['getVNC']['icon'] = 'remote';
$config->zanode->dtable->fieldList['actions']['list']['getVNC']['hint'] = $lang->zanode->getVNC;
$config->zanode->dtable->fieldList['actions']['list']['getVNC']['target'] = '_blank';
$config->zanode->dtable->fieldList['actions']['list']['getVNC']['url'] = array('module' => 'zanode', 'method' => 'getVNC', 'params' => 'id={id}');
$config->zanode->dtable->fieldList['actions']['list']['resume']['icon'] = 'resume';
$config->zanode->dtable->fieldList['actions']['list']['resume']['hint'] = $lang->zanode->resume;
$config->zanode->dtable->fieldList['actions']['list']['resume']['url'] = array('module' => 'zanode', 'method' => 'resume', 'params' => 'zanodeID={id}');
$config->zanode->dtable->fieldList['actions']['list']['resume']['className'] = 'ajax-submit';
$config->zanode->dtable->fieldList['actions']['list']['suspend']['icon'] = 'moon';
$config->zanode->dtable->fieldList['actions']['list']['suspend']['hint'] = $lang->zanode->suspend;
$config->zanode->dtable->fieldList['actions']['list']['suspend']['url'] = array('module' => 'zanode', 'method' => 'suspend', 'params' => 'zanodeID={id}');
$config->zanode->dtable->fieldList['actions']['list']['suspend']['className'] = 'ajax-submit';
$config->zanode->dtable->fieldList['actions']['list']['start']['icon'] = 'play';
$config->zanode->dtable->fieldList['actions']['list']['start']['hint'] = $lang->zanode->start;
$config->zanode->dtable->fieldList['actions']['list']['start']['url'] = array('module' => 'zanode', 'method' => 'start', 'params' => 'zanodeID={id}');
$config->zanode->dtable->fieldList['actions']['list']['start']['className'] = 'ajax-submit';
$config->zanode->dtable->fieldList['actions']['list']['close']['icon'] = 'off';
$config->zanode->dtable->fieldList['actions']['list']['close']['hint'] = $lang->zanode->close;
$config->zanode->dtable->fieldList['actions']['list']['close']['url'] = array('module' => 'zanode', 'method' => 'close', 'params' => 'zanodeID={id}');
$config->zanode->dtable->fieldList['actions']['list']['close']['className'] = 'ajax-submit';
$config->zanode->dtable->fieldList['actions']['list']['reboot']['icon'] = 'restart';
$config->zanode->dtable->fieldList['actions']['list']['reboot']['hint'] = $lang->zanode->reboot;
$config->zanode->dtable->fieldList['actions']['list']['reboot']['url'] = array('module' => 'zanode', 'method' => 'reboot', 'params' => 'zanodeID={id}');
$config->zanode->dtable->fieldList['actions']['list']['reboot']['className'] = 'ajax-submit';
$config->zanode->dtable->fieldList['actions']['list']['createSnapshot']['icon'] = "plus";
$config->zanode->dtable->fieldList['actions']['list']['createSnapshot']['hint'] = $lang->zanode->createSnapshot;
$config->zanode->dtable->fieldList['actions']['list']['createSnapshot']['url'] = array('module' => 'zanode', 'method' => 'createSnapshot', 'params' => 'zanodeID={id}');
$config->zanode->dtable->fieldList['actions']['list']['createSnapshot']['data-toggle'] = 'modal';
$config->zanode->dtable->fieldList['actions']['list']['createSnapshot']['className'] = 'create-snapshot';
$config->zanode->dtable->fieldList['actions']['list']['more']['icon'] = 'ellipsis-v';
$config->zanode->dtable->fieldList['actions']['list']['more']['hint'] = 'more';
$config->zanode->dtable->fieldList['actions']['list']['more']['type'] = 'dropdown';
$config->zanode->dtable->fieldList['actions']['list']['more']['caret'] = false;
$config->zanode->dtable->fieldList['actions']['list']['edit']['icon'] = 'edit';
$config->zanode->dtable->fieldList['actions']['list']['edit']['hint'] = $lang->zanode->edit;
$config->zanode->dtable->fieldList['actions']['list']['edit']['url'] = array('module' => 'zanode', 'method' => 'edit', 'params' => 'zanodeID={id}');
+1
View File
@@ -60,6 +60,7 @@ class zanode extends control
$this->view->orderBy = $orderBy;
$this->view->browseType = $browseType;
$this->view->showFeature = $showFeature;
$this->view->sortLink = $this->createLink('zanode', 'browse', "browseType={$browseType}&param={$param}&orderBy={orderBy}&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}");
$this->display();
}
+2
View File
@@ -0,0 +1,2 @@
button.create-snapshot img {position: relative; left: -80px; filter: drop-shadow(#18a6fd 80px 0); width: 18px;}
button.create-snapshot.disabled img {filter: drop-shadow(#313c52 80px 0);}
+1
View File
@@ -27,6 +27,7 @@ window.renderList = function (result, {col, row, value})
window.afterRender = function()
{
$('.dtable-cell-content .toolbar button.create-snapshot i').replaceWith("<img src='static/svg/snapshot.svg' />");
}
function goHelp()
+25 -1
View File
@@ -194,7 +194,7 @@ class zanodemodel extends model
$result = json_decode(commonModel::http($agnetUrl . static::KVM_EXPORT_PATH, json_encode($param,JSON_NUMERIC_CHECK), null, array("Authorization:$node->tokenSN"), 'data', 'POST', 10));
if(!empty($result) and $result->code == 'success')
{
$this->dao->update(TABLE_ZAHOST)->set('status')->eq(static::STATUS_CREATING_IMG)->where('id')->eq($node->id)->exec();
@@ -1155,4 +1155,28 @@ class zanodemodel extends model
public function syncCasesToZentao($path)
{
}
/**
* 判断按钮是否可点击。
* Judge an action is clickable or not.
*
* @param object $host
* @param string $action
* @access public
* @return bool
*/
public static function isClickable(object $node, string $action): bool
{
if($action == 'resume') return $node->status == 'suspend' && $node->hostType != 'physics' && $node->status != 'running' && $node->status != 'wait';
if($action == 'suspend') return $node->status != 'suspend' && $node->hostType != 'physics' && $node->status == 'running';
if($action == 'start') return $node->status == 'shutoff' && $node->hostType != 'physics' && !in_array($node->status, array('wait', 'creating_img', 'creating_snap', 'restoring'));
if($action == 'close') return $node->status != 'shutoff' && $node->hostType != 'physics' && !in_array($node->status, array('wait', 'creating_img', 'creating_snap', 'restoring'));
if($action == 'getVNC') return $node->hostType == '' && in_array($node->status ,array('running', 'launch', 'wait'));
if($action == 'reboot') return $node->hostType != 'physics' && !in_array($node->status, array('wait', 'creating_img', 'creating_snap', 'restoring', 'shutoff'));
if($action == 'createSnapshot') return $node->hostType != 'physics' && $node->status == 'running';
return true;
}
}
+1
View File
@@ -49,6 +49,7 @@ dtable
set::afterRender(jsRaw('window.afterRender')),
set::sortLink(jsRaw('createSortLink')),
set::footPager(usePager()),
set::orderBy($orderBy),
);
render();