Skip to content

Commit

Permalink
Merge pull request #269 from OpenSID/rilis-v2309.0.0
Browse files Browse the repository at this point in the history
Rilis v2309.0.0
  • Loading branch information
vickyrolanda authored Sep 1, 2023
2 parents c9ac7ca + 438a5f1 commit 50c32ea
Show file tree
Hide file tree
Showing 91 changed files with 1,638 additions and 167 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/public/build
/public/hot
/public/storage
/public/favicons
/public/favicon.png
/public/favicon.ico
/storage/*.key
Expand Down
8 changes: 7 additions & 1 deletion app/Enums/Modul.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,16 @@ final class Modul extends Enum
],
[
'icon' => 'fas fa-angle-right',
'text' => 'Group',
'text' => 'Grup',
'url' => 'pengaturan/groups',
'role' => 'pengaturan-group',
],
[
'icon' => 'fas fa-angle-right',
'text' => 'Riwayat Pengguna',
'url' => 'pengaturan/activities',
'role' => 'pengaturan-users',
],
],
],
];
Expand Down
22 changes: 21 additions & 1 deletion app/Helpers/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
use App\Models\Config;
use App\Models\SettingAplikasi;
use Illuminate\Support\Str;
use Intervention\Image\Facades\Image;

if (! function_exists('openkab_versi')) {
/**
* OpenKab database gabungan versi.
*/
function openkab_versi()
{
return 'v2308.0.0';
return 'v2309.0.0';
}
}

Expand Down Expand Up @@ -186,3 +187,22 @@ function ambilBerkas($pathBerkas, $tampil = true)

response()->download(storage_path($pathBerkas));
}

if (! function_exists('default_favicon')) {
/**
* OpenKab database gabungan versi.
*/
function default_favicon($favicon)
{
$path = public_path('favicons');
if (! file_exists($path)) {
mkdir($path, 0755, true);
$pathFavicon = public_path('favicons/'.$favicon);
if (! file_exists($pathFavicon)) {
$filePath = public_path('assets/img/opensid_logo.png');
Image::make($filePath)->resize(96, 96)->save($pathFavicon, '100', 'png');
}

}
}
}
8 changes: 5 additions & 3 deletions app/Http/Controllers/Api/BantuanKabupatenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function store(BantuanRequest $request)
$data['edate'] = Carbon::parse($data['edate']);
$data['status'] = $data['sdate'] < now() && $data['edate'] < now() ? 0 : 1;
$data['userid'] = 0;
Bantuan::insert($data);
Bantuan::create($data);

