Skip to content

Commit

Permalink
Rilis v24.03.0.0 (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
vickyrolanda authored Mar 1, 2024
2 parents 838fd37 + 3a0b335 commit fe93e56
Show file tree
Hide file tree
Showing 146 changed files with 909 additions and 334 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/AppVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AppVersion extends Command
*
* @var string
*/
protected $signature = 'tracksid:app-version';
protected $signature = 'pantau:app-version';

/**
* The console command description.
Expand Down
10 changes: 8 additions & 2 deletions app/Console/Commands/BackupDatabaseStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BackupDatabaseStorage extends Command
*
* @var string
*/
protected $signature = 'tracksid:backup-database-storage';
protected $signature = 'pantau:backup-database-storage';

/**
* The console command description.
Expand Down Expand Up @@ -59,6 +59,8 @@ private function backupDatabase()
try {
$backup = MySql::create()
->setDbName(env('DB_DATABASE'))
->setHost(env('DB_HOST', '127.0.0.1'))
->setPort(env('DB_PORT', 3306))
->setUserName(env('DB_USERNAME'))
->setPassword(env('DB_PASSWORD'));

Expand All @@ -72,9 +74,13 @@ private function backupDatabase()

private function backupStorage()
{
$folderdesa_from = 'storage';
$folderdesa_from = 'storage'.DIRECTORY_SEPARATOR.'app';
$folderdesa_to = folder_backup().DIRECTORY_SEPARATOR.'storage';

if (! file_exists($folderdesa_to)) {
mkdir($folderdesa_to, 0755, true);
}

if (file_exists($folderdesa_from)) {
exec('cp -R '.$folderdesa_from.' '.$folderdesa_to);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/BackupGoogleDrive.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BackupGoogleDrive extends Command
*
* @var string
*/
protected $signature = 'tracksid:backup-google-drive';
protected $signature = 'pantau:backup-google-drive';

/**
* The console command description.
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/BackupVps.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BackupVps extends Command
*
* @var string
*/
protected $signature = 'tracksid:backup-vps-sftp';
protected $signature = 'pantau:backup-vps-sftp';

/**
* The console command description.
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/BpsKemendagriCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BpsKemendagriCommand extends Command
*
* @var string
*/
protected $signature = 'tracksid:sinkronasi-bps-kemendagri';
protected $signature = 'pantau:sinkronasi-bps-kemendagri';

/**
* The console command description.
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/DesaOptimasiCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DesaOptimasiCommand extends Command
*
* @var string
*/
protected $signature = 'tracksid:optimasi-desa';
protected $signature = 'pantau:optimasi-desa';

/**
* The console command description.
Expand Down
12 changes: 6 additions & 6 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @param Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('tracksid:optimasi-desa')->weekly(); // setiap minggu at 00:00
$schedule->command('tracksid:sinkronasi-bps-kemendagri')->weekly(); // setiap minggu at 00:00
$schedule->command('tracksid:backup-database-storage')->timezone('Asia/Jakarta')->at('01:00'); // setiap hari at 01:00
$schedule->command('tracksid:backup-google-drive')->timezone('Asia/Jakarta')->at('03:00'); // setiap hari at 03:00
$schedule->command('tracksid:backup-vps-sftp')->timezone('Asia/Jakarta')->at('03:30'); // setiap hari at 03:00
$schedule->command('pantau:optimasi-desa')->weekly(); // setiap minggu at 00:00
$schedule->command('pantau:sinkronasi-bps-kemendagri')->weekly(); // setiap minggu at 00:00
$schedule->command('pantau:backup-database-storage')->timezone('Asia/Jakarta')->at('01:00'); // setiap hari at 01:00
$schedule->command('pantau:backup-google-drive')->timezone('Asia/Jakarta')->at('03:00'); // setiap hari at 03:00
$schedule->command('pantau:backup-vps-sftp')->timezone('Asia/Jakarta')->at('03:30'); // setiap hari at 03:00
}

/**
Expand Down
13 changes: 11 additions & 2 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,26 @@

class Handler extends ExceptionHandler
{
/**
* A list of exception types with their corresponding custom log levels.
*
* @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*>
*/
protected $levels = [
//
];

/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<Throwable>>
* @var array<int, class-string<\Throwable>>
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
* A list of the inputs that are never flashed to the session on validation exceptions.
*
* @var array<int, string>
*/
Expand Down
4 changes: 2 additions & 2 deletions app/Helpers/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
function pantau_versi()
{
return 'v2401.0.0';
return 'v2403.0.0';
}
}

