* [task#131010] Update create page.

This commit is contained in:
liyang
2024-11-08 08:31:19 +08:00
committed by 李阳
parent 5fda3ee804
commit 49857a6b32
4 changed files with 97 additions and 159 deletions
+2 -3
View File
@@ -2,9 +2,8 @@
$config->host->create = new stdclass();
$config->host->edit = new stdclass();
$config->host->changestatus = new stdclass();
$config->host->create->requiredFields = 'name,zap,tags,provider,intranet,extranet';
$config->host->edit->requiredFields = 'name,zap,tags,provider,intranet,extranet';
$config->host->create->intFields = 'cpuNumber,cpuCores,zap';
$config->host->create->requiredFields = 'name,intranet,extranet';
$config->host->edit->requiredFields = 'name,intranet,extranet';
$config->host->create->ipFields = 'intranet,extranet';
$config->host->editor = new stdclass();
+26 -43
View File
@@ -1,51 +1,34 @@
<?php
$config->host->form = new stdclass();
$config->host->form->create = array();
$config->host->form->create['name'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->create['admin'] = array('type' => 'int', 'required' => false, 'default' => '');
$config->host->form->create['cpuBrand'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->create['cpuModel'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->create['cpuNumber'] = array('type' => 'int', 'required' => false, 'default' => 0);
$config->host->form->create['cpuCores'] = array('type' => 'int', 'required' => false, 'default' => 0);
$config->host->form->create['diskSize'] = array('type' => 'float', 'required' => false, 'default' => 0);
$config->host->form->create['memory'] = array('type' => 'float', 'required' => false, 'default' => 0);
$config->host->form->create['group'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->create['serverRoom'] = array('type' => 'int', 'required' => false, 'default' => '');
$config->host->form->create['serverModel'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->create['hostType'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->create['osName'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->create['osVersion'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->create['zap'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->create['vsoft'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->create['intranet'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->create['extranet'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->create['provider'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->create['status'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->create['type'] = array('type' => 'string', 'required' => false, 'default' => 'normal');
$config->host->form->create['hardwareType'] = array('type' => 'string', 'required' => false, 'default' => 'server');
$config->host->form->create['name'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->create['admin'] = array('type' => 'int', 'required' => false, 'default' => '');
$config->host->form->create['cpuNumber'] = array('type' => 'int', 'required' => false, 'default' => 0);
$config->host->form->create['diskSize'] = array('type' => 'float', 'required' => false, 'default' => 0);
$config->host->form->create['memory'] = array('type' => 'float', 'required' => false, 'default' => 0);
$config->host->form->create['group'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->create['serverRoom'] = array('type' => 'int', 'required' => false, 'default' => '');
$config->host->form->create['osName'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->create['osVersion'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->create['intranet'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->create['extranet'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->create['status'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->create['type'] = array('type' => 'string', 'required' => false, 'default' => 'normal');
$config->host->form->edit = array();
$config->host->form->edit['name'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->edit['admin'] = array('type' => 'int', 'required' => false, 'default' => '');
$config->host->form->edit['cpuBrand'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->edit['cpuModel'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->edit['cpuNumber'] = array('type' => 'int', 'required' => false, 'default' => 0);
$config->host->form->edit['cpuCores'] = array('type' => 'int', 'required' => false, 'default' => 0);
$config->host->form->edit['diskSize'] = array('type' => 'float', 'required' => false, 'default' => 0);
$config->host->form->edit['memory'] = array('type' => 'float', 'required' => false, 'default' => 0);
$config->host->form->edit['group'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->edit['serverRoom'] = array('type' => 'int', 'required' => false, 'default' => '');
$config->host->form->edit['serverModel'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->edit['hostType'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->edit['osName'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->edit['osVersion'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->edit['zap'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->edit['vsoft'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->edit['intranet'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->edit['extranet'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->edit['provider'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->edit['status'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->edit['hardwareType'] = array('type' => 'string', 'required' => false, 'default' => 'server');
$config->host->form->edit['name'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->edit['admin'] = array('type' => 'int', 'required' => false, 'default' => '');
$config->host->form->edit['cpuNumber'] = array('type' => 'int', 'required' => false, 'default' => 0);
$config->host->form->edit['diskSize'] = array('type' => 'float', 'required' => false, 'default' => 0);
$config->host->form->edit['memory'] = array('type' => 'float', 'required' => false, 'default' => 0);
$config->host->form->edit['group'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->edit['serverRoom'] = array('type' => 'int', 'required' => false, 'default' => '');
$config->host->form->edit['osName'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->edit['osVersion'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->edit['intranet'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->edit['extranet'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->edit['provider'] = array('type' => 'string', 'required' => true, 'default' => '');
$config->host->form->edit['status'] = array('type' => 'string', 'required' => false, 'default' => '');
$config->host->form->changeStatus = array();
$config->host->form->changeStatus['reason'] = array('type' => 'string', 'required' => true, 'default' => '', 'control' => 'editor');
+67 -103
View File
@@ -16,80 +16,22 @@ formPanel
(
set::id('hostCreateForm'),
set::title($lang->host->create),
on::change('[name="CD"]')->call('showSpugConfig', jsRaw('this')),
formRow
(
formGroup
(
set::width('1/3'),
set::name('CD'),
set::label($lang->host->CD),
set::control('picker'),
set::items($lang->host->CDlist)
),
formGroup
(
set::width('1/3'),
set::name('name'),
set::label($lang->host->name)
),
formGroup
(
set::width('1/3'),
set::label($lang->host->admin),
set::control('picker'),
set::name('admin'),
set::items($accounts)
)
),
formRow
(
formGroup
(
set::width('1/3'),
set::label($lang->host->cpuBrand),
set::control('picker'),
set::name('cpuBrand'),
set::items($lang->host->cpuBrandList)
),
formGroup
(
set::width('1/3'),
set::name('cpuModel'),
set::label($lang->host->cpuModel)
)
),
formRow
(
formGroup
(
set::width('1/3'),
set::name('cpuNumber'),
set::label($lang->host->cpuNumber)
),
formGroup
(
set::width('1/3'),
set::name('cpuCores'),
set::label($lang->host->cpuCores)
)
),
formRow
(
formGroup
(
set::width('1/3'),
set::name('memory'),
set::label($lang->host->memory),
set::control(array
(
'type' => 'inputControl',
'suffix' => 'GB',
'suffixWidth' => 40
))
),
formGroup
(
set::width('1/3'),
set::name('diskSize'),
set::label($lang->host->diskSize),
set::control(array
(
'type' => 'inputControl',
'suffix' => 'GB',
'suffixWidth' => 40
))
)
),
formRow
@@ -116,17 +58,28 @@ formPanel
formGroup
(
set::width('1/3'),
set::name('serverModel'),
set::label($lang->host->serverModel)
set::label($lang->host->admin),
set::control('picker'),
set::name('admin'),
set::items($accounts)
),
),
formRow
(
setID('spugConfig'),
setClass('hidden'),
formGroup
(
set::width('1/3'),
set::label($lang->host->password),
set::name('password'),
set::control('password')
),
formGroup
(
set::width('1/3'),
set::label($lang->host->hostType),
set::control('picker'),
set::name('hostType'),
set::items($lang->host->hostTypeList),
set::value('virtual')
set::label($lang->host->sshPort),
set::name('sshPort')
)
),
formRow
@@ -151,25 +104,6 @@ formPanel
)
),
formRow
(
formGroup
(
set::width('1/3'),
set::name('zap'),
set::label($lang->host->zap),
set::value(8086)
),
formGroup
(
set::width('1/3'),
set::label($lang->host->tags),
set::control('picker'),
set::name('vsoft'),
set::items($lang->host->tagsList),
set::value('vm')
)
),
formRow
(
formGroup
(
@@ -189,20 +123,50 @@ formPanel
formGroup
(
set::width('1/3'),
set::label($lang->host->provider),
set::control('picker'),
set::name('provider'),
set::items($lang->host->providerList)
set::name('cpuNumber'),
set::label($lang->host->cpuNumber),
set::control(array('type' => 'number', 'min' => 1))
),
formGroup
(
set::width('1/3'),
set::name('status'),
set::control('radioList'),
set::label($lang->host->status),
set::value('online'),
set::inline(true),
set::items($lang->host->statusList)
set::name('memory'),
set::label($lang->host->memory),
set::control(array
(
'type' => 'inputControl',
'suffix' => 'GB',
'suffixWidth' => 40
))
)
),
formGroup
(
set::width('1/3'),
set::name('diskSize'),
set::label($lang->host->diskSize),
set::control(array
(
'type' => 'inputControl',
'suffix' => 'GB',
'suffixWidth' => 40
))
),
formGroup
(
set::width('2/3'),
set::name('desc'),
set::label($lang->host->desc),
set::control(array('type' => 'textarea', 'rows' => 3))
),
formGroup
(
set::width('1/3'),
set::name('status'),
set::control('radioList'),
set::label($lang->host->status),
set::value('online'),
set::inline(true),
set::items($lang->host->statusList)
)
);
+2 -10
View File
@@ -21,19 +21,11 @@ class hostZen extends host
*/
protected function checkFormData(object $formData): bool
{
$intFields = explode(',', $this->config->host->create->intFields);
foreach($intFields as $field)
{
if(!preg_match("/^-?\d+$/", (string)$formData->{$field}))
{
dao::$errors[$field] = sprintf($this->lang->host->notice->int, $this->lang->host->{$field});
}
}
$ipFields = explode(',', $this->config->host->create->ipFields);
foreach($ipFields as $field)
{
if(!preg_match('/((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/', (string)$formData->{$field}))
$address = str_replace(array('https://', 'http://'), '', $formData->{$field});
if(!filter_var($address, FILTER_VALIDATE_IP) && !filter_var(gethostbyname($address), FILTER_VALIDATE_IP))
{
dao::$errors[$field] = sprintf($this->lang->host->notice->ip, $this->lang->host->{$field});
}