Laravel details view. Adjusted navbar and routes

This commit is contained in:
2017-09-24 01:31:39 +02:00
parent 736cbd3ac7
commit 60b0cabed3
5 changed files with 142 additions and 25 deletions

View File

@@ -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,
]);
}