From 9b18d2e75092604ffb32698dfc3ee581ff83f1a3 Mon Sep 17 00:00:00 2001 From: zhaoke Date: Fri, 2 Dec 2022 07:56:40 +0000 Subject: [PATCH] * Add submit task --- api/v1/entries/hostSubmit.php | 48 ++++++++++++++++++++++++++++++ config/routes.php | 1 + module/zahost/lang/de.php | 2 +- module/zahost/lang/en.php | 2 +- module/zahost/lang/vi.php | 2 +- module/zahost/view/create.html.php | 4 +-- module/zahost/view/edit.html.php | 4 +-- module/zanode/css/edit.css | 3 ++ module/zanode/view/create.html.php | 4 +-- module/zanode/view/edit.html.php | 6 ++-- 10 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 api/v1/entries/hostSubmit.php create mode 100644 module/zanode/css/edit.css diff --git a/api/v1/entries/hostSubmit.php b/api/v1/entries/hostSubmit.php new file mode 100644 index 0000000000..586a7bfdc5 --- /dev/null +++ b/api/v1/entries/hostSubmit.php @@ -0,0 +1,48 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class hostSubmitEntry extends baseEntry +{ + /** + * Listen host heartbeat. + * + * @param int|string $userID + * @access public + * @return void + */ + public function post() + { + /* Check authorize. */ + $header = getallheaders(); + $token = isset($header['Authorization']) ? substr($header['Authorization'], 7) : ''; + if(!$token) return $this->sendError(401, 'Unauthorized'); + + $now = helper::now(); + + /* Check param. */ + $image = new stdclass(); + $task = $this->requestBody->task; + $image->status = $this->requestBody->status; + $image->speed = $this->requestBody->speed; + $image->rate = $this->requestBody->rate; + + $this->dao = $this->loadModel('common')->dao; + $id = $this->dao->select('id')->from(TABLE_ZAHOST) + ->where('tokenSN')->eq($token) + ->andWhere('tokenTime')->gt($now)->fi() + ->fetch('id'); + if(!$id) return $this->sendError(400, 'Secret error.'); + + $this->dao->update(TABLE_IMAGE)->data($image)->where("id")->eq($task)->exec(); + + return $this->sendSuccess(200, 'success'); + } +} diff --git a/config/routes.php b/config/routes.php index 18a55e1ec6..6369c4ff10 100644 --- a/config/routes.php +++ b/config/routes.php @@ -162,6 +162,7 @@ $routes['/modules'] = 'modules'; $routes['/reports'] = 'reports'; $routes['/host/heartbeat'] = 'hostHeartbeat'; +$routes['/host/submitResult'] = 'hostSubmit'; $routes['/zanode/heartbeat'] = 'zanodeHeartbeat'; diff --git a/module/zahost/lang/de.php b/module/zahost/lang/de.php index 95aa835f71..f62bf33eaf 100644 --- a/module/zahost/lang/de.php +++ b/module/zahost/lang/de.php @@ -20,7 +20,7 @@ $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->diskSize = 'Disk Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; diff --git a/module/zahost/lang/en.php b/module/zahost/lang/en.php index 4d2a57326b..5b3885c409 100644 --- a/module/zahost/lang/en.php +++ b/module/zahost/lang/en.php @@ -20,7 +20,7 @@ $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->diskSize = 'Disk Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; diff --git a/module/zahost/lang/vi.php b/module/zahost/lang/vi.php index 03737e60c7..3ab6b219af 100644 --- a/module/zahost/lang/vi.php +++ b/module/zahost/lang/vi.php @@ -20,7 +20,7 @@ $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->diskSize = 'Disk Size'; $lang->zahost->desc = 'Description'; $lang->zahost->type = 'Type'; $lang->zahost->status = 'Status'; diff --git a/module/zahost/view/create.html.php b/module/zahost/view/create.html.php index 7eccdf9827..0cede66734 100644 --- a/module/zahost/view/create.html.php +++ b/module/zahost/view/create.html.php @@ -46,7 +46,7 @@
- zahost->unitList['GB'];?> + GB
@@ -56,7 +56,7 @@
- zahost->unitList['GB'];?> + GB
diff --git a/module/zahost/view/edit.html.php b/module/zahost/view/edit.html.php index a1879cffa9..adf9f0941e 100644 --- a/module/zahost/view/edit.html.php +++ b/module/zahost/view/edit.html.php @@ -46,7 +46,7 @@
memory, "class='form-control'");?> - zahost->unitList['GB'];?> + GB
@@ -56,7 +56,7 @@
diskSize, "class='form-control'");?> - zahost->unitList['GB'];?> + GB
diff --git a/module/zanode/css/edit.css b/module/zanode/css/edit.css new file mode 100644 index 0000000000..f5c8086763 --- /dev/null +++ b/module/zanode/css/edit.css @@ -0,0 +1,3 @@ +#unit {padding: 0px !important; width:0px; border-left: 0px;width:63px;} +.input-group-addon {border: 0px; width: 100px;} +#memory-addon {width:63px;} diff --git a/module/zanode/view/create.html.php b/module/zanode/view/create.html.php index a5c4b957e3..676e8f324f 100644 --- a/module/zanode/view/create.html.php +++ b/module/zanode/view/create.html.php @@ -42,7 +42,7 @@
- zahost->unitList['GB'];?> + GB
@@ -52,7 +52,7 @@
- zahost->unitList['GB'];?> + GB
diff --git a/module/zanode/view/edit.html.php b/module/zanode/view/edit.html.php index d3f27e65c7..6af26b9953 100644 --- a/module/zanode/view/edit.html.php +++ b/module/zanode/view/edit.html.php @@ -26,7 +26,7 @@ zanode->name;?> - name, "class='form-control' placeholder=\"{$lang->zanode->nameValid}\"");?> + name, "class='form-control' placeholder=\"{$lang->zanode->nameValid}\" readonly='readonly'");?> @@ -42,7 +42,7 @@
memory, "class='form-control' readonly='readonly'");?> - zahost->unitList['GB'];?> + GB
@@ -52,7 +52,7 @@
diskSize, "class='form-control' readonly='readonly'");?> - zahost->unitList['GB'];?> + GB