From f9d2dd760c725a278a2ba0643322c75612940e37 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Wed, 30 Nov 2022 11:03:48 +0800 Subject: [PATCH 1/5] * Finish task #77672. --- module/zahost/control.php | 20 ++++++++++++++------ module/zahost/css/common.css | 7 +++++++ module/zahost/css/create.css | 8 -------- module/zahost/js/common.js | 6 ++++++ module/zahost/js/inithost.js | 4 +--- module/zahost/lang/de.php | 13 +++++++------ module/zahost/lang/en.php | 13 +++++++------ module/zahost/lang/fr.php | 13 +++++++------ module/zahost/lang/zh-cn.php | 7 ++++--- module/zahost/view/create.html.php | 24 +----------------------- module/zahost/view/inithost.html.php | 6 +++--- module/zahost/view/successmodal.html.php | 16 ++++++++++++++++ 12 files changed, 73 insertions(+), 64 deletions(-) create mode 100644 module/zahost/css/common.css create mode 100644 module/zahost/view/successmodal.html.php diff --git a/module/zahost/control.php b/module/zahost/control.php index 4104185a31..07b8138ff6 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -89,10 +89,13 @@ class zahost extends control return $this->send(array('result' => 'fail', 'message' => dao::getError())); } - return print(""); + $initLink = $this->createLink('zahost', 'inithost', "hostID=$hostID"); + return print(""); } - $this->view->title = $this->lang->zahost->create; + $this->view->title = $this->lang->zahost->create; + $this->view->notice = $this->lang->zahost->initHostNotice; + $this->view->buttonName = $this->lang->zahost->init; $this->display(); } @@ -287,10 +290,15 @@ class zahost extends control */ public function initHost($hostID) { - $this->view->title = $this->lang->zahost->init; - $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted'); - $this->view->hostID = $hostID; - $this->view->host = $this->zahost->getById($hostID); + $imageList = $this->zahost->getImagePairs($hostID); + + $this->view->title = $this->lang->zahost->init; + $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted'); + $this->view->hostID = $hostID; + $this->view->host = $this->zahost->getById($hostID); + $this->view->notice = $imageList ? $this->lang->zahost->createZanodeNotice : $this->lang->zahost->downloadImageNotice; + $this->view->buttonName = $imageList ? $this->lang->zahost->createZanode : $this->lang->zahost->image->downloadImage; + $this->view->modalLink = $imageList ? $this->createLink('zanode', 'create', "hostID=$hostID") : $this->createLink('zahost', 'browseImage', "hostID=$hostID"); $this->display(); } diff --git a/module/zahost/css/common.css b/module/zahost/css/common.css new file mode 100644 index 0000000000..a3e1e2fdd6 --- /dev/null +++ b/module/zahost/css/common.css @@ -0,0 +1,7 @@ +#modalLink{color: #2e7fff;text-decoration: underline;} +.modal-dialog .modal-content{border: 2px solid #75e5c4; background-color: #f1fcf9; border-radius: 4px;} +.icon-check-circle{color: #17ce97; margin-right: 10px; font-size: 20px;} +.modal-dialog{width: 384px;} +.modal-dialog{border-radius: 4px;} +.modal-header{padding:9px 18px 0px; margin:0px; border-bottom:0;} +.modal-dialog .modal-body{padding: 5px 5px 20px 15px;} diff --git a/module/zahost/css/create.css b/module/zahost/css/create.css index ffcc587882..ae37eb5805 100644 --- a/module/zahost/css/create.css +++ b/module/zahost/css/create.css @@ -1,11 +1,3 @@ #unit {padding: 0px !important; width:0px; border-left: 0px;width: 63px;} .input-group-addon {border: 0px; width: 100px;} #memory-addon{text-align: center;width: 63px;} -#initHostLink{color: #2e7fff;} -.modal-dialog .modal-content{border: 2px solid #75e5c4; background-color: #f1fcf9; border-radius: 4px;} -.icon-check-circle{color: #17ce97; margin-right: 10px; font-size: 20px;} -.modal-dialog{width: 384px;} -.modal-dialog{border-radius: 4px;} -.modal-header{padding:9px 18px 0px; margin:0px; border-bottom:0;} -.modal-dialog .modal-body{padding: 5px 5px 20px 15px;} -.modal-dialog .modal-body a{text-decoration: underline;} diff --git a/module/zahost/js/common.js b/module/zahost/js/common.js index 65357a2674..58462cdc7d 100755 --- a/module/zahost/js/common.js +++ b/module/zahost/js/common.js @@ -32,3 +32,9 @@ $(function() $('#osCategory').change(); }) + +function showModal(url = '') +{ + if(url) $("#modalLink").attr('href', url); + $('#successModal').modal('show', 'center'); +} diff --git a/module/zahost/js/inithost.js b/module/zahost/js/inithost.js index 670a4ce40d..62e2113a06 100644 --- a/module/zahost/js/inithost.js +++ b/module/zahost/js/inithost.js @@ -16,14 +16,12 @@ $('#checkServiceStatus').click(function(){ if(isSuccess){ html += '

' + zahostLang.initHost.initSuccessNotice + '

' - $('#jumpToImageList').removeAttr('disabled'); - $('#jumpToImageList').attr('href', createLink('zahost', 'browseImage', 'hostID=' + hostID)); }else{ html += '

' + zahostLang.initHost.initFailNoticeTitle + '

