ip mgmt 버그 수정/demo 계정기능 추가

This commit is contained in:
icurfer 2025-02-18 00:43:40 +09:00
parent 7d1c508828
commit 3c2f154afb
6 changed files with 229 additions and 221 deletions

9
_.env.prd Normal file
View File

@ -0,0 +1,9 @@
DEBUG=1
SQL_ENGINE='django.db.backends.mysql'
SQL_HOST='192.168.0.211'
SQL_USER='ddochi'
SQL_PASSWORD='tjdehd89!@'
SQL_DATABASE='butler_ddochi'
SQL_PORT='3306'
CSRF_TRUSTED_ORIGINS=https://www.icurfer.com,https://butler.icurfer.com,https://butler.icurfer.com:8000
MM_URL=https://mm.icurfer.com/hooks/rsu8fwfmtbbcpgtt4qa1so4hmy

View File

@ -4,7 +4,7 @@
{% block main_area %}
<h1 class="pt-3">Blog Posts</h1>
{% if request.user.is_authenticated %}
{% if request.user.is_authenticated and request.user.is_staff %}
<a href="{% url 'blog:create_post' %}" class="btn btn-primary mb-3">Create New Post</a>
{% endif %}
<ul class="list-group">

View File

@ -39,7 +39,7 @@
{% else %}
<p class="text-muted">현재 공지사항이 없습니다.</p>
{% endif %}
{% if request.user.is_authenticated %}
{% if request.user.is_authenticated and request.user.is_staff %}
<!-- 버튼 컨테이너 -->
<div class="d-flex justify-content-between align-items-center mb-3">
<a href="{% url 'board_notice:create_notice' %}" class="btn btn-primary">Create Notice</a>

View File

