Skip to content

Commit

Permalink
Merge pull request #23 from Zhyltix/ID-39-As-a-stakeholder-I-want-to-…
Browse files Browse the repository at this point in the history
…have-a-driving-dashboard-so-the-driver-feedback-can-be-showed-after-using-the-VAR

Id 39 as a stakeholder i want to have a driving dashboard so the driver feedback can be showed after using the var
  • Loading branch information
leonoosterhuis committed Jan 22, 2024
2 parents 32aad2b + b7097a9 commit bd67c52
Show file tree
Hide file tree
Showing 19 changed files with 654 additions and 40 deletions.
16 changes: 11 additions & 5 deletions app/Domain/Trip/Jobs/PostTripJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ class PostTripJob implements ShouldQueue
use SerializesModels;


public function handle(Trip $trip)
public Trip $trip;
public function __construct(Trip $trip)
{
$this->processTrip($trip);
$this->trip = $trip;
}


$this->processProfiles($trip);
public function handle()
{
$this->processTrip($this->trip);

$this->processEvents($trip);
$this->processProfiles($this->trip);

$this->processEvents($this->trip);
}

private function processTrip(Trip $trip): void
Expand All @@ -33,7 +40,6 @@ private function processTrip(Trip $trip): void
$avrageSpeed = $this->getAverageSpeed($trip);

$distance = $duration * $avrageSpeed / 3600;

$trip->update([
'distance' => $distance
]);
Expand Down
46 changes: 42 additions & 4 deletions app/UserInterface/Domain/Homepage/Controllers/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

namespace App\UserInterface\Domain\Homepage\Controllers;

use App\Domain\Device\Model\Device;
use App\Domain\Shared\Interface\BreadCrumbInterface;
use App\Domain\Shared\ValueObject\BreadCrumbValueObject;
use App\Domain\Shared\ValueObject\RouteValueObject;
use App\Domain\Trip\Jobs\PostTripJob;
use App\Domain\Trip\Model\Trip;
use App\Domain\Trip\Model\TripEvent;
use App\Helpers\View\Abstract\AbstractViewController;
use App\Helpers\View\ValueObject\ButtonValueObject;
use App\Helpers\View\ValueObject\PageHeaderValueOject;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class Main extends AbstractViewController implements BreadCrumbInterface
{
Expand All @@ -34,10 +39,7 @@ protected function pageHeader(): PageHeaderValueOject
/**
* @inheritdoc
*/
protected function appendViewData(Request $request): array
{
return [];
}


public function getBreadCrumb(Request $request): BreadCrumbValueObject
{
Expand All @@ -46,4 +48,40 @@ public function getBreadCrumb(Request $request): BreadCrumbValueObject
route: new RouteValueObject('homepage')
);
}

public function get_stats()
{

$data['weekly'] = $this->get_weekly_review();

return response()->json(['stats' => $data]);
}

public function get_weekly_review()
{
$allSpeeds = [];
$trip = Trip::whereUserId(Auth::id())->get();
foreach ($trip as $t) {
$allSpeeds[] = $t->data()->get()->avg('speed');
}
$sumspeed = array_sum($allSpeeds);
if (count($allSpeeds) == 0) {
$data['avg_speed'] = "N/A";
return $data;
}
$avgspeed = $sumspeed / count($allSpeeds);
$rounded = round($avgspeed);
$data['avg_speed'] = $rounded;
return $data;
}

public function get_recent_trips()
{
}

protected function appendViewData(Request $request): array
{
$data['device'] = Device::whereUserId(Auth::id())->orderBy('created_at', 'desc')->first();
return $data;
}
}

This file was deleted.

This file was deleted.

31 changes: 28 additions & 3 deletions app/UserInterface/Domain/Homepage/Resources/sass/_homepage.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.homepage-under-construction {
margin-top: 7.5rem;
margin-top: 0.25rem;
display: flex;
justify-content: center;
flex-direction: column;
Expand All @@ -18,6 +18,31 @@
}

img {
width: 400px;
width: 25rem;
}
}


