feat!: CMS module
parent
4da0faff42
commit
46c67936d9
|
|
@ -0,0 +1,171 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BankSampahApp.Controllers.Main
|
||||
{
|
||||
public class CmsController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View("~/Views/Main/Cms/Index.cshtml");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult TableRegulasi()
|
||||
{
|
||||
var data = new[]
|
||||
{
|
||||
new{
|
||||
judul = "Permen LHK No 14/2021",
|
||||
sub_judul = "Perturan Menteri Lingkungan Hidup Nomor 14 Tahun 2021",
|
||||
ditetapkan = "13 Juli 2020",
|
||||
status = "<div class=\"text-[#247332] font-bold\">Berlaku</div>",
|
||||
dokumen = "<a href=\"#\" class=\"btn bg-gray-500 text-white rounded-lg\"><i class=\"ph ph-file-text\"></i></a>",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||
"</div>",
|
||||
},
|
||||
new{
|
||||
judul = "Permen LHK No 15/2021",
|
||||
sub_judul = "Perturan Menteri Lingkungan Hidup Nomor 15 Tahun 2021",
|
||||
ditetapkan = "15 Agustus 2020",
|
||||
status = "<div class=\"text-[#247332] font-bold\">Berlaku</div>",
|
||||
dokumen = "<a href=\"#\" class=\"btn bg-gray-500 text-white rounded-lg\"><i class=\"ph ph-file-text\"></i></a>",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||
"</div>",
|
||||
},
|
||||
new{
|
||||
judul = "Permen LHK No 16/2021",
|
||||
sub_judul = "Perturan Menteri Lingkungan Hidup Nomor 16 Tahun 2021",
|
||||
ditetapkan = "1 September 2020",
|
||||
status = "<div class=\"text-[#247332] font-bold\">Berlaku</div>",
|
||||
dokumen = "<a href=\"#\" class=\"btn bg-gray-500 text-white rounded-lg\"><i class=\"ph ph-file-text\"></i></a>",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||
"</div>",
|
||||
},
|
||||
new{
|
||||
judul = "Permen LHK No 17/2021",
|
||||
sub_judul = "Perturan Menteri Lingkungan Hidup Nomor 17 Tahun 2021",
|
||||
ditetapkan = "10 Oktober 2020",
|
||||
status = "<div class=\"text-[#247332] font-bold\">Berlaku</div>",
|
||||
dokumen = "<a href=\"#\" class=\"btn bg-gray-500 text-white rounded-lg\"><i class=\"ph ph-file-text\"></i></a>",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||
"</div>",
|
||||
},
|
||||
new{
|
||||
judul = "Permen LHK No 18/2021",
|
||||
sub_judul = "Perturan Menteri Lingkungan Hidup Nomor 18 Tahun 2021",
|
||||
ditetapkan = "12 November 2020",
|
||||
status = "<div class=\"text-[#247332] font-bold\">Berlaku</div>",
|
||||
dokumen = "<a href=\"#\" class=\"btn bg-gray-500 text-white rounded-lg\"><i class=\"ph ph-file-text\"></i></a>",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||
"</div>",
|
||||
},
|
||||
new{
|
||||
judul = "Permen LHK No 19/2021",
|
||||
sub_judul = "Perturan Menteri Lingkungan Hidup Nomor 19 Tahun 2021",
|
||||
ditetapkan = "5 Desember 2020",
|
||||
status = "<div class=\"text-[#247332] font-bold\">Berlaku</div>",
|
||||
dokumen = "<a href=\"#\" class=\"btn bg-gray-500 text-white rounded-lg\"><i class=\"ph ph-file-text\"></i></a>",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||
"</div>",
|
||||
},
|
||||
new{
|
||||
judul = "Permen LHK No 20/2021",
|
||||
sub_judul = "Perturan Menteri Lingkungan Hidup Nomor 20 Tahun 2021",
|
||||
ditetapkan = "20 Januari 2021",
|
||||
status = "<div class=\"text-[#247332] font-bold\">Berlaku</div>",
|
||||
dokumen = "<a href=\"#\" class=\"btn bg-gray-500 text-white rounded-lg\"><i class=\"ph ph-file-text\"></i></a>",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||
"</div>",
|
||||
},
|
||||
new{
|
||||
judul = "Permen LHK No 21/2021",
|
||||
sub_judul = "Perturan Menteri Lingkungan Hidup Nomor 21 Tahun 2021",
|
||||
ditetapkan = "15 Februari 2021",
|
||||
status = "<div class=\"text-[#247332] font-bold\">Berlaku</div>",
|
||||
dokumen = "<a href=\"#\" class=\"btn bg-gray-500 text-white rounded-lg\"><i class=\"ph ph-file-text\"></i></a>",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||
"</div>",
|
||||
},
|
||||
new{
|
||||
judul = "Permen LHK No 22/2021",
|
||||
sub_judul = "Perturan Menteri Lingkungan Hidup Nomor 22 Tahun 2021",
|
||||
ditetapkan = "25 Maret 2021",
|
||||
status = "<div class=\"text-[#247332] font-bold\">Berlaku</div>",
|
||||
dokumen = "<a href=\"#\" class=\"btn bg-gray-500 text-white rounded-lg\"><i class=\"ph ph-file-text\"></i></a>",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||
"</div>",
|
||||
},
|
||||
new{
|
||||
judul = "Permen LHK No 23/2021",
|
||||
sub_judul = "Perturan Menteri Lingkungan Hidup Nomor 23 Tahun 2021",
|
||||
ditetapkan = "30 April 2021",
|
||||
status = "<div class=\"text-[#247332] font-bold\">Berlaku</div>",
|
||||
dokumen = "<a href=\"#\" class=\"btn bg-gray-500 text-white rounded-lg\"><i class=\"ph ph-file-text\"></i></a>",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||
"</div>",
|
||||
},
|
||||
new{
|
||||
judul = "Permen LHK No 24/2021",
|
||||
sub_judul = "Perturan Menteri Lingkungan Hidup Nomor 24 Tahun 2021",
|
||||
ditetapkan = "10 Mei 2021",
|
||||
status = "<div class=\"text-[#247332] font-bold\">Berlaku</div>",
|
||||
dokumen = "<a href=\"#\" class=\"btn bg-gray-500 text-white rounded-lg\"><i class=\"ph ph-file-text\"></i></a>",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||
"</div>",
|
||||
},
|
||||
new{
|
||||
judul = "Permen LHK No 25/2021",
|
||||
sub_judul = "Perturan Menteri Lingkungan Hidup Nomor 25 Tahun 2021",
|
||||
ditetapkan = "15 Juni 2021",
|
||||
status = "<div class=\"text-[#247332] font-bold\">Berlaku</div>",
|
||||
dokumen = "<a href=\"#\" class=\"btn bg-gray-500 text-white rounded-lg\"><i class=\"ph ph-file-text\"></i></a>",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||
"</div>",
|
||||
},
|
||||
new{
|
||||
judul = "Permen LHK No 26/2021",
|
||||
sub_judul = "Perturan Menteri Lingkungan Hidup Nomor 26 Tahun 2021",
|
||||
ditetapkan = "1 Juli 2021",
|
||||
status = "<div class=\"text-[#247332] font-bold\">Berlaku</div>",
|
||||
dokumen = "<a href=\"#\" class=\"btn bg-gray-500 text-white rounded-lg\"><i class=\"ph ph-file-text\"></i></a>",
|
||||
aksi = "<div class=\"flex gap-2\">" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-warning text-white btn-sm\"><i class=\"ph ph-note-pencil\"></i></a>" +
|
||||
"<a href=\"#\" class=\"btn btn-circle btn-error delete text-white btn-sm\"><i class=\"ph ph-trash\"></i></a>" +
|
||||
"</div>",
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var response = new
|
||||
{
|
||||
data = data
|
||||
};
|
||||
|
||||
return Json(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,230 @@
|
|||
@{
|
||||
ViewData["Title"] = "CMS";
|
||||
}
|
||||
|
||||
<div class="flex gap-2 flex-row justify-between md:gap-0 mt-2 mb-2">
|
||||
<div class="prose">
|
||||
<span class="text-xl font-semibold text-black font-['Plus Jakarta Sans']">Content Management System (Landing Page)</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-6">
|
||||
<!-- Section 1 -->
|
||||
<div class="collapse collapse-arrow bg-base-100 shadow-xl">
|
||||
<input type="checkbox" checked />
|
||||
<div class="collapse-title text-gray-900 text-base font-semibold font-['Plus_Jakarta_Sans'] leading-8">
|
||||
Gambar Utama Landing Page
|
||||
</div>
|
||||
<div class="collapse-content">
|
||||
<form id="formTambah" onsubmit="submitForm(event)">
|
||||
<div class="pt-4 flex flex-col gap-6">
|
||||
<!-- Slide 1 -->
|
||||
<div class="form-control w-full">
|
||||
<label class="label">
|
||||
<span class="label-text text-base font-medium">Slide 1 <span class="text-red-500">*</span></span>
|
||||
</label>
|
||||
<input type="file" class="file-input file-input-bordered w-full" accept="image/*" />
|
||||
<label class="label">
|
||||
<span class="label-text-alt text-base-content/60">Ukuran file maksimal 30 MB</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Slide 2 -->
|
||||
<div class="form-control w-full">
|
||||
<label class="label">
|
||||
<span class="label-text text-base font-medium">Slide 2 <span class="text-red-500">*</span></span>
|
||||
</label>
|
||||
<input type="file" class="file-input file-input-bordered w-full" accept="image/*" />
|
||||
<label class="label">
|
||||
<span class="label-text-alt text-base-content/60">Ukuran file maksimal 30 MB</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Slide 3 -->
|
||||
<div class="form-control w-full">
|
||||
<label class="label">
|
||||
<span class="label-text text-base font-medium">Slide 3 <span class="text-red-500">*</span></span>
|
||||
</label>
|
||||
<input type="file" class="file-input file-input-bordered w-full" accept="image/*" />
|
||||
<label class="label">
|
||||
<span class="label-text-alt text-base-content/60">Ukuran file maksimal 30 MB</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Submit Button -->
|
||||
<div class="flex justify-end mb-4">
|
||||
<button type="submit" class="w-full sm:w-auto px-8 py-2.5 bg-green-800 rounded-full text-white text-base font-semibold font-['Plus_Jakarta_Sans'] leading-6 hover:bg-green-900">
|
||||
Simpan
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Section 2 -->
|
||||
<div class="collapse collapse-arrow bg-base-100 shadow-xl">
|
||||
<input type="checkbox" checked />
|
||||
<div class="collapse-title text-gray-900 text-base font-semibold font-['Plus_Jakarta_Sans'] leading-8">
|
||||
Tentang Kami
|
||||
</div>
|
||||
<div class="collapse-content">
|
||||
<form id="formTambah" onsubmit="submitForm(event)">
|
||||
<div class="pt-4 flex flex-col gap-6">
|
||||
<div class="flex flex-col">
|
||||
<fieldset class="fieldset">
|
||||
<legend class="text-base">
|
||||
Judul
|
||||
</legend>
|
||||
<input type="text" id="judul" class="input w-full" placeholder="Judul" required />
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col">
|
||||
<fieldset class="fieldset">
|
||||
<legend class="text-base">
|
||||
Deskripsi
|
||||
</legend>
|
||||
<textarea id="deskripsi" class="textarea w-full h-32" placeholder="Deskripsi" required></textarea>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end mb-4">
|
||||
<button type="submit" class="w-full sm:w-auto px-8 py-2.5 bg-green-800 rounded-full text-white text-base font-semibold font-['Plus_Jakarta_Sans'] leading-6 hover:bg-green-900">
|
||||
Simpan
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Section 3 -->
|
||||
<div class="collapse collapse-arrow bg-base-100 shadow-xl">
|
||||
<input type="checkbox" checked />
|
||||
<div class="collapse-title text-gray-900 text-base font-semibold font-['Plus_Jakarta_Sans'] leading-8">
|
||||
Regulasi
|
||||
</div>
|
||||
<div class="collapse-content">
|
||||
<div class="flex justify-end mb-4">
|
||||
<a href="javascript:void(0)" class="btn bg-[#344054] text-white hover:bg-gray-900 px-4 py-2 rounded-full">
|
||||
Tambah Regulasi
|
||||
<i class="ph ph-plus"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="w-full overflow-x-auto">
|
||||
<table class="table-zebra table w-full" id="example">
|
||||
<!-- head -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-[10%]">No</th>
|
||||
<th class="w-[20%]">Judul</th>
|
||||
<th class="w-[15%]">Sub Judul</th>
|
||||
<th class="w-[15%]">Ditetapkan</th>
|
||||
<th class="w-[15%]">Status</th>
|
||||
<th class="w-[10%]">Dokumen</th>
|
||||
<th class="w-[15%]">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script type="text/javascript">
|
||||
var table;
|
||||
|
||||
$(document).ready(function () {
|
||||
table = new DataTable('#example', {
|
||||
ajax: '/Main/Cms/TableRegulasi',
|
||||
scrollX: true,
|
||||
autoWidth: false,
|
||||
initComplete: function () {
|
||||
$('div.dt-scroll-body thead').css('visibility', 'collapse');
|
||||
},
|
||||
columns: [
|
||||
{ data: null, render: (d, t, r, m) => m.row + 1, orderable: false, searchable: false },
|
||||
{ data: 'judul' },
|
||||
{
|
||||
data: 'sub_judul',
|
||||
className: 'truncate', // Class untuk efek ellipsis
|
||||
render: function (data, type, row) {
|
||||
// Menambahkan styling untuk memastikan ellipsis berfungsi dengan baik
|
||||
return `<div class="truncate max-w-[15rem]" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">${data}</div>`;
|
||||
}
|
||||
},
|
||||
{ data: 'ditetapkan' },
|
||||
{ data: 'status' },
|
||||
{ data: 'dokumen', orderable: false, searchable: false, },
|
||||
{ data: 'aksi', orderable: false, searchable: false, },
|
||||
]
|
||||
});
|
||||
|
||||
// Delete button handler
|
||||
$('#example').on('click', '.delete-btn', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var id = $(this).data('id');
|
||||
|
||||
Swal.fire({
|
||||
title: 'Apakah anda yakin?',
|
||||
text: "Data yang dihapus tidak dapat dikembalikan lagi",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Ya, Hapus',
|
||||
cancelButtonText: 'Batal',
|
||||
buttonsStyling: false,
|
||||
customClass: {
|
||||
confirmButton: 'btn bg-red-500 text-white hover:bg-red-600 px-4 py-2 rounded-full mr-2',
|
||||
cancelButton: 'btn bg-white text-gray-500 hover:bg-gray-50 px-4 py-2 rounded-full border border-gray-300',
|
||||
},
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// TODO: Implement actual delete API call
|
||||
Swal.fire({
|
||||
title: 'Terhapus!',
|
||||
text: 'Data berhasil dihapus.',
|
||||
icon: 'success',
|
||||
confirmButtonText: 'OK',
|
||||
buttonsStyling: false,
|
||||
customClass: {
|
||||
confirmButton: 'btn bg-green-800 text-white hover:bg-green-900 px-4 py-2 rounded-full',
|
||||
},
|
||||
}).then(() => {
|
||||
// Reload table
|
||||
table.ajax.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function submitForm(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var isEditMode = $('#edit_mode').val() === 'true';
|
||||
|
||||
// TODO: Implement form submission logic
|
||||
Swal.fire({
|
||||
title: 'Berhasil!',
|
||||
text: isEditMode ? 'Data berhasil diperbarui' : 'Data berhasil ditambahkan',
|
||||
icon: 'success',
|
||||
confirmButtonText: 'OK',
|
||||
buttonsStyling: false,
|
||||
customClass: {
|
||||
confirmButton: 'btn bg-green-800 text-white hover:bg-green-900 px-4 py-2 rounded-full',
|
||||
},
|
||||
}).then(() => {
|
||||
closeModal();
|
||||
|
||||
// Reload table
|
||||
table.ajax.reload();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
|
|
@ -169,6 +169,14 @@
|
|||
</details>
|
||||
</li>
|
||||
|
||||
<!-- CMS -->
|
||||
<li>
|
||||
<a asp-controller="Cms" class="rounded-full @(controller == "Cms" ? "menu-active" : "")">
|
||||
<i class="ph ph-newspaper me-2 text-lg"></i>
|
||||
CMS
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- Reduksi -->
|
||||
<li>
|
||||
<details @(new[] { "Maggot", "Composting", "ReduksiSampah", "BankSampah" }.Contains(controller) ? "open" : "")>
|
||||
|
|
|
|||
Loading…
Reference in New Issue