Laravel details view. Adjusted navbar and routes
This commit is contained in:
@@ -11,26 +11,30 @@ use App\Http\Requests;
|
|||||||
class PagesController extends Controller
|
class PagesController extends Controller
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
public function dashboard() {
|
public function details() {
|
||||||
$pagetitle = 'Dashboard';
|
$pagetitle = 'Details';
|
||||||
$activeNav = 'dashboard';
|
$activeNav = 'details';
|
||||||
|
|
||||||
$temperature = Stats::select('temperature')
|
$temperature = Stats::select('temperature')
|
||||||
|
->where('node_id', 1)
|
||||||
->limit('144')
|
->limit('144')
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->pluck('temperature');
|
->pluck('temperature');
|
||||||
|
|
||||||
$humidity = Stats::select('humidity')
|
$humidity = Stats::select('humidity')
|
||||||
|
->where('node_id', 1)
|
||||||
->limit('144')
|
->limit('144')
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->pluck('humidity');
|
->pluck('humidity');
|
||||||
|
|
||||||
$gm3 = Stats::select('gm3')
|
$gm3 = Stats::select('gm3')
|
||||||
|
->where('node_id', 1)
|
||||||
->limit('144')
|
->limit('144')
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->pluck('gm3');
|
->pluck('gm3');
|
||||||
|
|
||||||
$created_at = Stats::select('created_at')
|
$created_at = Stats::select('created_at')
|
||||||
|
->where('node_id', 1)
|
||||||
->limit('144')
|
->limit('144')
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->pluck('created_at');
|
->pluck('created_at');
|
||||||
@@ -56,10 +60,7 @@ public function dashboard() {
|
|||||||
$latestHumidity = '' . $latestHumidity[0];
|
$latestHumidity = '' . $latestHumidity[0];
|
||||||
$latestGM3 = '' . $latestGM3[0];
|
$latestGM3 = '' . $latestGM3[0];
|
||||||
|
|
||||||
|
$chart[0] = Charts::multi('line', 'material')
|
||||||
$latestShit = 'Temp: ' . $latestTemp . ' Hum: ' . $latestHumidity . ' g/m³: ' . $latestGM3;
|
|
||||||
|
|
||||||
$chart = Charts::multi('line', 'material')
|
|
||||||
->title("Temperatur, Luftfeuchtigkeit, g/m³")
|
->title("Temperatur, Luftfeuchtigkeit, g/m³")
|
||||||
->dimensions(0, 400) // Width x Height
|
->dimensions(0, 400) // Width x Height
|
||||||
// This defines a preset of colors already done:)
|
// This defines a preset of colors already done:)
|
||||||
@@ -72,22 +73,37 @@ public function dashboard() {
|
|||||||
->dataset('g/m³', $gm3)
|
->dataset('g/m³', $gm3)
|
||||||
// Setup what the values mean
|
// Setup what the values mean
|
||||||
->labels($created_at);
|
->labels($created_at);
|
||||||
|
|
||||||
|
$chart[1] = Charts::multi('line', 'material')
|
||||||
|
->title("Temperatur")
|
||||||
|
->dimensions(0, 400) // Width x Height
|
||||||
|
// This defines a preset of colors already done:)
|
||||||
|
->template("material")
|
||||||
|
// You could always set them manually
|
||||||
|
// ->colors(['#2196F3', '#F44336', '#FFC107'])
|
||||||
|
// Setup the diferent datasets (this is a multi chart)
|
||||||
|
->dataset('°C', $temperature)
|
||||||
|
//->dataset('%', $humidity)
|
||||||
|
//->dataset('g/m³', $gm3)
|
||||||
|
// Setup what the values mean
|
||||||
|
->labels($created_at);
|
||||||
|
|
||||||
return view('dashboard')->with([
|
return view('details')->with([
|
||||||
'pagetitle' => $pagetitle,
|
'pagetitle' => $pagetitle,
|
||||||
'activeNav' => $activeNav,
|
'activeNav' => $activeNav,
|
||||||
'chart' => $chart,
|
'chart' => $chart,
|
||||||
'latestTemp' => $latestTemp,
|
'latestTemp' => $latestTemp,
|
||||||
'latestHumidity' => $latestHumidity,
|
'latestHumidity' => $latestHumidity,
|
||||||
'latestGM3' => $latestGM3,
|
'latestGM3' => $latestGM3,
|
||||||
'latestShit' => $latestShit,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function welcome() {
|
public function dashboard() {
|
||||||
$pagetitle = 'Willkommen';
|
$pagetitle = 'Dashboard';
|
||||||
$activeNav = 'welcome';
|
$activeNav = 'dashboard';
|
||||||
|
|
||||||
|
|
||||||
|
//Db queries
|
||||||
$latestTemp = Stats::select('temperature')
|
$latestTemp = Stats::select('temperature')
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
->limit('1')
|
->limit('1')
|
||||||
@@ -103,12 +119,29 @@ public function dashboard() {
|
|||||||
->limit('1')
|
->limit('1')
|
||||||
->pluck('gm3');
|
->pluck('gm3');
|
||||||
|
|
||||||
return view('welcome')->with([
|
//Pick values from array
|
||||||
|
$latestTemp = $latestTemp[0];
|
||||||
|
$latestHumidity = $latestHumidity[0];
|
||||||
|
$latestGM3 = $latestGM3[0];
|
||||||
|
|
||||||
|
//prepare suggestion
|
||||||
|
$compareIDs = '1-2';
|
||||||
|
$ids = explode('-', $compareIDs);
|
||||||
|
$latestTest = 11.0; //Outside
|
||||||
|
$lowerHumidityMode = true; //true --> suggestion lowers inside humidity; false --> suggestion heighten inside humidity
|
||||||
|
if ($lowerHumidityMode) {
|
||||||
|
($latestGM3 > $latestTest) ? $air = true : $air = false;
|
||||||
|
} else {
|
||||||
|
($latestGM3 < $latestTest) ? $air = true : $air = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('dashboard')->with([
|
||||||
'pagetitle' => $pagetitle,
|
'pagetitle' => $pagetitle,
|
||||||
'activeNav' => $activeNav,
|
'activeNav' => $activeNav,
|
||||||
'latestTemp' => $latestTemp,
|
'latestTemp' => $latestTemp,
|
||||||
'latestHumidity' => $latestHumidity,
|
'latestHumidity' => $latestHumidity,
|
||||||
'latestGM3' => $latestGM3,
|
'latestGM3' => $latestGM3,
|
||||||
|
'air' => $air,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,9 +3,7 @@
|
|||||||
@section('title', $pagetitle)
|
@section('title', $pagetitle)
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
{!! Charts::styles() !!}
|
|
||||||
<h1>Dashboard <small>Infos auf einen Blick</small></h1>
|
<h1>Dashboard <small>Infos auf einen Blick</small></h1>
|
||||||
|
|
||||||
<table style="width:100%">
|
<table style="width:100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@@ -44,13 +42,38 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
<div class="resizechart resizechart2">
|
@if($latestHumidity > 80)
|
||||||
{!! $chart->html() !!}
|
<div class="panel panel-danger">
|
||||||
|
@else
|
||||||
|
<div class="panel panel-success">
|
||||||
|
@endif
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">Schimmelbildung</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
@if($latestHumidity >= 75)
|
||||||
|
Die Luftfeuchtigkeit liegt bei {!! $latestHumidity !!} %. Es besteht Schimmelgefahr!
|
||||||
|
@else
|
||||||
|
Es besteht keine Schimmelgefahr! Luftfeuchtigkeit: {!! $latestHumidity !!} %.
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if($air)
|
||||||
{!! Charts::scripts() !!}
|
<div class="panel panel-success">
|
||||||
{!! $chart->script() !!}
|
@else
|
||||||
|
<div class="panel panel-danger">
|
||||||
|
@endif
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">Lüftungsempfehlung</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
@if($air)
|
||||||
|
Es kann gelüftet werden, um die Luftfeuchtigkeit zu verringern.
|
||||||
|
@else
|
||||||
|
Es sollte nicht gelüftet werde. Die Luftfeuchtigkeit würde sich erhöhen.
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
61
Laravel/resources/views/details.blade.php
Normal file
61
Laravel/resources/views/details.blade.php
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
@extends('layouts.master')
|
||||||
|
|
||||||
|
@section('title', $pagetitle)
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
{!! Charts::styles() !!}
|
||||||
|
<h1>Details <small>Genauere Infos</small></h1>
|
||||||
|
|
||||||
|
<table style="width:100%">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<div class="panel panel-primary">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">Temperatur</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<p>{!! $latestTemp !!} °C</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<div class="panel panel-primary">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">Luftfeuchtigkeit</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<p>{!! $latestHumidity !!} %</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<div class="panel panel-primary">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">Absoluter Feuchtegehalt </h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<p>{!! $latestGM3 !!} g/m³</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="resizechart resizechart2">
|
||||||
|
@foreach($chart as $ch)
|
||||||
|
{!! $ch->html() !!}
|
||||||
|
</br>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{!! Charts::scripts() !!}
|
||||||
|
@foreach($chart as $ch)
|
||||||
|
{!! $ch->script() !!}
|
||||||
|
@endforeach
|
||||||
|
@endsection
|
@@ -55,12 +55,12 @@
|
|||||||
{{-- Left Side Of Navbar --}}
|
{{-- Left Side Of Navbar --}}
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
{{-- Navlink Startseite --}}
|
{{-- Navlink Startseite --}}
|
||||||
@if(isset($activeNav) && $activeNav == 'dashboard')
|
@if(isset($activeNav) && $activeNav == 'details')
|
||||||
<li class="active">
|
<li class="active">
|
||||||
@else
|
@else
|
||||||
<li>
|
<li>
|
||||||
@endif
|
@endif
|
||||||
<a href="{{ url('/dashboard') }}">Dashboard</a>
|
<a href="{{ url('/details') }}">Details</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
@@ -12,6 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
Route::get('/', 'PagesController@welcome');
|
Route::get('/', 'PagesController@dashboard');
|
||||||
|
|
||||||
Route::get('/dashboard', 'PagesController@dashboard');
|
Route::get('/details', 'PagesController@details');
|
||||||
|
Reference in New Issue
Block a user