cfmgrv4 init...1

This commit is contained in:
최준흠 2024-09-28 18:47:43 +09:00
parent e91771c8b4
commit 5d620c8d88
22 changed files with 113 additions and 126 deletions

View File

@ -165,7 +165,8 @@ define('ICONS', [
'NEW' => '<i class="bi bi-database-add"></i>',
'REPLY' => '<i class="bi bi-arrow-return-right"></i>',
'DELETE' => '<i class="bi bi-trash"></i>',
'RELOAD' => '<i class="bi bi-repeat"></i>',
'REBOOT' => '<i class="bi bi-repeat"></i>',
'RELOAD' => '<i class="bi bi-bootstrap-reboot"></i>',
'SETUP' => '<i class="bi bi-gear"></i>',
'FLAG' => '<i class="bi bi-send"></i>',
'SEARCH' => '<i class="bi bi-search"></i>',

View File

@ -153,7 +153,7 @@ abstract class MVController extends CommonController
}
}
// 리스트
private function list_condition_process($isTotalCount = false): void
private function list_condition_process(): void
{
//조건절 처리
foreach ($this->filter_fields as $field) {
@ -171,19 +171,11 @@ abstract class MVController extends CommonController
$this->start = $this->request->getVar('start') ?: DEFAULTS['EMPTY'];
$this->end = $this->request->getVar('end') ?: DEFAULTS['EMPTY'];
$this->getModel()->setList_DateFilter($this->start, $this->end);
if (!$isTotalCount) {
//Sorting 처리
$this->order_field = $this->request->getVar('order_field') ?: DEFAULTS['EMPTY'];
$this->order_value = $this->request->getVar('order_value') ?: DEFAULTS['EMPTY'];
if ($this->order_field !== DEFAULTS['EMPTY'] && $this->order_value !== DEFAULTS['EMPTY']) {
$this->getModel()->setList_OrderBy("{$this->order_field} {$this->order_value}");
}
}
}
//Totalcount 처리
private function list_total_process(): int
{
$this->list_condition_process(true);
$this->list_condition_process();
$total_count = $this->getModel()->countAllResults();
// echo $this->getModel()->getLastQuery();
return $total_count;
@ -220,6 +212,10 @@ abstract class MVController extends CommonController
private function list_entitys_process(): array
{
$this->list_condition_process();
//Sorting 처리
$this->order_field = $this->request->getVar('order_field') ?: DEFAULTS['EMPTY'];
$this->order_value = $this->request->getVar('order_value') ?: DEFAULTS['EMPTY'];
$this->getModel()->setList_OrderBy($this->order_field !== DEFAULTS['EMPTY'] && $this->order_value !== DEFAULTS['EMPTY'] ? "{$this->order_field} {$this->order_value}" : "");
if ($this->page) {
$this->getModel()->limit(
$this->per_page,
@ -227,7 +223,7 @@ abstract class MVController extends CommonController
);
}
$entitys = $this->getModel()->findAll();
// echo $this->getModel()->getLastQuery();
echo $this->getModel()->getLastQuery();
return $entitys;
}
final protected function list_procedure(): string

View File

@ -2,30 +2,28 @@
use App\Models\Cloudflare\RecordModel;
function getFieldLabel_RecordHelper(string $field, array $viewDatas, array $attributes = []): string
function getFieldLabel_RecordHelper(string $field, array $viewDatas, array $extras = []): string
{
switch ($field) {
case RecordModel::PARENT:
$extras = [...$extras, "class" => 'text-danger'];
break;
default:
if (strpos($viewDatas['field_rules'][$field], 'required') !== false) {
$attributes = ['style="color:red";'];
$extras = [...$extras, "class" => 'text-danger'];
}
$label = sprintf(
"<span %s>%s</span>",
implode(" ", $attributes),
lang("{$viewDatas['class_path']}.label.{$field}")
);
break;
}
return $label;
return form_label(lang("{$viewDatas['class_path']}.label.{$field}"), $field, $extras);
}
//header.php에서 getFieldForm_Helper사용
function getFieldForm_RecordHelper(string $field, mixed $value, array $viewDatas, array $attributes = []): string
function getFieldForm_RecordHelper(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
$value = $value ?: DEFAULTS['EMPTY'];
switch ($field) {
case RecordModel::PARENT:
$form = form_dropdown($field, $viewDatas['field_options'][$field], $value, [...$attributes, 'class' => "select-field"]);
// // return form_multiselect($field, $field_options[$field], is_array($value) ? [...$value] : [$value], [...$attributes]);
$form = form_dropdown($field, $viewDatas['field_options'][$field], $value, [...$extras, 'class' => "select-field"]);
// // return form_multiselect($field, $field_options[$field], is_array($value) ? [...$value] : [$value], [$extras]);
// foreach ($viewDatas['field_options'][$field] as $key => $label) {
// $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, explode(DEFAULTS["DELIMITER_ROLE"], $value))) . $label;
// }
@ -41,7 +39,7 @@ function getFieldForm_RecordHelper(string $field, mixed $value, array $viewDatas
case "locked":
case "proxied":
case "proxiable":
$form = form_dropdown($field, $viewDatas['field_options'][$field], $value, $attributes);
$form = form_dropdown($field, $viewDatas['field_options'][$field], $value, $extras);
break;
case 'updated_at':
case 'created_at':
@ -53,11 +51,31 @@ function getFieldForm_RecordHelper(string $field, mixed $value, array $viewDatas
}
return $form;
} //
function getFieldView_RecordHelper(string $field, mixed $entity, array $viewDatas, array $attributes = [])
function getFieldView_RecordHelper(string $field, mixed $entity, array $viewDatas, array $extras = [])
{
$value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
case RecordModel::PARENT:
if ($extras['old_zone'] === $entity->getParent()) {
$value = "";
} else {
$value = anchor(
current_url() . '/reload/' . $entity->getParent(),
ICONS["RELOAD"],
[
"class" => "btn btn-sm btn-primary btn-circle fa fa-refresh",
"target" => "_self"
]
) . "<span class=\"label_zones\">{$viewDatas['field_options'][$field][$value]}</span>";
}
break;
case RecordModel::TITLE:
$value = anchor(
current_url() . '/immobilized/' . $entity->getPK(),
$value,
["target" => "_self", "class" => "label_hosts"]
);
break;
case 'category_uid':
foreach (array_values($viewDatas['field_options'][$field]) as $category_2depths) {
foreach ($category_2depths as $key => $depth) {
@ -78,53 +96,36 @@ function getFieldView_RecordHelper(string $field, mixed $entity, array $viewData
break;
default:
if (in_array($field, $viewDatas['filter_fields']) && $value) {
$value = $viewDatas['field_options'][$field][$value];
}
break;
}
return $value;
} //
function getListHeaders_RecordHelper(string $field, array $viewDatas, array $attributes = []): string
{
$label = getFieldLabel_RecordHelper($field, $viewDatas, $attributes);
if ($field == $viewDatas['order_field']) {
$label .= $viewDatas['order_value'] == 'ASC' ? ICONS["UP"] : ICONS["DOWN"];
}
$order_value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
$viewDatas['uri']->addQuery('order_field', $field);
$viewDatas['uri']->addQuery('order_value', $order_value);
$header = anchor((string)$viewDatas['uri'], $label);
switch ($field) {
case 'title':
$attributes = [...$attributes, "class=\"col-2\""];
break;
}
return sprintf("<th %s>%s</th>", implode(" ", $attributes), $header);
}
function getListColumns_RecordHelper(string $field, mixed $entity, array $viewDatas, array $attributes = []): string
{
switch ($field) {
case RecordModel::TITLE:
$value = anchor(
current_url() . '/view/' . $entity->getPK(),
getFieldView_RecordHelper($field, $entity, $viewDatas),
["target" => "_self"]
);
break;
default:
if (in_array($field, $viewDatas['filter_fields'])) {
$attributes["onChange"] = sprintf(
$extras["onChange"] = sprintf(
'location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value',
current_url(),
$entity->getPK(),
$field,
$field
);
$value = getFieldForm_RecordHelper($field, $entity, $viewDatas, $attributes);
$value = getFieldForm_RecordHelper($field, $entity->$field, $viewDatas, $extras);
}
$value = getFieldView_RecordHelper($field, $entity, $viewDatas);
break;
}
return $value;
} //
function getListColumns_RecordHelper(string $field, array $viewDatas, array $extras = []): string
{
$label = getFieldLabel_RecordHelper($field, $viewDatas, $extras);
if ($field == $viewDatas['order_field']) {
$label .= $viewDatas['order_value'] == 'ASC' ? ICONS["UP"] : ICONS["DOWN"];
}
$order_value = $viewDatas['order_value'] == 'DESC' ? "ASC" : "DESC";
$viewDatas['uri']->addQuery('order_field', $field);
$viewDatas['uri']->addQuery('order_value', $order_value);
$label = anchor((string)$viewDatas['uri'], $label);
switch ($field) {
case RecordModel::PARENT:
$label .= "<button onClick=\"getElementsByClassNameCopyToClipboard('label_zones'); return false;\" class=\"btn btn-sm btn-danger btn-circle\">Copy Zones</buttion>";
break;
case RecordModel::TITLE:
$label .= "<button onClick=\"getElementsByClassNameCopyToClipboard('label_hosts'); return false;\" class=\"btn btn-sm btn-danger btn-circle\">Copy Hosts</buttion>";
break;
}
return sprintf("<th %s>%s</th>", implode(" ", $extras), $label);
}

View File

@ -38,7 +38,7 @@ class RecordModel extends CommonModel
$rules[$field] = "required|trim|string";
break;
case "type":
$rules[$field] = "required|in_list[A,AAA,CNAME,MX,NS,PTR,SPF,TXT,SRV,INFO]";
$rules[$field] = "required|in_list[A,AAAA,CNAME,NS,MX,PTR,SPF,TXT,SRV,INFO]";
break;
case "ttl":
$rules[$field] = "if_exist|numeric";
@ -100,25 +100,24 @@ class RecordModel extends CommonModel
return is_null($this->first()) ? true : false;
}
//CDN값 수정 못하는 고정 Record 처리
public function setFixedCDNRecord(array $hosts)
public function setImmobilized(array $hosts)
{
if (count($hosts)) {
$this->whereIn('host', $hosts)->set(['fixed' => 'on'])->update();
log_message("notice", "-----set fixed Records " . implode(",", $hosts) . "처리 완료-----");
}
}
//List 검색용
public function setList_WordFilter(string $word, $field = null): void
{
parent::setList_WordFilter($word, $field);
$this->orLike('content', $word, 'both');
}
public function setList_OrderBy(string $order)
public function setList_OrderBy(string $order = "")
{
parent::setList_OrderBy($order);
//Join을 해서 도메인부터 Sorting하기위함
$this->join('cloudflarezone', "cloudflarezone.uid=cloudflarerecord.zone_uid");
$this->orderBy("cloudflare.domain ASC");
parent::setList_OrderBy($order);
$this->orderBy("cloudflarezone.domain ASC");
}
}

View File

@ -103,9 +103,9 @@ class ZoneModel extends CommonModel
// $subquery = $this->db->table(RecordModel::TABLE)->select(RecordModel::PARENT)->like('content', $word, 'both');
// $this->orWhereIn(self::PK, $subquery);
}
public function setList_OrderBy(string $order): void
public function setList_OrderBy(string $order = ""): void
{
$this->orderBy(self::TITLE . " ASC");
parent::setList_OrderBy($order);
$this->orderBy(self::TITLE . " ASC");
}
}

View File

@ -71,8 +71,7 @@ abstract class CommonModel extends Model
$rules[$field] .= $action == "create" ? "|is_unique[{$this->table}.{$field}]" : "";
} else {
$rules[$field] = "required|numeric";
}
;
};
break;
case $this->getTitleField():
$rules[$field] = "required|string";
@ -231,8 +230,10 @@ abstract class CommonModel extends Model
$this->where("{$field} <= '{$end} 23:59:59'");
}
}
public function setList_OrderBy(string $order)
public function setList_OrderBy(string $order = "")
{
$this->orderBy($order);
if ($order) {
$this->orderBy($order);
}
}
}

