Skip to content

Commit

Permalink
penambahan pengaturan dan halaman maintenace (#902)
Browse files Browse the repository at this point in the history
  • Loading branch information
yogiperdana authored Oct 25, 2023
1 parent 22f0997 commit 89b8ac2
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 119 deletions.
29 changes: 15 additions & 14 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,23 @@ class Kernel extends HttpKernel
* @var array
*/
protected $routeMiddleware = [
'auth' => Authenticate::class,
'auth.basic' => AuthenticateWithBasicAuth::class,
'bindings' => SubstituteBindings::class,
'cache.headers' => SetCacheHeaders::class,
'can' => Authorize::class,
'guest' => RedirectIfAuthenticated::class,
'password.confirm' => RequirePassword::class,
'signed' => ValidateSignature::class,
'throttle' => ThrottleRequests::class,
'verified' => EnsureEmailIsVerified::class,
'auth' => Authenticate::class,
'auth.basic' => AuthenticateWithBasicAuth::class,
'bindings' => SubstituteBindings::class,
'cache.headers' => SetCacheHeaders::class,
'can' => Authorize::class,
'guest' => RedirectIfAuthenticated::class,
'password.confirm' => RequirePassword::class,
'signed' => ValidateSignature::class,
'throttle' => ThrottleRequests::class,
'verified' => EnsureEmailIsVerified::class,
// 'check_role' => CheckRole::class,
'installed' => KDInstalled::class,
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
'installed' => KDInstalled::class,
'maintenance' => \App\Http\Middleware\MaintenanceMode::class,
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
'permission' => \Spatie\Permission\Middlewares\PermissionMiddleware::class,
'role_or_permission' => \Spatie\Permission\Middlewares\RoleOrPermissionMiddleware::class,
'xss_sanitization' => \App\Http\Middleware\XssSanitization::class,
'xss_sanitization' => \App\Http\Middleware\XssSanitization::class,
];

/**
Expand Down
28 changes: 28 additions & 0 deletions app/Http/Middleware/MaintenanceMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Middleware;

use App\Models\SettingAplikasi;
use Closure;

class MaintenanceMode
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$maintenance = SettingAplikasi::find(11);
if ($maintenance) {
if ($maintenance->value == 1) {
abort(503);
}
}

return $next($request);
}
}
3 changes: 2 additions & 1 deletion catatan_rilis.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ Di rilis v2310.0.0 berisi perbaikan yang diminta Komunitas OpenDK.
Terima kasih pada totoprayogo1916 yang terus berkontribusi.


#### Penyesuaian Teknis
#### Penambahan Fitur

1. [#883](https://github.com/OpenSID/OpenDK/issues/883) Penambahan informasi catatan rilis.
2. [#528](https://github.com/OpenSID/OpenDK/issues/528) Penambahan fungsi untuk jalankan migrasi lewat admin.
3. [#567](https://github.com/OpenSID/OpenDK/issues/567) Penambahan pengaturan dan halaman maintenace.


#### Perbaikan Bug
Expand Down
38 changes: 38 additions & 0 deletions database/migrations/2023_10_19_154602_maintenance_mode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

use App\Enums\Status;
use App\Models\SettingAplikasi;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class MaintenanceMode extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
SettingAplikasi::insert([
'id' => 11,
'key' => 'mode_maintenance',
'value' => Status::TidakAktif,
'type' => 'boolean',
'description' => 'Mode maintenance.',
'kategori' => 'web',
'option' => '{}',
]);
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
SettingAplikasi::where('key', 'mode_maintenance')->delete();
}
}
21 changes: 17 additions & 4 deletions resources/views/errors/503.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
@extends('errors::minimal')
<!doctype html>
<title>Sedang dalam Perbaikan</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>

@section('title', __('Service Unavailable'))
@section('code', '503')
@section('message', __($exception->getMessage() ?: 'Service Unavailable'))
<article>
<h1>Sedang dalam Perbaikan!</h1>
<div>
<p>Mohon maaf atas ketidaknyamanannya. Situs ini sedang dalam perbaikan.</p>
<p>&mdash; {{ env('APP_NAME') }}</p>
</div>
</article>
2 changes: 2 additions & 0 deletions resources/views/setting/aplikasi/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
{!! Form::textarea('value', null, ['class' => 'form-control', 'required' => true, 'id' => 'value']) !!}
@elseif ($aplikasi->type == 'number')
{!! Form::number('value', null, ['class' => 'form-control', 'required' => true, 'id' => 'value']) !!}
@elseif ($aplikasi->type == 'boolean')
{!! Form::select('value', ['1' => 'Aktif', '0' => 'Tidak Aktif'], null, ['class' => 'form-control']) !!}
@else
{!! Form::text('value', null, ['class' => 'form-control', 'required' => true, 'id' => 'value']) !!}
@endif
Expand Down
8 changes: 6 additions & 2 deletions resources/views/setting/aplikasi/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<thead>
<tr>
<th>Judul</th>
<th>Isi</th>
<th>Nilai</th>
<th>Deskripsi</th>
<th style="max-width: 100px;">Aksi</th>
</tr>
Expand All @@ -32,7 +32,11 @@
@forelse($settings as $setting)
<tr>
<td>{{ ucwords(str_replace('_', ' ', $setting->key)) }}</td>
<td>{{ $setting->value }}</td>
@if ($setting->type == 'boolean')
<td>{{ $setting->value == 1 ? 'Aktif' : 'Tidak Aktif' }}</td>
@else
<td>{{ $setting->value }}</td>
@endif
<td>{{ $setting->description }}</td>
<td>
<a href="{{ route('setting.aplikasi.edit', $setting->id) }}" title="Ubah" data-button="edit">
Expand Down
Loading

0 comments on commit 89b8ac2

Please sign in to comment.