return response()->json([
'success' => true,
Expand Down Expand Up @@ -75,7 +75,8 @@ public function update(BantuanRequest $request, $id)
$data['edate'] = Carbon::parse($data['edate']);
$data['status'] = $data['sdate'] < now() && $data['edate'] < now() ? 0 : 1;
$data['userid'] = 0;
Bantuan::where('id', (int) $id)->whereNull('config_id')->update($data);
$bantuan = Bantuan::find((int) $id);
$bantuan->update($data);

return response()->json([
'success' => true,
Expand All @@ -99,7 +100,8 @@ public function destroy(Request $request)
{
$id = (int) $request->id;
try {
Bantuan::where('id', $id)->whereNull('config_id')->delete();
$bantuan = Bantuan::find($id);
$bantuan->delete();

return response()->json([
'success' => true,
Expand Down
105 changes: 100 additions & 5 deletions app/Http/Controllers/Api/IdentitasController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Http\Requests\UploadImageRequest;
use App\Http\Transformers\IdentitasTransformer;
use App\Models\Identitas;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image;
use Symfony\Component\HttpFoundation\Response;

Expand Down Expand Up @@ -37,7 +38,8 @@ public function update(IdentitasRequest $request, $id)
{
try {
$data = $request->all();
Identitas::where('id', $id)->update($data);
$identitas = Identitas::find($id);
$identitas->update($data);

return response()->json([
'success' => true,
Expand All @@ -56,23 +58,19 @@ public function upload(UploadImageRequest $request, $id)
{
try {
$path = storage_path('app/public/img');

if (! file_exists($path)) {
mkdir($path, 755, true);
}
$filename = uniqid('img_');
$file = $request->file('file');

Image::make($file->path())->resize(16, 16)->save(public_path().'/favicon.png');
copy(public_path().'/favicon.png', public_path().'/favicon.ico'); //create favicon
Image::make($file->path())->resize(150, 150,
function ($constraint) {
$constraint->aspectRatio();
})->save($path.'/'.$filename.'.png'); //create logo

Identitas::where('id', $id)->update([
'logo' => $filename.'.png',
'favicon' => $filename,
]);

return response()->json([
Expand All @@ -88,4 +86,101 @@ function ($constraint) {
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}

public function uploadFavicon(UploadImageRequest $request, $id)
{
try {
$path = public_path('favicons');
if (! file_exists($path)) {
mkdir($path, 755, true);
}
$file = $request->file('file');

$this->generateFaviconsFromImagePath($file->path(), $path);
Identitas::where('id', $id)->update([
'favicon' => 'favicon-96x96.png',
]);

return response()->json([
'success' => true,
'data' => asset('favicons/favicon-96x96.png'),
], Response::HTTP_OK);
} catch (\Exception $e) {
report($e);

return response()->json([
'success' => false,
'message' => $e->getMessage(),
], Response::HTTP_INTERNAL_SERVER_ERROR);
}
}

private function generateFaviconsFromImagePath($filePath, $distPath) {
// create an image manager instance with imagick driver
// Image::configure(['driver' => 'imagick']);

Image::make($filePath)->resize(192, 192)->save($distPath . "/android-chrome-192x192.png", '100', 'png');
Image::make($filePath)->resize(512, 512)->save($distPath . "/android-chrome-512x512.png", '100', 'png');
Image::make($filePath)->resize(180, 180)->save($distPath . "/apple-touch-icon.png", '100', 'png');
Image::make($filePath)->resize(16, 16)->save($distPath . "/favicon-16x16.png", '100', 'png');
Image::make($filePath)->resize(32, 32)->save($distPath . "/favicon-32x32.png", '100', 'png');
Image::make($filePath)->resize(96, 96)->save($distPath . "/favicon-96x96.png", '100', 'png');
Image::make($filePath)->resize(150, 150)->save($distPath . "/mstile-150x150.png", '100', 'png');
copy($distPath . "/favicon-16x16.png", $distPath . "/favicon.ico");

$dataManifest = [
"name" => "Favicon",
"icons" => [
[
"src" => "/android-chrome-192x192.png",
"sizes" => "192x192",
"type" => "image/png",
"density" => 0.75
],
[
"src" => "/android-chrome-512x512.png",
"sizes" => "512x512",
"type" => "image/png",
"density" => .75
],
[
"src" => "/apple-touch-icon.png",
"sizes" => "180x180",
"type" => "image/png",
"density" => 0.75
],
[
"src" => "/favicon-16x16.png",
"sizes" => "16x16",
"type" => "image/png",
"density" => 1
],
[
"src" => "/favicon-32x32.png",
"sizes" => "32x32",
"type" => "image/png",
"density" => 1
],
[
"src" => "/favicon-96x96.png",
"sizes" => "96x96",
"type" => "image/png",
"density" => 1
],
[
"src" => "/mstile-150x150.png",
"sizes" => "150x150",
"type" => "image/png",
"density" => 1
]
]
];
file_put_contents($distPath.'/manifest.json', json_encode($dataManifest));
// favicon.ico
// $icon = new \Imagick();
// $icon->addImage(new \Imagick($distPath . "/favicon-16x16.png"));
// $icon->addImage(new \Imagick($distPath . "/favicon-32x32.png"));
// $icon->setResolution(16,16);
// $icon->writeImages($distPath . "/favicon.ico", true);
}
}
11 changes: 7 additions & 4 deletions app/Http/Controllers/Api/KategoriController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function store(KategoriRequest $request)
'slug' => url_title($data['kategori']),
'urut' => 0,
];
Kategori::insert($insert);
Kategori::create($insert);

return response()->json([
'success' => true,
Expand Down Expand Up @@ -87,7 +87,8 @@ public function update(KategoriRequest $request, $id)
try {
$data = $request->validated();
$data['slug'] = url_title($data['kategori']);
Kategori::where('id', $id)->whereNull('config_id')->update($data);
$kategori = Kategori::find($id);
$kategori->update($data);

return response()->json([
'success' => true,
Expand All @@ -111,8 +112,10 @@ public function destroy(Request $request)
{
$id = (int) $request->id;
try {
Kategori::where('id', $id)->orWhere('parrent', $id)->delete();

$kategori = Kategori::where('id', $id)->orWhere('parrent', $id)->get();
foreach($kategori as $k){
$k->delete();
}
return response()->json([
'success' => true,
], Response::HTTP_OK);
Expand Down
8 changes: 6 additions & 2 deletions app/Http/Controllers/Api/PengaturanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ public function update(PengaturanRequest $request)
try {
foreach ($request->validated() as $key => $value) {
Pengaturan::where('key', $key)->update(['value' => $value]);
activity('data-log')->event('updated')->withProperties($request)->log('Pengaturan Aplikasi');
if ($key == 'lock_theme') {
// udpate class tema
$attributeValue = null;
if (! $value) {
Pengaturan::where('key', 'web_theme')->update(['attribute' => 'class="disabled" disabled']);
$attributeValue = 'class="disabled" disabled';
Pengaturan::where('key', 'web_theme')->update(['attribute' => $attributeValue]);
} else {
Pengaturan::where('key', 'web_theme')->update(['attribute' => null]);
Pengaturan::where('key', 'web_theme')->update(['attribute' => $attributeValue]);
}
activity('data-log')->event('updated')->withProperties(['key' => 'web_theme', 'attribute' => $attributeValue])->log('Pengaturan Aplikasi');
}
}

Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Api/TeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function store(Request $request)
}
}
}

activity('data-log')->event('created')->withProperties($request)->log('Pengaturan Group');
return response()->json([
'success' => true,
], Response::HTTP_OK);
Expand Down Expand Up @@ -139,7 +139,7 @@ public function update(Request $request, $id)
}
}
}

activity('data-log')->event('updated')->withProperties($request)->log('Pengaturan Group');
return response()->json([
'success' => true,
], Response::HTTP_OK);
Expand Down Expand Up @@ -169,7 +169,7 @@ public function delete(Request $request)
}

Team::Where('id', $id)->delete();

activity('data-log')->event('deleted')->withProperties($request)->log('Pengaturan Group');
return response()->json([
'success' => true,
], Response::HTTP_OK);
Expand Down
74 changes: 74 additions & 0 deletions app/Http/Controllers/Auth/ChangePasswordController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Models\User as ModelsUser;
use App\Rules\MatchOldPassword;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rules\Password;

class ChangePasswordController extends ResetPasswordController
{
public function showResetForm(Request $request, $token = null)
{
return view('auth.passwords.change');
}

/**
* Get the password reset validation rules.
*
* @return array
*/
protected function rules()
{
return [
'password_old' => ['required', new MatchOldPassword],
'password' => ['required', 'confirmed', Password::min(8)->letters()->symbols()->numbers()->mixedCase()]
];
}

/**
* Reset the given user's password.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
*/
public function reset(Request $request)
{
$request->validate($this->rules(), $this->validationErrorMessages());
$password = $request->get('password');
$user = Auth::user();
$this->changePassword($user, $password);

// If the password was successfully reset, we will redirect the user back to
// the application's home authenticated view. If there is an error we can
// redirect them back to where they came from with their error message.

// return $this->sendResetResponse($request, 'password changed succesfull');
Auth::logout();
return redirect(route('login'))->with('success', 'Password berhasil diubah, silakan login kembali');
}

public function resetByAdmin(ModelsUser $user ,Request $request)
{
$user->password = $user->email;
$user->save();

return $this->sendResetResponse($request, 'password user reset succesfull with new password '. $password);
}

/**
* Reset the given user's password.
*
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
* @param string $password
* @return void
*/
protected function changePassword($user, $password)
{
$user->password = $password;
$user->save();
}

}
Loading

0 comments on commit 50c32ea

Please sign in to comment.