Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions app/Http/Controllers/LaporanTemaProController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace App\Http\Controllers;

use App\Models\Desa;
use Illuminate\Http\Request;
use Yajra\DataTables\Facades\DataTables;

class LaporanTemaProController extends Controller
{
public function index(Request $request)
{
$fillters = [
'kode_provinsi' => $request->kode_provinsi,
'kode_kabupaten' => $request->kode_kabupaten,
'kode_kecamatan' => $request->kode_kecamatan,
'status' => $request->status,
'akses' => $request->akses,
'versi_lokal' => $request->versi_lokal,
'versi_hosting' => $request->versi_hosting,
'tte' => $request->tte,
];

$tema = $request->query('tema', '');

if ($request->ajax()) {
$query = Desa::fillter($fillters);

if ($tema) {
$query->where('tema', 'like', "%{$tema}%");
} else {
// Filter hanya tema pro berdasarkan konstanta TEMA_PRO
$query->where(function ($q) {
foreach (Desa::TEMA_PRO as $temaPro) {
$q->orWhere('tema', 'like', "%{$temaPro}%");
}
})->whereNotNull('tema');
}

return DataTables::of($query)
->addIndexColumn()
->editColumn('updated_at', function ($row) {
return $row->updated_at ? $row->updated_at->format('d/m/Y H:i') : '-';
})
->editColumn('url_hosting', function ($row) {
return $row->url_hosting ? '<a href="' . $row->url_hosting . '" target="_blank">' . $row->url_hosting . '</a>' : '-';
})
->rawColumns(['url_hosting'])
->make(true);
}

$temaPro = Desa::TemaPro();
$temaProList = Desa::TemaProList();

return view('laporan.tema-pro', compact('temaPro', 'temaProList'));
}
}
46 changes: 44 additions & 2 deletions app/Models/Desa.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
use Illuminate\Support\Str;