View File

@ -31,27 +31,29 @@
<tr>
<th>번호</th>
<?php foreach ($viewDatas['fields'] as $field): ?>
<?= getListHeaders_RecordHelper($field, $viewDatas) ?>
<?= getListColumns_RecordHelper($field, $viewDatas) ?>
<?php endforeach ?>
<th>작업</th>
</tr>
</thead>
<tbody>
<?php $cnt = 0 ?>
<?php $old_zone = '' ?>
<?php foreach ($viewDatas['entitys'] as $entity): ?>
<tr id="<?= $entity->getPK() ?>" <?= $entity->status != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
<tr id="<?= $entity->getPK() ?>" <?= $entity->locked != 'on' ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this)">
<td class="text-center text-wrap">
<?= form_checkbox(["id" => "checkbox_uid_{$entity->getPK()}", "name" => "batchjob_uids[]", "value" => $entity->getPK(), "class" => "batchjobuids_checkboxs"]); ?>
<?= anchor(current_url() . '/modify/' . $entity->getPK(), $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt), ["target" => "_self"]) ?>
</td>
<?php foreach ($viewDatas['fields'] as $field): ?>
<td><?= getListColumns_RecordHelper($field, $entity, $viewDatas) ?></td>
<td><?= getFieldView_RecordHelper($field, $entity, $viewDatas, ['old_zone' => $old_zone]) ?></td>
<?php endforeach ?>
<td>
<?= anchor(current_url() . '/delete/' . $entity->getPK(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
</td>
</tr>
<?php $cnt++ ?>
<?php $old_zone = $entity->getParent(); ?>
<?php endforeach ?>
</tbody>
</table>

View File

@ -7,7 +7,7 @@
* {
margin: 0px;
padding: 0px;
font-size: 14px;
font-size: 16px;
}
body {
height: 100vw; /* 화면 넓이의 100% */

View File

@ -28,7 +28,6 @@ nav.index_top nav.search input[type="text"] {
}
/*검색submit*/
nav.index_top nav.search input[type="submit"] {
font-size: 12px;
font-weight: bold;
width: 80px;
height: 30px;
@ -58,7 +57,6 @@ table.index_table thead th {
white-space: nowrap;
padding-top: 15px;
padding-bottom: 15px;
font-size: 16px;
font-weight: bold;
border-top: 2px solid black;
border-bottom: 1px solid silver;
@ -87,7 +85,7 @@ div.index_pagination nav ul.pagination li {
}
div.index_pagination nav ul.pagination li a {
padding: 5px 10px 5px 10px;
font-size: 20px;
font-size: 1.5rem;
color: white;
background-color: #808080;
}

View File

@ -21,6 +21,7 @@ div#left_menu > div.accordion {
/* display:none; */
background-color: white;
width: 20px;
height: 50px;
display: none;
}
div#left_menu > div.accordion div.accordion-item:hover {

View File

@ -6,7 +6,7 @@ div#left_menu{
}
div#left_menu div.parent {
font-size:24px;
font-size:1.5rem;
font-weight:bold;
height:170px;
padding-top:30px;
@ -18,7 +18,7 @@ div#left_menu div.parent div.title{
color:#26417D;
}
div#left_menu div.parent div{
font-size:24px;
font-size: 1.5rem;
}
/* leftmenu bar */
@ -35,7 +35,7 @@ div#left_menu div.active {
div#left_menu div.sibling a{
text-decoration: none;
color:black;
font-size:18px;
font-size: 1.3rem;
}
div#left_menu div.sibling span.play{
float:right;