@ -3,198 +3,189 @@
{% block title %}IP Management{% endblock %}
{% block main_area %}
<h2 class="fw-bold pt-3 pb-2">IP 관리 대장</h2>
{% if not request.user.is_authenticated %}
<p class="text-danger">비로그인 익명사용자로 접근 중입니다.
<br>로그인시 로그인 사용자가 등록한 데이터만 조회됩니다.
</p>
{% endif %}
<!-- 검색 폼 -->
<div class="row">
<div class="col-4">
</div>
<div class="col-4">
</div>
<div class="col-4">
<form method="get" class="mb-3">
<div class="input-group">
<input type="text" name="var_search" class="form-control" placeholder="Search by Author or Network Name..."
value="{{ var_search }}">
<button type="submit" class="btn btn-outline-primary">Search</button>
</div>
</form>
</div>
</div>
<!-- IP 레코드 목록 -->
<form id="recordForm" method="post" action="">
{% csrf_token %}
<table class="table table-striped table-hover table-bordered">
<thead class="table-dark">
<tr>
<th scope="col">Select</th>
<th scope="col">Network Name</th>
<th scope="col">IP Address</th>
<th scope="col">Server Name</th>
<th scope="col">Description</th>
<th scope="col">Remark</th>
<th scope="col">Author</th>
<th scope="col">Updated At</th>
</tr>
</thead>
<tbody>
{% for record in records %}
<tr data-record-id="{{ record.id }}">
<td class="text-center">
<input type="checkbox" name="selected_records" value="{{ record.id }}"
class="form-check-input record-checkbox">
</td>
<td>{{ record.network_nm }}</td>
<td>{{ record.ip_addrs }}</td>
<td>{{ record.svr_nm }}</td>
<td>{{ record.desc }}</td>
<td>{{ record.remark }}</td>
<td>{{ record.author }}</td>
<td>{{ record.updated_at|date:"Y-m-d H:i" }}</td>
</tr>
<!-- 수정 모달 -->
<div class="modal fade" id="editDataModal-{{ record.id }}" tabindex="-1"
aria-labelledby="editDataModalLabel-{{ record.id }}" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-warning text-dark">
<h5 class="modal-title" id="editDataModalLabel-{{ record.id }}">Edit IP Record</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<!-- 데이터 수정 폼 -->
<form id="editDataForm-{{ record.id }}" method="post" action="{% url 'butler:ip_mgmt_edit' record.id %}">
{% csrf_token %}
<div class="mb-3">
<label for="networkNm-{{ record.id }}" class="form-label">Network Name</label>
<input type="text" class="form-control" id="networkNm-{{ record.id }}" name="network_nm"
value="{{ record.network_nm }}" required="required">
</div>
<div class="mb-3">
<label for="ipAddrs-{{ record.id }}" class="form-label">IP Address</label>
<input type="text" class="form-control" id="ipAddrs-{{ record.id }}" name="ip_addrs"
value="{{ record.ip_addrs }}" required="required">
</div>
<div class="mb-3">
<label for="svrNm-{{ record.id }}" class="form-label">Server Name</label>
<input type="text" class="form-control" id="svrNm-{{ record.id }}" name="svr_nm"
value="{{ record.svr_nm }}" required="required">
</div>
<div class="mb-3">
<label for="desc-{{ record.id }}" class="form-label">Description</label>
<textarea class="form-control" id="desc-{{ record.id }}" name="desc">{{ record.desc }}</textarea>
</div>
<div class="mb-3">
<label for="remark-{{ record.id }}" class="form-label">Remark</label>
<textarea class="form-control" id="remark-{{ record.id }}"
name="remark">{{ record.remark }}</textarea>
</div>
<button type="submit" class="btn btn-primary">Save Changes</button>
</form>
</div>
</div>
</div>
</div>
{% empty %}
<tr>
<td colspan="9" class="text-center">No records found.</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if request.user.is_authenticated %}
<!-- 버튼 컨테이너 -->
<div class="d-flex justify-content-between align-items-center mb-3">
<!-- 데이터 등록 버튼 -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addDataModal">
<i class="bi bi-plus-lg"></i>
Add New IP Record
</button>
<!-- 전체 삭제 버튼 -->
<button type="submit" formaction="{% url 'butler:ip_mgmt_delete' %}" class="btn btn-danger">
<i class="bi bi-trash"></i>
Delete Selected
</button>
<!-- 수정 버튼 -->
<button type="button" id="editSelectedButton" class="btn btn-warning" disabled="disabled">
<i class="bi bi-pencil-square"></i>
Edit Selected
</button>
</div>
<h2 class="fw-bold pt-3 pb-2">IP 관리 대장</h2>
{% if not request.user.is_authenticated %}
<p class="text-danger">비로그인 익명사용자로 접근 중입니다.
<br>로그인시 로그인 사용자가 등록한 데이터만 조회됩니다.
</p>
{% endif %}
</form>
<!-- 검색 폼 -->
<div class="row">
<div class="col-4"></div>
<div class="col-4"></div>
<div class="col-4">
<form method="get" class="mb-3">
<div class="input-group">
<input type="text" name="var_search" class="form-control" placeholder="Search by Author or Network Name..." value="{{ var_search }}">
<button type="submit" class="btn btn-outline-primary">Search</button>
</div>
</form>
</div>
</div>
<!-- IP 레코드 목록 -->
<form id="recordForm" method="post" action="">
{% csrf_token %}
<table class="table table-striped table-hover table-bordered">
<thead class="table-dark">
<tr>
<th scope="col">Select</th>
<th scope="col">Network Name</th>
<th scope="col">Location</th>
<th scope="col">Server Name</th>
<th scope="col">IP Address</th>
<th scope="col">Remark</th>
<th scope="col">Author</th>
<th scope="col">Updated At</th>
</tr>
</thead>
<tbody>
{% for record in records %}
<tr data-record-id="{{ record.id }}">
<td class="text-center">
<input type="checkbox" name="selected_records" value="{{ record.id }}" class="form-check-input record-checkbox">
</td>
<td>{{ record.network_nm }}</td>
<td>{{ record.contents }}</td>
<td>{{ record.svr_nm }}</td>
<td>{{ record.ip_addrs }}</td>
<td>{{ record.remark }}</td>
<td>{{ record.author }}</td>
<td>{{ record.updated_at|date:"Y-m-d H:i" }}</td>
</tr>
<!-- 데이터 등록 모달 -->
<div class="modal fade" id="addDataModal" tabindex="-1" aria-labelledby="addDataModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-success text-white">
<h5 class="modal-title" id="addDataModalLabel">Add New IP Record</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
<!-- 수정 모달 -->
<div class="modal fade" id="editDataModal-{{ record.id }}" tabindex="-1" aria-labelledby="editDataModalLabel-{{ record.id }}" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-warning text-dark">
<h5 class="modal-title" id="editDataModalLabel-{{ record.id }}">Edit IP Record</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<!-- 데이터 수정 폼 -->
<form id="editDataForm-{{ record.id }}" method="post" action="{% url 'butler:ip_mgmt_edit' record.id %}">
{% csrf_token %}
<div class="mb-3">
<label for="networkNm-{{ record.id }}" class="form-label">Network Name</label>
<input type="text" class="form-control" id="networkNm-{{ record.id }}" name="network_nm" value="{{ record.network_nm }}" required="required">
</div>
<div class="mb-3">
<label for="contents-{{ record.id }}" class="form-label">Location</label>
<textarea class="form-control" id="contents-{{ record.id }}" name="contents">{{ record.contents }}</textarea>
</div>
<div class="mb-3">
<label for="svrNm-{{ record.id }}" class="form-label">Server Name</label>
<input type="text" class="form-control" id="svrNm-{{ record.id }}" name="svr_nm" value="{{ record.svr_nm }}" required="required">
</div>
<div class="mb-3">
<label for="ipAddrs-{{ record.id }}" class="form-label">IP Address</label>
<input type="text" class="form-control" id="ipAddrs-{{ record.id }}" name="ip_addrs" value="{{ record.ip_addrs }}" required="required">
</div>
<div class="mb-3">
<label for="remark-{{ record.id }}" class="form-label">Remark</label>
<textarea class="form-control" id="remark-{{ record.id }}" name="remark">{{ record.remark }}</textarea>
</div>
<button type="submit" class="btn btn-primary">Save Changes</button>
</form>
</div>
</div>
</div>
</div>
{% empty %}
<tr>
<td colspan="9" class="text-center">No records found.</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if request.user.is_authenticated and request.user.is_staff %}
<!-- 버튼 컨테이너 -->
<div class="d-flex justify-content-between align-items-center mb-3">
<!-- 데이터 등록 버튼 -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addDataModal">
<i class="bi bi-plus-lg"></i>
Add New IP Record
</button>
<!-- 전체 삭제 버튼 -->
<button type="submit" formaction="{% url 'butler:ip_mgmt_delete' %}" class="btn btn-danger">
<i class="bi bi-trash"></i>
Delete Selected
</button>
<!-- 수정 버튼 -->
<button type="button" id="editSelectedButton" class="btn btn-warning" disabled="disabled">
<i class="bi bi-pencil-square"></i>
Edit Selected
</button>
</div>
<div class="modal-body">
<!-- 데이터 등록 폼 -->
<form id="addDataForm" method="post" action="{% url 'butler:ip_mgmt_add' %}">
{% csrf_token %}
<div class="mb-3">
<label for="networkNm" class="form-label">Network Name</label>
<input type="text" class="form-control" id="networkNm" name="network_nm" required="required">
</div>
<div class="mb-3">
<label for="ipAddrs" class="form-label">IP Address</label>
<input type="text" class="form-control" id="ipAddrs" name="ip_addrs" required="required">
</div>
<div class="mb-3">
<label for="svrNm" class="form-label">Server Name</label>
<input type="text" class="form-control" id="svrNm" name="svr_nm" required="required">
</div>
<div class="mb-3">
<label for="desc" class="form-label">Description</label>
<textarea class="form-control" id="desc" name="desc"></textarea>
</div>
<div class="mb-3">
<label for="remark" class="form-label">Remark</label>
<textarea class="form-control" id="remark" name="remark"></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
{% endif %}
</form>
<!-- 데이터 등록 모달 -->
<div class="modal fade" id="addDataModal" tabindex="-1" aria-labelledby="addDataModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-success text-white">
<h5 class="modal-title" id="addDataModalLabel">Add New IP Record</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<!-- 데이터 등록 폼 -->
<form id="addDataForm" method="post" action="{% url 'butler:ip_mgmt_add' %}">
{% csrf_token %}
<div class="mb-3">
<label for="networkNm" class="form-label">Network Name</label>
<input type="text" class="form-control" id="networkNm" name="network_nm" required="required">
</div>
<div class="mb-3">
<label for="desc" class="form-label">Location</label>
<textarea class="form-control" id="contents" name="contents"></textarea>
</div>
<div class="mb-3">
<label for="svrNm" class="form-label">Server Name</label>
<input type="text" class="form-control" id="svrNm" name="svr_nm" required="required">
</div>
<div class="mb-3">
<label for="ipAddrs" class="form-label">IP Address</label>
<input type="text" class="form-control" id="ipAddrs" name="ip_addrs" required="required">
</div>
<div class="mb-3">
<label for="remark" class="form-label">Remark</label>
<textarea class="form-control" id="remark" name="remark"></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const editButton = document.getElementById('editSelectedButton');
const checkboxes = document.querySelectorAll('.record-checkbox');
<script>
document.addEventListener('DOMContentLoaded', function () {
const editButton = document.getElementById('editSelectedButton');
const checkboxes = document.querySelectorAll('.record-checkbox');
// Event listener to enable/disable the edit button
document.addEventListener('change', function () {
const selected = [...checkboxes].filter(checkbox => checkbox.checked);
if (selected.length === 1) {
editButton.disabled = false;
editButton.dataset.recordId = selected[0].value;
} else {
editButton.disabled = true;
delete editButton.dataset.recordId;
}
// Event listener to enable/disable the edit button
document.addEventListener('change', function () {
const selected = [...checkboxes].filter(checkbox => checkbox.checked);
if (selected.length === 1) {
editButton.disabled = false;
editButton.dataset.recordId = selected[0].value;
} else {
editButton.disabled = true;
delete editButton.dataset.recordId;
}
});
// Event listener to open the edit modal
editButton.addEventListener('click', function () {
const recordId = editButton.dataset.recordId;
if (recordId) {
const modal = new bootstrap.Modal(document.getElementById(`editDataModal-${recordId}`));
modal.show();
}
});
});
// Event listener to open the edit modal
editButton.addEventListener('click', function () {
const recordId = editButton.dataset.recordId;
if (recordId) {
const modal = new bootstrap.Modal(document.getElementById(`editDataModal-${recordId}`));
modal.show();
}
});
});
</script>
</script>
{% endblock %}