class Desa extends Model
{

{
use HasFactory, HasRegionAccess, FilterWilayahTrait;
public const TEMA_PRO = ['Silir', 'Batuah', 'Pusako', 'DeNava', 'Lestari'];


/** {@inheritdoc} */
protected $table = 'desa';
Expand Down Expand Up @@ -550,4 +551,45 @@ public function scopeKecamatanOpenSID($query, $fillters = [])
->groupBy(['sub.kode_kecamatan', 'sub.nama_kecamatan', 'sub.kode_kabupaten', 'sub.nama_kabupaten', 'sub.kode_provinsi', 'sub.nama_provinsi'])
->orderBy('sub.nama_kecamatan');
}

public function scopeTemaPro($query)
{
return $query->where(function ($q) {
foreach (self::TEMA_PRO as $tema) {
$q->orWhere('tema', 'like', "%{$tema}%");
}
})->whereNotNull('tema')->count();
}

public function scopeTemaProList($query)
{
// Get data for themes that exist in database
$existingThemes = $query->where(function ($q) {
foreach (self::TEMA_PRO as $tema) {
$q->orWhere('tema', 'like', "%{$tema}%");
}
})
->selectRaw("
CASE
" . collect(self::TEMA_PRO)->map(function ($tema) {
return "WHEN tema LIKE \"%{$tema}%\" THEN \"{$tema}\"";
})->implode(' ') . "
ELSE tema
END AS tema_nama,
COUNT(*) as total
")
->groupBy('tema_nama')
->pluck('total', 'tema_nama')
->toArray();

// Ensure all TEMA_PRO themes are included with 0 count if not found
$allThemes = collect(self::TEMA_PRO)->map(function ($tema) use ($existingThemes) {
return (object) [
'tema_nama' => $tema,
'total' => $existingThemes[$tema] ?? 0
];
})->sortByDesc('total')->values();

return $allThemes;
}
}
1 change: 1 addition & 0 deletions catatan_rilis.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Di rilis v2509.0.0 berisi perbaikan yang diminta Komunitas Open Desa.
7. [#540](https://github.com/OpenSID/pantau/issues/540) Penambahan tema Lestari pada laporan Pengguna Tema bawaan.
8. [#541](https://github.com/OpenSID/pantau/issues/541) Penambahan halaman KelolaDesa.
9. [#551](https://github.com/OpenSID/pantau/issues/551) Susun menu & urutan pada pantau.
10. [#545](https://github.com/OpenSID/pantau/issues/545) Penambahan Dasbor Tema Pro.

#### Perbaikan Bug

Expand Down
2 changes: 1 addition & 1 deletion config/adminlte.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@
'url' => 'laporan/desa-aktif',
'can' => 'laporan.desa-aktif.view',
],

],
],
[
Expand Down Expand Up @@ -443,6 +442,7 @@
[
'text' => 'Pengguna Tema Pro',
'url' => 'laporan/tema-pro',
'can' => 'laporan.tema-pro.view',
],
[
'text' => 'Pengguna Tema Bawaan',
Expand Down
1 change: 1 addition & 0 deletions database/factories/DesaFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function definition()
'jml_surat_tte' => $this->faker->numberBetween(0, 100),
'modul_tte' => $this->faker->boolean(),
'jml_keluarga' => $this->faker->numberBetween(0, 1000),
'tema' => $this->faker->randomElement(['esensi', 'natra', 'palanta', 'batuah', 'denatra']),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Spatie\Permission\Models\Permission;
use Spatie\Permission\Models\Role;

return new class extends Migration {
private
$permissions = [
'laporan.tema-pro.view',
];
/**
* Run the migrations.
*/
public function up(): void
{
// Reset cached roles and permissions
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();

foreach ($this->permissions as $permission) {
Permission::create(['name' => $permission]);
}

// Assign permissions to roles
$adminRole = Role::where('name', 'Administrator')->first();

if ($adminRole) {
// Admin gets all permissions
$adminRole->givePermissionTo(Permission::all());
}
}

/**
* Reverse the migrations.
*/
public function down(): void
{
// Reset cached roles and permissions
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
Permission::whereIn('name', $this->permissions)->each(function ($permission) {
$permission->roles()->detach();
$permission->users()->detach();
});
Permission::whereIn('name', $this->permissions)->delete();
}
};
144 changes: 144 additions & 0 deletions resources/views/laporan/tema-pro.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
@extends('layouts.index')
@include('layouts.components.select2_wilayah')

@section('title', 'Desa Pengguna Tema Pro')

@section('content_header')
<h1>
Dasbor<small class="font-weight-light ml-1 text-md font-weight-bold">Status Penggunaan Tema Pro
</small></h1>
@stop

@section('content')
@include('layouts.components.notification')
<div class="row">
@if(empty(request()->query('tema')))
<div class="col-lg-12">
<div class="card card-outline card-primary">
<div class="card-body">
<div class="row">
@php $colorIndex = 0; @endphp
@php $colors = ['bg-info', 'bg-success', 'bg-warning', 'bg-danger', 'bg-secondary', 'bg-dark']; @endphp

@foreach($temaProList as $item)
<div class="col-lg-4">
<!-- small card -->
<div class="small-box {{ $colors[$colorIndex % count($colors)] }}">
<div class="inner">
<h3>{{ $item->total }}</h3>
<p>Tema {{ ucfirst($item->tema_nama) }}</p>
</div>
<div class="icon">
<i class="fas fa-palette"></i>
</div>
<a href="{{ url('laporan/tema-pro') }}?tema={{ $item->tema_nama }}"
class="small-box-footer">Lihat detail <i class="fas fa-arrow-circle-right"></i></a>
</div>
</div>
@php $colorIndex++; @endphp
@endforeach

@if(count($temaProList) == 0)
<div class="col-lg-12">
<div class="alert alert-info">
<i class="fas fa-info-circle"></i> Tidak ada data tema pro yang tersedia.
</div>
</div>
@endif
</div>
</div>
</div>
</div>
@endif

<div class="col-lg-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Daftar Desa Pengguna Tema Pro
{{request()->query('tema') ? '- ' . request()->query('tema') : ''}}
</h3>
<div class="card-tools">
<span data-toggle="tooltip" title="" class="badge badge-primary">
@if(request()->query('tema'))
@foreach($temaProList as $item)
@if($item->tema_nama == request()->query('tema'))
{{$item->total}}
@break
@endif
@endforeach
@else
{{$temaPro}}
@endif
</span>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table" id="table-desa">
<thead>
<tr>
<th>No</th>
<th>Tanggal Terpantau</th>
<th>Desa</th>
<th>Kecamatan</th>
<th>Kabupaten</th>
<th>Provinsi</th>
<th>Web</th>
<th>Tema</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<!-- /.table-responsive -->
</div>
</div>
</div>
</div>
@endsection

@section('js')
<script>
var desa = $('#table-desa').DataTable({
processing: true,
serverSide: true,
autoWidth: false,
ordering: true,
ajax: {
url: `{{ url('laporan/tema-pro') }}{{request()->query('tema') ? '?tema=' . request()->query('tema') : ''}}`,
method: 'get'
},
columns: [{
data: 'DT_RowIndex',
name: 'DT_RowIndex',
searchable: false,
orderable: false
},
{
data: 'updated_at'
},
{
data: 'nama_desa'
},
{
data: 'nama_kecamatan'
},
{
data: 'nama_kabupaten'
},
{
data: 'nama_provinsi',
},
{
data: 'url_hosting'
},
{
data: 'tema'
},
],
order: [
[1, 'desc']
],
});
</script>
@endsection
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use App\Http\Controllers\PenggunaController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\LaporanTemaController;
use App\Http\Controllers\LaporanTemaProController;
use App\Http\Controllers\OpenDKDashboardController;
use App\Http\Controllers\LaporanDesaAktifController;
use App\Http\Controllers\KecamatanAktifOpendkController;
Expand Down Expand Up @@ -149,6 +150,7 @@
Route::get('versi', [LaporanController::class, 'versi']);
Route::get('desa-aktif', [LaporanDesaAktifController::class, 'index']);
Route::get('tema', [LaporanTemaController::class, 'index']);
Route::get('tema-pro', [LaporanTemaProController::class, 'index']);
});

// PBB
Expand Down
Loading