View File

@ -25,7 +25,7 @@ div#content div.login form div.label_column{
}
div#content div.login form label.col-form-label{
font-size:18px;
font-size: 1.5rem;
font-weight:bold;
/* border:1px solid red; */
}

View File

@ -10,13 +10,13 @@
border:1px solid red;
} */
#top_menu a.navbar-brand{
font-size:24px;
font-size: 1.5rem;
font-weight:bold;
}
/* 메뉴바그룹 상단글자*/
#top_menu div.dropdown-center ul.navbar-nav a#navbarDarkDropdownMenuLink{
font-size:18px;
font-size: 1.3rem;
font-weight:bold;
/* border:1px solid silver; */
}
@ -49,7 +49,7 @@
}
#top_menu div.dropdown-center ul.navbar-nav li.dropdown ul.dropdown-menu li a{
width:150px;
font-size:16px;
font-size: 1.2rem;
font-weight:bold;
text-align:center;
text-decoration:none;

View File

@ -19,6 +19,6 @@
}
#top_navigator ul.justify-content-end li.cart a{
font-size:18px;
font-size: 1.5rem;
font-weight: 500;
}

View File

@ -5,10 +5,8 @@
* Updated :
------------------------------------------------------------ */
* {
margin:0px;
padding:0px;
border:0px;
font-size:14px;
font: Arial;
}
* {
margin: 0px;
padding: 0px;
font-size: 14px;
}