Expand Down Expand Up @@ -130,7 +130,7 @@ function lastrelease($url)
->throw();

return json_decode($response->body());
} catch (\Throwable $th) {
} catch (Throwable $th) {
return false;
}
}
Expand Down
41 changes: 41 additions & 0 deletions app/Http/Controllers/Api/TrackKelolaDesaController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Requests\TrackKelolaDesaRequest;
use App\Models\TrackKeloladesa;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class TrackKelolaDesaController extends Controller
{
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return \Illuminate\Http\Response
*/
public function store(TrackKelolaDesaRequest $request)
{
$request->validated();
DB::beginTransaction();
try {
TrackKeloladesa::query()->updateOrCreate(
$request->requestWhere(),
$request->requestData()
);

DB::commit();

return response()->json(['status' => 'success']);
} catch (Exception $e) {
Log::error($e);
DB::rollBack();

return response()->json($e->getMessage(), 422);
}
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function validator(array $data)
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\Models\User
* @return User
*/
protected function create(array $data)
{
Expand Down
12 changes: 8 additions & 4 deletions app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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

Expand All @@ -19,16 +20,19 @@ public function __construct()

public function index()
{
$pengaturanAplikasi = PengaturanAplikasi::get_pengaturan();
$pengaturanAplikasi['akhir_backup'] = ! empty($pengaturanAplikasi['akhir_backup']) ? $pengaturanAplikasi['akhir_backup'] : Carbon::now()->startOfMonth()->format('Y-m-d');

return view('dashboard', [
'jumlahDesa' => $this->desa->jumlahDesa()->get()->first(),
'desaBaru' => $this->desa->desaBaru()->count(),
'kabupatenKosong' => collect($this->desa->kabupatenKosong())->count(),
'info_backup' => [
'cloud_storage' => PengaturanAplikasi::get_pengaturan()['cloud_storage'],
'akhir_backup' => PengaturanAplikasi::get_pengaturan()['akhir_backup'],
'waktu_backup' => PengaturanAplikasi::get_pengaturan()['waktu_backup'],
'cloud_storage' => $pengaturanAplikasi['cloud_storage'],
'akhir_backup' => $pengaturanAplikasi['akhir_backup'],
'waktu_backup' => $pengaturanAplikasi['waktu_backup'],
'info' => 'Peringatan !!!',
'isi' => 'Gagal Backup Otomatis ke Cloud Storage.',
'isi' => 'Gagal Backup Otomatis ke Cloud Storage pada tanggal '.Carbon::createFromFormat('Y-m-d', $pengaturanAplikasi['akhir_backup'])->addDays($pengaturanAplikasi['waktu_backup'])->format('Y-m-d'),
],
]);
}
Expand Down
85 changes: 62 additions & 23 deletions app/Http/Controllers/MobileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace App\Http\Controllers;

use App\Models\Desa;
use App\Models\TrackKeloladesa;
use App\Models\TrackMobile;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
Expand All @@ -14,38 +14,60 @@ class MobileController extends Controller
{
private $mobile;

private $kelolaDesa;

protected $baseRoute = 'mobile';

protected $baseView = 'mobile';

public function __construct()
{
$this->mobile = new TrackMobile();
$this->kelolaDesa = new TrackKeloladesa();
Config::set('title', $this->baseView.'');
}

public function index()
{
$totalPengguna = $this->mobile->wilayahKhusus()->count();
$totalDesaPengguna = $this->mobile->wilayahKhusus()->desa()->count();
$totalDesaPenggunaAktif = $this->mobile->wilayahKhusus()->desa()->active()->count();
$totalPenggunaAktif = $this->mobile->wilayahKhusus()->count();
$totalPengguna = $this->kelolaDesa->wilayahKhusus()->count();
$totalDesaPengguna = $this->kelolaDesa->wilayahKhusus()->desa()->count();
$totalDesaPenggunaAktif = $this->kelolaDesa->wilayahKhusus()->desa()->active()->count();
$totalPenggunaAktif = $this->kelolaDesa->wilayahKhusus()->count();

$totalPenggunaKelolaDesa = $this->kelolaDesa->wilayahKhusus()->count();
$totalDesaPenggunaKelolaDesa = $this->kelolaDesa->wilayahKhusus()->desa()->count();
$totalDesaPenggunaAktifKelolaDesa = $this->kelolaDesa->wilayahKhusus()->desa()->active()->count();
$totalPenggunaAktifKelolaDesa = $this->kelolaDesa->wilayahKhusus()->count();

$desaWidgets = [
'semua' => ['urlWidget' => (Auth::check() ? url($this->baseRoute.'/pengguna') : ''), 'titleWidget' => 'Total Pengguna', 'classWidget' => 'col-lg-3', 'classBackgroundWidget' => 'bg-info', 'totalWidget' => $totalPengguna, 'iconWidget' => 'fa-user'],
'aktif' => ['urlWidget' => (Auth::check() ? url($this->baseRoute.'/pengguna?akses_mobile=1') : ''), 'titleWidget' => 'Pengguna Aktif', 'classWidget' => 'col-lg-3', 'classBackgroundWidget' => 'bg-success', 'totalWidget' => $totalPenggunaAktif, 'iconWidget' => 'fa-shopping-cart'],
'desa' => ['urlWidget' => url($this->baseRoute.'/desa'), 'titleWidget' => 'Total Desa', 'classWidget' => 'col-lg-3', 'classBackgroundWidget' => 'bg-primary', 'totalWidget' => $totalDesaPengguna, 'iconWidget' => 'fa-user'],
'desa_aktif' => ['urlWidget' => url($this->baseRoute.'/desa?akses_mobile=1'), 'titleWidget' => 'Desa pengguna Aktif', 'classWidget' => 'col-lg-3', 'classBackgroundWidget' => 'bg-warning', 'totalWidget' => $totalDesaPenggunaAktif, 'iconWidget' => 'fa-shopping-cart'],
];

$desaWidgetsKelolaDesa = [
'semua' => ['urlWidget' => (Auth::check() ? url($this->baseRoute.'/pengguna') : ''), 'titleWidget' => 'Total Pengguna', 'classWidget' => 'col-lg-3', 'classBackgroundWidget' => 'bg-info', 'totalWidget' => $totalPenggunaKelolaDesa, 'iconWidget' => 'fa-user'],
'aktif' => ['urlWidget' => (Auth::check() ? url($this->baseRoute.'/pengguna?akses_mobile=1') : ''), 'titleWidget' => 'Pengguna Aktif', 'classWidget' => 'col-lg-3', 'classBackgroundWidget' => 'bg-success', 'totalWidget' => $totalPenggunaAktifKelolaDesa, 'iconWidget' => 'fa-shopping-cart'],
'desa' => ['urlWidget' => url($this->baseRoute.'/desa'), 'titleWidget' => 'Total Desa', 'classWidget' => 'col-lg-3', 'classBackgroundWidget' => 'bg-primary', 'totalWidget' => $totalDesaPenggunaKelolaDesa, 'iconWidget' => 'fa-user'],
'desa_aktif' => ['urlWidget' => url($this->baseRoute.'/desa?akses_mobile=1'), 'titleWidget' => 'Desa pengguna Aktif', 'classWidget' => 'col-lg-3', 'classBackgroundWidget' => 'bg-warning', 'totalWidget' => $totalDesaPenggunaAktifKelolaDesa, 'iconWidget' => 'fa-shopping-cart'],
];

$penggunaBaru = $this->mobile->wilayahKhusus()->selectRaw('kode_desa, count(kode_desa) as jumlah')->with(['desa'])
->groupBy('kode_desa')
->where('created_at', '>=', now()->subDay(7))->get();
->groupBy('kode_desa')
->where('created_at', '>=', now()->subDay(7))->get();

$penggunaBaruKelolaDesa = $this->kelolaDesa->wilayahKhusus()->selectRaw('kode_desa, count(kode_desa) as jumlah')->with(['desa'])
->groupBy('kode_desa')
->where('created_at', '>=', now()->subDay(7))->get();

return view($this->baseView.'.dashboard', [
'baseRoute' => $this->baseRoute,
'baseView' => $this->baseView,
'desaWidgets' => $desaWidgets,
'daftar_baru' => $penggunaBaru,
'desaWidgetsKelolaDesa' => $desaWidgetsKelolaDesa,
'daftar_baruKelolaDesa' => $penggunaBaruKelolaDesa,
]);
}

Expand All @@ -66,6 +88,23 @@ public function pengguna(Request $request)
return view($this->baseView.'.pengguna', compact('fillters'));
}

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

if ($request->ajax()) {
return DataTables::of(TrackKeloladesa::wilayahKhusus()->filter($request)->with(['desa']))
->addIndexColumn()
->make(true);
}

return view($this->baseView.'.penggunakeloladesa', compact('fillters'));
}

public function desa(Request $request)
{
$fillters = [
Expand All @@ -74,20 +113,24 @@ public function desa(Request $request)
'akses_mobile' => $request->akses_mobile,
];
if ($request->ajax()) {
return DataTables::of(Desa::whereHas('mobile', function (Builder $query) use ($request) {
$query->when($request['kode_provinsi'], function ($q) use ($request) {
$q->whereRaw('left(kode_desa, 2) = '.$request['kode_provinsi']);
});
$query->when($request['kode_kabupaten'], function ($q) use ($request) {
return DataTables::of(Desa::leftJoin('track_mobile', 'desa.kode_desa', '=', 'track_mobile.kode_desa')
->leftJoin('track_keloladesa', 'desa.kode_desa', '=', 'track_keloladesa.kode_desa')
->groupBy('desa.kode_desa', 'desa.nama_kecamatan', 'desa.nama_kabupaten', 'desa.nama_provinsi', 'desa.nama_desa')
->havingRaw('COUNT(track_mobile.id) > 0 OR COUNT(track_keloladesa.id_device) > 0')
->selectRaw('COUNT(track_mobile.id) as count_track_mobile, COUNT(track_keloladesa.id_device) as count_track_keloladesa, desa.kode_desa, desa.nama_kecamatan, desa.nama_kabupaten, desa.nama_provinsi, desa.nama_desa')
->when($request['kode_provinsi'], function ($q) use ($request) {
$q->whereRaw('left(desa.kode_desa, 2) = '.$request['kode_provinsi']);
})
->when($request['kode_kabupaten'], function ($q) use ($request) {
$q->whereRaw('left(kode_desa, 5) = '.$request['kode_kabupaten']);
});
$query->when($request['kode_kecamatan'], function ($q) use ($request) {
})
->when($request['kode_kecamatan'], function ($q) use ($request) {
$q->whereRaw('left(kode_desa, 8) = '.$request['kode_kecamatan']);
});
$query->when(! empty($request['akses_mobile']), function ($query) use ($request) {
})
->when(! empty($request['akses_mobile']), function ($query) use ($request) {
$interval = 'interval '.TrackMobile::ACTIVE_DAYS.' day';
$sign = '>=';
switch($request['akses_mobile']) {
switch ($request['akses_mobile']) {
case '1':
$interval = 'interval '.TrackMobile::ACTIVE_DAYS.' day';
break;
Expand All @@ -101,13 +144,9 @@ public function desa(Request $request)
}

return $query->whereRaw('tgl_akses '.$sign.' now() - '.$interval);
});
})->wilayahKhusus()->with(['mobile' => function ($r) {
$r->select('kode_desa');
}]))
->addColumn('jumlah', function ($data) {
return $data->mobile->count();
})
->wilayahKhusus())

->make(true);
}

Expand Down
Loading

0 comments on commit fe93e56

Please sign in to comment.