mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
Merge branch 'dillon/44-customer-satisfaction-feedback-project-d' into dillon/44-customer-satisfaction-feedback-project
This commit is contained in:
@@ -14,7 +14,16 @@ class CanExportFeedback extends AbstractRule
|
||||
*/
|
||||
protected function authorized($object): bool
|
||||
{
|
||||
return true;
|
||||
if(Auth()->user()){
|
||||
$roleToCheck = Auth()->user()->type;
|
||||
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<a :href="href" @click="downloadFile" target="_blank">
|
||||
<slot></slot>
|
||||
</a>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
href: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
downloadFile(event) {
|
||||
event.preventDefault();
|
||||
|
||||
fetch(this.href, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + this.$store.getters.getAccessToken,
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.status === 200) {
|
||||
const contentDisposition = response.headers.get('Content-Disposition');
|
||||
const filename = contentDisposition ? contentDisposition.split('filename=')[1] : 'downloaded_file';
|
||||
|
||||
return response.blob()
|
||||
.then((blob) => {
|
||||
const blobUrl = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = blobUrl;
|
||||
a.download = filename;
|
||||
a.style.display = 'none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
window.URL.revokeObjectURL(blobUrl);
|
||||
});
|
||||
} else {
|
||||
console.error('Request failed with status:', response.status);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Network error:', error);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -14,7 +14,7 @@
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<a href="{{route('feedback.export')}}" target="_blank">
|
||||
<anchor-link-component href="{{route('feedback.export')}}">
|
||||
<button type="button" class="btn btn-sm p-t-10 p-b-10 p-r-35 p-l-35 btn-primary b-rad-none">
|
||||
<div class="row align-items-center">
|
||||
<div class="col-auto p-r-0 p-l-0">
|
||||
@@ -23,7 +23,7 @@
|
||||
<div class="col p-r-5">Export To Excel</div>
|
||||
</div>
|
||||
</button>
|
||||
</a>
|
||||
</anchor-link-component>
|
||||
<div class="row align-items-center m-t-10 p-t-10 p-b-10 b-t b-grey muted all-caps fs-10">
|
||||
<div class="col-1">Question Set</div>
|
||||
<div class="col-2">Question Text</div>
|
||||
|
||||
+1
-1
@@ -1198,7 +1198,7 @@ Route::get('/feedback', function () {
|
||||
return view('pages.feedback');
|
||||
})->name('admin.feedback');
|
||||
|
||||
Route::get('/export/feedback', 'Exports\ExportFeedbackDataController@export')->name('feedback.export');
|
||||
Route::get('/export/feedback', 'Exports\ExportFeedbackDataController@export')->middleware(['api'])->middleware(['valid.token'])->name('feedback.export');
|
||||
|
||||
Route::get('/404', function () {
|
||||
abort(404);
|
||||
|
||||
Reference in New Issue
Block a user