From e5c6bdc8f6bd7635640e0c966d48aa815d505f35 Mon Sep 17 00:00:00 2001 From: liyang Date: Tue, 12 Nov 2024 22:36:20 +0800 Subject: [PATCH] * [bug#56872] Fix bug for update os. --- module/host/control.php | 26 ++++++++++++++++++++++---- module/host/ui/create.html.php | 3 +-- module/host/ui/edit.html.php | 6 ++++-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/module/host/control.php b/module/host/control.php index 9adc0a31cf..627b17b033 100644 --- a/module/host/control.php +++ b/module/host/control.php @@ -64,7 +64,7 @@ class host extends control * @access public * @return void */ - public function create(string $osName = 'linux') + public function create() { if($_POST) { @@ -79,7 +79,6 @@ class host extends control } $this->view->title = $this->lang->host->create; - $this->view->osName = $osName; $this->view->rooms = $this->loadModel('serverroom')->getPairs(); $this->view->accounts = $this->loadModel('account')->getPairs(); $this->view->optionMenu = $this->loadModel('tree')->getOptionMenu(0, 'host'); @@ -95,7 +94,7 @@ class host extends control * @access public * @return void */ - public function edit(int $id, string $osName = '') + public function edit(int $id) { if($_POST) { @@ -111,7 +110,6 @@ class host extends control $this->view->title = $this->lang->host->edit; $this->view->host = $this->host->fetchByID($id); - $this->view->osName = $osName ? $osName : $this->view->host->osName; $this->view->rooms = $this->loadModel('serverroom')->getPairs(); $this->view->accounts = $this->loadModel('account')->getPairs(); $this->view->optionMenu = $this->loadModel('tree')->getOptionMenu(0, 'host'); @@ -195,4 +193,24 @@ class host extends control $this->view->type = $type; $this->display(); } + + /** + * Js获取所有的操作系统列表。 + * Get all os list. + * + * @param string $type + * @access public + * @return void + */ + public function ajaxGetOS(string $type) + { + $type = "{$type}List"; + $osList = $this->lang->host->{$type}; + if(empty($osList)) return ''; + + $osItems = array(); + foreach($osList as $version => $os) $osItems[] = array('text' => $os, 'value' => $version); + + return print(json_encode($osItems)); + } } diff --git a/module/host/ui/create.html.php b/module/host/ui/create.html.php index 2cf942fae1..3dd4c81fde 100644 --- a/module/host/ui/create.html.php +++ b/module/host/ui/create.html.php @@ -50,8 +50,7 @@ formPanel set::label($lang->host->osName), set::control('picker'), set::name('osName'), - set::items($lang->host->osNameList), - set::value($osName ? $osName : $host->osName), + set::items(array()), on::change('osChange') ) ), diff --git a/module/host/ui/edit.html.php b/module/host/ui/edit.html.php index 928405c679..2b8b310f36 100644 --- a/module/host/ui/edit.html.php +++ b/module/host/ui/edit.html.php @@ -18,6 +18,7 @@ formPanel ( set::id('hostEditForm'), set::title($lang->host->edit), + on::init()->do('$(function() {setTimeout(osChange, 50); });'), formRow ( setID('groupRow'), @@ -56,7 +57,7 @@ formPanel set::control('picker'), set::name('osName'), set::items($lang->host->osNameList), - set::value($osName ? $osName : $host->osName), + set::value(zget($host, 'osName', '')), on::change('osChange') ) ), @@ -71,11 +72,12 @@ formPanel ), formGroup ( + setID('osVersion'), set::width('1/3'), set::label($lang->host->osVersion), set::control('picker'), set::name('osVersion'), - set::items($lang->host->{"{$osName}List"}), + set::items(array()), set::value($host->osVersion) ) ),