Anzeige Auslastung p. Monat bei Properties im Dashboard.

main
Giò Diani 2025-01-08 22:02:33 +01:00
parent 7884febe53
commit 258f1e4df6
3 changed files with 30 additions and 10 deletions

View File

@ -68,6 +68,16 @@ class Api
return self::get("/region/{$id}/capacities"); return self::get("/region/{$id}/capacities");
} }
public static function propertyCapacitiesMonthly(int $id, string $date): mixed
{
return self::get("/property/{$id}/capacities/monthly/{$date}");
}
public static function propertyCapacitiesDaily(int $id, string $date): mixed
{
return self::get("/property/{$id}/capacities/weekdays/{$date}");
}

View File

@ -92,7 +92,7 @@ const cCapacityMonthlyOptions = {
grid: { grid: {
top: 0, top: 0,
bottom: 25, bottom: 25,
left: 50, left: 70,
right: 10 right: 10
}, },
xAxis: { xAxis: {
@ -102,15 +102,19 @@ const cCapacityMonthlyOptions = {
yAxis: { yAxis: {
type: 'category', type: 'category',
}, },
options: [{ options: [
@foreach ($capacitiesMonthly as $cM)
{
yAxis: { yAxis: {
data: ['Apr 24', 'May 24', 'Jun 24', 'Aug 24', 'Sep 24', 'Oct 24', 'Nov 24', 'Dec 24', 'Jan 25', 'Feb 25', 'Mar 25', 'Apr 25', 'May 25', 'Jun 25', 'Jul 25', 'Aug 25', 'Sep 25', 'Oct 25'] data: {!! json_encode($cM['months']) !!}
}, },
series: [{ series: [{
type: 'bar', type: 'bar',
data: [100, 80, 20, 20, 3, 23, 34, 23, 45, 12, 34,23,45,12,34,45,12,34] data: {!! json_encode($cM['capacities']) !!}
}] }]
}] },
@endforeach
]
}; };
cCapacityMonthly.setOption(cCapacityMonthlyOptions); cCapacityMonthly.setOption(cCapacityMonthlyOptions);

View File

@ -11,8 +11,6 @@ Route::get('/', function () {
$propsPerRegionName = []; $propsPerRegionName = [];
$propsPerRegionCounts = []; $propsPerRegionCounts = [];
// dump($regionHeat);
foreach ($propsPerRegion as $el) { foreach ($propsPerRegion as $el) {
$propsPerRegionName[] = $el['name']; $propsPerRegionName[] = $el['name'];
$propsPerRegionCounts[] = $el['count_properties']; $propsPerRegionCounts[] = $el['count_properties'];
@ -28,6 +26,16 @@ Route::get('/prop/{id}', function (int $id) {
$propertyBase = Api::propertyBase($id); $propertyBase = Api::propertyBase($id);
$extractions = Api::propertyExtractions($id); $extractions = Api::propertyExtractions($id);
$propertyCapacities = Api::propertyCapacities($id); $propertyCapacities = Api::propertyCapacities($id);
$propertyCapacitiesMonthly = [];
$propertyCapacitiesDaily = [];
foreach ($extractions as $extraction) {
$propertyCapacitiesMonthly[] = Api::propertyCapacitiesMonthly($id, $extraction['created_at']);
}
//dump($propertyCapacitiesMonthly);
$data = []; $data = [];
$dates = []; $dates = [];
@ -38,8 +46,6 @@ Route::get('/prop/{id}', function (int $id) {
$extCalendar = json_decode($ext['calendar'], 1); $extCalendar = json_decode($ext['calendar'], 1);
foreach ($extCalendar as $date => $status) { foreach ($extCalendar as $date => $status) {
$series[] = [$date, $status]; $series[] = [$date, $status];
} }
@ -48,5 +54,5 @@ Route::get('/prop/{id}', function (int $id) {
} }
return view('property', ['base' => $propertyBase[0], "extractiondates" => json_encode($dates), "calendar" => $data, 'capacities' => $propertyCapacities]); return view('property', ['base' => $propertyBase[0], "extractiondates" => json_encode($dates), "calendar" => $data, 'capacities' => $propertyCapacities, 'capacitiesMonthly' => $propertyCapacitiesMonthly]);
}); });