refactor dashboard
parent
cd2d211259
commit
5ad31709a9
|
@ -109,7 +109,7 @@ class Api
|
||||||
|
|
||||||
public static function regionMovingAverage(int $id, string $date): mixed
|
public static function regionMovingAverage(int $id, string $date): mixed
|
||||||
{
|
{
|
||||||
return self::get("/region/{$id}/movingAverage/{$date}");
|
return self::get("/region/{$id}/moving-average/{$date}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,12 +350,6 @@ cHeatmap.on('click', 'series', (e) => {
|
||||||
window.open(`/property/${e.value[1]}?date=${e.value[0]}`, '_self');
|
window.open(`/property/${e.value[1]}?date=${e.value[0]}`, '_self');
|
||||||
})
|
})
|
||||||
|
|
||||||
cPropsPerRegion.on('click', 'series', (e) => {
|
|
||||||
console.log(e.dataIndex);
|
|
||||||
//window.open(`/property/${e.value[1]}?date=${e.value[0]}`, '_self');
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
@section('body-class', 'region')
|
@section('body-class', 'region')
|
||||||
@section('header')
|
@section('header')
|
||||||
<nav>
|
<nav>
|
||||||
<strong>{{ $region[0]['name'] }}</strong>
|
<strong>{{ $region['name'] }}</strong>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="/">Start</a></li>
|
<li><a href="/">Start</a></li>
|
||||||
@foreach($regions as $r)
|
@foreach($regions as $r)
|
||||||
|
@ -317,19 +317,19 @@ const cPredictionOptions = {
|
||||||
name: 'Gleitender Mittelwert',
|
name: 'Gleitender Mittelwert',
|
||||||
type: 'line',
|
type: 'line',
|
||||||
symbolSize: 7,
|
symbolSize: 7,
|
||||||
data: {!! json_encode($p['movAvg']) !!}
|
data: {!! json_encode($p['capacities_moving_average']) !!}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Ausgangsdaten',
|
name: 'Ausgangsdaten',
|
||||||
type: 'line',
|
type: 'line',
|
||||||
symbolSize: 7,
|
symbolSize: 7,
|
||||||
data: {!! json_encode($p['cap_earlierTimeframe']) !!}
|
data: {!! json_encode($p['capacities_timeframe_before']) !!}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Vergleichsdaten',
|
name: 'Vergleichsdaten',
|
||||||
type: 'line',
|
type: 'line',
|
||||||
symbolSize: 7,
|
symbolSize: 7,
|
||||||
data: {!! json_encode($p['cap_laterTimeframe']) !!}
|
data: {!! json_encode($p['capacities_timeframe_after']) !!}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -433,7 +433,7 @@ const cHeatmapOptions = {
|
||||||
name: 'Verfügbarkeit',
|
name: 'Verfügbarkeit',
|
||||||
type: 'heatmap',
|
type: 'heatmap',
|
||||||
blurSize: 0,
|
blurSize: 0,
|
||||||
data: {!! json_encode($regionPropertiesCapacities['values']) !!},
|
data: {!! $diagramsOptions['heatmap']['series']['data'] !!},
|
||||||
label: {
|
label: {
|
||||||
show: false
|
show: false
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,13 +7,18 @@ use App\Chart;
|
||||||
Route::get('/', function () {
|
Route::get('/', function () {
|
||||||
|
|
||||||
$regionBase = Api::regionBase(-1);
|
$regionBase = Api::regionBase(-1);
|
||||||
$regionBase[] = ['region_name' => 'Alle Regionen', 'region_id' => -1];
|
|
||||||
$regionPropertiesCapacities = Api::regionPropertiesCapacities(-1);
|
$regionPropertiesCapacities = Api::regionPropertiesCapacities(-1);
|
||||||
$propertiesGrowth = Api::propertiesGrowth();
|
$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 = [
|
$diagramsOptions = [
|
||||||
"shared" => [
|
"shared" => [
|
||||||
|
@ -25,15 +30,15 @@ Route::get('/', function () {
|
||||||
"data" => json_encode($regionPropertiesCapacities['property_ids'])
|
"data" => json_encode($regionPropertiesCapacities['property_ids'])
|
||||||
],
|
],
|
||||||
"series" => [
|
"series" => [
|
||||||
"data" => json_encode($regionPropertiesCapacities['values'])
|
"data" => json_encode($heatmapValues)
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"propertiesPerRegion" => [
|
"propertiesPerRegion" => [
|
||||||
"yAxis" => [
|
"yAxis" => [
|
||||||
"data" => json_encode(array_column($regions, 'count_properties'))
|
"data" => json_encode(array_column($propertiesPerRegion, 'count_properties'))
|
||||||
],
|
],
|
||||||
"xAxis" => [
|
"xAxis" => [
|
||||||
"data" => json_encode(array_column($regions, 'name'))
|
"data" => json_encode(array_column($propertiesPerRegion, 'name'))
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"extractions" => [
|
"extractions" => [
|
||||||
|
@ -52,7 +57,7 @@ Route::get('/', function () {
|
||||||
|
|
||||||
Route::get('/region/{id}', function (int $id) {
|
Route::get('/region/{id}', function (int $id) {
|
||||||
|
|
||||||
$regions = Api::regions();
|
$regions = Api::regions()['regions'];
|
||||||
$regions[] = ['name' => 'Alle Regionen', 'id' => -1];
|
$regions[] = ['name' => 'Alle Regionen', 'id' => -1];
|
||||||
$region = $id >= 0 ? Api::regionBase($id) : [['name' => 'Alle Regionen']];
|
$region = $id >= 0 ? Api::regionBase($id) : [['name' => 'Alle Regionen']];
|
||||||
$regionPropertiesCapacities = Api::regionPropertiesCapacities($id);
|
$regionPropertiesCapacities = Api::regionPropertiesCapacities($id);
|
||||||
|
@ -62,6 +67,12 @@ Route::get('/region/{id}', function (int $id) {
|
||||||
$regionCapacitiesDaily = [];
|
$regionCapacitiesDaily = [];
|
||||||
$regionPredictions = [];
|
$regionPredictions = [];
|
||||||
|
|
||||||
|
$heatmapValues = [];
|
||||||
|
|
||||||
|
foreach ($regionPropertiesCapacities['values'] as $el) {
|
||||||
|
$heatmapValues[] = array_values($el);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($regionCapacitiesRegion['dates'] as $date) {
|
foreach ($regionCapacitiesRegion['dates'] as $date) {
|
||||||
$regionCapacitiesMonthly[] = Api::regionCapacitiesMonthly($id, $date);
|
$regionCapacitiesMonthly[] = Api::regionCapacitiesMonthly($id, $date);
|
||||||
$regionCapacitiesDaily[] = Api::regionCapacitiesDaily($id, $date);
|
$regionCapacitiesDaily[] = Api::regionCapacitiesDaily($id, $date);
|
||||||
|
@ -81,7 +92,7 @@ Route::get('/region/{id}', function (int $id) {
|
||||||
"data" => json_encode($regionPropertiesCapacities['property_ids'])
|
"data" => json_encode($regionPropertiesCapacities['property_ids'])
|
||||||
],
|
],
|
||||||
"series" => [
|
"series" => [
|
||||||
"data" => json_encode($regionPropertiesCapacities['values'])
|
"data" => json_encode($heatmapValues)
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"predictions" => [
|
"predictions" => [
|
||||||
|
@ -123,15 +134,14 @@ Route::get('/region/{id}', function (int $id) {
|
||||||
Route::get('/property/{id}', function (int $id) {
|
Route::get('/property/{id}', function (int $id) {
|
||||||
|
|
||||||
|
|
||||||
$regions = Api::regions();
|
$regions = Api::regions()['regions'];
|
||||||
$regions[] = ['name' => 'Alle Regionen', 'id' => -1];
|
$regions[] = ['name' => 'Alle Regionen', 'id' => -1];
|
||||||
|
|
||||||
$base = Api::propertyBase($id);
|
$base = Api::propertyBase($id);
|
||||||
$calendars = Api::propertyExtractions($id);
|
$calendars = Api::propertyExtractions($id)['extractions'];
|
||||||
$propertyCapacities = Api::propertyCapacities($id);
|
$propertyCapacities = Api::propertyCapacities($id);
|
||||||
$propertyNeighbours = Api::propertyNeighbours($id);
|
$propertyNeighbours = Api::propertyNeighbours($id)['neighbours'];
|
||||||
|
$regionCapacitiesRegion = Api::regionCapacities($base['region_id']);
|
||||||
$regionCapacitiesRegion = Api::regionCapacities($base[0]['region_id']);
|
|
||||||
$regionCapacitiesAll = Api::regionCapacities(-1);
|
$regionCapacitiesAll = Api::regionCapacities(-1);
|
||||||
$regionCapacities = [[],[]];
|
$regionCapacities = [[],[]];
|
||||||
|
|
||||||
|
@ -158,13 +168,14 @@ Route::get('/property/{id}', function (int $id) {
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
return view('property-nodata', [
|
return view('property-nodata', [
|
||||||
'base' => $base[0],
|
'base' => $base,
|
||||||
'regions' => $regions,
|
'regions' => $regions,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare data for calendar chart
|
// prepare data for calendar chart
|
||||||
$calendarData = [];
|
$calendarData = [];
|
||||||
|
|
||||||
foreach ($calendars as $el) {
|
foreach ($calendars as $el) {
|
||||||
|
|
||||||
$series = [];
|
$series = [];
|
||||||
|
@ -207,7 +218,7 @@ Route::get('/property/{id}', function (int $id) {
|
||||||
return view('property', [
|
return view('property', [
|
||||||
'diagramsOptions' => $diagramsOptions,
|
'diagramsOptions' => $diagramsOptions,
|
||||||
'startDate' => $propertyCapacities['dates'][0],
|
'startDate' => $propertyCapacities['dates'][0],
|
||||||
'base' => $base[0],
|
'base' => $base,
|
||||||
'regions' => $regions,
|
'regions' => $regions,
|
||||||
'neighbours' => $propertyNeighbours
|
'neighbours' => $propertyNeighbours
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -18,11 +18,14 @@ from fastapi.responses import JSONResponse
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
class Regions(BaseModel):
|
class RegionsItems(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
id: str
|
id: str
|
||||||
count_properties: int
|
count_properties: int
|
||||||
|
|
||||||
|
class Regions(BaseModel):
|
||||||
|
regions: List[RegionsItems]
|
||||||
|
|
||||||
class RegionBase(BaseModel):
|
class RegionBase(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
id: str
|
id: str
|
||||||
|
@ -144,7 +147,7 @@ def regions():
|
||||||
"""
|
"""
|
||||||
Returns a list of all available regions.
|
Returns a list of all available regions.
|
||||||
"""
|
"""
|
||||||
return d.properties_per_region().pl().to_dicts()
|
return {"regions" : d.properties_per_region().pl().to_dicts()}
|
||||||
|
|
||||||
@app.get("/region/{id}/base", response_model=RegionBase, tags=['region'])
|
@app.get("/region/{id}/base", response_model=RegionBase, tags=['region'])
|
||||||
def region_base(id: int):
|
def region_base(id: int):
|
||||||
|
@ -217,11 +220,11 @@ def property_base_data(id: int):
|
||||||
base = d.property_base_data(id).pl().to_dicts()
|
base = d.property_base_data(id).pl().to_dicts()
|
||||||
return {
|
return {
|
||||||
"property_platform_id": base[0]['property_platform_id'],
|
"property_platform_id": base[0]['property_platform_id'],
|
||||||
"first_found": base[0]['property_platform_id'],
|
"first_found": str(base[0]['first_found']),
|
||||||
"last_found": base[0]['property_platform_id'],
|
"last_found": str(base[0]['last_found']),
|
||||||
"latlng": base[0]['property_platform_id'],
|
"latlng": base[0]['latlng'],
|
||||||
"region_id": base[0]['property_platform_id'],
|
"region_id": base[0]['region_id'],
|
||||||
"region_name": base[0]['property_platform_id']}
|
"region_name": base[0]['region_name']}
|
||||||
|
|
||||||
@app.get("/property/{id}/neighbours", response_model=PropertyNeighbours, tags=['property'])
|
@app.get("/property/{id}/neighbours", response_model=PropertyNeighbours, tags=['property'])
|
||||||
def property_neighbours(id: int):
|
def property_neighbours(id: int):
|
||||||
|
|
Loading…
Reference in New Issue