Skip to content

Commit

Permalink
Rilis 2410.0.0 (#436)
Browse files Browse the repository at this point in the history
Co-authored-by: ahmad afandi <[email protected]>
Co-authored-by: Firliani Fauziah <[email protected]>
  • Loading branch information
3 people authored Oct 1, 2024
1 parent 28b3ae1 commit 55421e2
Show file tree
Hide file tree
Showing 34 changed files with 93,456 additions and 102 deletions.
18 changes: 11 additions & 7 deletions app/Helpers/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
function pantau_versi()
{
return 'v2409.0.0';
return 'v2410.0.0';
}
}

Expand Down Expand Up @@ -244,13 +244,17 @@ function cleanVersi($version)
*/
function lastrelease_opendk()
{
$version = Cache::get('opendk_version', '2307.0.0');
$versi_opendk = lastrelease('https://api.github.com/repos/OpenSID/opendk/releases/latest');
// Cache data until the end of the day
$version = Cache::remember('release_opendk', now()->endOfDay(), function () {
$version = '2404.0.0';
$versi_api = lastrelease('https://api.github.com/repos/OpenSID/opendk/releases/latest');

if ($versi_opendk !== false) {
$version = str_replace('v', '', $versi_opendk->tag_name);
Cache::forever('opendk_version', $version);
}
if ($versi_api !== false) {
$version = str_replace('v', '', $versi_api->tag_name);
}

return $version;
});

return $version;
}
Expand Down
50 changes: 50 additions & 0 deletions app/Http/Controllers/Api/InstallOpenDKController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Desa;
use App\Models\Opendk;
use Carbon\Carbon;
use Illuminate\Http\Request;

class InstallOpenDKController extends Controller
{
public function chart(Request $request)
{
$provinsi = $request->get('provinsi');
$kabupaten = $request->get('kabupaten');
$kecamatan = $request->get('kecamatan');
$minCreatedAt = Carbon::now()->subYears(2)->format('Y-m-d');
$opendk = Opendk::selectRaw("DATE_FORMAT(created_at, '%m-%Y') month_year, count(*) as total")
->groupBy('month_year')->orderBy('created_at')->whereDate('created_at', '>', $minCreatedAt);
if ($provinsi) {
$opendk->where('kode_provinsi', $provinsi);
}
if ($kabupaten) {
$opendk->where('kode_kabupaten', $kabupaten);
}
if ($kecamatan) {
$opendk->where('kode_kecamatan', $kecamatan);
}

$opendkData = $opendk->get();
$labels = [];
$datasetOpendk = [];
foreach ($opendkData as $item) {
$period = Carbon::createFromFormat('d-m-Y', '01-'.$item->month_year)->translatedFormat('M-y');
$labels[] = $period;
$datasetOpendk[] = $item->total;
}
$datasets = [
['label' => 'OpenDK', 'data' => $datasetOpendk],
];

$result = [
'labels' => $labels,
'datasets' => $datasets,
];

return response()->json($result);
}
}
2 changes: 0 additions & 2 deletions app/Http/Controllers/Api/InstallOpensidController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public function chart(Request $request)
$datasetOpensid = [];
foreach ($opensidData as $item) {
$period = Carbon::createFromFormat('d-m-Y', '01-'.$item->month_year)->translatedFormat('M-y');
\Log::error($item);
\Log::error($period);
$labels[] = $period;
$datasetOpensid[] = $item->total;
}
Expand Down
27 changes: 12 additions & 15 deletions app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ public function datatablePenggunaOpendk(Request $request)
return $item;
});
return DataTables::of($desa)
->editColumn('updated_at', static fn($q) => $q->updated_at->format('Y-m-d H:i:s'))
->addIndexColumn() // Menambahkan kolom indeks
->escapeColumns([])
->make(true);
Expand Down Expand Up @@ -291,22 +292,18 @@ public function datatablePenggunaOpenkab(Request $request)

