Skip to content
Snippets Groups Projects
Commit 0600bf0f authored by nicrausaz's avatar nicrausaz
Browse files

Telecharger fichier et export données persos

parent 113fc1eb
No related branches found
No related tags found
No related merge requests found
...@@ -33,7 +33,6 @@ class FilesController extends Controller ...@@ -33,7 +33,6 @@ class FilesController extends Controller
$has_access = AccessLevelHelper::hasAccessToJob($applicant_job, $this->user_permissions); $has_access = AccessLevelHelper::hasAccessToJob($applicant_job, $this->user_permissions);
if ($has_access) { if ($has_access) {
$file = DB::table('file')->where('file_id', $id)->first(); $file = DB::table('file')->where('file_id', $id)->first();
// TODO: Fix this
return response()->download($file->file_path); return response()->download($file->file_path);
} else { } else {
return abort(403, lang::get('http.unauthorized')); return abort(403, lang::get('http.unauthorized'));
......
...@@ -12,7 +12,7 @@ class CorsMiddleware ...@@ -12,7 +12,7 @@ class CorsMiddleware
'Access-Control-Allow-Methods' => 'GET, POST, PUT, PATCH, DELETE, OPTIONS', 'Access-Control-Allow-Methods' => 'GET, POST, PUT, PATCH, DELETE, OPTIONS',
'Access-Control-Allow-Credentials' => 'true', 'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Max-Age' => '86400', 'Access-Control-Max-Age' => '86400',
'Access-Control-Allow-Headers' => 'Content-Type, Authorization, X-Requested-With' 'Access-Control-Allow-Headers' => 'Content-Type, Accept, Authorization, X-Requested-With, Application'
]; ];
if ($request->isMethod('OPTIONS')) if ($request->isMethod('OPTIONS'))
...@@ -23,7 +23,7 @@ class CorsMiddleware ...@@ -23,7 +23,7 @@ class CorsMiddleware
$response = $next($request); $response = $next($request);
foreach($headers as $key => $value) foreach($headers as $key => $value)
{ {
$response->header($key, $value); $response->headers->set($key, $value);
} }
return $response; return $response;
......
No preview for this file type
...@@ -63,7 +63,7 @@ export default { ...@@ -63,7 +63,7 @@ export default {
print() { window.print() }, print() { window.print() },
contact() { window.location.href = 'mailto:' + this.$store.state.moduleApplications.currentApplication.application_data.personal_data.applicant_mail }, contact() { window.location.href = 'mailto:' + this.$store.state.moduleApplications.currentApplication.application_data.personal_data.applicant_mail },
deleteApplication() { }, deleteApplication() { },
exportData() { }, exportData() { this.$store.dispatch('moduleApplications/exportData', { id: this.$store.state.moduleApplications.currentApplication.application_data.personal_data.applicant_id, name: this.$store.state.moduleApplications.currentApplication.application_data.personal_data.applicant_name + this.$store.state.moduleApplications.currentApplication.application_data.personal_data.applicant_fsname }) },
rate() { } rate() { }
} }
} }
......
...@@ -5,22 +5,30 @@ ...@@ -5,22 +5,30 @@
<h4>Annexes</h4> <h4>Annexes</h4>
</v-card-title> </v-card-title>
<v-divider></v-divider> <v-divider></v-divider>
<v-list dense> <v-list-tile
<v-container fluid> avatar
<v-layout row wrap> v-for="file in $store.state.moduleApplications.currentApplication.application_data.files"
<v-flex :key="file.file_id"
v-for="file in $store.state.moduleApplications.currentApplication.application_data.files" @click="getFile(file.file_id, file.file_name)"
:key="file.file_id" >
xs4 <v-list-tile-avatar>
> <img src="@/assets/logo_pdf.png" height="75px">
<a @click="getFile(file.file_id)"> </v-list-tile-avatar>
<img src="@/assets/logo_pdf.png" height="75px"> <v-list-tile-content>
<u>{{ file.file_name }}</u> <v-list-tile-title>
</a> <a>
</v-flex> <u>{{ file.file_name }}</u>
</v-layout> </a>
</v-container> </v-list-tile-title>
</v-list> </v-list-tile-content>
<v-list-tile-action>
<v-btn icon ripple>
<v-icon color="grey">cloud_download</v-icon>
</v-btn>
</v-list-tile-action>
</v-list-tile>
<v-divider></v-divider>
<v-btn color="primary" @click="getAllFiles">Tout télécharger</v-btn>
</v-card> </v-card>
</v-sheet> </v-sheet>
</template> </template>
...@@ -29,8 +37,13 @@ ...@@ -29,8 +37,13 @@
export default { export default {
name: 'files-data-sheet', name: 'files-data-sheet',
methods: { methods: {
getFile(id) { getFile(id, name) {
this.$store.dispatch('moduleApplications/getFile', { id: id }) this.$store.dispatch('moduleApplications/getFile', { id: id, name: name })
},
getAllFiles() {
this.$store.state.moduleApplications.currentApplication.application_data.files.forEach(file => {
this.$store.dispatch('moduleApplications/getFile', { id: file.file_id, name: file.file_name })
})
} }
} }
} }
......
...@@ -79,8 +79,30 @@ export function getFile(context, data) { ...@@ -79,8 +79,30 @@ export function getFile(context, data) {
axios({ axios({
method: 'get', method: 'get',
url: '/file/' + data.id, url: '/file/' + data.id,
responseType: 'blob'
}) })
.then(response => { .then(response => {
console.log(response) const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', data.name);
document.body.appendChild(link);
link.click();
})
}
export function exportData(context, data) {
axios({
method: 'get',
url: '/applicant/' + data.id + '/export',
responseType: 'blob'
})
.then(response => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'export' + data.name + '.json');
document.body.appendChild(link);
link.click();
}) })
} }
\ No newline at end of file
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<v-flex grow pa-1> <v-flex grow pa-1>
<PersonalDataSheet/> <PersonalDataSheet/>
</v-flex> </v-flex>
<v-flex shrink pa-1> <v-flex grow pa-1>
<FilesDataSheet/> <FilesDataSheet/>
</v-flex> </v-flex>
</v-layout> </v-layout>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment