diff --git a/app/Domain/Trip/Jobs/PostTripJob.php b/app/Domain/Trip/Jobs/PostTripJob.php index 89eea467..d8048f9d 100644 --- a/app/Domain/Trip/Jobs/PostTripJob.php +++ b/app/Domain/Trip/Jobs/PostTripJob.php @@ -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 @@ -33,7 +40,6 @@ private function processTrip(Trip $trip): void $avrageSpeed = $this->getAverageSpeed($trip); $distance = $duration * $avrageSpeed / 3600; - $trip->update([ 'distance' => $distance ]); diff --git a/app/UserInterface/Domain/Homepage/Controllers/Main.php b/app/UserInterface/Domain/Homepage/Controllers/Main.php index ac5d1701..02611297 100644 --- a/app/UserInterface/Domain/Homepage/Controllers/Main.php +++ b/app/UserInterface/Domain/Homepage/Controllers/Main.php @@ -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 { @@ -34,10 +39,7 @@ protected function pageHeader(): PageHeaderValueOject /** * @inheritdoc */ - protected function appendViewData(Request $request): array - { - return []; - } + public function getBreadCrumb(Request $request): BreadCrumbValueObject { @@ -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; + } } diff --git a/app/UserInterface/Domain/Homepage/Resources/sass/_homepage 2.scss b/app/UserInterface/Domain/Homepage/Resources/sass/_homepage 2.scss deleted file mode 100644 index 1d8a2418..00000000 --- a/app/UserInterface/Domain/Homepage/Resources/sass/_homepage 2.scss +++ /dev/null @@ -1,3 +0,0 @@ -body { - display: none; -} diff --git a/app/UserInterface/Domain/Homepage/Resources/sass/_homepage 3.scss b/app/UserInterface/Domain/Homepage/Resources/sass/_homepage 3.scss deleted file mode 100644 index 1d8a2418..00000000 --- a/app/UserInterface/Domain/Homepage/Resources/sass/_homepage 3.scss +++ /dev/null @@ -1,3 +0,0 @@ -body { - display: none; -} diff --git a/app/UserInterface/Domain/Homepage/Resources/sass/_homepage.scss b/app/UserInterface/Domain/Homepage/Resources/sass/_homepage.scss index 8112993c..d0bae564 100644 --- a/app/UserInterface/Domain/Homepage/Resources/sass/_homepage.scss +++ b/app/UserInterface/Domain/Homepage/Resources/sass/_homepage.scss @@ -1,5 +1,5 @@ .homepage-under-construction { - margin-top: 7.5rem; + margin-top: 0.25rem; display: flex; justify-content: center; flex-direction: column; @@ -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; + } +} \ No newline at end of file diff --git a/app/UserInterface/Domain/Homepage/Resources/sass/_recent_device.scss b/app/UserInterface/Domain/Homepage/Resources/sass/_recent_device.scss new file mode 100644 index 00000000..7cb7fc74 --- /dev/null +++ b/app/UserInterface/Domain/Homepage/Resources/sass/_recent_device.scss @@ -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); + } + } + } + } + } +} \ No newline at end of file diff --git a/app/UserInterface/Domain/Homepage/Resources/sass/_recent_trip.scss b/app/UserInterface/Domain/Homepage/Resources/sass/_recent_trip.scss new file mode 100644 index 00000000..5d5e1e40 --- /dev/null +++ b/app/UserInterface/Domain/Homepage/Resources/sass/_recent_trip.scss @@ -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; + } + } + } +} \ No newline at end of file diff --git a/app/UserInterface/Domain/Homepage/Resources/views/homepage.blade.php b/app/UserInterface/Domain/Homepage/Resources/views/homepage.blade.php index 03aac360..1213a7aa 100644 --- a/app/UserInterface/Domain/Homepage/Resources/views/homepage.blade.php +++ b/app/UserInterface/Domain/Homepage/Resources/views/homepage.blade.php @@ -2,18 +2,373 @@ @section('head') @vite('app/UserInterface/Domain/Homepage/Resources/sass/_homepage.scss') + @vite('app/UserInterface/Domain/Homepage/Resources/sass/_recent_device.scss') + @vite('app/UserInterface/Domain/Homepage/Resources/sass/_recent_trip.scss') @endsection @section('content')
{{$device->getLastActiveFormatted()}}
+- This page is under construction. Please check back later. -
+