public function datatablePenggunaOpensid(Request $request)
{
if ($request->ajax()) {
$desa = Desa::orderBy('created_at', 'desc')
->get()
->map(function ($item) {
if($item->modul_tte == 0){
$item->modul_tte = '<span class="badge badge-secondary">Tidak Aktif</span>';
}elseif($item->modul_tte == 1){
$item->modul_tte = '<span class="badge badge-success">Aktif</span>';
}
$item->tanggal = formatDateTimeForHuman($item->created_at); // Misalnya formatDateTimeForHuman merupakan fungsi untuk mengubah format tanggal
$item->tanggal = '<span class="text-nowrap text-muted">' . $item->tanggal . '</span>'; // Menambahkan kelas Bootstrap
return $item;
});
return DataTables::of($desa)
if ($request->ajax()) {
return DataTables::of(Desa::orderBy('created_at', 'desc'))
->editColumn('modul_tte', function($item){
if($item->modul_tte == 0){
return '<span class="badge badge-secondary">Tidak Aktif</span>';
}elseif($item->modul_tte == 1){
return '<span class="badge badge-success">Aktif</span>';
}
})->editColumn('tanggal', static fn($item) => '<span class="text-nowrap text-muted">' . formatDateTimeForHuman($item->created_at) . '</span>')
->addIndexColumn() // Menambahkan kolom indeks
->escapeColumns([])
->escapeColumns()
->rawColumns(['modul_tte', 'tanggal'])
->make(true);
}

Expand Down
50 changes: 50 additions & 0 deletions app/Http/Controllers/LaporanTemaController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App\Http\Controllers;

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

class LaporanTemaController 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()) {
if($tema){
$data = DataTables::of(Desa::fillter($fillters)->where('tema', $tema));
}else{
$data = DataTables::of(Desa::fillter($fillters)->whereIn('tema', ['esensi', 'natra', 'palanta']));
}
return $data->addIndexColumn()
->editColumn('updated_at', fn($q) => $q->updated_at->format('Y-m-d H:i:s'))
->editColumn('url_hosting', function ($q) {
return '<a href="https://' . $q->url_hosting . '" target="_blank">'. $q->url_hosting .'</a>';
})
->rawColumns(['url_hosting']) // Mengizinkan HTML di kolom url_hosting
->make(true);
}

$palanta = Desa::TemaPalanta();
$natra = Desa::TemaNatra();
$esensi = Desa::TemaEsensi();
$tema = Desa::Tema();

return view('laporan.tema', compact('fillters', 'palanta', 'natra', 'esensi', 'tema'));
}
}
154 changes: 154 additions & 0 deletions app/Http/Controllers/OpenDKDashboardController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<?php

namespace App\Http\Controllers;

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

