main
Ilham Wara Nugroho 2026-02-24 09:46:35 +07:00
parent fc8e7d8b49
commit 47cb21e8c4
4 changed files with 271 additions and 208 deletions

View File

@ -36,8 +36,8 @@ class HomeController extends Controller
$data['dataset'] = Dataset::orderBy('DatasetId','DESC')->count(); $data['dataset'] = Dataset::orderBy('DatasetId','DESC')->count();
$data['datasetTambahan'] = DatasetTambahan::orderBy('DatasetId','DESC')->count(); $data['datasetTambahan'] = DatasetTambahan::orderBy('DatasetId','DESC')->count();
}else{ }else{
$data['dataset'] = Dataset::orderBy('DatasetId','DESC')->whereIn('instansi_id',[auth()->user()->ms_instansi_id])->count(); $data['dataset'] = Dataset::orderBy('DatasetId','DESC')->whereIn('instansi_id',[session('instansi_id')])->count();
$data['datasetTambahan'] = DatasetTambahan::whereIn('instansi_id',[auth()->user()->ms_instansi_id])->count(); $data['datasetTambahan'] = DatasetTambahan::whereIn('instansi_id',[session('instansi_id')])->count();
} }
$data['instansi'] = Instansi::count(); $data['instansi'] = Instansi::count();
@ -56,12 +56,52 @@ class HomeController extends Controller
return view($this->template.'.dataset',$data); return view($this->template.'.dataset',$data);
} }
function gridInstansiUtama(Request $request){
$instansi = Instansi::where('MsInstansiId',session('instansi_id'))->first();
$data = TabelData::whereIn('MsTabelDataId',json_decode($instansi->resource_data))->get();
$_data = [];
foreach ($data as $key => $row) {
//cek upload
$status = '';
$cek = Dataset::where('ms_tabel_data_id',$row->MsTabelDataId)->where('tahun',date('Y'))->count();
if($cek > 0){
$status = '<span class="bg-emerald-500 rounded w-100 p-1 text-[10px] text-white">Sudah Unggah</spa>';
}else{
$status = '<span class="bg-red-500 rounded w-100 p-1 text-[10px] text-white">Belum Unggah</spa>';
}
$_data[] = [
'no' => $key+1,
'name' => 'Tabel '.@$row->nomor_tabel.' - '.@$row->name,
'status' => @$status,
];
}
return response()->json($_data);
}
function gridInstansiTambahan(Request $request){
$data = DatasetTambahan::whereIn('ms_instansi_id',session('instansi_id'))->get();
$_data = [];
foreach ($data as $key => $row) {
$_data[] = [
'no' => $key+1,
'name' => @$row->name,
];
}
return response()->json($_data);
}
public function gridTabel(Request $request) public function gridTabel(Request $request)
{ {
if((session('group_id') == 1) || (session('group_alias') == 'admin')){ if((session('group_id') == 1) || (session('group_alias') == 'admin')){
$data = Instansi::all(); $data = Instansi::all();
}else{ }else{
$data = Instansi::where('MsInstansiId',auth()->user()->ms_instansi_id)->get(); $data = Instansi::where('MsInstansiId',session('instansi_id'))->get();
} }
// $data = User::with(['group'])->orderBy('id','DESC')->get(); // $data = User::with(['group'])->orderBy('id','DESC')->get();
$_data = []; $_data = [];
@ -75,7 +115,7 @@ class HomeController extends Controller
$dataset = Dataset::whereIn('ms_tabel_data_id',$resource)->count(); $dataset = Dataset::whereIn('ms_tabel_data_id',$resource)->count();
} }
$persentase = $countresource > 0 ? round(($dataset/$countresource)*100) : '0'; $persentase = $countresource > 0 ? round(($dataset/$countresource)*100) : '0';
$btn = '<a data-toggle="modal" data-target="modal" href="#" data-id="'.encode_id($row->MsInstansiId).'" class="p-2 rounded bg-blue-500 text-white">'.$dataset.'/'.$countresource.'</a>'; $btn = '<a onclick="openModal()" href="#" data-id="'.encode_id($row->MsInstansiId).'" class="p-2 rounded bg-blue-500 text-white">'.$dataset.'/'.$countresource.'</a>';
if($persentase == 0){ if($persentase == 0){
$percent = '<span class="p-2 rounded bg-red-500 text-white">'.$persentase.'%</span>'; $percent = '<span class="p-2 rounded bg-red-500 text-white">'.$persentase.'%</span>';
}elseif($persentase > 0 && $persentase <= 50){ }elseif($persentase > 0 && $persentase <= 50){
@ -148,7 +188,7 @@ class HomeController extends Controller
$data = TabelData::with(['dataset'])->where('show_dashboard',1)->get(); $data = TabelData::with(['dataset'])->where('show_dashboard',1)->get();
}else{ }else{
$data = TabelData::with(['dataset'])->whereHas('dataset',function($query){ $data = TabelData::with(['dataset'])->whereHas('dataset',function($query){
$query->where('instansi_id',auth()->user()->ms_instansi_id); $query->where('instansi_id',session('instansi_id'));
})->where('show_dashboard',1)->get(); })->where('show_dashboard',1)->get();
} }
// $data = User::with(['group'])->orderBy('id','DESC')->get(); // $data = User::with(['group'])->orderBy('id','DESC')->get();
@ -160,7 +200,7 @@ class HomeController extends Controller
if((session('group_id') == 1) || (session('group_alias') == 'admin')){ if((session('group_id') == 1) || (session('group_alias') == 'admin')){
$action .= '<a href="'.url('dashboard/dataset/resource/'.encode_id($row->MsTemplateId)) .'" class="btn w-full bg-success text-white">Lihat Data</a>'; $action .= '<a href="'.url('dashboard/dataset/resource/'.encode_id($row->MsTemplateId)) .'" class="btn w-full bg-success text-white">Lihat Data</a>';
}else{ }else{
$action .= '<a href="'.url('dashboard/dataset/resource/instansi/'.encode_id(auth()->user()->ms_instansi_id).'/'.encode_id($row->MsTemplateId)).'" class="btn w-full bg-success text-white">Lihat Data</a>'; $action .= '<a href="'.url('dashboard/dataset/resource/instansi/'.encode_id(session('instansi_id')).'/'.encode_id($row->MsTemplateId)).'" class="btn w-full bg-success text-white">Lihat Data</a>';
} }
$_data[] = [ $_data[] = [

View File

@ -47,143 +47,161 @@
</div> --}} </div> --}}
</div> </div>
<!-- Datatable Section --> @if((session('group_id') == 1) || (session('group_alias') == 'admin'))
<div class="bg-white rounded-3xl border border-slate-200 shadow-sm overflow-hidden"> <!-- Datatable Section -->
<div class="p-6 border-b border-slate-100 flex flex-col md:flex-row md:items-center justify-between gap-4"> <div class="bg-white rounded-3xl border border-slate-200 shadow-sm overflow-hidden">
<div> <div class="p-6 border-b border-slate-100 flex flex-col md:flex-row md:items-center justify-between gap-4">
<h3 class="text-lg font-bold text-slate-900">Mapping Dataset SLHD - Tahun {{date('Y')}}</h3> <div>
{{-- <p class="text-xs text-slate-500 font-medium">Pengelolaan data masuk dari berbagai stasiun pemantauan.</p> --}} <h3 class="text-lg font-bold text-slate-900">Mapping Dataset SLHD - Tahun {{date('Y')}}</h3>
{{-- <p class="text-xs text-slate-500 font-medium">Pengelolaan data masuk dari berbagai stasiun pemantauan.</p> --}}
</div>
{{-- <div class="flex items-center space-x-2">
<button class="p-2 border border-slate-200 rounded-xl hover:bg-slate-50 transition-colors flex items-center text-sm font-semibold text-slate-600">
<i data-lucide="download-cloud" class="w-4 h-4 mr-2"></i> Ekspor
</button>
<button class="p-2 bg-slate-900 text-white rounded-xl hover:bg-slate-800 transition-colors flex items-center text-sm font-semibold">
<i data-lucide="filter" class="w-4 h-4 mr-2"></i> Filter
</button>
</div> --}}
</div> </div>
{{-- <div class="flex items-center space-x-2">
<button class="p-2 border border-slate-200 rounded-xl hover:bg-slate-50 transition-colors flex items-center text-sm font-semibold text-slate-600">
<i data-lucide="download-cloud" class="w-4 h-4 mr-2"></i> Ekspor
</button>
<button class="p-2 bg-slate-900 text-white rounded-xl hover:bg-slate-800 transition-colors flex items-center text-sm font-semibold">
<i data-lucide="filter" class="w-4 h-4 mr-2"></i> Filter
</button>
</div> --}}
</div>
<div class="overflow-x-auto p-8"> <div class="overflow-x-auto p-8">
<table class="w-full border text-left border-collapse"
data-search="true" <table class="w-full border text-left border-collapse"
data-toggle="table" data-search="true"
data-pagination="true" data-toggle="table"
data-toolbar="#toolbar" data-pagination="true"
data-show-refresh="true" data-toolbar="#toolbar"
data-url="{{route($route.'.gridTabel')}}" data-show-refresh="true"
data-sort-name="ids" data-url="{{route($route.'.gridTabel')}}"
data-sort-order="desc" data-sort-name="ids"
data-page-size="10" data-sort-order="desc"
data-id-field="id" data-page-size="10"
id="grid-data"> data-id-field="id"
<thead class="bg-slate-100 border-b border-slate-100"> id="grid-data">
<tr> <thead class="bg-slate-100 border-b border-slate-100">
<th class="text-[10px] border font-bold text-slate-900 text-center" data-width="10" data-field="no">No</th>
<th class="text-[10px] border font-bold text-slate-900 text-center" data-field="name">Instansi</th>
<th class="text-[10px] border font-bold text-slate-900 text-center" data-width="20" data-field="dataset">Dataset</th>
<th class="text-[10px] border font-bold text-slate-900 text-center" data-width="20" data-field="persentase">Persentase</th>
</tr>
</thead>
<tbody></tbody>
</table>
<table class="w-full text-left border-collapse hidden">
<thead class="bg-slate-50/50 border-b border-slate-100">
<tr> <tr>
<th class="text-[10px] border font-bold text-slate-900 text-center">Judul Dataset</th> <th class="border font-bold text-slate-900 text-center" data-width="10" data-field="no">No</th>
<th class="text-[10px] border font-bold text-slate-900 text-center">Kategori</th> <th class="border font-bold text-slate-900 text-center" data-field="name">Instansi</th>
<th class="text-[10px] border font-bold text-slate-900 text-center">Terakhir Update</th> <th class="border font-bold text-slate-900 text-center" data-width="20" data-field="dataset">Dataset</th>
<th class="text-[10px] border font-bold text-slate-900 text-center">Status</th> <th class="border font-bold text-slate-900 text-center" data-width="20" data-field="persentase">Persentase</th>
<th class="text-[10px] border font-bold text-slate-900 text-center text-right">Aksi</th>
</tr> </tr>
</thead> </thead>
<tbody class="divide-y divide-slate-100"> <tbody></tbody>
<tr class="hover:bg-slate-50 transition-colors group"> </table>
<td class="px-6 py-4"> </div>
<div class="flex items-center"> </div>
<div class="w-8 h-8 rounded bg-blue-100 flex items-center justify-center text-blue-600 mr-3"> @else
<i data-lucide="file-spreadsheet" class="w-4 h-4"></i> <div class="grid grid-cols-2 gap-2">
</div> <div class="bg-white rounded-3xl border border-slate-200 shadow-sm overflow-hidden">
<div> <div class="p-6 border-b border-slate-100 flex flex-col md:flex-row md:items-center justify-between gap-4">
<p class="text-sm font-bold text-slate-900">Kualitas Air Sungai Jakarta 2024</p> <div>
<p class="text-[10px] text-slate-400 font-medium">CSV, XLS 12.5 MB</p> <h3 class="text-lg font-bold text-slate-900">Dataset Utama Tahun {{date('Y')}}</h3>
</div> </div>
</div> </div>
</td>
<td class="px-6 py-4">
<span class="text-xs text-slate-600 font-semibold bg-slate-100 px-2 py-1 rounded">Air Limbah</span>
</td>
<td class="px-6 py-4 text-xs text-slate-500 font-medium">12 Feb 2026</td>
<td class="px-6 py-4">
<div class="flex items-center">
<span class="w-2 h-2 bg-green-500 rounded-full mr-2"></span>
<span class="text-[10px] font-bold text-green-700 uppercase">Terverifikasi</span>
</div>
</td>
<td class="px-6 py-4 text-right">
<button class="text-slate-400 hover:text-blue-600 p-1 transition-colors"><i data-lucide="more-vertical" class="w-5 h-5"></i></button>
</td>
</tr>
<tr class="hover:bg-slate-50 transition-colors group">
<td class="px-6 py-4">
<div class="flex items-center">
<div class="w-8 h-8 rounded bg-orange-100 flex items-center justify-center text-orange-600 mr-3">
<i data-lucide="trash-2" class="w-4 h-4"></i>
</div>
<div>
<p class="text-sm font-bold text-slate-900">Volume Sampah Per Kecamatan</p>
<p class="text-[10px] text-slate-400 font-medium">PDF, XLS 8.2 MB</p>
</div>
</div>
</td>
<td class="px-6 py-4">
<span class="text-xs text-slate-600 font-semibold bg-slate-100 px-2 py-1 rounded">Persampahan</span>
</td>
<td class="px-6 py-4 text-xs text-slate-500 font-medium">08 Feb 2026</td>
<td class="px-6 py-4">
<div class="flex items-center">
<span class="w-2 h-2 bg-yellow-500 rounded-full mr-2"></span>
<span class="text-[10px] font-bold text-yellow-700 uppercase">Draft</span>
</div>
</td>
<td class="px-6 py-4 text-right">
<button class="text-slate-400 hover:text-blue-600 p-1 transition-colors"><i data-lucide="more-vertical" class="w-5 h-5"></i></button>
</td>
</tr>
<tr class="hover:bg-slate-50 transition-colors group">
<td class="px-6 py-4">
<div class="flex items-center">
<div class="w-8 h-8 rounded bg-purple-100 flex items-center justify-center text-purple-600 mr-3">
<i data-lucide="wind" class="w-4 h-4"></i>
</div>
<div>
<p class="text-sm font-bold text-slate-900">ISPU Real-time Station</p>
<p class="text-[10px] text-slate-400 font-medium">JSON API Live Stream</p>
</div>
</div>
</td>
<td class="px-6 py-4">
<span class="text-xs text-slate-600 font-semibold bg-slate-100 px-2 py-1 rounded">Udara</span>
</td>
<td class="px-6 py-4 text-xs text-slate-500 font-medium">Hari ini</td>
<td class="px-6 py-4">
<div class="flex items-center">
<span class="w-2 h-2 bg-blue-500 rounded-full mr-2 animate-pulse"></span>
<span class="text-[10px] font-bold text-blue-700 uppercase">Otomatis</span>
</div>
</td>
<td class="px-6 py-4 text-right">
<button class="text-slate-400 hover:text-blue-600 p-1 transition-colors"><i data-lucide="more-vertical" class="w-5 h-5"></i></button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="overflow-x-auto p-8">
<table class="w-full border"
data-search="false"
data-toggle="table"
data-pagination="true"
data-toolbar="#toolbar"
data-show-refresh="false"
data-url="{{route($route.'.gridInstansiUtama')}}"
data-sort-name="ids"
data-sort-order="desc"
data-page-size="10"
data-id-field="id"
id="grid-data">
<thead class="bg-slate-100 border-b border-slate-100">
<tr>
<th class="text-[10px] border font-bold text-slate-900 text-center" data-field="name">Dataset</th>
<th class="text-[10px] border font-bold text-slate-900 text-center" data-field="status">Status</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
<div class="bg-white rounded-3xl border border-slate-200 shadow-sm overflow-hidden">
<div class="p-6 border-b border-slate-100 flex flex-col md:flex-row md:items-center justify-between gap-4">
<div>
<h3 class="text-lg font-bold text-slate-900">Dataset Tambahan Tahun {{date('Y')}}</h3>
</div>
</div>
<div class="overflow-x-auto p-8">
<table class="w-full border text-left border-collapse"
data-search="false"
data-toggle="table"
data-pagination="true"
data-toolbar="#toolbar"
data-show-refresh="false"
data-url="{{route($route.'.gridInstansiTambahan')}}"
data-sort-name="ids"
data-sort-order="desc"
data-page-size="10"
data-id-field="id"
id="grid-data">
<thead class="bg-slate-100 border-b border-slate-100">
<tr>
<th class="text-[10px] border font-bold text-slate-900 text-center" data-width="20" data-field="dataset">Dataset</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
@endif
</div> </div>
<div id="modal"> <div id="modal" class="fixed inset-0 bg-black/50 hidden items-center justify-center z-50">
</div> <!-- Modal Box -->
<div class="bg-white w-full max-w-4xl rounded-2xl shadow-2xl p-6 relative animate-scale">
<!-- Close Button -->
<button
onclick="closeModal()"
class="absolute top-3 right-3 text-gray-400 hover:text-gray-600 text-xl">
&times;
</button>
<h2 class="text-xl font-bold mb-4">Tabel Data Dirjen Bina Marga</h2>
<table class="w-full border text-left border-collapse">
<thead class="bg-slate-100 border-b border-slate-100">
<tr>
<th class="p-2 border font-bold text-slate-900 text-center" data-field="name">No</th>
<th class="p-2 border font-bold text-slate-900 text-center" data-field="name">Dataset</th>
<th class="p-2 border font-bold text-slate-900 text-center" data-field="name">Tanggal Input</th>
</tr>
</thead>
<tbody>
<tr>
<td class="p-2 border text-slate-900 text-center" data-field="name">1</td>
<td class="p-2 border text-slate-900 text-center" data-field="name">Tes</td>
<td class="p-2 border text-slate-900 text-center" data-field="name">2</td>
</tr>
</tbody>
</table>
</div>
</div>
@endsection
@section('js')
<script>
function openModal() {
document.getElementById('modal').classList.remove('hidden');
document.getElementById('modal').classList.add('flex');
}
function closeModal() {
document.getElementById('modal').classList.remove('flex');
document.getElementById('modal').classList.add('hidden');
}
</script>
@endsection @endsection