View File

@ -13,10 +13,12 @@
</li>
{% endif %}
{% if request.user.is_authenticated %}
<!-- 회원정보 변경 버튼 -->
<li class="nav-item me-3">
<button type="button" class="btn btn-outline-info mb-2" data-bs-toggle="modal" data-bs-target="#editProfileModal">Edit Profile</button>
</li>
{% if request.user.username != "demo" %}
<!-- 회원정보 변경 버튼 -->
<li class="nav-item me-3">
<button type="button" class="btn btn-outline-info mb-2" data-bs-toggle="modal" data-bs-target="#editProfileModal">Edit Profile</button>
</li>
{% endif %}
<!-- 로그아웃 버튼 -->
<li class="nav-item">
<form method="post" action="{% url 'custom_auth:logout' %}">
@ -98,7 +100,7 @@
<input type="password" class="form-control" id="passwordConfirmSignup" name="password2" required="required">
</div>
<a href="{% url 'butler:privacy' %}" class="text-dark" target="_blank">개인정보 처리방침</a>
<p class="text-danger">회원 가입후 권한 신청 메일을 보내주세요.</p>
<p class="text-danger">회원 가입후 권한 신청 메일(icurfer@gmail.com)을 보내주세요.</p>
<p class="text-danger">회원 가입시 본 개인정보 처리방침에 동의하는 것으로 간주됩니다.</p>
<button type="submit" class="btn btn-success w-100">Sign Up</button>
</form>