class OpenDKDashboardController extends Controller
{
public function index(Request $request)
{
$fillters = [
'kode_provinsi' => $request->kode_provinsi,
'kode_kabupaten' => $request->kode_kabupaten,
'kode_kecamatan' => $request->kode_kecamatan,
];
$versiTerakhir = lastrelease_opendk();
$installHariIni = Opendk::whereDate('created_at', '>=',Carbon::now()->format('Y-m-d'))->get();
return view('website.opendk.index', [
'fillters' => $fillters,
'total_desa' => format_angka(Desa::count()),
'pengguna_opendk' => Opendk::count(),
'info_rilis' => 'Rilis OpenDK '.$versiTerakhir,
'installHariIni' => $installHariIni,
'provinsi_pengguna_opendk' => Opendk::selectRaw('nama_provinsi, count(*) as total')->orderBy('total', 'desc')->groupBy('nama_provinsi')->get(),
]);
}

public function detail()
{
return view('website.opendk.detail');
}

public function versi(Request $request)
{
$fillters = [
'kode_provinsi' => $request->kode_provinsi,
'kode_kabupaten' => $request->kode_kabupaten,
'kode_kecamatan' => $request->kode_kecamatan,
];

if ($request->ajax()) {
return DataTables::of(Opendk::filter($fillters)->groupBy('versi')->selectRaw('versi, count(*) as jumlah'))
->addIndexColumn()
->make(true);
}

return view('website.opendk.versi_lengkap', compact('fillters'));
}

public function versi_detail(Request $request)
{
$fillters = [
'kode_provinsi' => $request->kode_provinsi,
'kode_kabupaten' => $request->kode_kabupaten,
'kode_kecamatan' => $request->kode_kecamatan,
];

if ($request->ajax()) {
$versi = $request->versi;
return DataTables::of(Opendk::filter($fillters)->when($versi, static fn($q) => $q->where('versi', $versi)))
->editColumn('updated_at', static fn($q) => $q->updated_at->translatedFormat('Y-m-d H:i:s'))
->addIndexColumn()
->make(true);
}

return view('website.opendk.versi_detail', compact('fillters'));
}

public function install_baru(Request $request)
{
if ($request->ajax()) {
return DataTables::of(Opendk::whereDate('created_at', '>=', Carbon::now()->subDays(7)))
->editColumn('created_at', static fn($q) => $q->created_at->translatedFormat('j F Y H:i'))
->addIndexColumn()
->make(true);
}
}

public function peta(Request $request)
{
if ($request->ajax()) {
$fillters = [
'kode_provinsi' => $request->kode_provinsi,
'kode_kabupaten' => $request->kode_kabupaten,
'kode_kecamatan' => $request->kode_kecamatan
];
//
$geoJSONdata = Opendk::filter($fillters)
->whereRaw("CONCAT('',lat * 1) = lat") // tdk ikut sertakan data bukan bilangan
->whereRaw("CONCAT('',lng * 1) = lng") // tdk ikut sertakan data bukan bilangan
->whereRaw('lat BETWEEN -10 AND 6')
->whereRaw('lng BETWEEN 95 AND 142')
->where(function ($query) {
$query
->where('lat', '!=', config('tracksid.desa_contoh.lat'))
->where('lng', '!=', config('tracksid.desa_contoh.lng'));
})->orderBy('kode_kecamatan', 'ASC')->get()->map(function ($kecamatan) {
return [
'type' => 'Feature',
'geometry' => [
'type' => 'Point',
'coordinates' => [
(float) $kecamatan->lng,
(float) $kecamatan->lat,
],
],
'properties' => $this->properties($kecamatan),
'id' => $kecamatan->id,
];
});

return response()->json([
'type' => 'FeatureCollection',
'features' => $geoJSONdata,
]);
}
}

private function properties(Opendk $kecamatan)
{
$link = '';
if (auth()->check()) {
$link = '<tr><td>Website</td><td> : <a href="http://'.strtolower($kecamatan->url).'" target="_blank">'.strtolower($kecamatan->url).'</a></b></td></tr>';
}

return [
'logo' => null,
'popupContent' => '
<h6 class="text-center"><b style="color:red">'.strtoupper($kecamatan->sebutan_wilayah.' '.$kecamatan->nama_kecamatan).'</b></h6>
<b><table width="100%">
<tr>
<td>'.ucwords($kecamatan->sebutan_wilayah).'</td><td> : '.ucwords($kecamatan->sebutan_wilayah.' '.$kecamatan->nama_kecamatan).'</b></td>
</tr>
<tr>
<td>Kecamatan</td><td> : '.ucwords($kecamatan->nama_kecamatan).'</b></td>
</tr>
<tr>
<td>Kab/Kota</td><td> : '.ucwords($kecamatan->nama_kabupaten).'</b></td>
</tr>
<tr>
<td>Provinsi</td><td> : '.ucwords($kecamatan->nama_provinsi).'</b></td>
</tr>
<tr>
<td>Alamat</td><td> : '.$kecamatan->alamat.'</b></td>
</tr>
'.$link.'
</table></b>',
];
}
}
7 changes: 1 addition & 6 deletions app/Http/Controllers/WebsiteDashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,7 @@ public function openkab(Request $request)
'latestDesa' => $latestDesa,
'provinsi' => $sortedProvinsi->values()->all(),
]);
}

public function opendk(Request $request)
{
return view('website.opendk');
}
}

public function openkabData(Request $request)
{
Expand Down
20 changes: 9 additions & 11 deletions app/Http/Middleware/WebDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,19 @@ class WebDashboard
public function handle(Request $request, Closure $next)
{
$route = Route::current();
$uri = $route->uri();

if (!auth()->check() && !Str::startsWith($uri, 'web')) {
return redirect('web');
}
$uri = $route->uri();

if (auth()->check() && $uri == '/') {
return redirect('dashboard');
}
if (!auth()->check()) {
if(!Str::startsWith($uri, 'web') && $uri !== '/'){
return redirect('web');
}
}

// Change the config values here
if (Str::startsWith($uri, 'web')) {
Config::set('adminlte', Config::get('weblte')); // example
Config::set('adminlte', Config::get('weblte')); // example
if(auth()->check()){
Config::set('adminlte.dashboard_url', 'dashboard');
}

return $next($request);
}
}
3 changes: 2 additions & 1 deletion app/Http/Requests/TrackRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ public function requestData()
'jml_dokumen',
'jml_keluarga',
'anjungan',
'kontak'
'kontak',
'tema'
]);
}
}
Loading

0 comments on commit 55421e2

Please sign in to comment.