partial update add page laporan pimpinan and fix upload big data excel pdam
This commit is contained in:
85
README.md
85
README.md
@@ -1,66 +1,37 @@
|
|||||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
# Usage icon
|
||||||
|
|
||||||
<p align="center">
|
search or pick icon in <a href="https://icon-sets.iconify.design/mingcute/?keyword=mingcute">here</a>
|
||||||
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
|
||||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
|
||||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
|
||||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
## About Laravel
|
# Set up queue for running automatically
|
||||||
|
|
||||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
- Install Supervisor
|
||||||
|
|
||||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
```
|
||||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
sudo apt update && sudo apt install supervisor -y
|
||||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
```
|
||||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
|
||||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
|
||||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
|
||||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
|
||||||
|
|
||||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
- Create Supervisor Config
|
||||||
|
|
||||||
## Learning Laravel
|
```
|
||||||
|
sudo nano /etc/supervisor/conf.d/laravel-worker.conf
|
||||||
|
|
||||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
[program:laravel-worker]
|
||||||
|
process_name=%(program_name)s_%(process_num)02d
|
||||||
|
command=php /path-to-your-project/artisan queue:work --tries=3 --timeout=600
|
||||||
|
autostart=true
|
||||||
|
autorestart=true
|
||||||
|
numprocs=1
|
||||||
|
user=www-data
|
||||||
|
redirect_stderr=true
|
||||||
|
stdout_logfile=/var/log/supervisor/laravel-worker.log
|
||||||
|
```
|
||||||
|
|
||||||
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
|
- Reload Supervisor
|
||||||
|
|
||||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
```
|
||||||
|
sudo supervisorctl reread
|
||||||
## Laravel Sponsors
|
sudo supervisorctl update
|
||||||
|
sudo supervisorctl start laravel-worker
|
||||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
|
sudo supervisorctl restart laravel-worker
|
||||||
|
sudo supervisorctl status
|
||||||
### Premium Partners
|
```
|
||||||
|
|
||||||
- **[Vehikl](https://vehikl.com/)**
|
|
||||||
- **[Tighten Co.](https://tighten.co)**
|
|
||||||
- **[WebReinvent](https://webreinvent.com/)**
|
|
||||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
|
||||||
- **[64 Robots](https://64robots.com)**
|
|
||||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
|
|
||||||
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
|
||||||
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
|
|
||||||
- **[Jump24](https://jump24.co.uk)**
|
|
||||||
- **[Redberry](https://redberry.international/laravel/)**
|
|
||||||
- **[Active Logic](https://activelogic.com)**
|
|
||||||
- **[byte5](https://byte5.de)**
|
|
||||||
- **[OP.GG](https://op.gg)**
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
|
|
||||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
|
||||||
|
|
||||||
## Code of Conduct
|
|
||||||
|
|
||||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
|
||||||
|
|
||||||
## Security Vulnerabilities
|
|
||||||
|
|
||||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Http\Resources\BigdataResumeResource;
|
||||||
use App\Models\BigdataResume;
|
use App\Models\BigdataResume;
|
||||||
use App\Models\DataSetting;
|
use App\Models\DataSetting;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -149,6 +150,22 @@ class BigDataResumeController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function bigdata_report(Request $request){
|
||||||
|
try{
|
||||||
|
$query = BigdataResume::query()->orderBy('id', 'desc');
|
||||||
|
|
||||||
|
if($request->filled('search')){
|
||||||
|
$query->where('name', 'LIKE', '%'.$request->input('search').'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $query->paginate(15);
|
||||||
|
return BigdataResumeResource::collection($query)->response()->getData(true);
|
||||||
|
}catch(\Exception $e){
|
||||||
|
Log::error($e->getMessage());
|
||||||
|
return response()->json(['message' => 'Error when fetching data'], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class CustomersController extends Controller
|
|||||||
if ($request->has('search') &&!empty($request->get('search'))) {
|
if ($request->has('search') &&!empty($request->get('search'))) {
|
||||||
$query = $query->where('nomor_pelanggan', 'LIKE', '%'.$request->get('search').'%')
|
$query = $query->where('nomor_pelanggan', 'LIKE', '%'.$request->get('search').'%')
|
||||||
->orWhere('nama', 'LIKE', '%'.$request->get('search').'%')
|
->orWhere('nama', 'LIKE', '%'.$request->get('search').'%')
|
||||||
->orWhere('kota_palayanan', 'LIKE', '%'.$request->get('search').'%');
|
->orWhere('kota_pelayanan', 'LIKE', '%'.$request->get('search').'%');
|
||||||
}
|
}
|
||||||
return CustomersResource::collection($query->paginate());
|
return CustomersResource::collection($query->paginate());
|
||||||
}
|
}
|
||||||
|
|||||||
48
app/Http/Controllers/BigdataResumesController.php
Normal file
48
app/Http/Controllers/BigdataResumesController.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class BigdataResumesController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('bigdata-resumes.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(string $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(string $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(string $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
42
app/Http/Resources/BigdataResumeResource.php
Normal file
42
app/Http/Resources/BigdataResumeResource.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Resources;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
class BigdataResumeResource extends JsonResource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Transform the resource into an array.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'import_datasource_id' => $this->import_datasource_id,
|
||||||
|
'potention_count' => (int) $this->potention_count,
|
||||||
|
'potention_sum' => number_format((float) $this->potention_sum, 2, ',', '.'),
|
||||||
|
|
||||||
|
'non_verified_count' => (int) $this->non_verified_count,
|
||||||
|
'non_verified_sum' => number_format((float) $this->non_verified_sum, 2, ',', '.'),
|
||||||
|
|
||||||
|
'verified_count' => (int) $this->verified_count,
|
||||||
|
'verified_sum' => number_format((float) $this->verified_sum, 2, ',', '.'),
|
||||||
|
|
||||||
|
'business_count' => (int) $this->business_count,
|
||||||
|
'business_sum' => number_format((float) $this->business_sum, 2, ',', '.'),
|
||||||
|
|
||||||
|
'non_business_count' => (int) $this->non_business_count,
|
||||||
|
'non_business_sum' => number_format((float) $this->non_business_sum, 2, ',', '.'),
|
||||||
|
|
||||||
|
'spatial_count' => (int) $this->spatial_count,
|
||||||
|
'spatial_sum' => number_format((float) $this->spatial_sum, 2, ',', '.'),
|
||||||
|
|
||||||
|
'year' => $this->year,
|
||||||
|
'created_at' => $this->created_at->toDateTimeString(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,42 +11,87 @@ use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
|||||||
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Maatwebsite\Excel\Concerns\WithBatchInserts;
|
use Maatwebsite\Excel\Concerns\WithBatchInserts;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class CustomersImport implements ToCollection, WithMultipleSheets
|
class CustomersImport implements ToCollection, WithMultipleSheets, WithChunkReading, WithBatchInserts, ShouldQueue, WithHeadingRow
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param Collection $collection
|
* @param Collection $collection
|
||||||
*/
|
*/
|
||||||
public function collection(Collection $collection)
|
public function collection(Collection $collection)
|
||||||
{
|
{
|
||||||
$batchData = [];
|
$batchData = [];
|
||||||
|
$batchSize = 1000; // Process in smaller chunks
|
||||||
|
|
||||||
foreach ($collection->skip(1) as $row) {
|
foreach ($collection as $row) {
|
||||||
if (!isset($row[0]) || empty($row[0])) {
|
if (!isset($row['nomor_pelanggan']) || empty($row['nomor_pelanggan'])) {
|
||||||
continue;
|
continue; // Skip rows without 'nomor_pelanggan'
|
||||||
}
|
}
|
||||||
|
|
||||||
$latitude = filter_var($row[4], FILTER_VALIDATE_FLOAT) ? bcadd($row[4], '0', 18) : null;
|
// Default values
|
||||||
$longitude = filter_var($row[5], FILTER_VALIDATE_FLOAT) ? bcadd($row[5], '0', 18) : null;
|
$latitude = '0';
|
||||||
|
$longitude = '0';
|
||||||
|
|
||||||
|
// Convert and normalize latitude
|
||||||
|
if (isset($row['latkor']) && !empty(trim($row['latkor']))) {
|
||||||
|
$latitude = str_replace(',', '.', trim($row['latkor'])); // Replace comma with dot
|
||||||
|
if (is_numeric($latitude)) {
|
||||||
|
$latitude = bcadd($latitude, '0', 18); // Convert to decimal with 18 precision
|
||||||
|
} else {
|
||||||
|
$latitude = '0'; // Default fallback
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$latitude = '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert and normalize longitude
|
||||||
|
if (isset($row['lonkor']) && !empty(trim($row['lonkor']))) {
|
||||||
|
$longitude = str_replace(',', '.', trim($row['lonkor'])); // Replace comma with dot
|
||||||
|
if (is_numeric($longitude)) {
|
||||||
|
$longitude = bcadd($longitude, '0', 18); // Convert to decimal with 18 precision
|
||||||
|
} else {
|
||||||
|
$longitude = '0'; // Default fallback
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$longitude = '0';
|
||||||
|
}
|
||||||
|
|
||||||
$batchData[] = [
|
$batchData[] = [
|
||||||
'nomor_pelanggan' => $row[0],
|
'nomor_pelanggan' => $row['nomor_pelanggan'] ?? '',
|
||||||
'kota_pelayanan' => $row[1],
|
'kota_pelayanan' => $row['kota_pelayanan'] ?? '',
|
||||||
'nama' => $row[2],
|
'nama' => $row['nama'] ?? '',
|
||||||
'alamat' => $row[3],
|
'alamat' => $row['alamat'] ?? '',
|
||||||
'latitude' => $latitude,
|
'latitude' => $latitude,
|
||||||
'longitude' => $longitude,
|
'longitude' => $longitude,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Batch insert every 1000 rows
|
||||||
|
if (count($batchData) >= $batchSize) {
|
||||||
|
Customer::upsert($batchData, ['nomor_pelanggan'], ['kota_pelayanan', 'nama', 'alamat', 'latitude', 'longitude']);
|
||||||
|
$batchData = []; // Clear the batch
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert remaining data
|
||||||
if (!empty($batchData)) {
|
if (!empty($batchData)) {
|
||||||
Customer::upsert($batchData, ['nomor_pelanggan'], ['kota_pelayanan', 'nama', 'alamat', 'latitude', 'longitude']);
|
Customer::upsert($batchData, ['nomor_pelanggan'], ['kota_pelayanan', 'nama', 'alamat', 'latitude', 'longitude']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function sheets(): array {
|
public function sheets(): array {
|
||||||
return [
|
return [
|
||||||
0 => $this
|
0 => $this
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function chunkSize(): int
|
||||||
|
{
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function batchSize(): int
|
||||||
|
{
|
||||||
|
return 1000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
],
|
],
|
||||||
"dev": [
|
"dev": [
|
||||||
"Composer\\Config::disableProcessTimeout",
|
"Composer\\Config::disableProcessTimeout",
|
||||||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:work --timeout=300 --tries=3\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
|
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ class UsersRoleMenuSeeder extends Seeder
|
|||||||
[
|
[
|
||||||
"name" => "Laporan",
|
"name" => "Laporan",
|
||||||
"url" => "/laporan",
|
"url" => "/laporan",
|
||||||
"icon" => "mingcute:task-line",
|
"icon" => "mingcute:report-line",
|
||||||
"parent_id" => null,
|
"parent_id" => null,
|
||||||
"sort_order" => 6,
|
"sort_order" => 6,
|
||||||
]
|
]
|
||||||
@@ -214,6 +214,13 @@ class UsersRoleMenuSeeder extends Seeder
|
|||||||
"parent_id" => $laporan->id,
|
"parent_id" => $laporan->id,
|
||||||
"sort_order" => 1,
|
"sort_order" => 1,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"name" => "Lap Pimpinan",
|
||||||
|
"url" => "bigdata-resumes",
|
||||||
|
"icon" => null,
|
||||||
|
"parent_id" => $laporan->id,
|
||||||
|
"sort_order" => 2,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($children_menus as $child_menu) {
|
foreach ($children_menus as $child_menu) {
|
||||||
@@ -237,6 +244,7 @@ class UsersRoleMenuSeeder extends Seeder
|
|||||||
$spatial_plannings = Menu::where('name', 'Tata Ruang')->first();
|
$spatial_plannings = Menu::where('name', 'Tata Ruang')->first();
|
||||||
$pdam = Menu::where('name', 'PDAM')->first();
|
$pdam = Menu::where('name', 'PDAM')->first();
|
||||||
$peta = Menu::where('name', 'PETA')->first();
|
$peta = Menu::where('name', 'PETA')->first();
|
||||||
|
$bigdata_resume = Menu::where('name', 'Lap Pimpinan')->first();
|
||||||
|
|
||||||
// Superadmin gets all menus
|
// Superadmin gets all menus
|
||||||
$superadmin->menus()->sync([
|
$superadmin->menus()->sync([
|
||||||
@@ -265,6 +273,7 @@ class UsersRoleMenuSeeder extends Seeder
|
|||||||
$spatial_plannings->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
|
$spatial_plannings->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
|
||||||
$pdam->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
|
$pdam->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
|
||||||
$peta->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
|
$peta->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
|
||||||
|
$bigdata_resume->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Admin gets limited menus
|
// Admin gets limited menus
|
||||||
@@ -279,6 +288,7 @@ class UsersRoleMenuSeeder extends Seeder
|
|||||||
$dashboard->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
|
$dashboard->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
|
||||||
$data->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
|
$data->id => ["allow_show" => true, "allow_create" => true, "allow_update" => true, "allow_destroy" => true],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Attach User to role super admin
|
// Attach User to role super admin
|
||||||
User::findOrFail(1)->roles()->sync([$superadmin->id]);
|
User::findOrFail(1)->roles()->sync([$superadmin->id]);
|
||||||
}
|
}
|
||||||
|
|||||||
154
resources/js/bigdata-resumes/index.js
Normal file
154
resources/js/bigdata-resumes/index.js
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
import { Grid } from "gridjs/dist/gridjs.umd.js";
|
||||||
|
import gridjs from "gridjs/dist/gridjs.umd.js";
|
||||||
|
import "gridjs/dist/gridjs.umd.js";
|
||||||
|
import GlobalConfig, { addThousandSeparators } from "../global-config.js";
|
||||||
|
import Swal from "sweetalert2";
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
|
class BigdataResume {
|
||||||
|
constructor() {
|
||||||
|
this.toastMessage = document.getElementById("toast-message");
|
||||||
|
this.toastElement = document.getElementById("toastNotification");
|
||||||
|
this.toast = new bootstrap.Toast(this.toastElement);
|
||||||
|
this.table = null;
|
||||||
|
|
||||||
|
// Initialize functions
|
||||||
|
this.initTableDataSettings();
|
||||||
|
// this.initEvents();
|
||||||
|
}
|
||||||
|
initEvents() {
|
||||||
|
document.body.addEventListener("click", async (event) => {
|
||||||
|
const deleteButton = event.target.closest(
|
||||||
|
".btn-delete-data-settings"
|
||||||
|
);
|
||||||
|
if (deleteButton) {
|
||||||
|
event.preventDefault();
|
||||||
|
await this.handleDelete(deleteButton);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
initTableDataSettings() {
|
||||||
|
let tableContainer = document.getElementById("table-bigdata-resumes");
|
||||||
|
// Create a new Grid.js instance only if it doesn't exist
|
||||||
|
this.table = new Grid({
|
||||||
|
columns: [
|
||||||
|
{ name: "ID" },
|
||||||
|
{ name: "Potention Count" },
|
||||||
|
{ name: "Potention Sum" },
|
||||||
|
{ name: "Non Verified Count" },
|
||||||
|
{ name: "Non Verified Sum" },
|
||||||
|
{ name: "Verified Count" },
|
||||||
|
{ name: "Verified Sum" },
|
||||||
|
{ name: "Business Count" },
|
||||||
|
{ name: "Business Sum" },
|
||||||
|
{ name: "Non Business Count" },
|
||||||
|
{ name: "Non Business Sum" },
|
||||||
|
{ name: "Spatial Sum" },
|
||||||
|
{ name: "Spatial Count" },
|
||||||
|
{
|
||||||
|
name: "Created",
|
||||||
|
attributes: { style: "width: 200px; white-space: nowrap;" }, // Set width dynamically
|
||||||
|
},
|
||||||
|
],
|
||||||
|
pagination: {
|
||||||
|
limit: 15,
|
||||||
|
server: {
|
||||||
|
url: (prev, page) =>
|
||||||
|
`${prev}${prev.includes("?") ? "&" : "?"}page=${
|
||||||
|
page + 1
|
||||||
|
}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
sort: true,
|
||||||
|
search: {
|
||||||
|
server: {
|
||||||
|
url: (prev, keyword) => `${prev}?search=${keyword}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
url: `${GlobalConfig.apiHost}/api/bigdata-report`,
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${document
|
||||||
|
.querySelector('meta[name="api-token"]')
|
||||||
|
.getAttribute("content")}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
then: (data) =>
|
||||||
|
data.data.map((item) => [
|
||||||
|
item.id,
|
||||||
|
item.potention_count,
|
||||||
|
addThousandSeparators(item.potention_sum),
|
||||||
|
item.non_verified_count,
|
||||||
|
addThousandSeparators(item.non_verified_sum),
|
||||||
|
item.verified_count,
|
||||||
|
addThousandSeparators(item.verified_sum),
|
||||||
|
item.business_count,
|
||||||
|
addThousandSeparators(item.business_sum),
|
||||||
|
item.non_business_count,
|
||||||
|
addThousandSeparators(item.non_business_sum),
|
||||||
|
item.spatial_count,
|
||||||
|
addThousandSeparators(item.spatial_sum),
|
||||||
|
moment(item.created_at).format("YYYY-MM-DD H:mm:ss"),
|
||||||
|
]),
|
||||||
|
total: (data) => data.total,
|
||||||
|
},
|
||||||
|
}).render(tableContainer);
|
||||||
|
}
|
||||||
|
async handleDelete(deleteButton) {
|
||||||
|
const id = deleteButton.getAttribute("data-id");
|
||||||
|
|
||||||
|
const result = await Swal.fire({
|
||||||
|
title: "Are you sure?",
|
||||||
|
text: "You won't be able to revert this!",
|
||||||
|
icon: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: "#3085d6",
|
||||||
|
cancelButtonColor: "#d33",
|
||||||
|
confirmButtonText: "Yes, delete it!",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
try {
|
||||||
|
let response = await fetch(
|
||||||
|
`${GlobalConfig.apiHost}/api/data-settings/${id}`,
|
||||||
|
{
|
||||||
|
method: "DELETE",
|
||||||
|
credentials: "include",
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${document
|
||||||
|
.querySelector('meta[name="api-token"]')
|
||||||
|
.getAttribute("content")}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
let result = await response.json();
|
||||||
|
this.toastMessage.innerText =
|
||||||
|
result.message || "Deleted successfully!";
|
||||||
|
this.toast.show();
|
||||||
|
|
||||||
|
// Refresh Grid.js table
|
||||||
|
if (typeof this.table !== "undefined") {
|
||||||
|
this.table.updateConfig({}).forceRender();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let error = await response.json();
|
||||||
|
console.error("Delete failed:", error);
|
||||||
|
this.toastMessage.innerText =
|
||||||
|
error.message || "Delete failed!";
|
||||||
|
this.toast.show();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error deleting item:", error);
|
||||||
|
this.toastMessage.innerText = "An error occurred!";
|
||||||
|
this.toast.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.addEventListener("DOMContentLoaded", function (e) {
|
||||||
|
new BigdataResume();
|
||||||
|
});
|
||||||
27
resources/views/bigdata-resumes/index.blade.php
Normal file
27
resources/views/bigdata-resumes/index.blade.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
@extends('layouts.vertical', ['subtitle' => 'Laporan Pimpinan'])
|
||||||
|
|
||||||
|
@section('css')
|
||||||
|
@vite(['node_modules/gridjs/dist/theme/mermaid.min.css'])
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
@include('layouts.partials/page-title', ['title' => 'Laporan', 'subtitle' => 'Laporan Pimpinan'])
|
||||||
|
|
||||||
|
<x-toast-notification />
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card w-100">
|
||||||
|
<div class="card-body">
|
||||||
|
<div id="table-bigdata-resumes"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
@vite(['resources/js/bigdata-resumes/index.js'])
|
||||||
|
@endsection
|
||||||
@@ -9,7 +9,6 @@
|
|||||||
@include('layouts.partials/page-title', ['title' => 'Data', 'subtitle' => 'Business Industries'])
|
@include('layouts.partials/page-title', ['title' => 'Data', 'subtitle' => 'Business Industries'])
|
||||||
|
|
||||||
<x-toast-notification />
|
<x-toast-notification />
|
||||||
<x-modal-confirmation buttonText="Delete" confirmationMessage="Are you sure you want to delete this?" />
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
|||||||
@@ -132,5 +132,8 @@ Route::group(['middleware' => 'auth:sanctum'], function (){
|
|||||||
Route::get('/dashboard-potential-count', [LackOfPotentialController::class, 'count_lack_of_potential'])->name('api.count-dashboard-potential');
|
Route::get('/dashboard-potential-count', [LackOfPotentialController::class, 'count_lack_of_potential'])->name('api.count-dashboard-potential');
|
||||||
|
|
||||||
// big data resume
|
// big data resume
|
||||||
Route::get('/bigdata-resume', [BigDataResumeController::class, 'index'])->name('api.bigdata-resume');
|
Route::controller(BigDataResumeController::class)->group(function (){
|
||||||
|
Route::get('/bigdata-resume', 'index')->name('api.bigdata-resume');
|
||||||
|
Route::get('/bigdata-report', 'bigdata_report')->name('api.bigdata-report');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Controllers\BigdataResumesController;
|
||||||
use App\Http\Controllers\BusinessOrIndustriesController;
|
use App\Http\Controllers\BusinessOrIndustriesController;
|
||||||
use App\Http\Controllers\CustomersController;
|
use App\Http\Controllers\CustomersController;
|
||||||
use App\Http\Controllers\Dashboards\LackOfPotentialController;
|
use App\Http\Controllers\Dashboards\LackOfPotentialController;
|
||||||
@@ -108,5 +109,9 @@ Route::group(['middleware' => 'auth'], function(){
|
|||||||
Route::group(['prefix' => '/report'], function(){
|
Route::group(['prefix' => '/report'], function(){
|
||||||
// Resource route, kecuali create karena dibuat terpisah
|
// Resource route, kecuali create karena dibuat terpisah
|
||||||
Route::resource('/tourisms-report', ReportTourismController::class);
|
Route::resource('/tourisms-report', ReportTourismController::class);
|
||||||
|
|
||||||
|
Route::controller(BigdataResumesController::class)->group(function (){
|
||||||
|
Route::get('/bigdata-resumes', 'index')->name('bigdata-resumes');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user