'; html += '
' + zahostLang.initHost.initFailNoticeDesc + 'https://github.com/easysoft/zenagent/
' - $('#jumpToImageList').attr('disabled', 'disabled') } $('#statusContainer').html(html) + if(isSuccess) showModal(); }); return }) diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index 6d9e6193ae..5c6fd64540 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -35,8 +35,10 @@ $lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; $lang->zahost->os = 'System'; $lang->zahost->imageName = 'Image File'; -$lang->zahost->goback = 'Go back'; -$lang->zahost->createSuccessNotice = 'Save successfully, initialize the ZAhost or return list'; +$lang->zahost->createZanode = 'Create Zanode'; +$lang->zahost->initHostNotice = 'Save successfully, initialize the ZAhost or return list'; +$lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode'; +$lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode'; $lang->zahost->initHost = new stdclass; $lang->zahost->initHost->checkStatus = "Check Service Status"; @@ -82,10 +84,9 @@ $lang->zahost->image->statusList['inprogress'] = 'Inprogress'; $lang->zahost->image->statusList['completed'] = 'Completed'; $lang->zahost->image->statusList['failed'] = 'Failed'; -$lang->zahost->langList = array(); -$lang->zahost->langList['zh_cn'] = 'Simplified Chinese'; -$lang->zahost->langList['zh_tw'] = 'Traditional Chinese'; -$lang->zahost->langList['en_us'] = 'American English'; +$lang->zahost->image->imageEmpty = 'No Image'; +$lang->zahost->image->downloadImageFail = 'Failed to create image task'; +$lang->zahost->image->downloadImageSuccess = 'Successed to create image task'; $lang->zahost->empty = 'No Host'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 6d9e6193ae..5c6fd64540 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -35,8 +35,10 @@ $lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; $lang->zahost->os = 'System'; $lang->zahost->imageName = 'Image File'; -$lang->zahost->goback = 'Go back'; -$lang->zahost->createSuccessNotice = 'Save successfully, initialize the ZAhost or return list'; +$lang->zahost->createZanode = 'Create Zanode'; +$lang->zahost->initHostNotice = 'Save successfully, initialize the ZAhost or return list'; +$lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode'; +$lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode'; $lang->zahost->initHost = new stdclass; $lang->zahost->initHost->checkStatus = "Check Service Status"; @@ -82,10 +84,9 @@ $lang->zahost->image->statusList['inprogress'] = 'Inprogress'; $lang->zahost->image->statusList['completed'] = 'Completed'; $lang->zahost->image->statusList['failed'] = 'Failed'; -$lang->zahost->langList = array(); -$lang->zahost->langList['zh_cn'] = 'Simplified Chinese'; -$lang->zahost->langList['zh_tw'] = 'Traditional Chinese'; -$lang->zahost->langList['en_us'] = 'American English'; +$lang->zahost->image->imageEmpty = 'No Image'; +$lang->zahost->image->downloadImageFail = 'Failed to create image task'; +$lang->zahost->image->downloadImageSuccess = 'Successed to create image task'; $lang->zahost->empty = 'No Host'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index 5d575d1c07..21184aeeea 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -35,8 +35,10 @@ $lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; $lang->zahost->os = 'System'; $lang->zahost->imageName = 'Image File'; -$lang->zahost->goback = 'Go back'; -$lang->zahost->createSuccessNotice = 'Save successfully, initialize the ZAhost or return list'; +$lang->zahost->createZanode = 'Create Zanode'; +$lang->zahost->initHostNotice = 'Save successfully, initialize the ZAhost or return list'; +$lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode'; +$lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode'; $lang->zahost->initHost = new stdclass; $lang->zahost->initHost->checkStatus = "Check Service Status"; @@ -82,10 +84,9 @@ $lang->zahost->image->statusList['inprogress'] = 'Inprogress'; $lang->zahost->image->statusList['completed'] = 'Completed'; $lang->zahost->image->statusList['failed'] = 'Failed'; -$lang->zahost->langList = array(); -$lang->zahost->langList['zh_cn'] = 'Simplified Chinese'; -$lang->zahost->langList['zh_tw'] = 'Traditional Chinese'; -$lang->zahost->langList['en_us'] = 'American English'; +$lang->zahost->image->imageEmpty = 'No Image'; +$lang->zahost->image->downloadImageFail = 'Failed to create image task'; +$lang->zahost->image->downloadImageSuccess = 'Successed to create image task'; $lang->zahost->empty = 'No Host'; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index 35e13a7fb1..1e74cfeaf2 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -35,8 +35,10 @@ $lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; $lang->zahost->os = '操作系统平台'; $lang->zahost->imageName = '镜像文件'; -$lang->zahost->goback = '返回列表'; -$lang->zahost->createSuccessNotice = '保存成功,请您初始化宿主机或返回列表'; +$lang->zahost->createZanode = '创建执行节点'; +$lang->zahost->initHostNotice = '保存成功,请您初始化宿主机或返回列表。'; +$lang->zahost->createZanodeNotice = '初始化成功,您现在可以创建执行节点了。'; +$lang->zahost->downloadImageNotice = '初始化成功,请下载镜像用于创建执行节点。'; $lang->zahost->initHost = new stdclass; $lang->zahost->initHost->statusTitle = "服务状态"; @@ -86,7 +88,6 @@ $lang->zahost->image->imageEmpty = '无镜像'; $lang->zahost->image->downloadImageFail = '创建下载镜像任务失败'; $lang->zahost->image->downloadImageSuccess = '创建下载镜像任务成功'; - $lang->zahost->empty = '暂时没有宿主机'; $lang->zahost->statusList['ready'] = '准备中'; diff --git a/module/zahost/view/create.html.php b/module/zahost/view/create.html.php index 5e99065c8d..7eccdf9827 100644 --- a/module/zahost/view/create.html.php +++ b/module/zahost/view/create.html.php @@ -78,27 +78,5 @@ - - + getModuleRoot() . 'common/view/footer.html.php';?> diff --git a/module/zahost/view/inithost.html.php b/module/zahost/view/inithost.html.php index 21070cf6c7..f21adfbf5c 100644 --- a/module/zahost/view/inithost.html.php +++ b/module/zahost/view/inithost.html.php @@ -14,7 +14,6 @@ zahost); ?> -
@@ -31,8 +30,9 @@
- createLink('zahost', 'browseImage', "hostID={$hostID}"), $lang->zahost->initHost->next, '', "title='{$lang->zahost->initHost->next}' class='btn btn-primary margin-top-18' disabled='disabled' id='jumpToImageList'"); ?>
- \ No newline at end of file +
+ + diff --git a/module/zahost/view/successmodal.html.php b/module/zahost/view/successmodal.html.php new file mode 100644 index 0000000000..e1ccea7c5a --- /dev/null +++ b/module/zahost/view/successmodal.html.php @@ -0,0 +1,16 @@ + From f037f0b6fd9494b30049f86c9b25c2a20e16d306 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Thu, 1 Dec 2022 13:56:55 +0800 Subject: [PATCH 2/5] * Optimize page style. --- module/repo/css/ajaxgeteditorcontent.css | 6 +++--- module/repo/js/common.js | 2 +- module/repo/view/ajaxgetrelationinfo.html.php | 20 +++++++------------ 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/module/repo/css/ajaxgeteditorcontent.css b/module/repo/css/ajaxgeteditorcontent.css index 3eac922cf0..ead238f8ab 100644 --- a/module/repo/css/ajaxgeteditorcontent.css +++ b/module/repo/css/ajaxgeteditorcontent.css @@ -1,14 +1,14 @@ .m-repo-ajaxgeteditorcontent {overflow: hidden;} #monacoEditor .tip-circular {background: #2e7fff; border-radius: 10px; padding: 0px 7px;} -#log {margin-top: 2px; display: none; padding: 5px; justify-content: space-between; height: 25px; line-height: 20px;} +#log {margin-top: 8px; display: none; padding: 5px; justify-content: space-between; height: 25px; line-height: 20px; background: #efefef;} #log .history {margin-left: 5px;} #log .action-btn .btn {border: none; background: none;} -#related {display: none; margin-top: 2px; background: #fff;} +#related {display: none; margin-top: 2px; background: #fff; height: 0px;} #relationTabs .nav > li > a {padding: 8px 10px; display: flex; white-space: pre;} #relationTabs .nav-tabs > li > a > span {margin-right: 5px;} #relationTabs .tab-pane {display: none;} -#relationTabs .tabs-navbar {background: #F4F5F7;} +#relationTabs .tabs-navbar {background: #FFFFFF;} #relationTabs .tab-pane.active {display: block;} #relationTabs .tab-nav-item {max-width: none !important;} #relationTabs .tab-nav-item .icon {line-height: inherit;} diff --git a/module/repo/js/common.js b/module/repo/js/common.js index 0abab79586..0e1d450f02 100644 --- a/module/repo/js/common.js +++ b/module/repo/js/common.js @@ -86,7 +86,7 @@ function arrowTabs(domID, shift, hideRightBtn) var tabItemWidth = $('#' + domID + ' > .tabs-navbar > .nav-tabs')[0].clientWidth; var tabsWidth = $('#' + domID)[0].clientWidth; - if($('#' + domID + ' .close-bugs').length) tabsWidth = tabsWidth * 0.6; + if($('#' + domID + ' .close-bugs').length) tabsWidth = tabsWidth * 0.7; if(tabItemWidth < tabsWidth) { diff --git a/module/repo/view/ajaxgetrelationinfo.html.php b/module/repo/view/ajaxgetrelationinfo.html.php index e7fa743046..0a1dafbe4c 100644 --- a/module/repo/view/ajaxgetrelationinfo.html.php +++ b/module/repo/view/ajaxgetrelationinfo.html.php @@ -17,25 +17,23 @@ js::set('objectID', $object->id);
- + - - + + @@ -43,21 +41,19 @@ js::set('objectID', $object->id); - - + + @@ -65,7 +61,6 @@ js::set('objectID', $object->id); @@ -73,7 +68,6 @@ js::set('objectID', $object->id); From 0e2f1d1bfc7daa96a12c62ca7dfd44a80d210e9e Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Thu, 1 Dec 2022 16:01:56 +0800 Subject: [PATCH 3/5] * Modify repo diff page style. --- module/repo/css/diff.css | 5 +++++ module/repo/js/diff.js | 2 +- module/repo/view/diffeditor.html.php | 9 +++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/module/repo/css/diff.css b/module/repo/css/diff.css index 7306ab9edf..ac7b0f433c 100644 --- a/module/repo/css/diff.css +++ b/module/repo/css/diff.css @@ -32,3 +32,8 @@ table.diff {margin-bottom: 0px;} #fileTabs .tab-nav-item {max-width: none !important;} #filesTree #modules {margin-top: 5px;} #filesTree {overflow-y: auto;} + +.file-tree {padding: 0;} +#sidebar > .sidebar-toggle {left: auto; right: 3px;} +#sidebar > .sidebar-toggle > .icon {left : -1px;} +.hide-sidebar #sidebar {width: 0 !important;} diff --git a/module/repo/js/diff.js b/module/repo/js/diff.js index 4938b3df51..a3b19bcd9e 100644 --- a/module/repo/js/diff.js +++ b/module/repo/js/diff.js @@ -117,7 +117,7 @@ $(document).ready(function() var paneHeight = $(window).height() - 120; if(isonlybody) paneHeight = 500; $('#fileTabs .tab-pane').css('height', paneHeight + 'px') - $('#filesTree').css('height', paneHeight + 45) + $('#filesTree').css('height', paneHeight + 35) } setHeight(); diff --git a/module/repo/view/diffeditor.html.php b/module/repo/view/diffeditor.html.php index f81bea3883..1b147d8f64 100644 --- a/module/repo/view/diffeditor.html.php +++ b/module/repo/view/diffeditor.html.php @@ -13,16 +13,17 @@ js::set('openedFiles', array($entry)); js::set('urlParams', "repoID=$repoID&objectID=$objectID&entry=%s&oldRevision=$oldRevision&newRevision=$newRevision&showBug=$showBug&encoding=$encoding"); ?> -
+
-
-
+ - +
From 319f587f77bc3b1386c5e3e4cce7e16e6872d190 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Fri, 2 Dec 2022 08:33:22 +0800 Subject: [PATCH 4/5] * Finish task #77679. --- db/update18.0.beta1.sql | 1 + db/zentao.sql | 1 + module/zahost/control.php | 2 + module/zahost/css/create.css | 1 + module/zahost/js/inithost.js | 4 +- module/zahost/lang/de.php | 9 +- module/zahost/lang/en.php | 9 +- module/zahost/lang/fr.php | 57 +++++------ module/zahost/lang/zh-cn.php | 9 +- module/zahost/model.php | 15 +++ module/zahost/view/browse.html.php | 4 +- module/zahost/view/inithost.html.php | 6 +- module/zanode/config.php | 3 + module/zanode/control.php | 50 +++++++++- module/zanode/css/createimage.css | 2 + module/zanode/lang/de.php | 8 +- module/zanode/lang/en.php | 8 +- module/zanode/lang/fr.php | 8 +- module/zanode/lang/zh-cn.php | 8 +- module/zanode/model.php | 127 +++++++++++++++++++++++- module/zanode/view/browse.html.php | 19 ++-- module/zanode/view/createimage.html.php | 77 ++++++++++++++ 22 files changed, 368 insertions(+), 60 deletions(-) create mode 100644 db/update18.0.beta1.sql create mode 100644 module/zanode/css/createimage.css create mode 100644 module/zanode/view/createimage.html.php diff --git a/db/update18.0.beta1.sql b/db/update18.0.beta1.sql new file mode 100644 index 0000000000..97b46511c7 --- /dev/null +++ b/db/update18.0.beta1.sql @@ -0,0 +1 @@ +ALTER TABLE `zt_image` ADD `from` mediumint(8) NOT NULL DEFAULT '0' AFTER `status`; diff --git a/db/zentao.sql b/db/zentao.sql index 8faa92f382..40b9675a87 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -7301,6 +7301,7 @@ CREATE TABLE `zt_image` ( `address` varchar(64) NOT NULL DEFAULT '', `path` varchar(64) NOT NULL DEFAULT '', `status` varchar(20) NOT NULL DEFAULT '', + `from` smallint(8) unsigned NOT NULL DEFAULT '0', `osName` varchar(32) NOT NULL DEFAULT '', `memory` float unsigned NOT NULL, `disk` float unsigned NOT NULL, diff --git a/module/zahost/control.php b/module/zahost/control.php index 07b8138ff6..6b692d0f40 100644 --- a/module/zahost/control.php +++ b/module/zahost/control.php @@ -33,6 +33,7 @@ class zahost extends control $pager = pager::init($recTotal, $recPerPage, $pageID); $hostList = $this->zahost->getList($browseType, $param, $orderBy, $pager); + $nodeList = $this->zahost->getHostNodeGroup(); /* Build the search form. */ $actionURL = $this->createLink('zahost', 'browse', "browseType=bySearch¶m=myQueryID"); @@ -43,6 +44,7 @@ class zahost extends control $this->view->title = $this->lang->zahost->common; $this->view->hostList = $hostList; + $this->view->nodeList = $nodeList; $this->view->users = $this->loadModel('user')->getPairs('noletter,noempty,noclosed'); $this->view->pager = $pager; $this->view->param = $param; diff --git a/module/zahost/css/create.css b/module/zahost/css/create.css index ae37eb5805..cb6b02c7d5 100644 --- a/module/zahost/css/create.css +++ b/module/zahost/css/create.css @@ -1,3 +1,4 @@ #unit {padding: 0px !important; width:0px; border-left: 0px;width: 63px;} .input-group-addon {border: 0px; width: 100px;} #memory-addon{text-align: center;width: 63px;} +.modal-dialog{width: 396px;} diff --git a/module/zahost/js/inithost.js b/module/zahost/js/inithost.js index 62e2113a06..57d4edab15 100644 --- a/module/zahost/js/inithost.js +++ b/module/zahost/js/inithost.js @@ -14,9 +14,7 @@ $('#checkServiceStatus').click(function(){ } }; - if(isSuccess){ - html += '