View File

@ -10,7 +10,7 @@
<hr> <hr>
<div class="flex gap-4 mt-5"> <div class="flex gap-4 mt-5">
<label class="mb-3 w-1/2 font-semibold required">Instansi</label> <label class="mb-3 w-1/2 font-semibold required">Instansi</label>
<select name="instansi_id" required class="p-2 border rounded w-full instansi_id select2 @error('instansi_id') is-invalid @enderror" id=""> <select name="instansi_id" required class="p-2 border rounded w-full instansi_id select2 @error('instansi_id') is-invalid @enderror" id="instansi_id">
<option value="">-</option> <option value="">-</option>
@foreach($instansi as $dataInstansi) @foreach($instansi as $dataInstansi)
<option {{@$item->instansi_id == $dataInstansi->MsInstansiId ? 'selected' : ''}} value="{{encode_id($dataInstansi->MsInstansiId)}}">{{$dataInstansi->name}}</option> <option {{@$item->instansi_id == $dataInstansi->MsInstansiId ? 'selected' : ''}} value="{{encode_id($dataInstansi->MsInstansiId)}}">{{$dataInstansi->name}}</option>
@ -22,21 +22,25 @@
</div> </div>
<div class="flex gap-4"> <div class="flex gap-4">
<label class="mb-3 w-1/2 font-semibold required">Sumber Data Terkait</label> <label class="mb-3 w-1/2 font-semibold required">Sumber Data Terkait</label>
<select name="template_id" required class="p-2 border rounded w-full template_id select2 @error('template_id') is-invalid @enderror" id=""> <div class="flex flex-col w-full justify-center items-start gap-2">
<option value="">-</option> <select name="template_id" required class="p-2 border rounded w-full template_id select2 @error('template_id') is-invalid @enderror" id="template_id">
@foreach($template as $dataTemplate) <option value="">-- Pilih Sumber Data --</option>
{{-- @foreach($template as $dataTemplate)
<option {{@$item->template_id == $dataTemplate->MsTemplateId ? 'selected' : ''}} data-template="{{asset($dataTemplate->template_url)}}" value="{{encode_id($dataTemplate->MsTemplateId)}}">Tabel {{$dataTemplate->nomor_tabel}} - {{$dataTemplate->name}}</option> <option {{@$item->template_id == $dataTemplate->MsTemplateId ? 'selected' : ''}} data-template="{{asset($dataTemplate->template_url)}}" value="{{encode_id($dataTemplate->MsTemplateId)}}">Tabel {{$dataTemplate->nomor_tabel}} - {{$dataTemplate->name}}</option>
@endforeach @endforeach --}}
</select> </select>
<a href="{{ url('opendata/dataset/generateTemplate/'.encode_id(@$item->ms_tabel_data_id)); }}" class="p-2 bg-emerald-500 btnDownload text-white rounded flex gap-2 items-center"><i data-lucide="download" class="w-4 h-4 mr-2"></i><span>Download Template Excel</span></a>
</div>
@error('template_id') @error('template_id')
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span> <span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror @enderror
</div> </div>
<h5 class="text-lg text-slate-700 font-bold">Informasi Dataset</h5> <h5 class="text-lg text-slate-700 font-bold">Informasi Dataset</h5>
<hr> <hr>
<div class="flex gap-4 mt-5"> <div class="flex gap-4 mt-5">
<label class="mb-3 w-1/2 font-semibold required">Nama Dataset</label> <label class="mb-3 w-1/2 font-semibold required">Nama Dataset</label>
<input type="text" value="{{@$item->name ? @$item->name : old('name')}}" name="name" class="p-2 border rounded w-full @error('name') is-invalid @enderror" placeholder="Masukan Nama Dataset" required> <input type="text" value="{{@$item->name ? @$item->name : old('name')}}" name="name" class="p-2 border rounded w-full nama_dataset @error('name') is-invalid @enderror" placeholder="Masukan Nama Dataset" required>
@error('name') @error('name')
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span> <span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
@enderror @enderror
@ -98,79 +102,78 @@
@endsection @endsection
@section('js') @section('js')
<script> <script>
const input = document.getElementById('tag-input');
const container = document.getElementById('tag-container');
input.addEventListener('keydown', function (e) {
if (e.key === 'Enter' && this.value.trim() !== '') {
e.preventDefault();
const tagText = this.value.trim();
// Buat tag baru
const tag = document.createElement('span');
tag.className = 'inline-flex items-center px-2 py-1 bg-primary text-white text-sm rounded';
tag.innerHTML = `${tagText} <button type="button" class="ml-1 text-blue-500 hover:text-red-600">&times;</button>`;
// Hidden input untuk dikirim ke server
const hiddenInput = document.createElement('input');
hiddenInput.type = 'hidden';
hiddenInput.name = 'tags[]';
hiddenInput.value = tagText;
// Tempelkan ke tag
tag.appendChild(hiddenInput);
// Tambahkan tag ke container sebelum input
container.insertBefore(tag, input);
// Reset input
this.value = '';
// Hapus tag saat tombol × ditekan
tag.querySelector('button').addEventListener('click', () => tag.remove());
}
});
</script>
<script type="text/javascript">
$('.template_id').on('change',function(){ $('.template_id').on('change',function(){
var template = $(this).find(':selected').attr('data-template'); var template = $(this).find(':selected').attr('data-template');
var name = $(this).find(':selected').attr('data-name');
$('.btnDownload').attr('href',template); $('.btnDownload').attr('href',template);
$('.nama_dataset').val(name);
}); });
$('#template_default').on('change',function(){ function clear(elementId) {
var instansi_id = $('.instansi_id').find(':selected').val(); $('#' + elementId).empty();
var val = $(this).find(':selected').val(); $('#' + elementId).select2();
var template = $('.template_id').find(':selected').attr('data-template'); }
if(instansi_id == ''){ $('select').on("select2:selecting", function(e) {
toastr.error("Data instansi_id Belum Dipilih", 'Error!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'}); var selectorOrigin = this.id;
$('#template_default').val(''); var id = e.params.args.data.id;
}else{
if(val == 1){
$('.btnDownload').attr('href',template); if(selectorOrigin=='instansi_id'){
$('.btnDownload').removeClass('hidden'); $('#loading-spinner').show();
}else{ clear('template_id');
$('.btnDownload').attr('href',"#"); selector = 'template_id';
$('.btnDownload').addClass('hidden'); url_to = 'getResourceData';
} getSelect(id, selector, url_to);
} }
}); });
$(document).ready(function() {
$('.numberInput').on('input', function() {
this.value = this.value.replace(/[^0-9]/g, ''); // Hanya angka 0-9
});
$('#togglePassword').on('click', function() {
let passwordField = $('#password');
let icon = $(this).find('i');
// Cek apakah input saat ini bertipe password function getSelect(id, selectTo, urlTo, selected = "") {
if (passwordField.attr('type') === 'password') { id = id;
passwordField.attr('type', 'text'); // Ubah ke teks var base_url = "{{url('/')}}";
icon.removeClass('fa-eye').addClass('fa-eye-slash'); // Ganti ikon //alert(id);
} else { destino = "#" + selectTo;
passwordField.attr('type', 'password'); // Ubah ke password console.log(id);
icon.removeClass('fa-eye-slash').addClass('fa-eye'); // Kembalikan ikon valor = $('#' + id).find(":selected").val();
$.ajax({
method: "GET",
url: base_url + '/' + urlTo,
data: {
id: id
} }
})
.done(function(msg) {
obj = msg.data;
if (obj.length > 0) {
//Clear the current options
$(destino).empty();
if(selectTo=='template_id'){
$(destino).append('<option value="">-Pilih Sumber Data-</option>').select2("val", "0");
$.each(obj, function(index) {
value = obj[index].id;
text = obj[index].name;
text2 = obj[index].name2;
excel = obj[index].excel;
$(destino).append('<option data-name="'+text2+'" data-template="'+excel+'" value=' + value + '>' + text + '</option>');
});
console.log(selected)
if (selected) {
$(destino).val(selected).trigger('change');
selected = "";
}
}
} else {
if(selectTo=='template_id'){
$(destino).empty().append('<option value="0">-Pilih Sumber Data-</option>').select2("val", "0");
}
}
$('#loading-spinner').hide();
}); });
}); return false;
}
</script> </script>
@endsection @endsection

