diff --git a/module/zanode/control.php b/module/zanode/control.php index adad9480c5..5483a28f68 100644 --- a/module/zanode/control.php +++ b/module/zanode/control.php @@ -363,4 +363,18 @@ class zanode extends control return $this->send(array('result' => 'success', 'message' => '', 'data' => $serviceStatus)); } + + /** + * ajaxRunZTFScript + * + * @param int $scriptID + * @access public + * @return void + */ + public function ajaxRunZTFScript($scriptID = 0) + { + $script = $this->zanode->getAutomationByID($scriptID); + + return $this->send(array('result' => 'success', 'message' => '', 'data' => $serviceStatus)); + } } diff --git a/module/zanode/css/common.css b/module/zanode/css/common.css index 6f18896c39..e69de29bb2 100644 --- a/module/zanode/css/common.css +++ b/module/zanode/css/common.css @@ -1,7 +0,0 @@ -#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: fit-content;} -.modal-dialog{border-radius: 4px;} -.modal-header{padding:9px 15px 0px; margin:0px; border-bottom:0;} -.modal-dialog .modal-body{padding: 5px 15px 20px 15px;} diff --git a/module/zanode/js/common.js b/module/zanode/js/common.js index 07673afe7e..af78b5fd6f 100644 --- a/module/zanode/js/common.js +++ b/module/zanode/js/common.js @@ -36,9 +36,3 @@ $(function() if(typeof image == 'undefined' || !image) $('#os').change(); }) - -function showModal(url = '') -{ - if(url) $("#modalLink").attr('href', url); - $('#successModal').modal('show', 'center'); -} diff --git a/module/zanode/model.php b/module/zanode/model.php index 3f919c5416..b51470dc1b 100644 --- a/module/zanode/model.php +++ b/module/zanode/model.php @@ -489,6 +489,19 @@ class zanodemodel extends model ->fetch(); } + /** + * Get automation by id. + * + * @param int $id + * @return object + */ + public function getScriptByID($id) + { + return $this->dao->select('*')->from(TABLE_AUTOMATION) + ->where('id')->eq($id) + ->fetch(); + } + /** * Generage unique mac address. * @@ -636,7 +649,7 @@ class zanodemodel extends model "server" => getWebRoot(true), ); $result = json_decode(commonModel::http("http://{$node->extranet}:{$node->zap}/api/v1/service/setup", json_encode($param), array(), array("Authorization:$node->tokenSN"))); - + if(empty($result->data) || $result->code != 'success') { $result = new stdclass; @@ -663,6 +676,19 @@ class zanodemodel extends model ->fetch(); } + /** + * Get automation by id. + * + * @param int $id + * @return object + */ + public function getAutomationByID($id) + { + return $this->dao->select('*')->from(TABLE_AUTOMATION) + ->where('id')->eq($id) + ->fetch(); + } + /** * Set automation setting. * @@ -687,4 +713,34 @@ class zanodemodel extends model if(dao::isError()) return false; return $this->dao->lastInsertID(); } + + /** + * Run ZTFScript. + * + * @access public + * @return void + */ + public function runZTFScript() + { + $params = array( + 'cmd' => '', + 'ids' => '', + 'path' => '', + 'task' => '', + 'workspace' => '' + ); + + $result = json_decode(commonModel::http("http://{$node->ip}:{$node->zap}/api/v1/jobs/add", json_encode($params), array(), array("Authorization:$node->tokenSN"))); + + if(empty($result->data) || $result->code != 'success') + { + $result = new stdclass; + $result->data = $this->lang->zanode->init->serviceStatus; + } + + return array( + "ZenAgent" => "ready", + "ZTF" => $result->data->ztfStatus, + ); + } } diff --git a/module/zanode/view/init.html.php b/module/zanode/view/init.html.php index 1dfb6a4229..8cc20d042b 100644 --- a/module/zanode/view/init.html.php +++ b/module/zanode/view/init.html.php @@ -40,5 +40,5 @@ - +