Skip to content

Commit 05503ce

Browse files
authored
Merge pull request #202 from fleetbase/dev-v0.6.34
v0.6.34 ~ Several patches and improvements
2 parents 3743542 + fdc2c03 commit 05503ce

21 files changed

Lines changed: 245 additions & 154 deletions

File tree

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
11
import Component from '@glimmer/component';
2+
import { tracked } from '@glimmer/tracking';
3+
import { inject as service } from '@ember/service';
4+
import { task } from 'ember-concurrency-decorators';
25

3-
export default class OrderDetailsProofComponent extends Component {}
6+
export default class OrderDetailsProofComponent extends Component {
7+
@service fetch;
8+
@tracked proofs = [];
9+
10+
constructor(owner, { resource }) {
11+
super(...arguments);
12+
this.loadOrderProofs.perform(resource);
13+
}
14+
15+
@task *loadOrderProofs(order) {
16+
const proofs = yield this.fetch.get(`orders/${order.id}/proofs`);
17+
18+
this.proofs = proofs.map((proof) => ({
19+
...proof,
20+
type: this.#getTypeFromRemarks(proof.remarks),
21+
}));
22+
}
23+
24+
#getTypeFromRemarks(remarks = '') {
25+
if (remarks.endsWith('Photo')) return 'photo';
26+
if (remarks.endsWith('Scan')) return 'scan';
27+
if (remarks.endsWith('Signature')) return 'signature';
28+
return undefined;
29+
}
30+
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fleetbase/fleetops-api",
3-
"version": "0.6.33",
3+
"version": "0.6.34",
44
"description": "Fleet & Transport Management Extension for Fleetbase",
55
"keywords": [
66
"fleetbase-extension",

extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Fleet-Ops",
3-
"version": "0.6.33",
3+
"version": "0.6.34",
44
"description": "Fleet & Transport Management Extension for Fleetbase",
55
"repository": "https://github.com/fleetbase/fleetops",
66
"license": "AGPL-3.0-or-later",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fleetbase/fleetops-engine",
3-
"version": "0.6.33",
3+
"version": "0.6.34",
44
"description": "Fleet & Transport Management Extension for Fleetbase",
55
"fleetbase": {
66
"route": "fleet-ops"

server/src/Console/Commands/TestEmail.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TestEmail extends Command
3333
public function handle()
3434
{
3535
$email = $this->argument('email');
36-
$type = $this->option('type');
36+
$type = $this->option('type');
3737

3838
$this->info('Sending test email...');
3939
$this->info("Type: {$type}");
@@ -47,40 +47,40 @@ public function handle()
4747

4848
default:
4949
$this->error("Unknown email type: {$type}");
50+
5051
return Command::FAILURE;
5152
}
5253

5354
$this->info('✓ Test email sent successfully!');
55+
5456
return Command::SUCCESS;
5557
} catch (\Exception $e) {
5658
$this->error('Failed to send test email: ' . $e->getMessage());
59+
5760
return Command::FAILURE;
5861
}
5962
}
6063

6164
/**
6265
* Send a test customer credentials email.
63-
*
64-
* @param string $email
65-
* @return void
6666
*/
6767
private function sendCustomerCredentialsEmail(string $email): void
6868
{
6969
// Create a mock user
7070
$user = new User([
71-
'name' => 'Test Customer',
71+
'name' => 'Test Customer',
7272
'email' => $email,
7373
]);
7474

7575
// Create a mock company
7676
$company = new Company([
77-
'name' => 'Test Company',
77+
'name' => 'Test Company',
7878
'public_id' => 'test_company_123',
7979
]);
8080

8181
// Create a mock customer
8282
$customer = new Contact([
83-
'name' => 'Test Customer',
83+
'name' => 'Test Customer',
8484
'email' => $email,
8585
'phone' => '+1234567890',
8686
]);

server/src/Http/Controllers/Api/v1/ContactController.php

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Fleetbase\FleetOps\Http\Resources\v1\DeletedResource;
99
use Fleetbase\FleetOps\Models\Contact;
1010
use Fleetbase\Http\Controllers\Controller;
11-
use Fleetbase\Models\File;
1211
use Fleetbase\Models\User;
1312
use Fleetbase\Support\Utils;
1413
use Illuminate\Http\Request;
@@ -29,24 +28,13 @@ public function create(CreateContactRequest $request)
2928
$input['phone'] = is_string($input['phone']) ? Utils::formatPhoneNumber($input['phone']) : $input['phone'];
3029
$input['type'] = empty($input['type']) ? 'contact' : $input['type'];
3130

32-
// Handle photo as either file id/ or base64 data string
33-
$photo = $request->input('photo');
34-
if ($photo) {
35-
// Handle photo being a file id
36-
if (Utils::isPublicId($photo)) {
37-
$file = File::where('public_id', $photo)->first();
38-
if ($file) {
39-
$input['photo_uuid'] = $file->uuid;
40-
}
41-
}
31+
// Handle photo upload using FileResolverService
32+
if ($request->has('photo')) {
33+
$path = 'uploads/' . session('company') . '/contacts';
34+
$file = app(\Fleetbase\Services\FileResolverService::class)->resolve($request->input('photo'), $path);
4235

43-
// Handle the photo being base64 data string
44-
if (Utils::isBase64String($photo)) {
45-
$path = implode('/', ['uploads', session('company'), 'contacts']);
46-
$file = File::createFromBase64($photo, null, $path);
47-
if ($file) {
48-
$input['photo_uuid'] = $file->uuid;
49-
}
36+
if ($file) {
37+
$input['photo_uuid'] = $file->uuid;
5038
}
5139
}
5240

@@ -101,29 +89,20 @@ public function update($id, UpdateContactRequest $request)
10189
]);
10290
}
10391

