Migrate source code from personal account to CIEF's (round 2)

This commit is contained in:
Dillon
2023-08-24 06:57:51 +08:00
parent ccf9c5c688
commit 9599fae91c
25 changed files with 387 additions and 60 deletions
+16
View File
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [{
"name": "Listen for XDebug on Docker",
"type": "php",
"request": "launch",
"port": 9002,
"pathMappings": {
"/var/www/html": "${workspaceFolder}",
},
"log": true
}]
}
Vendored
+49
View File
@@ -0,0 +1,49 @@
// Webhook + Gitlab git pull + Vapor
def payload = readJSON text: "${payload}"
String userName = payload.user_name
String userEmail = payload.user_email
String httpUrl = payload.project.http_url
pipeline {
agent {
docker {
image 'dillonngo/docker-based-image:poc'
args "--group-add 992 -v /var/run/docker.sock:/var/run/docker.sock"
}
}
environment {
HOME = '.'
}
stages {
stage('Download source code from Git') {
steps {
git(
url: httpUrl,
credentialsId: 'gitlab-jenkins-localhost',
branch: 'dillon/jenkins-aws-s3-34'
)
}
}
stage('Install') {
steps {
sh 'composer update'
}
}
stage('Tests') {
steps {
sh 'vendor/bin/phpunit tests/Unit'
}
}
stage('Deploy') {
steps {
sh 'vendor/bin/vapor deploy production --message="Test Jenkins"'
}
}
}
}
@@ -123,7 +123,7 @@ class CreateCustomerLogic extends AbstractControllerLogic
CreatePerfexCRMCustomer::dispatch($createLeadPerfexCRMObject);
}
$this->generateEmailVerificationAttemptProcessor->execute($user);
// $this->generateEmailVerificationAttemptProcessor->execute($user); //cief todo
return $this->response($this->authenticationProcessor->execute($request));
@@ -54,11 +54,17 @@ class RenderDocumentLogic extends AbstractControllerLogic
$this->canRenderDocument->passes();
if(!Storage::disk('documents')->exists($file))
// if(!Storage::disk('documents')->exists($file))
// {
// throw new ResourceNotFoundException();
// }
// return $this->response(['src' => explode('.', $file)[1] == 'pdf' ? chunk_split(base64_encode(Storage::disk('documents')->get($file))) : Storage::disk('documents')->get($file) ]);
if(!Storage::disk('s3')->exists($file))
{
throw new ResourceNotFoundException();
}
return $this->response(['src' => explode('.', $file)[1] == 'pdf' ? chunk_split(base64_encode(Storage::disk('documents')->get($file))) : Storage::disk('documents')->get($file) ]);
}
}
}
@@ -99,12 +99,15 @@ class ConvertsBase64ToFile
*/
private function generateFile(FileObject $file, string $suffix = '') {
$filePath = $this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension();
// $filePath = $this->path.'/'.$file->getFileName().$suffix.'.'.$file->getExtension();
Storage::disk('documents')->put($filePath, $file->getDecodedData());
// Storage::disk('documents')->put($filePath, $file->getDecodedData());
// return $filePath;
$filePath = 'localhost/'.$file->getFileName().$suffix.'.'.$file->getExtension();
Storage::put($filePath, $file->getDecodedData(), 's3');
return $filePath;
}
/**
@@ -122,4 +125,4 @@ class ConvertsBase64ToFile
]);
}
}
}
@@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers\AWS;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Response;
class AWSImageUploadController extends Controller
{
public function imageUpload()
{
return view('pages.aws_image_upload');
}
public function imageUploadPost(Request $request)
{
$request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
]);
$imageName = time().'.'.$request->image->extension();
$request->image->storeAs('images', $imageName);
//cief todo: checking if storage disk exist
if (Storage::disk('documents')) {
$check1 = "The disk documents exists.";
} else {
$check1 = "The disk documents does not exist.";
}
// $diskNames = Storage::diskNames();
// if (count($diskNames) > 0) {
// $check2 = "The following disks are configured: " . implode(', ', $diskNames);
// } else {
// $check2 = "No storage disks are configured.";
// }
if (Storage::disk('public')) {
$check2 = "The disk public exists.";
} else {
$check2 = "The disk public does not exist.";
}
if (Storage::disk('local')) {
$check3 = "The disk local exists.";
} else {
$check3 = "The disk local does not exist.";
}
return redirect()->back()
->with('success','You have successfully upload image.')
->with('image',$imageName)
->with('check1', $check1)
->with('check2', $check2)
->with('check3', $check3);
}
public function displayImage($fileName)
{
// dd($fileName);
//1.
// $path = 'images/'.$fileName;
// $url = Storage::url($path);
// $url = Storage::temporaryUrl('file.jpg', now()->addMinutes(5));
// return $url;
//2
// $path = 'images/'.$fileName;
// // if(Storage::disk('s3')->exists($path)){
// return Storage::disk('s3')->get($path);
// // }
// return null;
//original
$path = 'images/'.$fileName;
$file = Storage::get($path);
$type = Storage::mimeType($path);
$response = Response::make($file, 200);
$response->header("Content-Type", $type);
return $response;
// $path = 'images/'.$fileName;
// return Storage::temporaryUrl($path, now()->addMinutes(5));
}
}
+3 -1
View File
@@ -24,6 +24,8 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot()
{
//
if (!file_exists(storage_path('framework/sessions'))) {
mkdir(storage_path('framework/sessions'), 0777, true);
}
}
}
+14 -1
View File
@@ -2,6 +2,8 @@ FROM php:7.4-fpm
WORKDIR /var/www/html
RUN pecl install xdebug-2.9.8 && docker-php-ext-enable xdebug
RUN docker-php-ext-install pdo pdo_mysql
RUN apt-get update && apt-get install -y \
@@ -25,4 +27,15 @@ RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get -y install nodejs
RUN chown -R www-data:www-data /var/www
RUN chmod 755 /var/www
RUN chmod 755 /var/www
# Configure xdebug
RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_port=9002" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.idekey=VSCODE" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
# Moved to docker-setup folder
# RUN echo 'pm.max_children = 15' >> /usr/local/etc/php-fpm.d/zz-docker.conf && \
# echo 'pm.max_requests = 500' >> /usr/local/etc/php-fpm.d/zz-docker.conf
+1
View File
@@ -44,6 +44,7 @@ services:
container_name: exchange-php
volumes:
- ../:/var/www/html
- ./php/default.conf:/usr/local/etc/php-fpm.d/zz-docker.conf
ports:
- "9002:9000"
networks:
+7
View File
@@ -23,6 +23,13 @@ server {
fastcgi_intercept_errors on;
fastcgi_keep_conn on;
fastcgi_param PHP_VALUE "auto_prepend_file= \n allow_url_include=Off";
# Xdebug configuration
# fastcgi_param XDEBUG_MODE debug;
# fastcgi_param XDEBUG_CLIENT_HOST host.docker.internal;
# fastcgi_param XDEBUG_CLIENT_PORT 9002;
# fastcgi_param XDEBUG_IDE_KEY VSCODE;
proxy_send_timeout 3600;
proxy_read_timeout 3600;
fastcgi_send_timeout 3600;
+8
View File
@@ -0,0 +1,8 @@
[global]
daemonize = no
[www]
listen = 9000
pm.max_children = 15
pm.max_requests = 500
+1
View File
@@ -22,6 +22,7 @@
"jquery": "^3.2",
"jquery.scrollbar": "^0.2.11",
"jwt-decode": "^3.1.2",
"laravel-vapor": "^0.6.0",
"noty": "^3.2.0-beta",
"perfect-scrollbar": "^1.5.0",
"popper.js": "^1.12",
+6 -1
View File
@@ -28,6 +28,10 @@ import { debounce } from 'vue-debounce'
import Avatar from 'vue-avatar';
import Vapor from 'laravel-vapor';
// Vapor.withBaseAssetUrl(import.meta.env.VITE_VAPOR_ASSET_URL);
window.Vapor = Vapor;
/** Application Injections */
Vue.use(vuelidate);
Vue.use(VueTheMask);
@@ -36,7 +40,8 @@ Vue.use(filters);
Vue.directive('closable', closable);
Vue.mixin({
methods: {
route: route
route: route,
asset: window.Vapor.asset
},
mixins: [request, crudHandler]
});
@@ -13,7 +13,7 @@
<div class="col-12 col-lg-5 padding-25 d-none d-md-inline">
<div class="row h-100 align-items-end">
<div class="col no-padding">
<img src="/images/2829248.png" class="w-100">
<img :src="asset('images/2829248.png')" class="w-100">
</div>
</div>
</div>
@@ -98,4 +98,4 @@
},
mixins: [componentHandler]
}
</script>
</script>
@@ -5,7 +5,7 @@
<div class="col bg-white padding-15">
<div class="row">
<div class="col-4">
<img class="m-b-10 w-100" src="/images/1688_approved.png" />
<img class="m-b-10 w-100" :src="asset('images/1688_approved.png')" />
</div>
<div class="col"></div>
<div class="col-4">
+6 -1
View File
@@ -7,8 +7,13 @@ export default {
let encodedParams = queryParams.toString();
let filteredEncodedParams = encodedParams.replace(/%3D/g,'=');
filteredEncodedParams = filteredEncodedParams.replace(/%26/g,'&');
console.log('filteredEncodedParams: ', filteredEncodedParams);
console.log('filteredEncodedParams: ', filteredEncodedParams);
console.log('queryDomain: ', queryDomain);
let combinedAbsoluteUrl = queryDomain;
if(filteredEncodedParams !== undefined && filteredEncodedParams !== 'undefined'){
combinedAbsoluteUrl = queryDomain + '?' + filteredEncodedParams;
console.log('combinedAbsoluteUrl: ', combinedAbsoluteUrl);
}
return fetch(queryDomain + '?' + filteredEncodedParams, {
method: method,
responseType: 'json',
@@ -0,0 +1,23 @@
<!doctype html>
<html lang="en">
<head>
@include('vendor/head')
</head>
<style>
.grecaptcha-badge {
visibility: hidden;
}
</style>
<body class="horizontal-menu horizontal-app-menu bg-master-lightest overflow-hidden">
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TQKCPCD"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<div id="app" style="min-height: 100%;">
<div id="grecaptcha_container"></div>
@yield('content')
</div>
@include('vendor/js')
@stack('scripts')
</body>
</html>
@@ -0,0 +1,26 @@
@extends('layouts.base_debug')
@section('content')
<div class="row d-md-none" style="display: none;" v-show="$store.getters.isShowing('sideMenu')" >
<div class="col absolute bg-master w-100 h-100" style="opacity: 0.3; z-index: 9998; left: 0px;"></div>
<div class="col-8 bg-master-lightest position-fixed h-100" style="z-index: 9999" >
@include('partials.menu')
</div>
</div>
@include('partials.header')
<div class="page-container">
<div class="page-content-wrapper p-b-50" style="padding-top: 70px;">
<div class="content pt-md-auto pt-4">
<div class="container-fluid p-0 px-sm-5 container-fixed-lg">
<div class="row no-margin">
<div class="col">
@yield('inner_content')
</div>
</div>
</div>
</div>
@include('partials.footer')
</div>
</div>
@endsection
@@ -0,0 +1,45 @@
@extends('layouts.base_portal')
@section('inner_content')
<div class="container">
<div class="panel panel-primary">
<div class="panel-body">
<p>Session: {{ session('image') }}</p>
<p>check1: {{ session('check1') }}</p>
<p>check2: {{ session('check2') }}</p>
<p>check3: {{ session('check3') }}</p>
@if ($message = session('success'))
<div class="alert alert-success alert-block">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>{{ $message }}</strong>
</div>
<img src="{{ route('aws.image.displayImage', session('image')) }}" style="width: 400px">
@endif
@if (count($errors) > 0)
<div class="alert alert-danger">
<strong>Whoops!</strong> There were some problems with your input.
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form action="{{ route('aws.image.upload.post') }}" method="POST" enctype="multipart/form-data">
@csrf
<div class="row">
<div class="col-md-6">
<input type="file" name="image" class="form-control">
</div>
<div class="col-md-6">
<button type="submit" class="btn btn-success">Upload</button>
</div>
</div>
</form>
</div>
</div>
</div>
@endsection
+11 -19
View File
@@ -100,32 +100,24 @@
<billing-document-component :data="data"></billing-document-component>
</template>
</list-component>
</div>
<div class="row tabsContainer tabContent m-l-0 m-r-0 hide" tab-name="purchase-order">
</div>
<div class="row tabsContainer tabContent m-l-0 m-r-0 hide" tab-name="purchase-order">
<list-component key="2" section="purchaseOrderSection" :endpoint="route('api.document.list')" :options="{'per_page': 30, 'with_owner': true, 'document_type_in': ['PURCHASE_ORDER']}">
<template slot="list" slot-scope="{data}">
<billing-document-component :data="data"></billing-document-component>
</template>
</list-component>
</div>
<div class="row tabsContainer tabContent m-l-0 m-r-0 hide" tab-name="delivery-order">
<list-component key="2" section="deliveryOrderSection" :endpoint="route('api.document.list')" :options="{'per_page': 30, 'with_owner': true, 'document_type_in': ['DELIVER_ORDER']}">
<template slot="list" slot-scope="{data}">
<billing-document-component :data="data"></billing-document-component>
</template>
</list-component>
</div>
<div class="row tabsContainer tabContent m-l-0 m-r-0 hide" tab-name="supplier-delivery-order">
<list-component key="2" section="SupplierDeliveryOrderSection" :endpoint="route('api.document.list')" :options="{'per_page': 30, 'with_owner': true, 'document_type_in': ['SUPPLIER_DELIVER_ORDER']}">
<template slot="list" slot-scope="{data}">
<billing-document-component :data="data"></billing-document-component>
</template>
</list-component>
</div>
</div>
</div>
<div class="row tabsContainer tabContent m-l-0 m-r-0 hide" tab-name="delivery-order">
</div>
<div class="row tabsContainer tabContent m-l-0 m-r-0 hide" tab-name="supplier-delivery-order">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@endsection
+2 -2
View File
@@ -3,9 +3,9 @@
<div class="container-fluid">
<div class="row no-margin">
<div class="col p-l-0 p-t-20 p-b-20 sm-text-center">
<small class="small no-margin pull-left sm-pull-reset all-caps fs-10 muted" style=" letter-spacing: 1px; ">Copyright © {{ date('Y') }} CIEF Exchange. All rights reserved.</small>
<small class="small no-margin pull-left sm-pull-reset all-caps fs-10 muted" style=" letter-spacing: 1px; ">Copyright © {{ date('Y') }} CIEF Exchange. All rights reserved. Powered by Laravel Vapor.</small>
</div>
</div>
</div>
</div>
<!-- END COPYRIGHT -->
<!-- END COPYRIGHT -->
+2 -1
View File
@@ -8,7 +8,8 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani
Route::post('/create', 'CreateCompanyController@create')->name('create');
Route::put('/update/{id}', 'UpdateCompanyController@update')->name('update');
Route::put('update/{id}/status', 'UpdateCompanyStatusController@update')->name('status.update');
Route::delete('/delete/{id}', 'DeleteCompanyController@destroy')->name('delete');
// Route::delete('/delete/{id}', 'DeleteCompanyController@destroy')->name('delete');
Route::delete('/delete/{id}', 'DeleteCompanyController@destroy')->name('destroy');
Route::put('/name-and-debtor/update/{id}', 'UpdateCompanyNameAndDebtorController@update')->name('update.nameAndDebtor');
Route::put('/update/debtor/{id}', 'UpdateCompanyDebtorController@update')->name('delete');
+1 -1
View File
@@ -1,4 +1,4 @@
<?php
<?php
use Illuminate\Support\Facades\Route;
+33 -21
View File
@@ -113,7 +113,7 @@ Route::get('/support', function () {
'company' => null,
'booking' => null
]);
})->name('support');
})->name('support.fetch'); //duplicate name
Route::post('/support', function (Request $request) {
@@ -147,7 +147,7 @@ Route::post('/support', function (Request $request) {
'booking' => $booking,
]);
})->name('support');
})->name('support'); //duplicate name
Route::get('/online_payment/redirect', 'Billplz\CallbackBillplzController@callback')->name('online_payment.redirect');
@@ -159,7 +159,7 @@ Route::get('/export/customers/leads', 'Exports\ExportCustomersToExcelController@
Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsProducts $exportsProducts) {
return $exportsProducts->download('products.csv', Excel::CSV, ['Content-Type' => 'text/csv']);
})->name('products.random');
})->name('products.random.1'); //duplicate name
Route::get('/fix_bills', function () {
ini_set('max_execution_time', '1000000');
@@ -188,7 +188,7 @@ Route::get('/fix_bills', function () {
}
})->name('products.random');
})->name('products.random.2'); //duplicate name
Route::get('/wallet/{marking}/details', function ($marking) {
$id = \App\Models\Company::where('reference', '=', $marking)->first()->id;
@@ -226,7 +226,7 @@ Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsP
})->get();
dd($bookings->count());
return $exportsProducts->download('products.csv', Excel::CSV, ['Content-Type' => 'text/csv']);
})->name('products.random');
})->name('products.random.3');
Route::get('/auto-purchase-order-fill', 'Bookings\AutoPurchaseOrderFillController@auto')->name('assign');
@@ -467,24 +467,24 @@ Route::get('/1688/fix/{reference}', function($reference){
//
// (App()->make(createPurchaseOrderFor1688OrderProcessor::class))->execute($document->owner);
// }
})->name('ecommerce.fix');
})->name('ecommerce.fix'); //duplicate name
Route::get('/po/manual/fix', function(){
// Route::get('/po/manual/fix', function(){
// $bookings = Booking::whereIn('company_id', [199, 510])->whereHas('documents', function($query){
// return $query->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER);
// })->get();
//
// foreach ($bookings as $booking){
// $booking->status = ApprovalStatus::APPROVED;
// $booking->save();
//
// $booking->documents()->whereIn('document_type', [DocumentType::PURCHASE_ORDER, DocumentType::DELIVER_ORDER, DocumentType::INVOICE, DocumentType::SUPPLIER_DELIVER_ORDER])->delete();
// $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->update(['status' => ApprovalStatus::PENDING_SUBMISSION]);
//
// }
// // $bookings = Booking::whereIn('company_id', [199, 510])->whereHas('documents', function($query){
// // return $query->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER);
// // })->get();
// //
// // foreach ($bookings as $booking){
// // $booking->status = ApprovalStatus::APPROVED;
// // $booking->save();
// //
// // $booking->documents()->whereIn('document_type', [DocumentType::PURCHASE_ORDER, DocumentType::DELIVER_ORDER, DocumentType::INVOICE, DocumentType::SUPPLIER_DELIVER_ORDER])->delete();
// // $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->update(['status' => ApprovalStatus::PENDING_SUBMISSION]);
// //
// // }
})->name('ecommerce.fix');
// })->name('ecommerce.fix'); //duplicate name
Route::get('/payment/check', function(){
@@ -600,4 +600,16 @@ Route::get('/po/outsource/check', function(){
Route::get('/upload-honey-trap', function () {
return view('pages.honey_trap');
})->name('upload_honey_trap');
})->name('upload_honey_trap');
Route::get('/aws-image-upload', 'AWS\AWSImageUploadController@imageUpload')->name('aws.image.upload');
Route::post('/aws-image-upload', 'AWS\AWSImageUploadController@imageUploadPost')->name('aws.image.upload.post');
Route::get('/aws-image/{filename}', 'AWS\AWSImageUploadController@displayImage')->name('aws.image.displayImage');
Route::get('/token', function (Request $request) {
$token = $request->session()->token();
echo $token;
$token = csrf_token();
echo $token;
});
+12 -2
View File
@@ -1,18 +1,28 @@
id: 46771
id: 48019
name: vapor-laravel-poc
separate-vendor: true
environments:
production:
domain: staging.izyim.com
memory: 1024
cli-memory: 512
database: vapor-laravel-poc-db
storage: exchange-2.0-replica
# gateway-version: 2
# cache: vapor-laravel-poc-cache
runtime: 'docker'
timeout: 600
timeout: 180
build:
- 'composer update'
- 'npm install'
- 'npm run dev'
- 'gulp build'
# - 'rm -rf node_modules'
# - 'php artisan optimize'
# # - 'php artisan config:clear'
# - 'php artisan key:generate'
# - 'php artisan config:cache'
# - 'php artisan route:cache'
# - 'php artisan view:cache'
deploy:
- 'php artisan migrate --force'