Skip to content

Commit

Permalink
Improved dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu committed Dec 30, 2020
1 parent e83a5a0 commit 775c7c6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 32 deletions.
36 changes: 14 additions & 22 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,30 @@

namespace App\Http\Controllers;

use App\SpotifyPlayActivity;
use Illuminate\Contracts\Support\Renderable;

class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
class HomeController extends Controller {

public function index(): Renderable {
$lastSpotifyTrack = SpotifyPlayActivity::with(['track', 'track.album', 'track.artists'])
->where('user_id', auth()->user()->id)
->orderBy('timestamp_start', 'DESC')
->limit(1)
->first();

/**
* Show the application dashboard.
*
* @return Renderable
*/
public function index(): Renderable
{
return view('home');
return view('home', [
'lastSpotifyTrack' => $lastSpotifyTrack
]);
}

public static function getCurrentGitHash(): string
{
public static function getCurrentGitHash(): string {
try {
$gitBasePath = base_path() . '/.git';

$gitStr = file_get_contents($gitBasePath . '/HEAD');
return rtrim(preg_replace("/(.*?\/){2}/", '', $gitStr));
} catch (\Exception $e) {
} catch(\Exception $e) {
report($e);
return 'unknown';
}
Expand Down
23 changes: 13 additions & 10 deletions resources/views/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,25 @@
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Willkommen im neuen KStats</h5>
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif

<p>Optisch kaum anders, aber im inner'n hat sich viel getan. Dies ist aktuell erst eine
"Vorab-Version", einige Features und Statistiken, die du vielleicht kennst sind aktuell noch
nicht Verfügbar, kommen aber bald zurück!</p>
@isset($lastSpotifyTrack)
<small class="text-muted float-right">abgespielt {{$lastSpotifyTrack->timestamp_start->diffForHumans()}}</small>
@endisset
<h5 class="card-title">Dein zuletzt gehörter Track</h5>
@isset($lastSpotifyTrack)
@include('spotify.components.track', ['track' => $lastSpotifyTrack->track])
@else
<p class="text-danger">
Du hast bisher noch kein Lied auf Spotify gehört oder nutzt die KStats
Statistik nicht! :c
</p>
@endisset
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h2>Verbundene Dienste</h2>
<table class="table">
<thead>
<tr>
Expand Down

0 comments on commit 775c7c6

Please sign in to comment.