104-
// Handle photo as either file id/ or base64 data string
105-
$photo = $request->input('photo');
106-
if ($photo) {
107-
// Handle photo being a file id
108-
if (Utils::isPublicId($photo)) {
109-
$file = File::where('public_id', $photo)->first();
110-
if ($file) {
111-
$input['photo_uuid'] = $file->uuid;
112-
}
113-
}
114-
115-
// Handle the photo being base64 data string
116-
if (Utils::isBase64String($photo)) {
117-
$path = implode('/', ['uploads', session('company'), 'customers']);
118-
$file = File::createFromBase64($photo, null, $path);
119-
if ($file) {
120-
$input['photo_uuid'] = $file->uuid;
121-
}
122-
}
92+
// Handle photo upload using FileResolverService
93+
if ($request->has('photo')) {
94+
$photo = $request->input('photo');
12395

12496
// Handle removal key
12597
if ($photo === 'REMOVE') {
12698
$input['photo_uuid'] = null;
99+
} else {
100+
$path = 'uploads/' . session('company') . '/contacts';
101+
$file = app(\Fleetbase\Services\FileResolverService::class)->resolve($photo, $path);
102+
103+
if ($file) {
104+
$input['photo_uuid'] = $file->uuid;
105+
}
127106
}
128107
}
129108

server/src/Http/Controllers/Api/v1/DriverController.php

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Fleetbase\LaravelMysqlSpatial\Types\Point;
2121
use Fleetbase\Models\Company;
2222
use Fleetbase\Models\CompanyUser;
23-
use Fleetbase\Models\File;
2423
use Fleetbase\Models\User;
2524
use Fleetbase\Models\UserDevice;
2625
use Fleetbase\Models\VerificationCode;
@@ -124,20 +123,10 @@ public function create(CreateDriverRequest $request)
124123
// create the driver
125124
$driver = Driver::create($input);
126125

127-
// Handle photo as either file id/ or base64 data string
128-
$photo = $request->input('photo');
129-
if ($photo) {
130-
$file = null;
131-
// Handle photo being a file id
132-
if (Utils::isPublicId($photo)) {
133-
$file = File::where('public_id', $photo)->first();
134-
}
135-
136-
// Handle the photo being base64 data string
137-
if (Utils::isBase64String($photo)) {
138-
$path = implode('/', ['uploads', session('company'), 'drivers']);
139-
$file = File::createFromBase64($photo, null, $path);
140-
}
126+
// Handle photo upload using FileResolverService
127+
if ($request->has('photo')) {
128+
$path = 'uploads/' . $company->uuid . '/drivers';
129+
$file = app(\Fleetbase\Services\FileResolverService::class)->resolve($request->input('photo'), $path);
141130

142131
if ($file) {
143132
$user->update(['photo_uuid' => $file->uuid]);
@@ -218,20 +207,10 @@ public function update($id, UpdateDriverRequest $request)
218207
$driver->update($input);
219208
$driver->flushAttributesCache();
220209

221-
// Handle photo as either file id/ or base64 data string
222-
$photo = $request->input('photo');
223-
if ($photo) {
224-
$file = null;
225-
// Handle photo being a file id
226-
if (Utils::isPublicId($photo)) {
227-
$file = File::where('public_id', $photo)->first();
228-
}
229-
230-
// Handle the photo being base64 data string
231-
if (Utils::isBase64String($photo)) {
232-
$path = implode('/', ['uploads', session('company'), 'drivers']);
233-
$file = File::createFromBase64($photo, null, $path);
234-
}
210+
// Handle photo upload using FileResolverService
211+
if ($request->has('photo')) {
212+
$path = 'uploads/' . session('company') . '/drivers';
213+
$file = app(\Fleetbase\Services\FileResolverService::class)->resolve($request->input('photo'), $path);
235214

236215
if ($file) {
237216
$driver->user->update(['photo_uuid' => $file->uuid]);

server/src/Http/Controllers/Api/v1/OrderController.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ public function update($id, UpdateOrderRequest $request)
352352

353353
// find for the order
354354
try {
355-
$order = Order::findRecordOrFail($id);
355+
$order = Order::findRecordOrFail($id, ['trackingNumber', 'driverAssigned', 'purchaseRate', 'customer', 'facilitator']);
356356
} catch (ModelNotFoundException $exception) {
357357
return response()->json(
358358
[
@@ -518,6 +518,9 @@ public function update($id, UpdateOrderRequest $request)
518518
$order->update($input);
519519
$order->flushAttributesCache();
520520

521+
// load required relations
522+
$order->load(['trackingNumber', 'driverAssigned', 'purchaseRate', 'customer', 'facilitator']);
523+
521524
// response the order resource
522525
return new OrderResource($order);
523526
}
@@ -725,7 +728,7 @@ public function find($id, Request $request)
725728
{
726729
// find for the order
727730
try {
728-
$order = Order::findRecordOrFail($id);
731+
$order = Order::findRecordOrFail($id, ['trackingNumber', 'driverAssigned', 'purchaseRate', 'customer', 'facilitator']);
729732
} catch (ModelNotFoundException $exception) {
730733
return response()->json(
731734
[
@@ -805,7 +808,7 @@ public function getDistanceMatrix(string $id)
805808
public function dispatchOrder(string $id)
806809
{
807810
try {
808-
$order = Order::findRecordOrFail($id);
811+
$order = Order::findRecordOrFail($id, ['trackingNumber', 'driverAssigned', 'purchaseRate', 'customer', 'facilitator']);
809812
} catch (ModelNotFoundException $exception) {
810813
return response()->json(
811814
[
@@ -887,7 +890,7 @@ public function startOrder(string $id, Request $request)
887890
$assignAdhocDriver = $request->input('assign');
888891

889892
try {
890-
$order = Order::findRecordOrFail($id, ['payload.waypoints'], []);
893+
$order = Order::findRecordOrFail($id, ['payload.waypoints', 'driverAssigned'], []);
891894
} catch (ModelNotFoundException $exception) {
892895
return response()->json(
893896
[
@@ -1220,14 +1223,11 @@ public function cancelOrder(string $id)
12201223
public function setDestination(string $id, string $placeId)
12211224
{
12221225
try {
1223-
$order = Order::findRecordOrFail($id);
1226+
$order = Order::findRecordOrFail($id, ['payload.waypoints', 'payload.pickup', 'payload.dropoff', 'driverAssigned']);
12241227
} catch (ModelNotFoundException $exception) {
12251228
return response()->apiError('Order resource not found.', 404);
12261229
}
12271230

1228-
// Load required relations
1229-
$order->loadMissing(['payload.waypoints', 'payload.pickup', 'payload.dropoff']);
1230-
12311231
// Get the order payload
12321232
$payload = $order->payload;
12331233

server/src/Http/Controllers/Api/v1/VehicleController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function create(CreateVehicleRequest $request)
2727
{
2828
// get request input
2929
$input = $request->only(['status', 'make', 'model', 'year', 'trim', 'type', 'plate_number', 'vin', 'meta', 'online', 'location', 'altitude', 'heading', 'speed']);
30-
30+
3131
// make sure company is set
3232
$input['company_uuid'] = session('company');
3333

server/src/Http/Controllers/Internal/v1/DriverController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function (&$request, &$input) {
136136

137137
if ($input->has('user_uuid')) {
138138
$user = User::where('uuid', $input->get('user_uuid'))->first();
139-
139+
140140
// If user doesn't exist with provided UUID, create new user
141141
if (!$user) {
142142
$userInput = $input

0 commit comments

Comments
 (0)