Laravel details view. Adjusted navbar and routes
This commit is contained in:
@@ -11,26 +11,30 @@ use App\Http\Requests;
|
||||
class PagesController extends Controller
|
||||
{
|
||||
//
|
||||
public function dashboard() {
|
||||
$pagetitle = 'Dashboard';
|
||||
$activeNav = 'dashboard';
|
||||
public function details() {
|
||||
$pagetitle = 'Details';
|
||||
$activeNav = 'details';
|
||||
|
||||
$temperature = Stats::select('temperature')
|
||||
->where('node_id', 1)
|
||||
->limit('144')
|
||||
->orderBy('created_at', 'desc')
|
||||
->pluck('temperature');
|
||||
|
||||
$humidity = Stats::select('humidity')
|
||||
->where('node_id', 1)
|
||||
->limit('144')
|
||||
->orderBy('created_at', 'desc')
|
||||
->pluck('humidity');
|
||||
|
||||
$gm3 = Stats::select('gm3')
|
||||
->where('node_id', 1)
|
||||
->limit('144')
|
||||
->orderBy('created_at', 'desc')
|
||||
->pluck('gm3');
|
||||
|
||||
$created_at = Stats::select('created_at')
|
||||
->where('node_id', 1)
|
||||
->limit('144')
|
||||
->orderBy('created_at', 'desc')
|
||||
->pluck('created_at');
|
||||
@@ -56,10 +60,7 @@ public function dashboard() {
|
||||
$latestHumidity = '' . $latestHumidity[0];
|
||||
$latestGM3 = '' . $latestGM3[0];
|
||||
|
||||
|
||||
$latestShit = 'Temp: ' . $latestTemp . ' Hum: ' . $latestHumidity . ' g/m³: ' . $latestGM3;
|
||||
|
||||
$chart = Charts::multi('line', 'material')
|
||||
$chart[0] = Charts::multi('line', 'material')
|
||||
->title("Temperatur, Luftfeuchtigkeit, g/m³")
|
||||
->dimensions(0, 400) // Width x Height
|
||||
// This defines a preset of colors already done:)
|
||||
@@ -72,22 +73,37 @@ public function dashboard() {
|
||||
->dataset('g/m³', $gm3)
|
||||
// Setup what the values mean
|
||||
->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,
|
||||
'activeNav' => $activeNav,
|
||||
'chart' => $chart,
|
||||
'latestTemp' => $latestTemp,
|
||||
'latestHumidity' => $latestHumidity,
|
||||
'latestGM3' => $latestGM3,
|
||||
'latestShit' => $latestShit,
|
||||
]);
|
||||
}
|
||||
|
||||
public function welcome() {
|
||||
$pagetitle = 'Willkommen';
|
||||
$activeNav = 'welcome';
|
||||
public function dashboard() {
|
||||
$pagetitle = 'Dashboard';
|
||||
$activeNav = 'dashboard';
|
||||
|
||||
|
||||
//Db queries
|
||||
$latestTemp = Stats::select('temperature')
|
||||
->orderBy('created_at', 'desc')
|
||||
->limit('1')
|
||||
@@ -103,12 +119,29 @@ public function dashboard() {
|
||||
->limit('1')
|
||||
->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,
|
||||
'activeNav' => $activeNav,
|
||||
'latestTemp' => $latestTemp,
|
||||
'latestHumidity' => $latestHumidity,
|
||||
'latestGM3' => $latestGM3,
|
||||
'air' => $air,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -3,9 +3,7 @@
|
||||
@section('title', $pagetitle)
|
||||
|
||||
@section('content')
|
||||
{!! Charts::styles() !!}
|
||||
<h1>Dashboard <small>Infos auf einen Blick</small></h1>
|
||||
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
<td>
|
||||
@@ -44,13 +42,38 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<div class="resizechart resizechart2">
|
||||
{!! $chart->html() !!}
|
||||
@if($latestHumidity > 80)
|
||||
<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>
|
||||
|
||||
|
||||
{!! Charts::scripts() !!}
|
||||
{!! $chart->script() !!}
|
||||
@if($air)
|
||||
<div class="panel panel-success">
|
||||
@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
|
||||
|
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 --}}
|
||||
<ul class="nav navbar-nav">
|
||||
{{-- Navlink Startseite --}}
|
||||
@if(isset($activeNav) && $activeNav == 'dashboard')
|
||||
@if(isset($activeNav) && $activeNav == 'details')
|
||||
<li class="active">
|
||||
@else
|
||||
<li>
|
||||
@endif
|
||||
<a href="{{ url('/dashboard') }}">Dashboard</a>
|
||||
<a href="{{ url('/details') }}">Details</a>
|
||||
</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