diff --git a/dashboard/app/Api.php b/dashboard/app/Api.php index ec1b2f4..aa704c3 100644 --- a/dashboard/app/Api.php +++ b/dashboard/app/Api.php @@ -68,6 +68,16 @@ class Api 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}"); + } + diff --git a/dashboard/resources/views/property.blade.php b/dashboard/resources/views/property.blade.php index 4769076..2cf97b7 100644 --- a/dashboard/resources/views/property.blade.php +++ b/dashboard/resources/views/property.blade.php @@ -92,7 +92,7 @@ const cCapacityMonthlyOptions = { grid: { top: 0, bottom: 25, - left: 50, + left: 70, right: 10 }, xAxis: { @@ -102,15 +102,19 @@ const cCapacityMonthlyOptions = { yAxis: { type: 'category', }, - options: [{ + options: [ + @foreach ($capacitiesMonthly as $cM) + { 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: [{ 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); diff --git a/dashboard/routes/web.php b/dashboard/routes/web.php index 89920f7..5dd0f01 100644 --- a/dashboard/routes/web.php +++ b/dashboard/routes/web.php @@ -11,8 +11,6 @@ Route::get('/', function () { $propsPerRegionName = []; $propsPerRegionCounts = []; - // dump($regionHeat); - foreach ($propsPerRegion as $el) { $propsPerRegionName[] = $el['name']; $propsPerRegionCounts[] = $el['count_properties']; @@ -28,6 +26,16 @@ Route::get('/prop/{id}', function (int $id) { $propertyBase = Api::propertyBase($id); $extractions = Api::propertyExtractions($id); $propertyCapacities = Api::propertyCapacities($id); + $propertyCapacitiesMonthly = []; + $propertyCapacitiesDaily = []; + + foreach ($extractions as $extraction) { + $propertyCapacitiesMonthly[] = Api::propertyCapacitiesMonthly($id, $extraction['created_at']); + } + + //dump($propertyCapacitiesMonthly); + + $data = []; $dates = []; @@ -38,8 +46,6 @@ Route::get('/prop/{id}', function (int $id) { $extCalendar = json_decode($ext['calendar'], 1); - - foreach ($extCalendar as $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]); });