' + zahostLang.initHost.initSuccessNotice + '

' - }else{ + if(!isSuccess){ html += '

' + zahostLang.initHost.initFailNoticeTitle + '

'; html += '
' + zahostLang.initHost.initFailNoticeDesc + 'https://github.com/easysoft/zenagent/
' } diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index 5c6fd64540..5fb5013c71 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -39,6 +39,7 @@ $lang->zahost->createZanode = 'Create Zanode'; $lang->zahost->initHostNotice = 'Save successfully, initialize the ZAhost or return list'; $lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode'; $lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode'; +$lang->zahost->undeletedNotice = "The host has nodes that cannot be deleted."; $lang->zahost->initHost = new stdclass; $lang->zahost->initHost->checkStatus = "Check Service Status"; @@ -47,7 +48,6 @@ $lang->zahost->initHost->not_available = "Installed, Not Started"; $lang->zahost->initHost->ready = "Ready"; $lang->zahost->initHost->next = "Next"; -$lang->zahost->initHost->initSuccessNotice = "The initialization was successful, click Next to complete the next steps."; $lang->zahost->initHost->initFailNoticeTitle = "Initialization failed, check the init script execution log and try the following two solutions:"; $lang->zahost->initHost->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ"; @@ -56,9 +56,10 @@ $lang->zahost->initHost->serviceStatus = [ "novnc" => 'not_install', "websockify" => 'not_install', ]; -$lang->zahost->initHost->title = "Initialize Host"; -$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; -$lang->zahost->initHost->initDesc = "Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->title = "Initialize Host"; +$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; +$lang->zahost->initHost->initDesc = "1. Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->initDescSecond = "2. Checking Service Status"; $lang->zahost->image = new stdclass; $lang->zahost->image->list = 'Image List'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 5c6fd64540..5fb5013c71 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -39,6 +39,7 @@ $lang->zahost->createZanode = 'Create Zanode'; $lang->zahost->initHostNotice = 'Save successfully, initialize the ZAhost or return list'; $lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode'; $lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode'; +$lang->zahost->undeletedNotice = "The host has nodes that cannot be deleted."; $lang->zahost->initHost = new stdclass; $lang->zahost->initHost->checkStatus = "Check Service Status"; @@ -47,7 +48,6 @@ $lang->zahost->initHost->not_available = "Installed, Not Started"; $lang->zahost->initHost->ready = "Ready"; $lang->zahost->initHost->next = "Next"; -$lang->zahost->initHost->initSuccessNotice = "The initialization was successful, click Next to complete the next steps."; $lang->zahost->initHost->initFailNoticeTitle = "Initialization failed, check the init script execution log and try the following two solutions:"; $lang->zahost->initHost->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ"; @@ -56,9 +56,10 @@ $lang->zahost->initHost->serviceStatus = [ "novnc" => 'not_install', "websockify" => 'not_install', ]; -$lang->zahost->initHost->title = "Initialize Host"; -$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; -$lang->zahost->initHost->initDesc = "Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->title = "Initialize Host"; +$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; +$lang->zahost->initHost->initDesc = "1. Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->initDescSecond = "2. Checking Service Status"; $lang->zahost->image = new stdclass; $lang->zahost->image->list = 'Image List'; diff --git a/module/zahost/lang/fr.php b/module/zahost/lang/fr.php index 21184aeeea..5fb5013c71 100644 --- a/module/zahost/lang/fr.php +++ b/module/zahost/lang/fr.php @@ -1,34 +1,34 @@ zahost->id = 'ID'; $lang->zahost->common = 'ZAhost'; -$lang->zahost->browse = 'Hôte Liste'; -$lang->zahost->create = 'Ajouter Hôte'; -$lang->zahost->view = 'Hôte Détail'; +$lang->zahost->browse = 'Host List'; +$lang->zahost->create = 'Add Host'; +$lang->zahost->view = 'Host View'; $lang->zahost->init = 'Init Host'; -$lang->zahost->edit = 'Éditer'; -$lang->zahost->editAction = 'Éditer Hôte'; -$lang->zahost->delete = 'Supprimer'; -$lang->zahost->deleteAction = 'Supprimer Hôte'; -$lang->zahost->byQuery = 'Recherche'; -$lang->zahost->all = 'Tous les hôtes'; +$lang->zahost->edit = 'Edit'; +$lang->zahost->editAction = 'Edit Host'; +$lang->zahost->delete = 'Delete'; +$lang->zahost->deleteAction = 'Delete Host'; +$lang->zahost->byQuery = 'Search'; +$lang->zahost->all = 'All'; $lang->zahost->browseNode = 'ZAnode Browse'; $lang->zahost->deleted = "Deleted"; -$lang->zahost->name = 'Nom'; -$lang->zahost->IP = 'IP/Domain'; -$lang->zahost->extranet = 'IP'; -$lang->zahost->cpuCore = 'CPU Cores'; -$lang->zahost->memory = 'Mémoire Espace'; -$lang->zahost->diskSize = 'Disque Espace'; +$lang->zahost->name = 'Name'; +$lang->zahost->IP = 'Extranet Address'; +$lang->zahost->extranet = 'Extranet Address'; +$lang->zahost->cpuCores = 'CPU Cores'; +$lang->zahost->memory = 'Memory Size'; +$lang->zahost->diskSize = 'diskSize Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; -$lang->zahost->createdBy = 'Créé par'; -$lang->zahost->createdDate = 'Date de création'; -$lang->zahost->editedBy = 'Édité par'; -$lang->zahost->editedDate = "Date d'édition"; -$lang->zahost->registerDate = "RegisterDate"; +$lang->zahost->createdBy = 'CreatedBy'; +$lang->zahost->createdDate = 'CreatedDate'; +$lang->zahost->editedBy = 'EditedBy'; +$lang->zahost->editedDate = 'EditedDate'; +$lang->zahost->registerDate = 'RegisterDate'; $lang->zahost->memorySize = $lang->zahost->memory; $lang->zahost->cpuCoreNum = $lang->zahost->cpuCores; @@ -39,6 +39,7 @@ $lang->zahost->createZanode = 'Create Zanode'; $lang->zahost->initHostNotice = 'Save successfully, initialize the ZAhost or return list'; $lang->zahost->createZanodeNotice = 'Initialization successful, ready to create the zanode'; $lang->zahost->downloadImageNotice = 'Initialization successful, download the image to create zanode'; +$lang->zahost->undeletedNotice = "The host has nodes that cannot be deleted."; $lang->zahost->initHost = new stdclass; $lang->zahost->initHost->checkStatus = "Check Service Status"; @@ -47,7 +48,6 @@ $lang->zahost->initHost->not_available = "Installed, Not Started"; $lang->zahost->initHost->ready = "Ready"; $lang->zahost->initHost->next = "Next"; -$lang->zahost->initHost->initSuccessNotice = "The initialization was successful, click Next to complete the next steps."; $lang->zahost->initHost->initFailNoticeTitle = "Initialization failed, check the init script execution log and try the following two solutions:"; $lang->zahost->initHost->initFailNoticeDesc = "1. Re-execute the script
2. Review the initialization FAQ"; @@ -56,9 +56,10 @@ $lang->zahost->initHost->serviceStatus = [ "novnc" => 'not_install', "websockify" => 'not_install', ]; -$lang->zahost->initHost->title = "Initialize Host"; -$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; -$lang->zahost->initHost->initDesc = "Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->title = "Initialize Host"; +$lang->zahost->initHost->descTitle = "Follow these steps to complete the initialization on the host:"; +$lang->zahost->initHost->initDesc = "1. Execute the init script on the host: bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->initDescSecond = "2. Checking Service Status"; $lang->zahost->image = new stdclass; $lang->zahost->image->list = 'Image List'; @@ -99,13 +100,13 @@ $lang->zahost->softwareList['kvm'] = 'KVM'; $lang->zahost->unitList['GB'] = 'GB'; $lang->zahost->unitList['TB'] = 'TB'; -$lang->zahost->zaHostType = 'Type Hôte'; -$lang->zahost->zaHostTypeList['physical'] = 'Physique'; +$lang->zahost->zaHostType = 'Type'; +$lang->zahost->zaHostTypeList['physical'] = 'Physical'; -$lang->zahost->confirmDelete = 'Voulez-vous supprimer cet hôte?'; +$lang->zahost->confirmDelete = 'Do you want to delete this host?'; $lang->zahost->notice = new stdclass(); -$lang->zahost->notice->ip = '『%s』format incorrect!'; +$lang->zahost->notice->ip = '『%s』incorrect format!'; $lang->zahost->notice->registerCommand = 'Register command: ./zagent-host -t host -s http://%s:%s -i %s -p 8086 -secret %s'; $lang->zahost->notice->loading = 'loading...'; $lang->zahost->notice->noImage = 'No available image'; diff --git a/module/zahost/lang/zh-cn.php b/module/zahost/lang/zh-cn.php index 1e74cfeaf2..ebf03d77bc 100644 --- a/module/zahost/lang/zh-cn.php +++ b/module/zahost/lang/zh-cn.php @@ -39,6 +39,7 @@ $lang->zahost->createZanode = '创建执行节点'; $lang->zahost->initHostNotice = '保存成功,请您初始化宿主机或返回列表。'; $lang->zahost->createZanodeNotice = '初始化成功,您现在可以创建执行节点了。'; $lang->zahost->downloadImageNotice = '初始化成功,请下载镜像用于创建执行节点。'; +$lang->zahost->undeletedNotice = "宿主机下存在执行节点无法删除。"; $lang->zahost->initHost = new stdclass; $lang->zahost->initHost->statusTitle = "服务状态"; @@ -48,7 +49,6 @@ $lang->zahost->initHost->not_available = "已安装,未启动"; $lang->zahost->initHost->ready = "已就绪"; $lang->zahost->initHost->next = "下一步"; -$lang->zahost->initHost->initSuccessNotice = "初始化成功,请点击下一步完成后续操作。"; $lang->zahost->initHost->initFailNoticeTitle = "初始化失败,请查看初始化脚本执行日志并尝试以下两种解决方案:"; $lang->zahost->initHost->initFailNoticeDesc = "1. 重新执行脚本
2. 查看初始化常见问题"; $lang->zahost->initHost->serviceStatus = [ @@ -56,9 +56,10 @@ $lang->zahost->initHost->serviceStatus = [ "novnc" => 'not_install', "websockify" => 'not_install', ]; -$lang->zahost->initHost->title = "初始化宿主机"; -$lang->zahost->initHost->descTitle = "请按照以下步骤在宿主机上完成初始化:"; -$lang->zahost->initHost->initDesc = "在宿主机上执行:bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k "; +$lang->zahost->initHost->title = "初始化宿主机"; +$lang->zahost->initHost->descTitle = "请根据引导完成宿主机上的初始化: "; +$lang->zahost->initHost->initDescFirst = "1. 在宿主机上执行:bash <(curl -s -S -L https://pkg.qucheng.com/zenagent/zagent.sh) -k"; +$lang->zahost->initHost->initDescSecond = "2. 检测服务状态"; $lang->zahost->image = new stdclass; $lang->zahost->image->list = '镜像列表'; diff --git a/module/zahost/model.php b/module/zahost/model.php index e8f21039d9..6b8e8ed48f 100644 --- a/module/zahost/model.php +++ b/module/zahost/model.php @@ -350,6 +350,21 @@ class zahostModel extends model ->fetchAll(); } + /** + * Get zanode group by zahost. + * + * @access public + * @return void + */ + public function getHostNodeGroup() + { + return $this->dao->select('t1.id as hostID, t2.*')->from(TABLE_ZAHOST)->alias('t1') + ->leftJoin(TABLE_ZAHOST)->alias('t2')->on('t2.parent = t1.id') + ->where('t2.deleted')->eq('0') + ->andWhere('t1.deleted')->eq('0') + ->fetchGroup('hostID', 'id'); + } + /** * Build test task menu. * diff --git a/module/zahost/view/browse.html.php b/module/zahost/view/browse.html.php index ec88016f08..490e701ad7 100644 --- a/module/zahost/view/browse.html.php +++ b/module/zahost/view/browse.html.php @@ -70,7 +70,9 @@
diff --git a/module/zahost/view/inithost.html.php b/module/zahost/view/inithost.html.php index f21adfbf5c..5a679c6f09 100644 --- a/module/zahost/view/inithost.html.php +++ b/module/zahost/view/inithost.html.php @@ -20,9 +20,13 @@

zahost->initHost->title; ?>

+

zahost->initHost->descTitle; ?>

-
zahost->initHost->initDesc . ' ' . $host->secret; ?>
+
+

zahost->initHost->initDescFirst . ' ' . $host->secret; ?>

+

zahost->initHost->initDescSecond;?>

+
diff --git a/module/zanode/config.php b/module/zanode/config.php index 8005b689a2..3bd4ffcf0b 100644 --- a/module/zanode/config.php +++ b/module/zanode/config.php @@ -1,8 +1,10 @@ zanode->create = new stdClass(); $config->zanode->edit = new stdClass(); +$config->zanode->createimage = new stdClass(); $config->zanode->create->requiredFields = 'name,host,image,cpu,memory,disk,osName'; $config->zanode->edit->requiredFields = ''; +$config->zanode->createimage->requiredFields = 'name'; $config->zanode->defaultPort = '8086'; @@ -42,3 +44,4 @@ $config->zanode->search['params']['diskSize'] = array('operator' => '=', 'cont $config->zanode->editor = new stdclass(); $config->zanode->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); $config->zanode->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools'); +$config->zanode->editor->createimage = array('id' => 'desc', 'tools' => 'simpleTools'); diff --git a/module/zanode/control.php b/module/zanode/control.php index e51e304214..0f6dc45a32 100644 --- a/module/zanode/control.php +++ b/module/zanode/control.php @@ -30,7 +30,6 @@ class zanode extends control $this->app->loadClass('pager', $static = true); - $queryID = ($browseType == 'bysearch') ? (int)$param : 0; $pager = pager::init($recTotal, $recPerPage, $pageID); $nodeList = $this->zanode->getListByQuery($browseType, $queryID, $orderBy, $pager); @@ -181,6 +180,39 @@ class zanode extends control } } + /** + * Create custom image. + * + * @param int $zanodeID + * @access public + * @return void + */ + public function createImage($zanodeID = 0) + { + $task = ''; + $node = $this->zanode->getNodeByID($zanodeID); + $customImage = $this->zanode->getCustomImage($zanodeID, 'created,inprogress'); + if($customImage) $task = $this->zanode->getTaskStatus($node->ip, $customImage->id, 'exportVm'); + + if($_POST) + { + $this->zanode->createImage($zanodeID); + + if(dao::isError()) + { + $response['result'] = 'fail'; + $response['message'] = dao::getError(); + return $this->send($response); + } + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); + } + + // $task = ''; + $this->view->task = $task; + $this->view->rate = !empty($task->rate) ? $task->rate : 0; + $this->display(); + } + /** * Desctroy node. * @@ -254,4 +286,20 @@ class zanode extends control $template = $this->loadModel('zahost')->getImageByID($imageID); return print(json_encode($template)); } + + /** + * Ajax get task status. + * + * @param int $extranet + * @param int $taskID + * @param string $type + * @param string $status + * @access public + * @return void + */ + public function ajaxGetTaskStatus($extranet, $taskID = 0, $type = '', $status = '') + { + $result = $this->zanode->getTaskStatus($extranet, $taskID, $type, $status); + return print(json_encode($result)); + } } diff --git a/module/zanode/css/createimage.css b/module/zanode/css/createimage.css new file mode 100644 index 0000000000..20b32c2b40 --- /dev/null +++ b/module/zanode/css/createimage.css @@ -0,0 +1,2 @@ +.progress{height: 20px;} +#mainContent{width: 50%; margin: 0 auto;} diff --git a/module/zanode/lang/de.php b/module/zanode/lang/de.php index bbefb5c016..78355dc0ae 100644 --- a/module/zanode/lang/de.php +++ b/module/zanode/lang/de.php @@ -16,6 +16,7 @@ $lang->zanode->all = 'All'; $lang->zanode->byQuery = 'Search'; $lang->zanode->osName = 'System'; $lang->zanode->image = 'VM Image'; +$lang->zanode->imageName = 'Image Name'; $lang->zanode->name = 'Name'; $lang->zanode->start = 'Start After Created'; $lang->zanode->hostName = 'Host Name'; @@ -45,8 +46,12 @@ $lang->zanode->notFoundAgent = 'No Agent service is found'; $lang->zanode->createVmFail = 'Failed to create a execution node'; $lang->zanode->noVncPort = 'Failed to get vnc port'; $lang->zanode->nameValid = "The name can only be letters, numbers, '-', '_', '.', and cannot start with a symbol"; +$lang->zanode->empty = 'No zanode is found'; -$lang->zanode->empty = 'No Execution Node'; +$lang->zanode->empty = 'No Execution Node'; +$lang->zanode->createImaging = 'Creating'; +$lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the execution node to be shut down. Do you want to continue?'; +$lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. Created'; $lang->zanode->apiError['-10100'] = 'Execution node not found.'; @@ -58,5 +63,6 @@ $lang->zanode->statusList['launch'] = 'Launch'; $lang->zanode->statusList['ready'] = 'Ready'; $lang->zanode->statusList['running'] = 'Running'; $lang->zanode->statusList['suspend'] = 'Suspend'; +$lang->zanode->statusList['offline'] = 'Offline'; $lang->zanode->statusList['destroy'] = 'Destroyed'; $lang->zanode->statusList['destroy_fail'] = 'Destroy Fail'; diff --git a/module/zanode/lang/en.php b/module/zanode/lang/en.php index bbefb5c016..78355dc0ae 100644 --- a/module/zanode/lang/en.php +++ b/module/zanode/lang/en.php @@ -16,6 +16,7 @@ $lang->zanode->all = 'All'; $lang->zanode->byQuery = 'Search'; $lang->zanode->osName = 'System'; $lang->zanode->image = 'VM Image'; +$lang->zanode->imageName = 'Image Name'; $lang->zanode->name = 'Name'; $lang->zanode->start = 'Start After Created'; $lang->zanode->hostName = 'Host Name'; @@ -45,8 +46,12 @@ $lang->zanode->notFoundAgent = 'No Agent service is found'; $lang->zanode->createVmFail = 'Failed to create a execution node'; $lang->zanode->noVncPort = 'Failed to get vnc port'; $lang->zanode->nameValid = "The name can only be letters, numbers, '-', '_', '.', and cannot start with a symbol"; +$lang->zanode->empty = 'No zanode is found'; -$lang->zanode->empty = 'No Execution Node'; +$lang->zanode->empty = 'No Execution Node'; +$lang->zanode->createImaging = 'Creating'; +$lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the execution node to be shut down. Do you want to continue?'; +$lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. Created'; $lang->zanode->apiError['-10100'] = 'Execution node not found.'; @@ -58,5 +63,6 @@ $lang->zanode->statusList['launch'] = 'Launch'; $lang->zanode->statusList['ready'] = 'Ready'; $lang->zanode->statusList['running'] = 'Running'; $lang->zanode->statusList['suspend'] = 'Suspend'; +$lang->zanode->statusList['offline'] = 'Offline'; $lang->zanode->statusList['destroy'] = 'Destroyed'; $lang->zanode->statusList['destroy_fail'] = 'Destroy Fail'; diff --git a/module/zanode/lang/fr.php b/module/zanode/lang/fr.php index bbefb5c016..78355dc0ae 100644 --- a/module/zanode/lang/fr.php +++ b/module/zanode/lang/fr.php @@ -16,6 +16,7 @@ $lang->zanode->all = 'All'; $lang->zanode->byQuery = 'Search'; $lang->zanode->osName = 'System'; $lang->zanode->image = 'VM Image'; +$lang->zanode->imageName = 'Image Name'; $lang->zanode->name = 'Name'; $lang->zanode->start = 'Start After Created'; $lang->zanode->hostName = 'Host Name'; @@ -45,8 +46,12 @@ $lang->zanode->notFoundAgent = 'No Agent service is found'; $lang->zanode->createVmFail = 'Failed to create a execution node'; $lang->zanode->noVncPort = 'Failed to get vnc port'; $lang->zanode->nameValid = "The name can only be letters, numbers, '-', '_', '.', and cannot start with a symbol"; +$lang->zanode->empty = 'No zanode is found'; -$lang->zanode->empty = 'No Execution Node'; +$lang->zanode->empty = 'No Execution Node'; +$lang->zanode->createImaging = 'Creating'; +$lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the execution node to be shut down. Do you want to continue?'; +$lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. Created'; $lang->zanode->apiError['-10100'] = 'Execution node not found.'; @@ -58,5 +63,6 @@ $lang->zanode->statusList['launch'] = 'Launch'; $lang->zanode->statusList['ready'] = 'Ready'; $lang->zanode->statusList['running'] = 'Running'; $lang->zanode->statusList['suspend'] = 'Suspend'; +$lang->zanode->statusList['offline'] = 'Offline'; $lang->zanode->statusList['destroy'] = 'Destroyed'; $lang->zanode->statusList['destroy_fail'] = 'Destroy Fail'; diff --git a/module/zanode/lang/zh-cn.php b/module/zanode/lang/zh-cn.php index 1e1b81b5d6..9c22cf710a 100644 --- a/module/zanode/lang/zh-cn.php +++ b/module/zanode/lang/zh-cn.php @@ -16,6 +16,7 @@ $lang->zanode->all = '全部'; $lang->zanode->byQuery = '搜索'; $lang->zanode->osName = '操作系统'; $lang->zanode->image = '镜像'; +$lang->zanode->imageName = '镜像名称'; $lang->zanode->name = '执行节点名称'; $lang->zanode->start = '创建后自动开启'; $lang->zanode->hostName = '所属宿主机'; @@ -45,9 +46,13 @@ $lang->zanode->notFoundAgent = '没有发现Agent服务'; $lang->zanode->createVmFail = '创建执行节点失败'; $lang->zanode->noVncPort = '无法获取执行节点端口'; $lang->zanode->nameValid = "名称只能是字母、数字,'-','_','.',且不能以符号开头"; - $lang->zanode->empty = '暂时没有执行节点'; +$lang->zanode->createImage = '创建镜像'; +$lang->zanode->createImaging = '正在创建镜像'; +$lang->zanode->createImageNotice = '系统将基于当前执行节点创建镜像,该过程需要关闭该执行节点,确定要继续么?'; +$lang->zanode->createImageSuccess = '镜像创建成功,您可以使用此镜像创建执行节点。去创建'; + $lang->zanode->apiError['-10100'] = '执行节点不存在'; $lang->zanode->publicList[0] = '不共享'; @@ -61,4 +66,3 @@ $lang->zanode->statusList['suspend'] = '暂停'; $lang->zanode->statusList['offline'] = '下线'; $lang->zanode->statusList['destroy'] = '已销毁'; $lang->zanode->statusList['destroy_fail'] = '销毁失败'; - diff --git a/module/zanode/model.php b/module/zanode/model.php index 5aed4ce371..a2b3f73da9 100644 --- a/module/zanode/model.php +++ b/module/zanode/model.php @@ -25,6 +25,8 @@ class zanodemodel extends model const KVM_CREATE_PATH = '/api/v1/kvm/create'; const KVM_TOKEN_PATH = '/api/v1/virtual/getVncToken'; + const KVM_EXPORT_PATH = '/api/v1/kvm/exportVm'; + const KVM_STATUS_PATH = '/api/v1/task/getStatus'; /** @@ -105,6 +107,55 @@ class zanodemodel extends model return true; } + /** + * Create Image by zanode. + * + * @param int $zanodeID + * @access public + * @return void + */ + public function createImage($zanodeID = 0) + { + $data = fixer::input('post')->get(); + + if(empty($data->name)) dao::$errors['message'][] = '名称不能为空'; + if(dao::isError()) return false; + + $node = $this->getNodeByID($zanodeID); + $image = $this->getImageByID($node->image); + + $newImage = new stdClass(); + $newImage->name = $data->name; + $newImage->status = 'created'; + $newImage->osName = $node->osName; + $newImage->from = $node->id; + $newImage->createdDate = helper::now(); + + $this->dao->insert(TABLE_IMAGE) + ->data($newImage) + ->autoCheck() + ->exec(); + + if(dao::isError()) return false; + + $newID = $this->dao->lastInsertID(); + + /* Prepare create params. */ + $agnetUrl = 'http://' . $node->ip . ':' . $this->config->zanode->defaultPort; + $param = array( + 'backing' => "'{$data->name}'", + 'task' => $newID, + 'vm' => $node->name + ); + + $result = json_decode(commonModel::http($agnetUrl . static::KVM_EXPORT_PATH, json_encode($param,JSON_NUMERIC_CHECK), null)); + + if(!empty($result) and $result->code == 'success') return $newID; + + $this->dao->delete()->from(TABLE_IMAGE)->where('id')->eq($newID)->exec(); + return false; + } + /** * Action Node. * @@ -287,6 +338,22 @@ class zanodemodel extends model ->fetchAll(); } + /** + * Get node list. + * + * @param string $orderBy + * @access public + * @return void + */ + public function getList($orderBy = 'id_desc') + { + return $this->dao->select('*')->from(TABLE_ZAHOST) + ->where('deleted')->eq(0) + ->andWhere("type")->eq('node') + ->orderBy($orderBy) + ->fetchAll('id'); + } + /** * Get node list by hostID. * @@ -358,7 +425,29 @@ class zanodemodel extends model */ public function getimageList($orderBy = 'id_desc', $pager = null) { - return $this->dao->select('*')->from(TABLE_IMAGE)->orderBy($orderBy)->page($pager)->fetchAll(); + return $this->dao->select('*')->from(TABLE_IMAGE) + ->where('from')->eq(0) + ->orderBy($orderBy) + ->page($pager) + ->fetchAll(); + } + + /** + * Get custom image. + * + * @param int $nodeID + * @param string|array $status + * @param string $orderBy + * @access public + * @return void + */ + public function getCustomImage($nodeID = 0, $status = '', $orderBy = 'id_desc') + { + return $this->dao->select('*')->from(TABLE_IMAGE) + ->where('`from`')->eq($nodeID) + ->beginIF($status)->andWhere('status')->in($status)->fi() + ->orderBy($orderBy) + ->fetch(); } /** @@ -446,6 +535,42 @@ class zanodemodel extends model return $returnData; } + /** + * Get task status by zagent api. + * + * @param int $extranet + * @param int $taskID + * @param string $type + * @param string $status + * @access public + * @return void + */ + public function getTaskStatus($extranet = '', $taskID = 0, $type = '', $status = '') + { + $agnetUrl = 'http://' . $extranet . ':8086' . static::KVM_STATUS_PATH; + $result = json_decode(commonModel::http("$agnetUrl", array(), array(CURLOPT_CUSTOMREQUEST => 'POST'), array(), 'json')); + + if(empty($result) or $result->code != 'success') return false; + $data = $result->data; + if(empty($data)) return array(); + + if($status and !$taskID and isset($data->$status)) return $data->$status; + + if(!$taskID) return $data; + + foreach($data as $status => $tasks) + { + if(empty($tasks)) continue; + + foreach($tasks as $task) + { + if($type == $task->type and $taskID == $task->task) return $task; + if($taskID == $task->task) return $task; + } + } + + } + public function buildOperateMenu($node) { if($node->deleted) return ''; diff --git a/module/zanode/view/browse.html.php b/module/zanode/view/browse.html.php index 72ec091362..921c290db7 100644 --- a/module/zanode/view/browse.html.php +++ b/module/zanode/view/browse.html.php @@ -57,7 +57,7 @@
+ @@ -74,16 +74,19 @@
- title;?>
- spec; ?>
+
- verify; ?>
- name;?>
- desc; ?>
+
- storyTitle; ?>
- title;?>
- steps; ?>
heartbeat) ? '' : $host->heartbeat;?> hostID}", $host, 'list');?> - createLink('zahost', 'delete', "hostID={$host->id}"), '', 'hiddenwin', "title='{$lang->zahost->delete}' class='btn'");;?> + hostID]) ? '' : 'disabled';?> + hostID]) ? $lang->zahost->delete : $lang->zahost->undeletedNotice;?> + createLink('zahost', 'delete', "hostID={$host->id}"), '', 'hiddenwin', "title='$title' class='btn $disabled'");;?>
zanode->osName); ?> zanode->status); ?> zanode->hostName); ?> - actions ?>actions ?>
hostName; ?> zanode->suspend}' class='btn btn-primary' target='hiddenwin'"; - $suspendAttr .= $node->status == 'suspend' ? ' disabled' : " target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmSuspend}\")==false) return false;'"; + $suspendAttr = "title='{$lang->zanode->suspend}' target='hiddenwin'"; + $suspendAttr .= $node->status == 'suspend' ? ' class="btn disabled"' : "class='btn' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmSuspend}\")==false) return false;'"; + + $resumeAttr = "title='{$lang->zanode->resume}' target='hiddenwin'"; + $resumeAttr .= $node->status == 'running' ? ' class="btn disabled"' : "class='btn' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmResume}\")==false) return false;'"; + + $rebootAttr = "title='{$lang->zanode->reboot}' target='hiddenwin'"; + $rebootAttr .= $node->status == 'suspend' ? ' class="btn disabled"' : "class='btn' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmReboot}\")==false) return false;'"; - $resumeAttr = "title='{$lang->zanode->resume}' class='btn btn-primary' target='hiddenwin'"; - $resumeAttr .= $node->status == 'running' ? 'disabled' : " target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmResume}\")==false) return false;'"; - $rebootAttr = "title='{$lang->zanode->reboot}' class='btn btn-primary' target='hiddenwin'"; - $rebootAttr .= $node->status == 'suspend' ? ' disabled' : " target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmReboot}\")==false) return false;'"; common::printLink('zanode', 'suspend', "zanodeID={$node->id}", " ", '', $suspendAttr); common::printLink('zanode', 'resume', "zanodeID={$node->id}", " ", '', $resumeAttr); common::printLink('zanode', 'reboot', "zanodeID={$node->id}", " ", '', $rebootAttr); + common::printLink('zanode', 'createImage', "zanodeID={$node->id}", " ", '', "class='btn iframe' title='{$lang->zanode->createImage}'", '', true); common::printIcon('zanode', 'edit', "id={$node->id}", $node, 'list'); common::printLink('zanode', 'delete', "zanodeID={$node->id}", " ", '', "title='{$lang->zanode->destroy}' class='btn btn-primary' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmDelete}\")==false) return false;'"); ?> @@ -99,4 +102,4 @@ -getModuleRoot() . 'common/view/footer.html.php'; ?> \ No newline at end of file +getModuleRoot() . 'common/view/footer.html.php'; ?> diff --git a/module/zanode/view/createimage.html.php b/module/zanode/view/createimage.html.php new file mode 100644 index 0000000000..c22f94d1e0 --- /dev/null +++ b/module/zanode/view/createimage.html.php @@ -0,0 +1,77 @@ + + * @package task + * @version $Id: cancel.html.php 935 2010-07-06 07:49:24Z jajacn@126.com $ + * @link http://www.zentao.net + */ +?> + + +
+
+
+

