Überarbeitung Dashboard
This commit is contained in:
1 parent
8bef4b9621
commit
a5a21fb925
10 files changed
+242
-95
No files matched your search
@@ -8,11 +8,6 @@ use Illuminate\Support\Facades\Http;
|
||||
class Api
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function get(string $path, string $query = ''): ?array
|
||||
{
|
||||
|
||||
@@ -20,7 +15,7 @@ class Api
|
||||
$request = $endpoint.$path;
|
||||
|
||||
if (Cache::has($request)) {
|
||||
return Cache::get($request);
|
||||
// return Cache::get($request);
|
||||
}
|
||||
|
||||
$get = Http::timeout(1600)->get($request);
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App;
|
||||
class Chart
|
||||
{
|
||||
public static function colors(int $count = 5){
|
||||
$colors = ['#fff7fb','#ece7f2','#d0d1e6','#a6bddb','#74a9cf','#3690c0','#0570b0','#045a8d','#023858'];
|
||||
$colors = ['#bfd3e6','#8c96c6','#88419d','#810f7c','#4d004b'];
|
||||
return json_encode($colors);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ span + button{
|
||||
}
|
||||
|
||||
button[popovertarget]{
|
||||
background: no-repeat center / .3em #5470c6 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 192 512'%3E%3C!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--%3E%3Cpath fill='%23fff' d='M48 80a48 48 0 1 1 96 0A48 48 0 1 1 48 80zM0 224c0-17.7 14.3-32 32-32l64 0c17.7 0 32 14.3 32 32l0 224 32 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 512c-17.7 0-32-14.3-32-32s14.3-32 32-32l32 0 0-192-32 0c-17.7 0-32-14.3-32-32z'/%3E%3C/svg%3E%0A");
|
||||
background: no-repeat center / .3em #4d004b url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 192 512'%3E%3C!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--%3E%3Cpath fill='%23fff' d='M48 80a48 48 0 1 1 96 0A48 48 0 1 1 48 80zM0 224c0-17.7 14.3-32 32-32l64 0c17.7 0 32 14.3 32 32l0 224 32 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 512c-17.7 0-32-14.3-32-32s14.3-32 32-32l32 0 0-192-32 0c-17.7 0-32-14.3-32-32z'/%3E%3C/svg%3E%0A");
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
width: 1.5em;
|
||||
@@ -242,7 +242,7 @@ article>header>h2{
|
||||
}
|
||||
|
||||
.leaflet-marker-icon span{
|
||||
background: blue;
|
||||
background: #4d004b;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
display: block;
|
||||
@@ -256,17 +256,17 @@ article>header>h2{
|
||||
|
||||
/*['#9ecae1','#6baed6','#4292c6','#2171b5','#084594'*/
|
||||
.leaflet-marker-icon.region1 span{
|
||||
background: #9ecae1;
|
||||
background: #8c96c6;
|
||||
}
|
||||
|
||||
.leaflet-marker-icon.region2 span{
|
||||
background: #6baed6;
|
||||
background: #88419d;
|
||||
}
|
||||
|
||||
.leaflet-marker-icon.region3 span{
|
||||
background: #4292c6;
|
||||
background: #810f7c;
|
||||
}
|
||||
|
||||
.leaflet-marker-icon.region4 span{
|
||||
background: #2171b5;
|
||||
background: #4d004b;
|
||||
}
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
const sharedOptions = {
|
||||
basic: {
|
||||
color: ['#9ecae1','#6baed6','#4292c6','#2171b5','#08519c','#08306b'],
|
||||
color: {!! $chartOptions['colors'] !!},
|
||||
grid: {
|
||||
top: 20,
|
||||
left: 60,
|
||||
@@ -165,7 +165,7 @@ const cPropsPerRegionOptions = {
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
type: 'category',
|
||||
data: {!! $propsPerRegion[0] !!}
|
||||
data: {!! $propsPerRegion[1] !!}
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
@@ -178,7 +178,7 @@ const cPropsPerRegionOptions = {
|
||||
},
|
||||
series: [
|
||||
{
|
||||
data: {!! $propsPerRegion[1] !!},
|
||||
data: {!! $propsPerRegion[2] !!},
|
||||
type: 'bar',
|
||||
itemStyle: {
|
||||
color: (e) => {
|
||||
|
||||
@@ -11,12 +11,6 @@
|
||||
<dt>Zum letzten mal gefunden</dt>
|
||||
<dd>{{ $base['last_found'] }}</dd>
|
||||
</dl>
|
||||
<h2>Kurzzeitmietobjekte in der Nähe</h2>
|
||||
<ul>
|
||||
@foreach($neighbours as $n)
|
||||
<li><a href="/prop/{{ $n['id'] }}">{{ $n['lat'] }}, {{$n['lon']}}</a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@@ -27,8 +21,13 @@
|
||||
<article class="header" style="grid-area: chart1;">
|
||||
<header>
|
||||
<h2 id="belegung-title">
|
||||
Belegung am
|
||||
</h2>
|
||||
Kalenderansicht der Belegung am <span class="date">{{ $startDate }}</span>
|
||||
</h2><button popovertarget="popup-cal"></button>
|
||||
<div popover id="popup-cal">
|
||||
<p>
|
||||
Das Kalenderdiagram zeigt die drei Verfügbarkeitskategorien des Mietobjekts.
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
<div id="chart-calendar"></div>
|
||||
</article>
|
||||
@@ -43,7 +42,7 @@
|
||||
<article class="header" style="grid-area: chart3;">
|
||||
<header>
|
||||
<h2>
|
||||
Auslastung nach Monat am 2024-04-15T07:06:22
|
||||
Belegung Mietobjekt Monate am <span class="date">{{ $startDate }}</span>
|
||||
</h2>
|
||||
</header>
|
||||
<div id="chart-capacity-monthly">
|
||||
@@ -65,12 +64,35 @@
|
||||
<article class="header" style="grid-area: chart4;">
|
||||
<header>
|
||||
<h2>
|
||||
Auslastung Tage für Monat
|
||||
Belegung Mietobjekt Tage am <span class="date">{{ $startDate }}</span>
|
||||
</h2>
|
||||
</header>
|
||||
<div id="chart-capacity-daily">
|
||||
</article>
|
||||
<script type="module">
|
||||
|
||||
const sharedOptions = {
|
||||
basic: {
|
||||
color: {!! $chartOptions['colors'] !!},
|
||||
grid: {
|
||||
top: 20,
|
||||
left: 60,
|
||||
right: 0,
|
||||
bottom: 50
|
||||
},
|
||||
name: (opt) => {
|
||||
return {
|
||||
name: opt.name,
|
||||
nameLocation: opt.location,
|
||||
nameGap: 24,
|
||||
nameTextStyle: {
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const chartTimeline = document.getElementById('timeline');
|
||||
const cTimeline = echarts.init(chartTimeline);
|
||||
|
||||
@@ -123,6 +145,9 @@ const cCapacityMonthlyOptions = {
|
||||
},
|
||||
series: [{
|
||||
type: 'bar',
|
||||
itemStyle: {
|
||||
color: sharedOptions.basic.color[3]
|
||||
},
|
||||
data: {!! json_encode($cM['capacities']) !!}
|
||||
}]
|
||||
},
|
||||
@@ -132,7 +157,6 @@ const cCapacityMonthlyOptions = {
|
||||
|
||||
cCapacityMonthly.setOption(cCapacityMonthlyOptions);
|
||||
|
||||
|
||||
const chartCapacityDaily = document.getElementById('chart-capacity-daily');
|
||||
const cCapacityDaily = echarts.init(chartCapacityDaily);
|
||||
|
||||
@@ -163,6 +187,9 @@ const cCapacityDailyOptions = {
|
||||
},
|
||||
series: [{
|
||||
type: 'bar',
|
||||
itemStyle: {
|
||||
color: sharedOptions.basic.color[3]
|
||||
},
|
||||
data: {!! json_encode($cD['capacities']) !!}
|
||||
}]
|
||||
},
|
||||
@@ -176,7 +203,7 @@ const chartCapacity = document.getElementById('chart-capacity');
|
||||
const cCapacity = echarts.init(chartCapacity);
|
||||
|
||||
const cCapacityOptions = {
|
||||
color: ['#9ecae1','#6baed6','#4292c6','#2171b5','#084594'],
|
||||
color: sharedOptions.basic.color,
|
||||
legend: {
|
||||
data: ['Auslastung Property', 'Auslastung {{ $base['region_name'] }}', 'Auslastung alle Regionen']
|
||||
},
|
||||
@@ -324,7 +351,10 @@ cCalendar.setOption(cCalendarOptions);
|
||||
|
||||
cTimeline.on('timelinechanged', (e) => {
|
||||
|
||||
h2Belegung.innerText = "Belegung am "+cCalendarOptions.timeline.data[e.currentIndex];
|
||||
let dateTitles = document.querySelectorAll('span.date');
|
||||
dateTitles.forEach(el => {
|
||||
el.innerText = cTimelineOptions.timeline.data[e.currentIndex];
|
||||
});
|
||||
|
||||
// Set markpoint on linechart
|
||||
let x = cCapacityOptions.xAxis.data[e.currentIndex];
|
||||
@@ -373,6 +403,7 @@ function icon(id = 0){
|
||||
}
|
||||
|
||||
const markers = L.featureGroup([
|
||||
L.marker([{{ $base['check_data'] }}], {icon: icon(1)}),
|
||||
@foreach($neighbours as $n)
|
||||
L.marker([{{ $n['lat'] }}, {{ $n['lon'] }}], {icon: icon()}).bindPopup('<a href="/property/{{ $n['id'] }}">{{ $n['lat'] }}, {{ $n['lon'] }}</a>'),
|
||||
@endforeach
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<article class="header" style="grid-area: chart3;">
|
||||
<header>
|
||||
<h2>
|
||||
Auslastung nach Monat am 2024-04-15T07:06:22
|
||||
Auslastung der Region nach Monat am <span class="date">{{ $startDate }}</span>
|
||||
</h2>
|
||||
</header>
|
||||
<div id="chart-capacity-monthly">
|
||||
@@ -54,7 +54,7 @@
|
||||
<article class="header" style="grid-area: chart4;">
|
||||
<header>
|
||||
<h2>
|
||||
Auslastung Tage für Monat
|
||||
Auslastung der Region nach Wochentage am <span class="date">{{ $startDate }}</span>
|
||||
</h2>
|
||||
</header>
|
||||
<div id="chart-capacity-daily">
|
||||
@@ -64,7 +64,7 @@
|
||||
|
||||
const sharedOptions = {
|
||||
basic: {
|
||||
color: ['#9ecae1','#6baed6','#4292c6','#2171b5','#084594'],
|
||||
color: {!! $chartOptions['colors'] !!},
|
||||
grid: {
|
||||
top: 20,
|
||||
left: 60,
|
||||
@@ -95,6 +95,7 @@ const cCapacityOptions = {
|
||||
trigger: 'axis',
|
||||
valueFormatter: (value) => value.toFixed(2)+' %'
|
||||
},
|
||||
color: sharedOptions.basic.color,
|
||||
grid: {
|
||||
top: 20,
|
||||
left: 25,
|
||||
@@ -134,7 +135,7 @@ const cCapacityOptions = {
|
||||
name: 'Auslastung Region',
|
||||
type: 'line',
|
||||
symbolSize: 7,
|
||||
data: {!! json_encode($regionCapacities['all']['capacities']) !!}
|
||||
data: {!! json_encode($regionCapacities['region']['capacities']) !!}
|
||||
}]
|
||||
};
|
||||
|
||||
@@ -170,6 +171,9 @@ const cCapacityMonthlyOptions = {
|
||||
},
|
||||
series: [{
|
||||
type: 'bar',
|
||||
itemStyle: {
|
||||
color: sharedOptions.basic.color[3]
|
||||
},
|
||||
data: {!! json_encode($m['capacities']) !!}
|
||||
}]
|
||||
},
|
||||
@@ -209,6 +213,9 @@ const cCapacityDailyOptions = {
|
||||
},
|
||||
series: [{
|
||||
type: 'bar',
|
||||
itemStyle: {
|
||||
color: sharedOptions.basic.color[3]
|
||||
},
|
||||
data: {!! json_encode($d['capacities']) !!}
|
||||
}]
|
||||
},
|
||||
@@ -284,6 +291,7 @@ const cPredictionOptions = {
|
||||
},
|
||||
@else
|
||||
{
|
||||
color: sharedOptions.basic.color,
|
||||
graphic: {
|
||||
elements: []
|
||||
},
|
||||
@@ -424,6 +432,11 @@ cTimeline.setOption(cTimelineOptions);
|
||||
|
||||
cTimeline.on('timelinechanged', (e) => {
|
||||
|
||||
let dateTitles = document.querySelectorAll('span.date');
|
||||
dateTitles.forEach(el => {
|
||||
el.innerText = cTimelineOptions.timeline.data[e.currentIndex];
|
||||
});
|
||||
|
||||
// Set markpoint on linechart
|
||||
let x = cCapacityOptions.xAxis.data[e.currentIndex];
|
||||
let y = cCapacityOptions.series[0].data[e.currentIndex];
|
||||
@@ -464,5 +477,10 @@ cCapacity.on('click', 'series', (e) => {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
cHeatmap.on('click', 'series', (e) => {
|
||||
window.open(`/property/${e.value[1]}?date=${e.value[0]}`, '_self');
|
||||
})
|
||||
|
||||
</script>
|
||||
@endsection
|
||||
+51
-40
@@ -36,8 +36,57 @@ Route::get('/', function () {
|
||||
"propsPerRegion" => [json_encode($propsPerRegionId), json_encode($propsPerRegionName), json_encode($propsPerRegionCounts)]]);
|
||||
});
|
||||
|
||||
Route::get('/region/{id}', function (int $id) {
|
||||
|
||||
$regionBaseAll = Api::regionBase(-1);
|
||||
$regionBaseAll[] = ['region_name' => 'Alle Regionen', 'region_id' => -1];
|
||||
$regionBaseRegion = $id >= 0 ? Api::regionBase($id) : [['region_name' => 'Alle Regionen']];
|
||||
|
||||
$regionPropertiesCapacities = Api::regionPropertiesCapacities($id);
|
||||
$regionCapacitiesRegion = Api::regionCapacities($id);
|
||||
$regionCapacitiesAll = Api::regionCapacities(-1);
|
||||
|
||||
$regionCapacitiesMonthly = [];
|
||||
$regionCapacitiesDaily = [];
|
||||
$regionPredictions = [];
|
||||
|
||||
foreach ($regionCapacitiesRegion['dates'] as $date) {
|
||||
$regionCapacitiesMonthly[] = Api::regionCapacitiesMonthly($id, $date);
|
||||
$regionCapacitiesDaily[] = Api::regionCapacitiesDaily($id, $date);
|
||||
$regionPredictions[] = Api::regionMovingAverage($id, $date);
|
||||
}
|
||||
|
||||
$chartOptions = [
|
||||
'colors' => Chart::colors()
|
||||
];
|
||||
|
||||
$regionCapacities = [
|
||||
'all' => $regionCapacitiesAll,
|
||||
'region' => $regionCapacitiesRegion,
|
||||
'region_monthly' => $regionCapacitiesMonthly,
|
||||
'region_daily' => $regionCapacitiesDaily
|
||||
|
||||
];
|
||||
|
||||
return view('region', [
|
||||
'chartOptions' => $chartOptions,
|
||||
'startDate' => $regionCapacitiesRegion['dates'][0],
|
||||
'regions' => $regionBaseAll,
|
||||
'region' => $regionBaseRegion,
|
||||
'region_id' => $id,
|
||||
'regionCapacities' => $regionCapacities,
|
||||
'regionPropertiesCapacities' => $regionPropertiesCapacities,
|
||||
'predictions' => $regionPredictions]);
|
||||
|
||||
|
||||
});
|
||||
|
||||
Route::get('/property/{id}', function (int $id) {
|
||||
|
||||
$chartOptions = [
|
||||
'colors' => Chart::colors()
|
||||
];
|
||||
|
||||
$propertyBase = Api::propertyBase($id);
|
||||
$calendars = Api::propertyExtractions($id);
|
||||
$propertyCapacities = Api::propertyCapacities($id);
|
||||
@@ -85,6 +134,8 @@ Route::get('/property/{id}', function (int $id) {
|
||||
}
|
||||
|
||||
return view('property', [
|
||||
'chartOptions' => $chartOptions,
|
||||
'startDate' => $propertyCapacities['dates'][0],
|
||||
'base' => $propertyBase[0],
|
||||
'extractiondates' => json_encode($propertyCapacities['dates']),
|
||||
'calendar' => $data,
|
||||
@@ -98,43 +149,3 @@ Route::get('/property/{id}', function (int $id) {
|
||||
});
|
||||
|
||||
|
||||
Route::get('/region/{id}', function (int $id) {
|
||||
|
||||
$regionBaseAll = Api::regionBase(-1);
|
||||
$regionBaseAll[] = ['region_name' => 'Alle Regionen', 'region_id' => -1];
|
||||
$regionBaseRegion = $id >= 0 ? Api::regionBase($id) : [['region_name' => 'Alle Regionen']];
|
||||
|
||||
$regionPropertiesCapacities = Api::regionPropertiesCapacities($id);
|
||||
$regionCapacitiesRegion = Api::regionCapacities($id);
|
||||
$regionCapacitiesAll = Api::regionCapacities(-1);
|
||||
|
||||
$regionCapacitiesMonthly = [];
|
||||
$regionCapacitiesDaily = [];
|
||||
$regionPredictions = [];
|
||||
|
||||
foreach ($regionCapacitiesRegion['dates'] as $date) {
|
||||
$regionCapacitiesMonthly[] = Api::regionCapacitiesMonthly($id, $date);
|
||||
$regionCapacitiesDaily[] = Api::regionCapacitiesDaily($id, $date);
|
||||
$regionPredictions[] = Api::regionMovingAverage($id, $date);
|
||||
}
|
||||
|
||||
$regionCapacities = [
|
||||
'all' => $regionCapacitiesAll,
|
||||
'region' => $regionCapacitiesRegion,
|
||||
'region_monthly' => $regionCapacitiesMonthly,
|
||||
'region_daily' => $regionCapacitiesDaily
|
||||
|
||||
];
|
||||
|
||||
dump($regionPredictions);
|
||||
|
||||
return view('region', [
|
||||
'regions' => $regionBaseAll,
|
||||
'region' => $regionBaseRegion,
|
||||
'region_id' => $id,
|
||||
'regionCapacities' => $regionCapacities,
|
||||
'regionPropertiesCapacities' => $regionPropertiesCapacities,
|
||||
'predictions' => $regionPredictions]);
|
||||
|
||||
|
||||
});
|
||||
Reference in new issue
Block a user