diff --git a/app/Http/Controllers/Api/LackOfPotentialController.php b/app/Http/Controllers/Api/LackOfPotentialController.php new file mode 100644 index 0000000..d681057 --- /dev/null +++ b/app/Http/Controllers/Api/LackOfPotentialController.php @@ -0,0 +1,31 @@ +json([ + 'total_reklame' => $total_reklame, + 'total_pdam' => $total_pdam, + 'total_tata_ruang' => $total_tata_ruang + ], 200); + }catch(\Exception $e){ + return response()->json([ + 'message' => 'Error: '.$e->getMessage() + ], 500); + } + } +} diff --git a/resources/js/dashboards/lack-of-potential.js b/resources/js/dashboards/lack-of-potential.js index 7a9af57..51c0751 100644 --- a/resources/js/dashboards/lack-of-potential.js +++ b/resources/js/dashboards/lack-of-potential.js @@ -6,11 +6,16 @@ class LackOfPotential { this.bigTotalLackPotential = 0; this.totalPotensi = await this.getDataTotalPotensi(2025); this.totalTargetPAD = await this.getDataSettings("TARGET_PAD"); + this.allCountData = await this.getValueDashboard(); + this.reklameCount = this.allCountData.total_reklame ?? 0; + this.pdamCount = this.allCountData.total_pdam ?? 0; + this.tataRuangCount = this.allCountData.total_tata_ruang ?? 0; this.bigTargetPAD = new Big(this.totalTargetPAD ?? 0); this.bigTotalPotensi = new Big(this.totalPotensi.totalData ?? 0); this.bigTotalLackPotential = this.bigTargetPAD - this.bigTotalPotensi; this.initChartKekuranganPotensi(); + this.initDataValueDashboard(); } async getDataTotalPotensi(year) { try { @@ -69,6 +74,33 @@ class LackOfPotential { return 0; } } + async getValueDashboard() { + try { + const response = await fetch( + `${GlobalConfig.apiHost}/api/dashboard-potential-count`, + { + credentials: "include", + headers: { + Authorization: `Bearer ${ + document.querySelector("meta[name='api-token']") + .content + }`, + "Content-Type": "application/json", + }, + } + ); + + if (!response.ok) { + console.error("Network response was not ok", response); + } + + const data = await response.json(); + return data; + } catch (error) { + console.error("Error fetching chart data:", error); + return 0; + } + } initChartKekuranganPotensi() { document .querySelectorAll(".document-count.chart-lack-of-potential") @@ -88,6 +120,12 @@ class LackOfPotential { element.innerText = ``; }); } + initDataValueDashboard() { + document.getElementById("reklame-count").innerText = this.reklameCount; + document.getElementById("pdam-count").innerText = this.pdamCount; + document.getElementById("pbb-bangunan-count").innerText = + this.tataRuangCount; + } } document.addEventListener("DOMContentLoaded", async function (e) { await new LackOfPotential().init(); diff --git a/resources/views/components/custom-circle.blade.php b/resources/views/components/custom-circle.blade.php index e735c37..70d35ab 100644 --- a/resources/views/components/custom-circle.blade.php +++ b/resources/views/components/custom-circle.blade.php @@ -1,5 +1,5 @@ -@props(['title' => 'title component', 'visible_data' => false, 'data' => 'data text', 'visible_data_type' => false, -'data_type' => '','style' => '', 'size' => '', 'line' => []]) +@props(['title' => 'title component', 'visible_data' => false, 'data_count' => '', 'visible_data_type' => false, +'data_type' => '','style' => '', 'size' => '', 'line' => [], 'data_id' => '']) @section('css') @vite(['resources/scss/components/_custom_circle.scss']) @@ -9,7 +9,7 @@
{{ $title }}
@if ($visible_data === "true") -