View File

@ -4,14 +4,11 @@
* Created : 2016/9/11 Tri-aBility by Junheum,Choi
* Updated :
------------------------------------------------------------ */
* {
margin:0px;
padding:0px;
border:0px;
font-size:14px;
font: Arial;
* {
margin: 0px;
padding: 0px;
font-size: 14px;
}
/* #head{
border:1px solid blue;
} */
@ -36,7 +33,7 @@
border-bottom:1px solid silver;
}
#layout #body nav.header nav h4.title{
font-size:26px;
font-size:2rem;
font-weight:bold;
}
#layout #body nav.header nav span.flow{

View File

@ -23,7 +23,7 @@ div#content div.top nav input[type=text]{
}
/*검색submit*/
div#content div.top nav input[type=submit]{
font-size:12px;
font-size: 1.5rem;
font-weight:bold;
width:80px;
height:40px;
@ -71,7 +71,7 @@ div#content table thead th{
white-space: nowrap;
padding-top:15px;
padding-bottom:15px;
font-size: 16px;
font-size: 1.5rem;
font-weight:bold;
border-top:2px solid black;
border-bottom:1px solid silver;

View File

@ -17,7 +17,7 @@ div#order div.orderbox {
border:1px solid gray;
}
div#order div.orderbox div.title{
font-size:18px;
font-size: 1.5rem;
font-weight: 600;
border-bottom:2px solid gray;
}
@ -41,7 +41,7 @@ div#order div.orderbox div.total span.label{
}
div#order div.orderbox div.total span.value{
float:right;
font-size:18px;
font-size: 1.5rem;
font-weight: 800;
}
div#order div.orderbox div.submit{