+ zanode->createImage;?> +

+
+ +
zanode->createImaging;?>
+
+
+
+
+ +
zanode->createImageSuccess, $link)?>
+ +
+ + + + + + + + + + + + +
zanode->imageName;?>
zanode->desc;?>
+ zanode->createImageNotice}\")==false) return false;'");?> +
+
+ +
+
+ + + From b4bde0acf79c1d03f2f86455d74eec97cf3c11a9 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Mon, 5 Dec 2022 08:35:45 +0800 Subject: [PATCH 5/5] * Code for task #77685. --- module/zanode/control.php | 26 ++++++++++++- module/zanode/css/createimage.css | 2 +- module/zanode/lang/de.php | 1 + module/zanode/lang/en.php | 1 + module/zanode/lang/fr.php | 1 + module/zanode/lang/zh-cn.php | 1 + module/zanode/model.php | 4 +- module/zanode/view/browse.html.php | 2 +- module/zanode/view/createimage.html.php | 51 ++++++++++++++++--------- 9 files changed, 67 insertions(+), 22 deletions(-) diff --git a/module/zanode/control.php b/module/zanode/control.php index 0f6dc45a32..d3e2de60a2 100644 --- a/module/zanode/control.php +++ b/module/zanode/control.php @@ -207,8 +207,8 @@ class zanode extends control return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); } - // $task = ''; $this->view->task = $task; + $this->view->node = $node; $this->view->rate = !empty($task->rate) ? $task->rate : 0; $this->display(); } @@ -302,4 +302,28 @@ class zanode extends control $result = $this->zanode->getTaskStatus($extranet, $taskID, $type, $status); return print(json_encode($result)); } + + /** + * Update image. + * + * @param int $imageID + * @access public + * @return void + */ + public function ajaxUpdateImage($imageID = 0) + { + if($_POST) + { + $data = fixer::input('post')->get(); + $this->dao->update(TABLE_IMAGE)->data($data)->where('id')->eq($imageID)->autoCheck()->exec(); + + if(dao::isError()) + { + $response['result'] = 'fail'; + $response['message'] = dao::getError(); + return $this->send($response); + } + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess)); + } + } } diff --git a/module/zanode/css/createimage.css b/module/zanode/css/createimage.css index 20b32c2b40..abeaaa30e9 100644 --- a/module/zanode/css/createimage.css +++ b/module/zanode/css/createimage.css @@ -1,2 +1,2 @@ .progress{height: 20px;} -#mainContent{width: 50%; margin: 0 auto;} +#mainContent{margin: 0 auto;} diff --git a/module/zanode/lang/de.php b/module/zanode/lang/de.php index 78355dc0ae..fb5352dff4 100644 --- a/module/zanode/lang/de.php +++ b/module/zanode/lang/de.php @@ -52,6 +52,7 @@ $lang->zanode->empty = 'No Execution Node'; $lang->zanode->createImaging = 'Creating'; $lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the execution node to be shut down. Do you want to continue?'; $lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. Created'; +$lang->zanode->createImageFail = 'Failed to create'; $lang->zanode->apiError['-10100'] = 'Execution node not found.'; diff --git a/module/zanode/lang/en.php b/module/zanode/lang/en.php index 78355dc0ae..fb5352dff4 100644 --- a/module/zanode/lang/en.php +++ b/module/zanode/lang/en.php @@ -52,6 +52,7 @@ $lang->zanode->empty = 'No Execution Node'; $lang->zanode->createImaging = 'Creating'; $lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the execution node to be shut down. Do you want to continue?'; $lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. Created'; +$lang->zanode->createImageFail = 'Failed to create'; $lang->zanode->apiError['-10100'] = 'Execution node not found.'; diff --git a/module/zanode/lang/fr.php b/module/zanode/lang/fr.php index 78355dc0ae..fb5352dff4 100644 --- a/module/zanode/lang/fr.php +++ b/module/zanode/lang/fr.php @@ -52,6 +52,7 @@ $lang->zanode->empty = 'No Execution Node'; $lang->zanode->createImaging = 'Creating'; $lang->zanode->createImageNotice = 'The system will be created based on the current node,This process requires the execution node to be shut down. Do you want to continue?'; $lang->zanode->createImageSuccess = 'Successed, You can use this image to create node. Created'; +$lang->zanode->createImageFail = 'Failed to create'; $lang->zanode->apiError['-10100'] = 'Execution node not found.'; diff --git a/module/zanode/lang/zh-cn.php b/module/zanode/lang/zh-cn.php index 9c22cf710a..a24562f30d 100644 --- a/module/zanode/lang/zh-cn.php +++ b/module/zanode/lang/zh-cn.php @@ -52,6 +52,7 @@ $lang->zanode->createImage = '创建镜像'; $lang->zanode->createImaging = '正在创建镜像'; $lang->zanode->createImageNotice = '系统将基于当前执行节点创建镜像,该过程需要关闭该执行节点,确定要继续么?'; $lang->zanode->createImageSuccess = '镜像创建成功,您可以使用此镜像创建执行节点。去创建'; +$lang->zanode->createImageFail = '镜像创建失败'; $lang->zanode->apiError['-10100'] = '执行节点不存在'; diff --git a/module/zanode/model.php b/module/zanode/model.php index 03e08333f3..63304c6eb6 100644 --- a/module/zanode/model.php +++ b/module/zanode/model.php @@ -143,7 +143,7 @@ class zanodemodel extends model /* Prepare create params. */ $agnetUrl = 'http://' . $node->ip . ':' . $this->config->zanode->defaultPort; $param = array( - 'backing' => "'{$data->name}'", + 'backing' => $data->name, 'task' => $newID, 'vm' => $node->name ); @@ -565,10 +565,10 @@ class zanodemodel extends model foreach($tasks as $task) { if($type == $task->type and $taskID == $task->task) return $task; - if($taskID == $task->task) return $task; } } + return $result; } public function buildOperateMenu($node) diff --git a/module/zanode/view/browse.html.php b/module/zanode/view/browse.html.php index 921c290db7..1eb6b95a72 100644 --- a/module/zanode/view/browse.html.php +++ b/module/zanode/view/browse.html.php @@ -86,7 +86,7 @@ common::printLink('zanode', 'suspend', "zanodeID={$node->id}", " ", '', $suspendAttr); common::printLink('zanode', 'resume', "zanodeID={$node->id}", " ", '', $resumeAttr); common::printLink('zanode', 'reboot', "zanodeID={$node->id}", " ", '', $rebootAttr); - common::printLink('zanode', 'createImage', "zanodeID={$node->id}", " ", '', "class='btn iframe' title='{$lang->zanode->createImage}'", '', true); + common::printLink('zanode', 'createImage', "zanodeID={$node->id}", " ", '', "class='btn iframe' title='{$lang->zanode->createImage}' data-width='50%'", '', true); common::printIcon('zanode', 'edit', "id={$node->id}", $node, 'list'); common::printLink('zanode', 'delete', "zanodeID={$node->id}", " ", '', "title='{$lang->zanode->destroy}' class='btn btn-primary' target='hiddenwin' onclick='if(confirm(\"{$lang->zanode->confirmDelete}\")==false) return false;'"); ?> diff --git a/module/zanode/view/createimage.html.php b/module/zanode/view/createimage.html.php index c22f94d1e0..e534014994 100644 --- a/module/zanode/view/createimage.html.php +++ b/module/zanode/view/createimage.html.php @@ -12,6 +12,12 @@ ?> + +task);?> +ip);?> + +
@@ -26,7 +32,8 @@
-
zanode->createImageSuccess, $link)?>
+
zanode->createImageSuccess, $link);?>
+
zanode->createImageFail;?>
@@ -48,30 +55,40 @@ - + +