refactor dashboard
This commit is contained in:
1 parent
cd2d211259
commit
5ad31709a9
5 files changed
+42
-34
No files matched your search
+26
-15
@@ -7,13 +7,18 @@ use App\Chart;
|
||||
Route::get('/', function () {
|
||||
|
||||
$regionBase = Api::regionBase(-1);
|
||||
$regionBase[] = ['region_name' => 'Alle Regionen', 'region_id' => -1];
|
||||
$regionPropertiesCapacities = Api::regionPropertiesCapacities(-1);
|
||||
$propertiesGrowth = Api::propertiesGrowth();
|
||||
$regions = Api::regions()['regions'];
|
||||
$propertiesPerRegion = $regions;
|
||||
$regions[] = ['name' => 'Alle Regionen', 'id' => -1];
|
||||
$propertiesGeo = Api::propertiesGeo()['properties'];
|
||||
|
||||
$regions = Api::regions();
|
||||
$heatmapValues = [];
|
||||
|
||||
$propertiesGeo = Api::propertiesGeo();
|
||||
foreach ($regionPropertiesCapacities['values'] as $el) {
|
||||
$heatmapValues[] = array_values($el);
|
||||
}
|
||||
|
||||
$diagramsOptions = [
|
||||
"shared" => [
|
||||
@@ -25,15 +30,15 @@ Route::get('/', function () {
|
||||
"data" => json_encode($regionPropertiesCapacities['property_ids'])
|
||||
],
|
||||
"series" => [
|
||||
"data" => json_encode($regionPropertiesCapacities['values'])
|
||||
"data" => json_encode($heatmapValues)
|
||||
]
|
||||
],
|
||||
"propertiesPerRegion" => [
|
||||
"yAxis" => [
|
||||
"data" => json_encode(array_column($regions, 'count_properties'))
|
||||
"data" => json_encode(array_column($propertiesPerRegion, 'count_properties'))
|
||||
],
|
||||
"xAxis" => [
|
||||
"data" => json_encode(array_column($regions, 'name'))
|
||||
"data" => json_encode(array_column($propertiesPerRegion, 'name'))
|
||||
]
|
||||
],
|
||||
"extractions" => [
|
||||
@@ -52,7 +57,7 @@ Route::get('/', function () {
|
||||
|
||||
Route::get('/region/{id}', function (int $id) {
|
||||
|
||||
$regions = Api::regions();
|
||||
$regions = Api::regions()['regions'];
|
||||
$regions[] = ['name' => 'Alle Regionen', 'id' => -1];
|
||||
$region = $id >= 0 ? Api::regionBase($id) : [['name' => 'Alle Regionen']];
|
||||
$regionPropertiesCapacities = Api::regionPropertiesCapacities($id);
|
||||
@@ -62,6 +67,12 @@ Route::get('/region/{id}', function (int $id) {
|
||||
$regionCapacitiesDaily = [];
|
||||
$regionPredictions = [];
|
||||
|
||||
$heatmapValues = [];
|
||||
|
||||
foreach ($regionPropertiesCapacities['values'] as $el) {
|
||||
$heatmapValues[] = array_values($el);
|
||||
}
|
||||
|
||||
foreach ($regionCapacitiesRegion['dates'] as $date) {
|
||||
$regionCapacitiesMonthly[] = Api::regionCapacitiesMonthly($id, $date);
|
||||
$regionCapacitiesDaily[] = Api::regionCapacitiesDaily($id, $date);
|
||||
@@ -81,7 +92,7 @@ Route::get('/region/{id}', function (int $id) {
|
||||
"data" => json_encode($regionPropertiesCapacities['property_ids'])
|
||||
],
|
||||
"series" => [
|
||||
"data" => json_encode($regionPropertiesCapacities['values'])
|
||||
"data" => json_encode($heatmapValues)
|
||||
]
|
||||
],
|
||||
"predictions" => [
|
||||
@@ -123,15 +134,14 @@ Route::get('/region/{id}', function (int $id) {
|
||||
Route::get('/property/{id}', function (int $id) {
|
||||
|
||||
|
||||
$regions = Api::regions();
|
||||
$regions = Api::regions()['regions'];
|
||||
$regions[] = ['name' => 'Alle Regionen', 'id' => -1];
|
||||
|
||||
$base = Api::propertyBase($id);
|
||||
$calendars = Api::propertyExtractions($id);
|
||||
$calendars = Api::propertyExtractions($id)['extractions'];
|
||||
$propertyCapacities = Api::propertyCapacities($id);
|
||||
$propertyNeighbours = Api::propertyNeighbours($id);
|
||||
|
||||
$regionCapacitiesRegion = Api::regionCapacities($base[0]['region_id']);
|
||||
$propertyNeighbours = Api::propertyNeighbours($id)['neighbours'];
|
||||
$regionCapacitiesRegion = Api::regionCapacities($base['region_id']);
|
||||
$regionCapacitiesAll = Api::regionCapacities(-1);
|
||||
$regionCapacities = [[],[]];
|
||||
|
||||
@@ -158,13 +168,14 @@ Route::get('/property/{id}', function (int $id) {
|
||||
}
|
||||
}else{
|
||||
return view('property-nodata', [
|
||||
'base' => $base[0],
|
||||
'base' => $base,
|
||||
'regions' => $regions,
|
||||
]);
|
||||
}
|
||||
|
||||
// prepare data for calendar chart
|
||||
$calendarData = [];
|
||||
|
||||
foreach ($calendars as $el) {
|
||||
|
||||
$series = [];
|
||||
@@ -207,7 +218,7 @@ Route::get('/property/{id}', function (int $id) {
|
||||
return view('property', [
|
||||
'diagramsOptions' => $diagramsOptions,
|
||||
'startDate' => $propertyCapacities['dates'][0],
|
||||
'base' => $base[0],
|
||||
'base' => $base,
|
||||
'regions' => $regions,
|
||||
'neighbours' => $propertyNeighbours
|
||||
]);
|
||||
|
||||
Reference in new issue
Block a user