dbmsv2 init...1
This commit is contained in:
parent
93e82b1104
commit
6889d58063
@ -3,6 +3,7 @@
|
|||||||
namespace App\Cells\Equipment;
|
namespace App\Cells\Equipment;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Entities\Equipment\ServerEntity;
|
||||||
use App\Services\Equipment\ServerPartService;
|
use App\Services\Equipment\ServerPartService;
|
||||||
use App\Services\Equipment\ServerService;
|
use App\Services\Equipment\ServerService;
|
||||||
|
|
||||||
@ -24,30 +25,29 @@ class ServerPartCell extends EquipmentCell
|
|||||||
|
|
||||||
public function parttable(array $params): string
|
public function parttable(array $params): string
|
||||||
{
|
{
|
||||||
$result = "";
|
|
||||||
if (array_key_exists('serverinfo_uid', $params)) {
|
|
||||||
$this->getService()->setAction(__FUNCTION__);
|
$this->getService()->setAction(__FUNCTION__);
|
||||||
$this->getService()->setFormFields();
|
$this->getService()->setFormFields();
|
||||||
$this->getService()->setFormFilters();
|
$this->getService()->setFormFilters();
|
||||||
$this->getService()->setFormRules();
|
$this->getService()->setFormRules();
|
||||||
$this->getService()->setFormOptions();
|
$this->getService()->setFormOptions();
|
||||||
// dd($params);
|
$entities = [];
|
||||||
|
$serverEntity = null;
|
||||||
|
if (array_key_exists('serverinfo_uid', $params)) {
|
||||||
//서버정보
|
//서버정보
|
||||||
$serverEntity = $this->getServerService()->getEntity($params['serverinfo_uid']);
|
$serverEntity = $this->getServerService()->getEntity($params['serverinfo_uid']);
|
||||||
if (!$serverEntity) {
|
if ($serverEntity instanceof ServerEntity) {
|
||||||
return "[{$params['serverinfo_uid']}]에 해당하는 서버정보가 지정되지 않았거나 존재하지 않습니다.";
|
|
||||||
}
|
|
||||||
//서버파트정보
|
//서버파트정보
|
||||||
$serverPartEntities = $this->getService()->getEntities(['serverinfo_uid' => $serverEntity->getPK(),]);
|
$serverPartEntities = $this->getService()->getEntities(['serverinfo_uid' => $serverEntity->getPK(),]);
|
||||||
$entities = [];
|
|
||||||
foreach ($serverPartEntities as $entity) {
|
foreach ($serverPartEntities as $entity) {
|
||||||
if (!array_key_exists($entity->getType(), $entities)) {
|
if (!array_key_exists($entity->getType(), $entities)) {
|
||||||
$entities[$entity->getType()] = [];
|
$entities[$entity->getType()] = [];
|
||||||
}
|
}
|
||||||
$entities[$entity->getType()][] = $entity;
|
$entities[$entity->getType()][] = $entity;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__;
|
$template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__;
|
||||||
$result = view('cells/serverpart/' . $template, [
|
return view('cells/serverpart/' . $template, [
|
||||||
'serverPartCellDatas' => [
|
'serverPartCellDatas' => [
|
||||||
'control' => $this->getService()->getControlDatas(),
|
'control' => $this->getService()->getControlDatas(),
|
||||||
'service' => $this->getService(),
|
'service' => $this->getService(),
|
||||||
@ -58,6 +58,4 @@ class ServerPartCell extends EquipmentCell
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,12 +6,12 @@ use CodeIgniter\Entity\Entity;
|
|||||||
|
|
||||||
abstract class CommonEntity extends Entity
|
abstract class CommonEntity extends Entity
|
||||||
{
|
{
|
||||||
|
const DEFAULT_STATUS = "";
|
||||||
protected $datamap = [];
|
protected $datamap = [];
|
||||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||||
//사용법 : $client->created_at->format('Y-m-d')
|
//사용법 : $client->created_at->format('Y-m-d')
|
||||||
//비교방법 : if ($client->created_at < new \DateTime('2024-01-01')) {
|
//비교방법 : if ($client->created_at < new \DateTime('2024-01-01')) {
|
||||||
protected $casts = [];
|
protected $casts = [];
|
||||||
|
|
||||||
public function __construct(array|null $data = null)
|
public function __construct(array|null $data = null)
|
||||||
{
|
{
|
||||||
parent::__construct($data);
|
parent::__construct($data);
|
||||||
|
|||||||
@ -8,8 +8,6 @@ class ServerPartEntity extends EquipmentEntity
|
|||||||
{
|
{
|
||||||
const PK = ServerPartModel::PK;
|
const PK = ServerPartModel::PK;
|
||||||
const TITLE = ServerPartModel::TITLE;
|
const TITLE = ServerPartModel::TITLE;
|
||||||
const DEFAULT_STATUS = null;
|
|
||||||
|
|
||||||
public function setPartEntity(mixed $entity): ServerPartEntity
|
public function setPartEntity(mixed $entity): ServerPartEntity
|
||||||
{
|
{
|
||||||
$this->attributes['partEntity'] = $entity;
|
$this->attributes['partEntity'] = $entity;
|
||||||
@ -56,4 +54,8 @@ class ServerPartEntity extends EquipmentEntity
|
|||||||
{
|
{
|
||||||
return $this->attributes['extra'] ?? "";
|
return $this->attributes['extra'] ?? "";
|
||||||
}
|
}
|
||||||
|
public function getStatus(): string
|
||||||
|
{
|
||||||
|
return self::DEFAULT_STATUS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Entities;
|
|
||||||
|
|
||||||
class FormOptionEntity extends CommonEntity
|
|
||||||
{
|
|
||||||
const PK = "uid";
|
|
||||||
const TITLE = "title";
|
|
||||||
const DEFAULT_STATUS = null;
|
|
||||||
}
|
|
||||||
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Helpers;
|
namespace App\Helpers;
|
||||||
|
|
||||||
|
use App\Entities\CommonEntity;
|
||||||
|
|
||||||
class CommonHelper
|
class CommonHelper
|
||||||
{
|
{
|
||||||
private $_myAuth = null;
|
private $_myAuth = null;
|
||||||
@ -231,16 +233,22 @@ class CommonHelper
|
|||||||
$html = "";
|
$html = "";
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
default:
|
default:
|
||||||
foreach ($viewDatas['control']['field_optons'][$field] as $key => $entity) {
|
foreach ($viewDatas['control']['field_optons'][$field] as $option_key => $option_value) {
|
||||||
$isSelected = $key == $value ? ' selected' : '';
|
$isSelected = $option_key == $value ? ' selected' : '';
|
||||||
$isDisabled = "";
|
$isDisabled = "";
|
||||||
$attribute = "";
|
$attribute = "";
|
||||||
foreach ($attributes as $attribute_tag => $attribute_value) {
|
$label = "";
|
||||||
$attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $attribute_value);
|
if ($option_value instanceof CommonEntity) {
|
||||||
|
if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) {
|
||||||
|
if ($option_value->getStatus() != $option_value::DEFAULT_STATUS)
|
||||||
|
$html = " disabled";
|
||||||
}
|
}
|
||||||
$title = $entity->getStatus() != $entity::DEFAULT_STATUS ? "서비스중." : "";
|
$label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? "X." : "";
|
||||||
$title .= $entity->getCustomTitle();
|
$label .= $option_value->getCustomTitle();
|
||||||
$html .= sprintf("<option value=\"%s\"%s%s%s>%s</option>", $key, $isSelected, $isDisabled, $attribute, $title);
|
} else {
|
||||||
|
$label = $option_value;
|
||||||
|
}
|
||||||
|
$html .= sprintf("<option value=\"%s\"%s%s%s>%s</option>", $option_key, $isSelected, $isDisabled, $attribute, $label);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,34 +12,6 @@ class ServiceHelper extends CustomerHelper
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->setTitleField(field: ServiceModel::TITLE);
|
$this->setTitleField(field: ServiceModel::TITLE);
|
||||||
}
|
}
|
||||||
protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string
|
|
||||||
{
|
|
||||||
$html = "";
|
|
||||||
switch ($field) {
|
|
||||||
case 'serverinfo_uid':
|
|
||||||
$attribute = "";
|
|
||||||
foreach ($viewDatas['control']['field_optons'][$field] as $key => $entity) {
|
|
||||||
$isSelected = $key == $value ? ' selected' : '';
|
|
||||||
$isDisabled = "";
|
|
||||||
if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) {
|
|
||||||
if ($entity->getStatus() != $entity::DEFAULT_STATUS)
|
|
||||||
$isDisabled = " disabled";
|
|
||||||
}
|
|
||||||
$attribute = "";
|
|
||||||
foreach ($attributes as $attribute_tag => $attribute_value) {
|
|
||||||
$attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $entity instanceof ServerEntity ? $entity->$attribute_value() : $attribute_value);
|
|
||||||
}
|
|
||||||
$title = $entity->getStatus() != $entity::DEFAULT_STATUS ? "서비스중." : "";
|
|
||||||
$title .= $entity->getCustomTitle();
|
|
||||||
$html .= sprintf("<option value=\"%s\"%s%s%s>%s</option>", $key, $isSelected, $isDisabled, $attribute, $title);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$html = parent::form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Helpers\Equipment;
|
namespace App\Helpers\Equipment;
|
||||||
|
|
||||||
use App\Entities\Equipment\PartEntity;
|
use App\Entities\CommonEntity;
|
||||||
use App\Models\Equipment\ServerPartModel;
|
use App\Models\Equipment\ServerPartModel;
|
||||||
|
|
||||||
class ServerPartHelper extends EquipmentHelper
|
class ServerPartHelper extends EquipmentHelper
|
||||||
@ -17,21 +17,22 @@ class ServerPartHelper extends EquipmentHelper
|
|||||||
$html = "";
|
$html = "";
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case 'part_uid':
|
case 'part_uid':
|
||||||
$attribute = "";
|
foreach ($viewDatas['control']['field_optons'][$field] as $option_key => $option_value) {
|
||||||
foreach ($viewDatas['control']['field_optons'][$field] as $key => $entity) {
|
$isSelected = $option_key == $value ? ' selected' : '';
|
||||||
$isSelected = $key == $value ? ' selected' : '';
|
|
||||||
$isDisabled = "";
|
$isDisabled = "";
|
||||||
if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) {
|
|
||||||
if ($entity->getStatus() != $entity::DEFAULT_STATUS)
|
|
||||||
$isDisabled = " disabled";
|
|
||||||
}
|
|
||||||
$attribute = "";
|
$attribute = "";
|
||||||
foreach ($attributes as $attribute_tag => $attribute_value) {
|
$label = "";
|
||||||
$attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $entity instanceof PartEntity ? $entity->$attribute_value() : $attribute_value);
|
if ($option_value instanceof CommonEntity) {
|
||||||
|
if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) {
|
||||||
|
if ($option_value->getStatus() != $option_value::DEFAULT_STATUS)
|
||||||
|
$html = " disabled";
|
||||||
}
|
}
|
||||||
$title = $entity->getStatus() != $entity::DEFAULT_STATUS ? "서비스중." : "";
|
$label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? "X." : "";
|
||||||
$title .= $entity->getCustomTitle();
|
$label .= $option_value->getCustomTitle();
|
||||||
$html .= sprintf("<option value=\"%s\"%s%s%s>%s</option>", $key, $isSelected, $isDisabled, $attribute, $title);
|
} else {
|
||||||
|
$label = $option_value;
|
||||||
|
}
|
||||||
|
$html .= sprintf("<option value=\"%s\"%s%s%s>%s</option>", $option_key, $isSelected, $isDisabled, $attribute, $label);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -65,6 +66,7 @@ class ServerPartHelper extends EquipmentHelper
|
|||||||
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
echo "Field:{$field}";
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
|
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
|
||||||
|
|||||||
@ -235,14 +235,7 @@ abstract class CommonService
|
|||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
default:
|
default:
|
||||||
$formOptionDatas = lang($this->getClassName() . '.' . strtoupper($field));
|
$options = lang($this->getClassName() . '.' . strtoupper($field));
|
||||||
if (!is_array($formOptionDatas)) {
|
|
||||||
throw new \Exception(__FUNCTION__ . "에서 {$field}}의 formOptionDatas 값이 array가 아닙니다.\n" . var_export($formOptionDatas, true));
|
|
||||||
}
|
|
||||||
$options = [];
|
|
||||||
foreach ($formOptionDatas as $key => $value) {
|
|
||||||
$options[$key] = new FormOptionEntity(['uid' => $key, 'title' => $value]);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!is_array($options)) {
|
if (!is_array($options)) {
|
||||||
|
|||||||
@ -57,8 +57,8 @@ class ServerPartService extends EquipmentService
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
"serverinfo_uid",
|
"serverinfo_uid",
|
||||||
"type",
|
|
||||||
"part_uid",
|
"part_uid",
|
||||||
|
"type",
|
||||||
"billing",
|
"billing",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -122,29 +122,30 @@ class ServerPartService extends EquipmentService
|
|||||||
{
|
{
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
case 'part_uid':
|
case 'part_uid':
|
||||||
$type = $this->getFormDatas()['type'] ?? null;
|
$partOptions = [];
|
||||||
switch ($type) {
|
foreach (SERVERPART['PARTTYPES'] as $partType) {
|
||||||
|
switch ($partType) {
|
||||||
case 'CPU':
|
case 'CPU':
|
||||||
case 'RAM':
|
case 'RAM':
|
||||||
case 'DISK':
|
case 'DISK':
|
||||||
case 'OS':
|
case 'OS':
|
||||||
case 'DB':
|
case 'DB':
|
||||||
case 'SOFTWARE':
|
case 'SOFTWARE':
|
||||||
$options = $this->getPartService()->getEntities(['type' => $type]);
|
$partOptions[$partType] = $this->getPartService()->getEntities(['type' => $partType]);
|
||||||
break;
|
break;
|
||||||
case 'SWITCH':
|
case 'SWITCH':
|
||||||
$options = $this->getSwitchService()->getEntities();
|
$partOptions[$partType] = $this->getSwitchService()->getEntities();
|
||||||
break;
|
break;
|
||||||
case 'IP':
|
case 'IP':
|
||||||
$options = $this->getIPService()->getEntities();
|
$partOptions[$partType] = $this->getIPService()->getEntities();
|
||||||
break;
|
break;
|
||||||
case 'CS':
|
case 'CS':
|
||||||
$options = $this->getCSService()->getEntities();
|
$partOptions[$partType] = $this->getCSService()->getEntities();
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$options = [];
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
$options = $partOptions;
|
||||||
|
// dd($options);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$options = parent::getFormOption($field, $options);
|
$options = parent::getFormOption($field, $options);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
<?php $htmls = $texts = [$serverPartCellDatas['serverEntity']->getCode()] ?>
|
<?php $htmls = $texts = [!$serverPartCellDatas['serverEntity'] ? "" : $serverPartCellDatas['serverEntity']->getCode()] ?>
|
||||||
<?php foreach (['SWITCH', 'IP', 'OS'] as $type): ?>
|
<?php foreach (['SWITCH', 'IP', 'OS'] as $type): ?>
|
||||||
<?php $texts[] = $serverPartCellDatas['service']->getHelper()->getFieldView($type, '', $serverPartCellDatas, ['return_type' => 'text']); ?>
|
<?php $texts[] = $serverPartCellDatas['service']->getHelper()->getFieldView($type, '', $serverPartCellDatas, ['return_type' => 'text']); ?>
|
||||||
<?php $button = $serverPartCellDatas['service']->getHelper()->getListButton($type, '', $serverPartCellDatas) ?>
|
<?php $button = $serverPartCellDatas['service']->getHelper()->getListButton($type, '', $serverPartCellDatas) ?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user