View File

@ -27,6 +27,8 @@ Route::name('dashboard.')->prefix('dashboard')->group(function () {
Route::get('/grid',[HomeController::class,'grid'])->name('grid'); Route::get('/grid',[HomeController::class,'grid'])->name('grid');
Route::get('/grid/tabel',[HomeController::class,'gridTabel'])->name('gridTabel'); Route::get('/grid/tabel',[HomeController::class,'gridTabel'])->name('gridTabel');
Route::get('/gridResource',[HomeController::class,'gridResource'])->name('gridResource'); Route::get('/gridResource',[HomeController::class,'gridResource'])->name('gridResource');
Route::get('/gridInstansiUtama',[HomeController::class,'gridInstansiUtama'])->name('gridInstansiUtama');
Route::get('/gridInstansiTambahan',[HomeController::class,'gridInstansiTambahan'])->name('gridInstansiTambahan');
Route::get('/datasetGrid/{alias}',[HomeController::class,'datasetGrid'])->name('datasetGrid'); Route::get('/datasetGrid/{alias}',[HomeController::class,'datasetGrid'])->name('datasetGrid');
Route::get('/api/chart/{template_id}/{instansi_id}',[HomeController::class,'apiChart'])->name('apiChart'); Route::get('/api/chart/{template_id}/{instansi_id}',[HomeController::class,'apiChart'])->name('apiChart');
}); });