From 77ea27d40f46ea49cec4e836faa873b3e6ce7e3e Mon Sep 17 00:00:00 2001 From: liyuchun <563917701@qq.com> Date: Wed, 21 Sep 2022 13:47:19 +0800 Subject: [PATCH] * Adjust execution node browse. --- module/executionnode/css/browse.css | 4 +++ module/executionnode/lang/de.php | 2 ++ module/executionnode/lang/en.php | 2 ++ module/executionnode/lang/fr.php | 2 ++ module/executionnode/lang/zh-cn.php | 2 ++ module/executionnode/model.php | 12 +++++---- module/executionnode/view/browse.html.php | 30 +++++++++++++---------- 7 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 module/executionnode/css/browse.css diff --git a/module/executionnode/css/browse.css b/module/executionnode/css/browse.css new file mode 100644 index 0000000000..523e69a013 --- /dev/null +++ b/module/executionnode/css/browse.css @@ -0,0 +1,4 @@ +.c-id {width: 60px;} +.c-status {width: 70px;} +.c-ip, .c-cpu, .c-host {width: 100px;} +.c-os {width: 120px;} diff --git a/module/executionnode/lang/de.php b/module/executionnode/lang/de.php index 9f22742c5d..39fb89f920 100755 --- a/module/executionnode/lang/de.php +++ b/module/executionnode/lang/de.php @@ -52,6 +52,8 @@ $lang->executionnode->nameValid = "The name can only be letters, numbers, '- $lang->executionnode->empty = 'No Execution Node'; $lang->executionnode->templateEmpty = 'No Template'; +$lang->executionnode->apiError['-10100'] = 'Execution node not found.'; + $lang->executionnode->publicList[0] = 'Private'; $lang->executionnode->publicList[1] = 'Public'; diff --git a/module/executionnode/lang/en.php b/module/executionnode/lang/en.php index 9f22742c5d..39fb89f920 100755 --- a/module/executionnode/lang/en.php +++ b/module/executionnode/lang/en.php @@ -52,6 +52,8 @@ $lang->executionnode->nameValid = "The name can only be letters, numbers, '- $lang->executionnode->empty = 'No Execution Node'; $lang->executionnode->templateEmpty = 'No Template'; +$lang->executionnode->apiError['-10100'] = 'Execution node not found.'; + $lang->executionnode->publicList[0] = 'Private'; $lang->executionnode->publicList[1] = 'Public'; diff --git a/module/executionnode/lang/fr.php b/module/executionnode/lang/fr.php index c67da16437..642e9a9623 100755 --- a/module/executionnode/lang/fr.php +++ b/module/executionnode/lang/fr.php @@ -54,6 +54,8 @@ $lang->executionnode->nameValid = "The name can only be letters, numbers, '- $lang->executionnode->empty = 'No Execution Node'; $lang->executionnode->templateEmpty = 'No Template'; +$lang->executionnode->apiError['-10100'] = 'Execution node not found.'; + $lang->executionnode->publicList[0] = 'Private'; $lang->executionnode->publicList[1] = 'Public'; diff --git a/module/executionnode/lang/zh-cn.php b/module/executionnode/lang/zh-cn.php index 625cd883e1..f3391d881c 100755 --- a/module/executionnode/lang/zh-cn.php +++ b/module/executionnode/lang/zh-cn.php @@ -52,6 +52,8 @@ $lang->executionnode->nameValid = "名称只能是字母、数字,'-','_ $lang->executionnode->empty = '暂时没有执行节点'; $lang->executionnode->templateEmpty = '暂时没有模板'; +$lang->executionnode->apiError['-10100'] = '执行节点不存在'; + $lang->executionnode->publicList[0] = '不共享'; $lang->executionnode->publicList[1] = '共享'; diff --git a/module/executionnode/model.php b/module/executionnode/model.php index a2b0cecf82..72d8b2407d 100755 --- a/module/executionnode/model.php +++ b/module/executionnode/model.php @@ -87,7 +87,7 @@ class executionnodemodel extends model dao::$errors[] = $this->lang->executionnode->notFoundAgent; return false; } - if($result->code != 200) + if($result->code != 1) { dao::$errors[] = $this->lang->executionnode->createVmFail; return false; @@ -97,7 +97,7 @@ class executionnodemodel extends model $data->templateID = $data->templateID; $data->hostID = $host->id; $data->macAddress = $macAddress; - $data->status = static::STATUS_RUNNING; + $data->status = static::STATUS_LAUNCH; $data->createdBy = $this->app->user->account; $data->createdDate = helper::now(); $data->osCategory = $vmTemplate->osCategory; @@ -138,7 +138,7 @@ class executionnodemodel extends model $data = json_decode($result, true); if(empty($data)) return $this->lang->executionnode->notFoundAgent; - if($data['code'] != 200) return $data['message']; + if($data['code'] != 1) return zget($this->lang->executionnode->apiError, $data['code'], $data['msg']); if($type != 'reboot') { @@ -173,7 +173,7 @@ class executionnodemodel extends model $data = json_decode($result, true); if(empty($data)) return $this->lang->executionnode->notFoundAgent; - if($data['code'] != 200) return $data['message']; + if($data['code'] != 1) return zget($this->lang->executionnode->apiError, $data['code'], $data['msg']); } /* delete execution node. */ @@ -299,6 +299,8 @@ class executionnodemodel extends model $query = str_replace('`osVersion`', 't4.`osVersion`', $query); } + $orderBy = str_replace('osVersion', 't4.osVersion', $orderBy); + return $this->dao->select('t1.*, t3.name as hostName, t2.publicIP as hostIP,t4.osVersion')->from(TABLE_VM)->alias('t1') ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t1.hostID = t2.id') ->leftJoin(TABLE_ASSET)->alias('t3')->on('t3.id = t2.assetID') @@ -510,7 +512,7 @@ class executionnodemodel extends model $agnetUrl = 'http://' . $host->publicIP . ':' . $host->agentPort . static::KVM_TOKEN_PATH; $result = json_decode(commonModel::http("$agnetUrl?port={$vm->vncPort}")); - if(empty($result) or $result->code != 200) return false; + if(empty($result) or $result->code != 1) return false; $returnData = new stdClass(); $returnData->hostIP = $host->publicIP; diff --git a/module/executionnode/view/browse.html.php b/module/executionnode/view/browse.html.php index 3d433807c6..d1b32a1c30 100755 --- a/module/executionnode/view/browse.html.php +++ b/module/executionnode/view/browse.html.php @@ -47,15 +47,17 @@ - - - - - - - - + + + + + + + + + + + @@ -64,14 +66,16 @@ - - executionnode->os->type[$node->osCategory][$node->osType] . ' ' . $lang->executionnode->versionList[$node->osType][$node->osVersion];?> - + + executionnode->os->type[$node->osCategory][$node->osType] . ' ' . $lang->executionnode->versionList[$node->osType][$node->osVersion];?> + + + - +
idAB);?>executionnode->name);?>executionnode->hostName);?> - executionnode->osType);?>executionnode->cpu);?>executionnode->memory);?>executionnode->disk);?>executionnode->status);?>executionnode->creater);?>idAB);?>executionnode->name);?>executionnode->ip);?>executionnode->cpu);?>executionnode->memory);?>executionnode->disk);?>executionnode->osCategory);?>executionnode->osType);?>executionnode->osVersion);?>executionnode->status);?>executionnode->hostName);?> actions?>
id;?> inlink('view', "id=$node->id", 'html', true), $node->name, '',"class='iframe'");?>hostName;?>hostIP;?> executionnode->os->cpu, $node->osCpu);?> executionnode->os->memory, $node->osMemory);?> executionnode->os->disk, $node->osDisk);?>executionnode->os->list, $node->osCategory);?>executionnode->os->type[$node->osCategory], $node->osType);?>executionnode->versionList[$node->osType], $node->osVersion);?> executionnode->statusList, $node->status);?>createdBy);?>hostName;?> executionnode->suspend}' class='btn btn-primary' target='hiddenwin'";