.recent {
height: 5rem;
border-radius: 0.625rem;
background-color: #ffffff;
padding: 0.9375rem;
color: #000000;
display: flex;
cursor: pointer;
margin-bottom: 1rem;
box-shadow: rgba(149, 157, 165, 0.2) 0px 2px 2.5px;
}

.review {
height: 11rem;
border-radius: 0.625rem;
background-color: #ffffff;
padding: 0.9375rem;
color: #000000;
display: flex;
cursor: pointer;
margin-bottom: 1rem;
box-shadow: rgba(149, 157, 165, 0.2) 0px 2px 2.5px;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#recent-device-wrapper {
padding: 1rem 2rem;
min-width: 100%;
justify-content: center;
align-items: center;
border-radius: 0.625rem;
background-color: #ffffff;
color: #000000;
cursor: pointer;
margin-bottom: 1rem;
box-shadow: rgba(149, 157, 165, 0.2) 0px 2px 2.5px;



#recent-device-header {
width: 100%;

.card {
padding: 2rem 2rem 2rem 2rem;
}

.icon {
display: flex;
justify-content: center;
align-items: center;
background-color: var(--color-gray-100);
border-radius: 10%;
padding: 1rem;

i {
font-size: 3rem;
padding: 0.5rem 0.5rem;
color: var(--color-tertiary-color);
}
}

.details {
padding: 0 0.9rem;

.name {
margin-top: 1rem;
margin-left: 0.5rem;

h3 {
font-size: 2rem;
font-weight: 600;
margin: 0;
}

p {
font-size: 1rem;
margin: 0;
color: var(--color-gray-500);
}
}

.badges {
margin-top: 0.5rem;

.badge {
border: 1px dashed var(--color-gray-300);
padding: 0.5rem 1rem;
border-radius: .475rem !important;
min-width: 125px;
margin: 0.5rem 0;
color: black;
text-align: left;
font-size: 1rem;

.badge-value {
i {
margin-right: 0.5rem;
}

font-size: 1.25rem;
}

.badge-label {
font-weight: 200;
margin: 0;
margin-top: 0.3rem;
color: var(--color-gray-500);
}
}
}
}
}
}
98 changes: 98 additions & 0 deletions app/UserInterface/Domain/Homepage/Resources/sass/_recent_trip.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#recent_trip_wrapper {
.page-item {
&:not(#datatable_previous, #datatable_next) {
a {
background-color: var(--color-secondary-color);
border-color: var(--color-secondary-color);

&:hover {
background-color: var(--color-secondary-color-hover);
border-color: var(--color-secondary-color-hover);
}
}
}

}
}

.dt-recent-trip-wrapper {
display: inline-block;
background-color: var(--color-tertiary-color);
color: white;
border-radius: 50%;
padding: 0.5em;
font-size: 1.25em;
font-weight: bold;
width: 2.8em;
height: 2.8em;

.number {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
font-size: 0.75em;
}
}

.r-type-inline-d {
font-size: 1.5rem;
}

.r-type-inline-l {
color: grey;
text-overflow: ellipsis;
}

.trip-review-container {
max-height: 125px;
height: 125px;
display: flex;
justify-content: space-evenly;
padding-left: 1rem;
flex-direction: column;

.trip-review {
display: flex;
align-items: center;
margin-top: 0.25rem;

&-title-wrapper {
display: flex;
justify-content: center;
width: 100%;
flex-direction: column;


.trip-review-title {
font-size: 1.25rem;
font-weight: 500;
}

.trip-review-unit {
font-size: 0.75rem;
font-weight: 400;
color: var(--color-gray-500);
}
}

&-value-wrapper {
width: 70px;
height: 35px;
margin-right: 1rem;
display: flex;
justify-content: center;
align-items: center;
background-color: var(--color-tertiary-color);
border-radius: 0.25rem;


.trip-review-value {
margin-top: 3px;
font-size: 1.25rem;
font-weight: 700;
color: white;
}
}
}
}
Loading

0 comments on commit bd67c52

Please sign in to comment.