Experimental solution (Vue Polling) to solve an AWS API Gateway problem limitation for Laravel Vapor in the event of a emergency rollback to Google

This commit is contained in:
Dillon Ngo
2024-01-21 10:31:39 +08:00
parent 33d2d02cb0
commit 9b9057ea81
6 changed files with 292 additions and 5 deletions
@@ -32,10 +32,12 @@ class ListPackingListJobResource extends JsonResource
'transport' => new TransportResource($this->transports()->first()),
'type' => $this->type,
'receive_packing_list' => $this->when($this->type === PackingListType::SHIPPING_PACKING_LIST, new PackingListV2Resource(PackingList::where('reference', $this->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->first(), $this->userInfo)),
'packages' => PackageResource::collection($packages),
$this->mergeWhen($this->owner instanceof Order, [
'order' => New OrderResource($this->owner)
]),
// 'packages' => PackageResource::collection($packages),
// $this->mergeWhen($this->owner instanceof Order, [
// 'order' => New OrderResource($this->owner)
// ]),
'packages' => PackageWithoutOrderResource::collection($packages),
$this->mergeWhen($this->owner instanceof Order, [ 'order' => New OrderResource($this->owner) ]),
'shipping_transaction' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first()),
'suspended_invoice' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->first()),
// 'suspended_invoices' => TransactionResource::collection($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->get()),
@@ -0,0 +1,41 @@
<?php
namespace App\Http\Resources;
use App\Models\Order;
use App\Models\PackingList;
use Illuminate\Http\Resources\Json\JsonResource;
class PackageWithoutOrderResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
$originalPackingList = $this->packingList->owner instanceof PackingList ? $this->packingList->owner : $this->packingList;
return [
'id' => $this->id,
'type' => $this->type,
'description' => $this->description,
'width' => floatval($this->width),
'height' => floatval($this->height),
'length' => floatval($this->length),
'weight' => $this->weight,
'quantity' => $this->quantity,
'cbm' => (($this->width / 100) * ($this->height / 100) * ($this->length / 100)) * $this->quantity,
'reference' => $this->packingList->reference,
'status' => $this->status,
// $this->mergeWhen($originalPackingList->owner instanceof Order, [
// 'order' => New OrderResource($originalPackingList->owner)
// ]),
'container' => new ContainerResource($originalPackingList->containers()->first()),
'transport' => new TransportResource($originalPackingList->transports()->first())
];
}
}
@@ -0,0 +1,90 @@
<template>
<div class="row m-t-20" @keyup.enter="search">
<div class="col">
<div class="row">
<div class="col-12 col-md">
<div class="row m-b-15">
<div class="col">
<div class="row">
<div class="col p-r-0">
<div class="form-group no-margin form-group-default b-rad-none">
<label class="text-primary">Order Number Like</label>
<input type="text" class="form-control" v-model="marking" />
</div>
</div>
</div>
</div>
<div class="col-auto p-l-0 p-r-0">
<div class="btn btn-primary b-rad-none" @click="search">
<i class="fa fa-search lh-40"></i>
</div>
</div>
<div class="col-auto p-l-0">
<div class="btn btn-secondary b-rad-none" @click="reset">
<i class="fa fa-remove lh-40"></i>
</div>
</div>
</div>
</div>
<div class="col-12 col-md">
<div class="row" v-if="with_export">
<div class="col">
<download-billing-with-dates-component :section="section"></download-billing-with-dates-component>
</div>
</div>
</div>
</div>
<!-- CIEF TODO: For easy revert to old code -->
<!-- <list-component :key="currentKey" :section="section" :endpoint="route('api.packing_list.list')" :options="options">
<template slot="list" slot-scope="{data}">
<admin-payments-billing-component :data="data" :invoice_status="invoice_status" :section="section" ></admin-payments-billing-component>
</template>
</list-component> -->
<list-polling-component :key="currentKey" :section="section" :endpoint="route('api.packing_list.list.job')" :options="options">
<template slot="list" slot-scope="{data}">
<admin-payments-billing-component :data="data" :invoice_status="invoice_status" :section="section" ></admin-payments-billing-component>
</template>
</list-polling-component>
</div>
</div>
</template>
<script>
export default {
props: {
invoice_status: {
type: String,
required: true
},
options: {
default () {
return {}
}
},
section:{
type: String,
required: true
},
with_export:{
type: Boolean,
default: false
}
},
data(){
return {
marking: '',
currentKey: 1,
}
},
methods: {
search() {
this.options['order_marking_in'] = this.marking;
this.currentKey+=1;
},
reset() {
this.marking = '';
delete(this.options['order_marking_in']);
this.currentKey+=1;
},
},
}
</script>
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
@extends('layouts.base_portal')
@section('inner_content')
<div class="row">
<div class="col">
<admin-payments-billing-polling-section-component></admin-payments-billing-polling-section-component>
</div>
</div>
@endsection
+6 -1
View File
@@ -1247,4 +1247,9 @@ Route::get('fix-payment-status-updated-but-failed-update-invoice', function (Upd
echo 'done fix ' . $invoice->owner->owner->reference . '<br>';
}
}
});
});
//A page to monitor Experimental solution (Vue Polling) to solve an AWS API Gateway problem limitation for Laravel Vapor in the event of a emergency rollback to Google
Route::get('/payment-and-billing-2', function () {
return view('pages.paymentAndBilling2');
})->name('admin.payment-and-billing-2');