mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-23 06:24:03 +00:00
Laravel Vapor - Export pdf file through S3 bucket (sync code for bug solved at shipping portal)
This commit is contained in:
+11
-8
@@ -128,15 +128,18 @@
|
||||
const url = this.route('importedInvoiceMapped.export')+'?date='+arrDateTime[0]+'&time='+arrDateTime[1]+'&fileName='+fileName;
|
||||
|
||||
if(window.LARAVEL_VAPOR_ENABLED){
|
||||
return fetch(url, {
|
||||
method: 'GET',
|
||||
responseType: 'json',
|
||||
}).then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
this.$store.dispatch('crudRequest', {endpoint: url, method: 'get'})
|
||||
.then(response =>
|
||||
{
|
||||
let success = response.ok;
|
||||
response.json().then(response => {
|
||||
if(!success){return;}
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
else{
|
||||
window.open(url, '_blank');
|
||||
|
||||
+11
-8
@@ -132,15 +132,18 @@
|
||||
const url = this.route('importedReceiptMapped.export')+'?date='+arrDateTime[0]+'&time='+arrDateTime[1]+'&fileName='+fileName;
|
||||
|
||||
if(window.LARAVEL_VAPOR_ENABLED){
|
||||
return fetch(url, {
|
||||
method: 'GET',
|
||||
responseType: 'json',
|
||||
}).then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
this.$store.dispatch('crudRequest', {endpoint: url, method: 'get'})
|
||||
.then(response =>
|
||||
{
|
||||
let success = response.ok;
|
||||
response.json().then(response => {
|
||||
if(!success){return;}
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
else{
|
||||
window.open(url, '_blank');
|
||||
|
||||
+22
-16
@@ -274,15 +274,18 @@ export default {
|
||||
}
|
||||
|
||||
if(window.LARAVEL_VAPOR_ENABLED){
|
||||
return fetch(route, {
|
||||
method: 'GET',
|
||||
responseType: 'json',
|
||||
}).then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
this.$store.dispatch('crudRequest', {endpoint: route, method: 'get'})
|
||||
.then(response =>
|
||||
{
|
||||
let success = response.ok;
|
||||
response.json().then(response => {
|
||||
if(!success){return;}
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
else{
|
||||
window.open(route, '_blank');
|
||||
@@ -299,15 +302,18 @@ export default {
|
||||
}
|
||||
|
||||
if(window.LARAVEL_VAPOR_ENABLED){
|
||||
return fetch(route, {
|
||||
method: 'GET',
|
||||
responseType: 'json',
|
||||
}).then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
this.$store.dispatch('crudRequest', {endpoint: url, method: 'get'})
|
||||
.then(response =>
|
||||
{
|
||||
let success = response.ok;
|
||||
response.json().then(response => {
|
||||
if(!success){return;}
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
else{
|
||||
window.open(route, '_blank');
|
||||
|
||||
+11
-8
@@ -123,15 +123,18 @@ export default {
|
||||
downloadTransaction(paramItem) {
|
||||
let url = this.route('transaction.credit_note.download', paramItem.id);
|
||||
if(window.LARAVEL_VAPOR_ENABLED){
|
||||
return fetch(url, {
|
||||
method: 'GET',
|
||||
responseType: 'json',
|
||||
}).then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
this.$store.dispatch('crudRequest', {endpoint: url, method: 'get'})
|
||||
.then(response =>
|
||||
{
|
||||
let success = response.ok;
|
||||
response.json().then(response => {
|
||||
if(!success){return;}
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
else{
|
||||
window.open(url, '_blank');
|
||||
|
||||
@@ -74,15 +74,18 @@
|
||||
downloadReport(){
|
||||
let route = route('newDebtor.export');
|
||||
if(window.LARAVEL_VAPOR_ENABLED){
|
||||
return fetch(route, {
|
||||
method: 'GET',
|
||||
responseType: 'json',
|
||||
}).then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
this.$store.dispatch('crudRequest', {endpoint: route, method: 'get'})
|
||||
.then(response =>
|
||||
{
|
||||
let success = response.ok;
|
||||
response.json().then(response => {
|
||||
if(!success){return;}
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
else{
|
||||
window.open(route, '_blank');
|
||||
|
||||
@@ -152,15 +152,18 @@
|
||||
|
||||
let url = this.route('whiteForm.mockUp', this.supplier.id)+'?rate='+this.parameters.rate+'&payments='+JSON.stringify(paymentIds);
|
||||
if(window.LARAVEL_VAPOR_ENABLED){
|
||||
return fetch(url, {
|
||||
method: 'GET',
|
||||
responseType: 'json',
|
||||
}).then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
this.$store.dispatch('crudRequest', {endpoint: url, method: 'get'})
|
||||
.then(response =>
|
||||
{
|
||||
let success = response.ok;
|
||||
response.json().then(response => {
|
||||
if(!success){return;}
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
else{
|
||||
window.open(url, '_blank');
|
||||
|
||||
+11
-8
@@ -126,15 +126,18 @@ export default {
|
||||
download(company, paramShowingPreciseAmount) {
|
||||
let url = this.route('wallet.details-export', company.reference, paramShowingPreciseAmount);
|
||||
if(window.LARAVEL_VAPOR_ENABLED){
|
||||
return fetch(url, {
|
||||
method: 'GET',
|
||||
responseType: 'json',
|
||||
}).then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
this.$store.dispatch('crudRequest', {endpoint: url, method: 'get'})
|
||||
.then(response =>
|
||||
{
|
||||
let success = response.ok;
|
||||
response.json().then(response => {
|
||||
if(!success){return;}
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
else{
|
||||
window.open(url, '_blank');
|
||||
|
||||
+11
-8
@@ -32,15 +32,18 @@
|
||||
downloadTransaction(paramItem) {
|
||||
let url = this.route('transaction.credit_note.download', paramItem.id);
|
||||
if(window.LARAVEL_VAPOR_ENABLED){
|
||||
return fetch(url, {
|
||||
method: 'GET',
|
||||
responseType: 'json',
|
||||
}).then(response => response.json())
|
||||
.then(response => {
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
this.$store.dispatch('crudRequest', {endpoint: url, method: 'get'})
|
||||
.then(response =>
|
||||
{
|
||||
let success = response.ok;
|
||||
response.json().then(response => {
|
||||
if(!success){return;}
|
||||
if (response.src) {
|
||||
window.location.href = response.src;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
else{
|
||||
window.open(url, '_blank');
|
||||
|
||||
+16
-1
@@ -6,10 +6,12 @@ export default {
|
||||
return dispatch('ensureReCaptchaIsSet').then(function () {
|
||||
let combinedAbsoluteUrl = endpoint;
|
||||
if(window.LARAVEL_VAPOR_ENABLED){
|
||||
const queryDomain = endpoint.split('?')[0];
|
||||
let queryDomain = endpoint.split('?')[0];
|
||||
let encodedParams = endpoint.split('?')[1];
|
||||
let decodedParams = fullyDecodeURI(encodedParams);
|
||||
const queryParams = encodeURIComponent(decodedParams);
|
||||
queryDomain = encodeUrlWithoutQueryParameter(queryDomain)
|
||||
console.log("queryDomain: " + queryDomain);
|
||||
encodedParams = queryParams.toString();
|
||||
let filteredEncodedParams = encodedParams.replace(/%3D/g,'=');
|
||||
filteredEncodedParams = filteredEncodedParams.replace(/%26/g,'&');
|
||||
@@ -53,3 +55,16 @@ function fullyDecodeURI(uri){
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
function encodeUrlWithoutQueryParameter(url){
|
||||
let regex = /\[\d+\]/;
|
||||
let match = url.match(regex);
|
||||
|
||||
if (match) {
|
||||
let encodedPattern = encodeURIComponent(match[0]);
|
||||
let encodedUrl = url.replace(match[0], encodedPattern);
|
||||
return encodedUrl;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
+16
-1
@@ -2,10 +2,12 @@ export default {
|
||||
actions: {
|
||||
crudRequestV2({getters, dispatch}, {endpoint, method, parameters}){
|
||||
return dispatch('ensureReCaptchaIsSet').then(function () {
|
||||
const queryDomain = endpoint.split('?')[0];
|
||||
let queryDomain = endpoint.split('?')[0];
|
||||
let encodedParams = endpoint.split('?')[1];
|
||||
let decodedParams = fullyDecodeURI(encodedParams);
|
||||
const queryParams = encodeURIComponent(decodedParams);
|
||||
queryDomain = encodeUrlWithoutQueryParameter(queryDomain)
|
||||
console.log("queryDomain: " + queryDomain);
|
||||
encodedParams = queryParams.toString();
|
||||
let filteredEncodedParams = encodedParams.replace(/%3D/g,'=');
|
||||
filteredEncodedParams = filteredEncodedParams.replace(/%26/g,'&');
|
||||
@@ -49,3 +51,16 @@ function fullyDecodeURI(uri){
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
function encodeUrlWithoutQueryParameter(url){
|
||||
let regex = /\[\d+\]/;
|
||||
let match = url.match(regex);
|
||||
|
||||
if (match) {
|
||||
let encodedPattern = encodeURIComponent(match[0]);
|
||||
let encodedUrl = url.replace(match[0], encodedPattern);
|
||||
return encodedUrl;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user