View File

@ -4,12 +4,10 @@
* Created : 2016/9/11 Tri-aBility by Junheum,Choi
* Updated :
------------------------------------------------------------ */
* {
margin:0px;
padding:0px;
border:0px;
font-size:14px;
font: Arial;
* {
margin: 0px;
padding: 0px;
font-size: 14px;
}
/* #head{

View File

@ -23,7 +23,7 @@ div#content div.top nav input[type=text]{
}
/*검색submit*/
div#content div.top nav input[type=submit]{
font-size:12px;
font-size: 1.5rem;
font-weight:bold;
width:80px;
height:40px;
@ -71,7 +71,7 @@ div#content table thead th{
white-space: nowrap;
padding-top:15px;
padding-bottom:15px;
font-size: 16px;
font-size: 1.5rem;
font-weight:bold;
border-top:2px solid black;
border-bottom:1px solid silver;

View File

@ -6,10 +6,6 @@
------------------------------------------------------------ */
@charset "utf-8";
body {
background-color: white;
}
/* user class */
h1,h2,h3,h4,h5,h6,strong,th,.bold{font-weight:500;}

View File

@ -90,14 +90,13 @@ function change_CurrencyFormat(obj,currencies){
}
//해당하는 클래스의 내용을 메모리에 Copy
async function getElementsByClassNameCopyToClipboard(className)
async function getElementsByClassNameCopyToClipboard(class_name)
{
var x = document.getElementsByClassName(className);
var x = document.getElementsByClassName(class_name);
var textToCopy = '';
for (var i = 0; i < x.length; i++) {
textToCopy += x[i].textContent+'\n';
}
await navigator.clipboard.writeText(textToCopy)
.then(() => { alert("복사가 완료되었습니다."); })
.catch(err => { console.log('복사가 오류', err); })