View File

@ -79,39 +79,45 @@
<hr>
<li class="my-2">
<button class="btn d-inline-flex align-items-center collapsed" data-bs-toggle="collapse" aria-expanded="false" data-bs-target="#components-collapse" aria-controls="components-collapse">DevOpsTools ▽</button>
<ul class="list-unstyled ps-3 collapse" id="components-collapse">
<span>Dev</span>
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_gitea}}" target="_blank">Repository - Gitea</a>
</li>
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_harbor}}" target="_blank">Registry - Harbor</a>
</li>
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_argocd}}" target="_blank">Deploy - ArgoCD</a>
</li>
<hr>
<span>Ops</span>
{% if request.user.is_authenticated and request.user.is_staff %}
{% if request.user.is_authenticated %}
<span>Dev</span>
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_web_ide}}" target="_blank">Web VScode - CodeServer</a>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_gitea}}" target="_blank">Repository - Gitea</a>
</li>
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_harbor}}" target="_blank">Registry - Harbor</a>
</li>
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_argocd}}" target="_blank">Deploy - ArgoCD</a>
</li>
<hr>
<span>Ops</span>
{% if request.user.is_authenticated and request.user.is_staff %}
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_web_ide}}" target="_blank">Web VScode - CodeServer</a>
</li>
{% endif %}
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_rancher}}" target="_blank">Cluster Management - Rancher</a>
</li>
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_grafana}}" target="_blank">Monitoring - Grafana</a>
</li>
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_prometheus}}" target="_blank">Metrics - Prometheus</a>
</li>
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_opensearch}}" target="_blank">Container Log - OpenSearch</a>
</li>
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_kiali}}" target="_blank">Main Cluster Traffic - Kiali</a>
</li>
{% else %}
<p>기능 사용을 위해서 로그인이 필요합니다.</p>
<a class="d-inline-flex align-items-center rounded" href="/notice/2/" target="_blank">사용 가이드</a>
{% endif %}
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_rancher}}" target="_blank">Cluster Management - Rancher</a>
</li>
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_grafana}}" target="_blank">Monitoring - Grafana</a>
</li>
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_prometheus}}" target="_blank">Metrics - Prometheus</a>
</li>
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_opensearch}}" target="_blank">Container Log - OpenSearch</a>
</li>
<li>
<a class="d-inline-flex align-items-center rounded" href="{{request.user.url_kiali}}" target="_blank">Main Cluster Traffic - Kiali</a>
</li>
</ul>
</li>
<hr>