refactor dashboard
parent
cd2d211259
commit
5ad31709a9
|
@ -109,7 +109,7 @@ class Api
|
|||
|
||||
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');
|
||||
})
|
||||
|
||||
cPropsPerRegion.on('click', 'series', (e) => {
|
||||
console.log(e.dataIndex);
|
||||
//window.open(`/property/${e.value[1]}?date=${e.value[0]}`, '_self');
|
||||
})
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
@endsection
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
@section('body-class', 'region')
|
||||
@section('header')
|
||||
<nav>
|
||||
<strong>{{ $region[0]['name'] }}</strong>
|
||||
<strong>{{ $region['name'] }}</strong>
|
||||
<ul>
|
||||
<li><a href="/">Start</a></li>
|
||||
@foreach($regions as $r)
|
||||
|
@ -317,19 +317,19 @@ const cPredictionOptions = {
|
|||
name: 'Gleitender Mittelwert',
|
||||
type: 'line',
|
||||
symbolSize: 7,
|
||||
data: {!! json_encode($p['movAvg']) !!}
|
||||
data: {!! json_encode($p['capacities_moving_average']) !!}
|
||||
},
|
||||
{
|
||||
name: 'Ausgangsdaten',
|
||||
type: 'line',
|
||||
symbolSize: 7,
|
||||
data: {!! json_encode($p['cap_earlierTimeframe']) !!}
|
||||
data: {!! json_encode($p['capacities_timeframe_before']) !!}
|
||||
},
|
||||
{
|
||||
name: 'Vergleichsdaten',
|
||||
type: 'line',
|
||||
symbolSize: 7,
|
||||
data: {!! json_encode($p['cap_laterTimeframe']) !!}
|
||||
data: {!! json_encode($p['capacities_timeframe_after']) !!}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -433,7 +433,7 @@ const cHeatmapOptions = {
|
|||
name: 'Verfügbarkeit',
|
||||
type: 'heatmap',
|
||||
blurSize: 0,
|
||||
data: {!! json_encode($regionPropertiesCapacities['values']) !!},
|
||||
data: {!! $diagramsOptions['heatmap']['series']['data'] !!},
|
||||
label: {
|
||||
show: false
|
||||
},
|
||||
|
|
|
@ -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
|
||||
]);
|
||||
|
|
|
@ -18,11 +18,14 @@ from fastapi.responses import JSONResponse
|
|||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class Regions(BaseModel):
|
||||
class RegionsItems(BaseModel):
|
||||
name: str
|
||||
id: str
|
||||
count_properties: int
|
||||
|
||||
class Regions(BaseModel):
|
||||
regions: List[RegionsItems]
|
||||
|
||||
class RegionBase(BaseModel):
|
||||
name: str
|
||||
id: str
|
||||
|
@ -144,7 +147,7 @@ def 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'])
|
||||
def region_base(id: int):
|
||||
|
@ -217,11 +220,11 @@ def property_base_data(id: int):
|
|||
base = d.property_base_data(id).pl().to_dicts()
|
||||
return {
|
||||
"property_platform_id": base[0]['property_platform_id'],
|
||||
"first_found": base[0]['property_platform_id'],
|
||||
"last_found": base[0]['property_platform_id'],
|
||||
"latlng": base[0]['property_platform_id'],
|
||||
"region_id": base[0]['property_platform_id'],
|
||||
"region_name": base[0]['property_platform_id']}
|
||||
"first_found": str(base[0]['first_found']),
|
||||
"last_found": str(base[0]['last_found']),
|
||||
"latlng": base[0]['latlng'],
|
||||
"region_id": base[0]['region_id'],
|
||||
"region_name": base[0]['region_name']}
|
||||
|
||||
@app.get("/property/{id}/neighbours", response_model=PropertyNeighbours, tags=['property'])
|
||||
def property_neighbours(id: int):
|
||||
|
|
Loading…
Reference in New Issue