cfmgrv4 init...2

This commit is contained in:
최준흠 2024-10-09 16:22:03 +09:00
parent f685c863c2
commit cb004fdb55
17 changed files with 180 additions and 240 deletions

View File

@ -89,9 +89,7 @@ abstract class MVController extends CommonController
));
}
}
protected function create_form_process(): void
{
}
protected function create_form_process(): void {}
final protected function create_form_procedure(): RedirectResponse|string
{
try {
@ -190,7 +188,7 @@ abstract class MVController extends CommonController
try {
helper(['form']);
$this->modify_process($uid);
$this->message = "{$this->class_name} : 수정작업이 완료되었습니다.";
$this->message = "{$this->class_name} : 생성작업이 완료되었습니다.";
$this->getModel()->transCommit();
log_message("notice", __FUNCTION__ . $this->message);
return view(
@ -214,10 +212,10 @@ abstract class MVController extends CommonController
try {
//변경할 UIDS
$uids = $this->request->getVar('batchjob_uids');
if ($uids === null || !is_array($uids) || count($uids) === 0) {
if (!$uids) {
throw new \Exception("적용할 리스트를 선택하셔야합니다.");
}
foreach ($uids as $uid) {
foreach (explode(",", $uids) as $uid) {
$this->modify_process($uid);
}
$this->message = "{$this->class_name} : 일괄처리작업이 완료되었습니다.";
@ -351,7 +349,7 @@ abstract class MVController extends CommonController
$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}" : ""
$this->order_value !== DEFAULTS['EMPTY'] ? "{$this->order_field} {$this->order_value}" : ""
);
if ($this->page) {
$this->getModel()->limit(

View File

@ -17,19 +17,14 @@ class AccountHelper extends CommonHelper
$value = $value ?: DEFAULTS['EMPTY'];
switch ($field) {
case AccountModel::PARENT:
$extraClass = isset($extras['class']) ? $extras['class'] . ' select-field' : 'select-field';
$extra_class = isset($extras['class']) ? $extras['class'] . ' select-field' : 'select-field';
$form = form_dropdown($field, [
"" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택',
...$viewDatas['field_options'][$field]
], isset($viewDatas[$field]) ? $viewDatas[$field] : $value, ['class' => $extraClass, ...array_diff_key($extras, ['class' => ''])]);
], isset($viewDatas[$field]) ? $viewDatas[$field] : $value, ['class' => $extra_class, ...array_diff_key($extras, ['class' => ''])]);
break;
case AccountModel::TITLE:
$form = form_input($field, $value, [
"placeholder" => "예)test@exmaple.com",
"style" =>
"width:100%; ::placeholder{color:silver; opacity: 1;}",
...$extras
]);
$form = form_input($field, $value, ["placeholder" => "예)test@exmaple.com", ...$extras]);
break;
case 'type':
$form = form_dropdown($field, [

View File

@ -16,11 +16,7 @@ class AuthHelper extends CommonHelper
$value = $value ?: DEFAULTS['EMPTY'];
switch ($field) {
case AuthModel::TITLE:
$form = form_input($field, $value, [
"placeholder" => "예)test@example.com",
"style" => "width:100%; ::placeholder{color:silver; opacity: 1;}",
...$extras
]);
$form = form_input($field, $value, ["placeholder" => "예)test@example.com", ...$extras]);
break;
default:
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);

View File

@ -17,19 +17,14 @@ class RecordHelper extends CommonHelper
$value = $value ?: DEFAULTS['EMPTY'];
switch ($field) {
case RecordModel::PARENT:
$extraClass = isset($extras['class']) ? $extras['class'] . ' select-field' : 'select-field';
$extra_class = isset($extras['class']) ? $extras['class'] . ' select-field' : 'select-field';
$form = form_dropdown($field, [
"" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택',
...$viewDatas['field_options'][$field]
], isset($viewDatas[$field]) ? $viewDatas[$field] : $value, ['class' => $extraClass, ...array_diff_key($extras, ['class' => ''])]);
], isset($viewDatas[$field]) ? $viewDatas[$field] : $value, ['class' => $extra_class, ...array_diff_key($extras, ['class' => ''])]);
break;
case RecordModel::TITLE: //host
$form = form_input($field, $value, [
"placeholder" => "예)www.example.com",
"style" =>
"width:200px; ::placeholder{color:silver; opacity: 1;}",
...$extras
]);
$form = form_input($field, $value, $extras);
break;
case 'hosts':
$form = form_textarea($field, html_entity_decode($value), [
@ -38,12 +33,7 @@ class RecordHelper extends CommonHelper
]);
break;
case 'content':
$form = form_input($field, $value, [
"placeholder" => "예)123.123.123.123",
"style" =>
"width:200px; ::placeholder{color:silver; opacity: 1;}",
...$extras
]);
$form = form_input($field, $value, ["placeholder" => "예)123.123.123.123", ...$extras]);
break;
case "type":
case "fixed":

View File

@ -17,19 +17,14 @@ class ZoneHelper extends CommonHelper
$value = $value ?: DEFAULTS['EMPTY'];
switch ($field) {
case ZoneModel::PARENT:
$extraClass = isset($extras['class']) ? $extras['class'] . ' select-field' : 'select-field';
$extra_class = isset($extras['class']) ? $extras['class'] . ' select-field' : 'select-field';
$form = form_dropdown($field, [
"" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택',
...$viewDatas['field_options'][$field]
], isset($viewDatas[$field]) ? $viewDatas[$field] : $value, ['class' => $extraClass, ...array_diff_key($extras, ['class' => ''])]);
], isset($viewDatas[$field]) ? $viewDatas[$field] : $value, ['class' => $extra_class, ...array_diff_key($extras, ['class' => ''])]);
break;
case ZoneModel::TITLE:
$form = form_input($field, $value, [
"placeholder" => "예)exmaple.com",
"style" =>
"width:100%; ::placeholder{color:silver; opacity: 1;}",
...$extras
]);
$form = form_input($field, $value, ["placeholder" => "예)exampel.com", ...$extras]);
break;
case 'domains':
$form = form_textarea($field, $value, ['rows' => '5', ...$extras]);
@ -41,12 +36,7 @@ class ZoneHelper extends CommonHelper
]);
break;
case 'content':
$form = form_input($field, $value, [
"placeholder" => "예)123.123.123.123",
"style" =>
"width:200px; ::placeholder{color:silver; opacity: 1;}",
...$extras
]);
$form = form_input($field, $value, ["placeholder" => "예)123.123.123.123", ...$extras]);
break;
case "development_mode":
case "ipv6":

View File

@ -4,9 +4,7 @@ namespace App\Helpers;
abstract class CommonHelper
{
protected function __construct()
{
}
protected function __construct() {}
final public function getRandomString($length = 10, $characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
{
return substr(str_shuffle($characters), 0, $length);
@ -156,10 +154,11 @@ abstract class CommonHelper
break;
case 'updated_at':
case 'created_at':
$form = form_input($field, $value, ["class" => "calender", ...$extras]);
$extra_class = isset($extras['class']) ? $extras['class'] . ' calender' : 'calender';
$form = form_input($field, $value, ['class' => $extra_class, ...array_diff_key($extras, ['class' => ''])]);
break;
default:
$form = form_input($field, $value, $extras);
$form = form_input($field, $value, ["autocomplete" => $field, ...$extras]);
break;
}
return $form;

View File

@ -15,21 +15,10 @@ class MapurlHelper extends CommonHelper
$value = $value ?: DEFAULTS['EMPTY'];
switch ($field) {
case MapurlModel::TITLE:
$form = form_input($field, $value, [
"placeholder" => "예)http://old.example.com",
"style" => "width:100%; ::placeholder{color:silver; opacity: 1;}",
"class" => "form-control",
"required" => ""
]);
$form = form_input($field, $value, ["placeholder" => "예)http://old.example.com", ...$extras]);
break;
case 'newurl':
$form = form_input($field, $value, [
"placeholder" => "예)https://new.example.com",
"style" =>
"width:100%; ::placeholder{color:silver; opacity: 1;}",
"class" => "form-control",
"required" => ""
]);
$form = form_input($field, $value, ["placeholder" => "예)http://new.example.com", ...$extras]);
break;
default:
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);

View File

@ -16,39 +16,28 @@ class UserHelper extends CommonHelper
switch ($field) {
case 'id':
case UserModel::TITLE:
$form = form_input($field, $value, [
"placeholder" => "예)",
"style" => "width:100%; ::placeholder{color:silver; opacity: 1;}",
...$extras
]);
$form = form_input($field, $value, $extras);
break;
case 'passwd':
case 'confirmpassword':
$form = form_password($field, "", [
"style" => "width:100%;",
...$extras
]);
$form = form_password($field, "", ["autocomplete" => $field, ...$extras]);
break;
case 'email':
$form = form_input($field, $value, [
"placeholder" => "예)test@example.com",
"style" => "width:100%; ::placeholder{color:silver; opacity: 1;}",
...$extras
]);
$form = form_input($field, $value, ["placeholder" => "예)test@example.com", ...$extras]);
break;
case 'mobile':
$form = form_input($field, $value, [
"placeholder" => "예)010-0010-0010",
"style" => "width:100%; ::placeholder{color:silver; opacity: 1;}",
...$extras
]);
$form = form_input($field, $value, ["placeholder" => "예)010-0010-0010", ...$extras]);
break;
case 'role':
if (in_array($viewDatas['action'], ['create', 'modify'])) {
$forms = [];
foreach ($viewDatas['field_options'][$field] as $key => $label) {
$values = is_array($value) ? $value : explode(DEFAULTS["DELIMITER_ROLE"], $value);
$forms[] = form_checkbox($field . "[]", $key, in_array($key, $values)) . $label;
$forms[] = form_checkbox(
"{$field}[]",
$key,
in_array($key, $values)
) . $label;
}
$form = implode(" ", $forms);
} else {

View File

@ -11,7 +11,7 @@
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<td nowrap class="text-start">
<?php
$extras = ["class" => 'form-control'];
$extras = ["class" => "form-control"];
if (strpos($viewDatas['field_rules'][$field], 'required') !== false) {
$extras = ["required" => "", ...$extras];
}

View File

@ -10,7 +10,6 @@
<link href="/css/common/resizeTable.css" media="screen" rel="stylesheet" type="text/css" />
<div class="index_body">
<?= $this->include("templates/{$viewDatas['layout']}/index_content_top"); ?>
<?= form_open(current_url() . '/batchjob', ['id' => 'batchjob_form', 'method' => "post"]) ?>
<table class="index_table data table table-bordered table-hover table-striped" data-rtc-resizable-table="reisze_table">
<thead>
<tr>
@ -42,10 +41,9 @@
</tbody>
</table>
<?= $this->include("templates/{$viewDatas['layout']}/index_content_batchjob"); ?>
<?= form_close() ?>
</div>
<div class=" index_pagination"><?= $viewDatas['pagination'] ?></div>
<div class="index_bottom"><?= $this->include("templates/{$viewDatas['layout']}/modal_form"); ?></div>
<div class="index_bottom"><?= $this->include("templates/common/modal_iframe"); ?></div>
<script type="text/javascript" src="/js/common/resizeTable.js"></script>
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/index.js"></script>
</div>

View File

@ -2,7 +2,7 @@
<?= $this->section('content') ?>
<div id="container" class="content">
<link href="/css/<?= $viewDatas['layout'] ?>/form.css" media="screen" rel="stylesheet" type="text/css" />
<?= form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<?= form_open(current_url(), ['id' => 'action_form', ...$viewDatas['forms']['attributes']], $viewDatas['forms']['hiddens']) ?>
<div class="action_form">
<table class="table table-bordered">
<?php $cnt = 1 ?>
@ -24,7 +24,7 @@
<?php endforeach; ?>
<tr>
<td colspan="<?= $cnt * 2 ?>" class="text-center">
<?= form_submit('', '수정', array("class" => "btn btn-outline btn-primary")); ?>
<?= form_submit("", '수정', ["class" => "btn btn-outline btn-primary"]) ?>
</td>
</tr>
</table>

View File

@ -1,4 +1,6 @@
<div class="index_batchjob">
<?= form_open(current_url() . '/batchjob', ['id' => 'batchjob_form', 'method' => "post"]) ?>
<input type="hidden" name="batchjob_uids" id="batchjob_uids" value="">
<ul class="nav justify-content-center">
<li class="nav-item"><?= form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL</li>
<?php foreach ($viewDatas['batchjob_fields'] as $field): ?>
@ -7,6 +9,7 @@
<li class="nav-item"><?= $viewDatas['helper']->getListButton('batchjob', $viewDatas) ?></li>
<li class="nav-item"><?= $viewDatas['helper']->getListButton('create', $viewDatas) ?></li>
</ul>
<?= form_close() ?>
</div>
<script>
function submitBatchJob() {
@ -23,11 +26,16 @@
return false;
}
//적용받는 uids가 한개라도 선택되었다면 true
var batchjobUids = [];
var checkboxes = document.querySelectorAll('input[name="batchjob_uids[]"]:checked');
if (checkboxes.length === 0) {
checkboxes.forEach(function(checkbox) {
batchjobUids.push(checkbox.value);
});
if (batchjobUids.length === 0) {
alert('적용할 리스트를 선택하셔야합니다.');
return false;
}
document.getElementById('batchjob_uids').value = batchjobUids.join(',');
return true;
}
</script>

View File

@ -6,84 +6,8 @@
</span>
</li>
<li class="nav-item">
<span class="nav-link active" aria-current="page" data-bs-toggle="modal" data-bs-target="#DNSModal" style="cursor:pointer;">Cloudflare DNS</span>
<span class="nav-link active" aria-current="page" data-bs-toggle="modal" data-bs-target="#index_header_dns" style="cursor:pointer;">Cloudflare DNS</span>
</li>
</ul>
<div class="modal fade" id="DNSModal" tabindex="-1" aria-labelledby="CloudflareDNSModal" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="CloudflareDNSModal">Cloudflare DNS</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<style>
table.cloudflare {
width: 100%;
border: thin solid;
}
table.cloudflare th {
border: thin solid;
text-align: center;
padding: 0px 5px 0px 5px;
background-color: #e8e9ea;
}
table.cloudflare td {
border: thin solid;
text-align: center;
padding: 0px 5px 0px 5px;
}
table.cloudflare td.dnsname:hover {
cursor: pointer;
background-color: #fde9bf;
}
</style>
<script>
function copyToClipboard(element, domain) {
navigator.clipboard.writeText(domain);
element.style.backgroundColor = '#fde9bf';
}
</script>
<table class="cloudflare">
<tr>
<th>cloudprime001@idcjp.jp(,숫자)</th>
<td class="dnsname" onclick="copyToClipboard(this,'felicity.ns.cloudflare.com')">felicity.ns.cloudflare.com</td>
<td class="dnsname" onclick="copyToClipboard(this,'tara.ns.cloudflare.com')">tara.ns.cloudflare.com</td>
</tr>
<tr>
<th>cloudjp002@idcjp.jp(~)</th>
<td class="dnsname" onclick="copyToClipboard(this,'aida.ns.cloudflare.com');">aida.ns.cloudflare.com</td>
<td class="dnsname" onclick="copyToClipboard(this,'kurt.ns.cloudflare.com');">kurt.ns.cloudflare.com</td>
</tr>
<tr>
<th>jpcf003@gmail.com(~)</th>
<td class="dnsname" onclick="copyToClipboard(this,'natasha.ns.cloudflare.com');">natasha.ns.cloudflare.com</td>
<td class="dnsname" onclick="copyToClipboard(this,'plato.ns.cloudflare.com');">plato.ns.cloudflare.com</td>
</tr>
<tr>
<th>cloudwin001@idcjp.jp(,숫자)</th>
<td class="dnsname" onclick="copyToClipboard(this,'alina.ns.cloudflare.com');">alina.ns.cloudflare.com</td>
<td class="dnsname" onclick="copyToClipboard(this,'rick.ns.cloudflare.com');">rick.ns.cloudflare.com</td>
</tr>
<tr>
<th>cloudwin002@idcjp.jp(~)</th>
<td class="dnsname" onclick="copyToClipboard(this,'hope.ns.cloudflare.com');">hope.ns.cloudflare.com</td>
<td class="dnsname" onclick="copyToClipboard(this,'piotr.ns.cloudflare.com');">piotr.ns.cloudflare.com</td>
</tr>
<tr>
<th>cloudwin003@idcjp.jp(~)</th>
<td class="dnsname" onclick="copyToClipboard(this,'tani.ns.cloudflare.com');">tani.ns.cloudflare.com</td>
<td class="dnsname" onclick="copyToClipboard(this,'woz.ns.cloudflare.com');">woz.ns.cloudflare.com</td>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?= $this->include("templates/{$viewDatas['layout']}/index_header/dns"); ?>
</div>

View File

@ -0,0 +1,79 @@
<div id="index_header_dns" class="index_header_modal modal fade" tabindex="-1" aria-labelledby="index_header_dns_label" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable"> <!-- modal-lg는 모달 크기를 크게 설정 -->
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="index_header_dns_label">
<h4>&nbsp;&nbsp;<?= ICONS['DESKTOP'] ?> Cloudflare DNS</h4>
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<style>
table.cloudflare {
width: 100%;
border: thin solid;
}
table.cloudflare th {
border: thin solid;
text-align: center;
padding: 0px 5px 0px 5px;
background-color: #e8e9ea;
}
table.cloudflare td {
border: thin solid;
text-align: center;
padding: 0px 5px 0px 5px;
}
table.cloudflare td.dnsname:hover {
cursor: pointer;
background-color: #fde9bf;
}
</style>
<script>
function copyToClipboard(element, domain) {
navigator.clipboard.writeText(domain);
element.style.backgroundColor = '#fde9bf';
}
</script>
<table class="cloudflare">
<tr>
<th>cloudprime001@idcjp.jp(,숫자)</th>
<td class="dnsname" onclick="copyToClipboard(this,'felicity.ns.cloudflare.com')">felicity.ns.cloudflare.com</td>
<td class="dnsname" onclick="copyToClipboard(this,'tara.ns.cloudflare.com')">tara.ns.cloudflare.com</td>
</tr>
<tr>
<th>cloudjp002@idcjp.jp(~)</th>
<td class="dnsname" onclick="copyToClipboard(this,'aida.ns.cloudflare.com');">aida.ns.cloudflare.com</td>
<td class="dnsname" onclick="copyToClipboard(this,'kurt.ns.cloudflare.com');">kurt.ns.cloudflare.com</td>
</tr>
<tr>
<th>jpcf003@gmail.com(~)</th>
<td class="dnsname" onclick="copyToClipboard(this,'natasha.ns.cloudflare.com');">natasha.ns.cloudflare.com</td>
<td class="dnsname" onclick="copyToClipboard(this,'plato.ns.cloudflare.com');">plato.ns.cloudflare.com</td>
</tr>
<tr>
<th>cloudwin001@idcjp.jp(,숫자)</th>
<td class="dnsname" onclick="copyToClipboard(this,'alina.ns.cloudflare.com');">alina.ns.cloudflare.com</td>
<td class="dnsname" onclick="copyToClipboard(this,'rick.ns.cloudflare.com');">rick.ns.cloudflare.com</td>
</tr>
<tr>
<th>cloudwin002@idcjp.jp(~)</th>
<td class="dnsname" onclick="copyToClipboard(this,'hope.ns.cloudflare.com');">hope.ns.cloudflare.com</td>
<td class="dnsname" onclick="copyToClipboard(this,'piotr.ns.cloudflare.com');">piotr.ns.cloudflare.com</td>
</tr>
<tr>
<th>cloudwin003@idcjp.jp(~)</th>
<td class="dnsname" onclick="copyToClipboard(this,'tani.ns.cloudflare.com');">tani.ns.cloudflare.com</td>
<td class="dnsname" onclick="copyToClipboard(this,'woz.ns.cloudflare.com');">woz.ns.cloudflare.com</td>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

View File

@ -1,20 +1,20 @@
<!-- 처음 호출할때 사용법
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#iframeInModal" data-src="시작URL">시작</button>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="시작URL">시작</button>
-->
<!-- 동적으로 ifram src 바꾸고싶을때
<span data-bs-toggle="modal" data-bs-target="#iframeInModal" data-src="바꾸고싶은URL" style="cursor:pointer;">바꾸기</span>
<span data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="바꾸고싶은URL" style="cursor:pointer;">바꾸기</span>
-->
<div id="index_action_form" class="index_action_form modal fade" tabindex="-1" aria-labelledby="iframeModalLabel" aria-hidden="true">
<div id="index_action_form" class="index_action_form modal fade" tabindex="-1" aria-labelledby="iframe_modal_label" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable"> <!-- modal-lg는 모달 크기를 크게 설정 -->
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="iframeModalLabel">
<h5 class="modal-title" id="iframe_modal_label">
<h4>&nbsp;&nbsp;<?= ICONS['DESKTOP'] ?> <?= $viewDatas['title'] ?>&nbsp;&nbsp;</h4>
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<iframe id="iframeInModal" src="about:blank" width="100%" frameborder="0" allowfullscreen></iframe>
<iframe id="form-container" src="about:blank" width="100%" frameborder="0" allowfullscreen></iframe>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
@ -25,7 +25,7 @@
<!-- Modal이 열릴 iframe의 src를 설정 -->
<script>
function resizeIframe() {
var iframe = document.getElementById('iframeInModal');
var iframe = document.getElementById('form-container');
iframe.style.height = iframe.contentWindow.document.body.scrollHeight + 'px';
}
@ -45,7 +45,7 @@
index_action_form.addEventListener('show.bs.modal', function(event) {
var button = event.relatedTarget;
var iframeSrc = button.getAttribute('data-src');
var iframe = document.getElementById('iframeInModal');
var iframe = document.getElementById('form-container');
iframe.src = iframeSrc;
// iframe이 로드된 후 높이를 조정하는 이벤트 리스너 추가
iframe.onload = function() {
@ -63,7 +63,7 @@
// 모달이 닫힐 때 iframe src를 초기화하여 종료 처리
index_action_form.addEventListener('hidden.bs.modal', function() {
var iframe = document.getElementById('iframeInModal');
var iframe = document.getElementById('form-container');
iframe.src = "about:blank"; // 모달 닫힐 때 iframe 초기화
});
</script>

View File

@ -0,0 +1,46 @@
<!--
처음 호출할때 사용법
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="시작URL">시작</button>
번호를 누르면 바꾸고싶은URL로 이동
<label data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="바꾸고싶은URL">번호</label>
-->
<div id="index_action_form" class="index_action_form modal fade" tabindex="-1" aria-labelledby="target_modal_label" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable"> <!-- modal-lg는 모달 크기를 크게 설정 -->
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="target_modal_label">
<h4>&nbsp;&nbsp;<?= ICONS['DESKTOP'] ?> <?= $viewDatas['title'] ?>&nbsp;&nbsp;</h4>
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div id="form-container" class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Modal이 열릴 iframe의 src를 설정 -->
<script>
// 모달이 열릴 때 이벤트 리스너 추가
document.getElementById('index_action_form').addEventListener('show.bs.modal', function(event) {
// 모달을 트리거한 버튼 요소 가져오기
var button = event.relatedTarget;
// data-src 속성에서 URL 가져오기
var url = button.getAttribute('data-src');
// URL로 loadActionForm 함수 호출
if (url) {
fetch(url)
.then(response => response.text())
.then(data => {
document.getElementById('form-container').innerHTML = data;
})
.catch(error => {
console.error('콘텐츠 로딩 오류:', error);
alert('콘텐츠를 로드하는 중 오류가 발생했습니다.');
});
} else {
alert('data-src 속성이 없습니다.');
}
});
</script>

View File

@ -1,61 +0,0 @@
<!-- 처음 호출할때 사용법
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#iframeInModal" data-src="시작URL">시작</button>
-->
<!-- 동적으로 ifram src 바꾸고싶을때
<span data-bs-toggle="modal" data-bs-target="#iframeInModal" data-src="바꾸고싶은URL" style="cursor:pointer;">바꾸기</span>
-->
<div id="index_action_form" class="index_action_form modal fade" tabindex="-1" aria-labelledby="iframeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable"> <!-- modal-lg는 모달 크기를 크게 설정 -->
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="iframeModalLabel">
<h4>&nbsp;&nbsp;<?= ICONS['DESKTOP'] ?> <?= $viewDatas['title'] ?>&nbsp;&nbsp;</h4>
</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<iframe id="iframeInModal" src="about:blank" width="100%" height="400" frameborder="0" allowfullscreen></iframe>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Modal이 열릴 iframe의 src를 설정 -->
<script>
function resizeIframe() {
var iframe = document.getElementById('iframeInModal');
iframe.style.height = iframe.contentWindow.document.body.scrollHeight + 'px';
}
function closeBootstrapModal() {
var modalElement = document.getElementById('index_action_form'); // 모달의 실제 DOM 요소 가져오기
var modalInstance = bootstrap.Modal.getInstance(modalElement); // 모달 인스턴스 가져오기
if (modalInstance) {
// 먼저 모달을 호출한 페이지를 리로드
window.location.reload();
modalInstance.hide(); // 모달 닫기 (hide() 메서드 사용)
} else {
console.error("Modal instance not found.");
}
}
var index_action_form = document.getElementById('index_action_form');
index_action_form.addEventListener('show.bs.modal', function(event) {
// 버튼이 클릭된 이벤트를 가져옴
var button = event.relatedTarget;
// console.log(button.getAttribute('data-src'));
var iframeSrc = button.getAttribute('data-src'); // data-src 값을 가져옴
var iframe = document.getElementById('iframeInModal');
// console.log(iframe.getAttribute('src'));
iframe.src = iframeSrc; // 가져온 data-src 값을 iframe에 설정
// iframe.onload = resizeIframe; // iframe이 로드된 후 높이를 조정
});
// 모달이 닫힐 때 iframe src를 초기화하여 종료 처리
index_action_form.addEventListener('hidden.bs.modal', function() {
var iframe = document.getElementById('iframeInModal');
iframe.src = "about:blank"; // 모달 닫힐 때 iframe 초기화
});
</script>