diff --git a/canapGEST/API/app/Http/Controllers/FilesController.php b/canapGEST/API/app/Http/Controllers/FilesController.php index 08e113e773083ec6fe11281735199591bad49fbd..803dbbecad978b1a629466eac93a6af3fcce18f4 100644 --- a/canapGEST/API/app/Http/Controllers/FilesController.php +++ b/canapGEST/API/app/Http/Controllers/FilesController.php @@ -33,7 +33,6 @@ class FilesController extends Controller $has_access = AccessLevelHelper::hasAccessToJob($applicant_job, $this->user_permissions); if ($has_access) { $file = DB::table('file')->where('file_id', $id)->first(); - // TODO: Fix this return response()->download($file->file_path); } else { return abort(403, lang::get('http.unauthorized')); diff --git a/canapGEST/API/app/Http/Middleware/CorsMiddleware.php b/canapGEST/API/app/Http/Middleware/CorsMiddleware.php index 0e8f717d330392a0c62fe1946ed9733eaf87079a..2df0b74779a710a895310176ce7e07b11ec8bebb 100644 --- a/canapGEST/API/app/Http/Middleware/CorsMiddleware.php +++ b/canapGEST/API/app/Http/Middleware/CorsMiddleware.php @@ -12,7 +12,7 @@ class CorsMiddleware 'Access-Control-Allow-Methods' => 'GET, POST, PUT, PATCH, DELETE, OPTIONS', 'Access-Control-Allow-Credentials' => 'true', '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')) @@ -23,7 +23,7 @@ class CorsMiddleware $response = $next($request); foreach($headers as $key => $value) { - $response->header($key, $value); + $response->headers->set($key, $value); } return $response; diff --git a/canapGEST/Documentation/journal_travail.xlsx b/canapGEST/Documentation/journal_travail.xlsx index 2f111e7bacceb7be6016d19342f54d35b7566ac8..de5b23ac17655aaae04dc8a59f285088ee9566f4 100644 Binary files a/canapGEST/Documentation/journal_travail.xlsx and b/canapGEST/Documentation/journal_travail.xlsx differ diff --git a/canapGEST/Site/src/components/application/applicationTitle.vue b/canapGEST/Site/src/components/application/applicationTitle.vue index 744f285d8271e030861ec7e8884c70cf49cdd872..910633fbd60e02e13eea161a578de2dcf421059e 100644 --- a/canapGEST/Site/src/components/application/applicationTitle.vue +++ b/canapGEST/Site/src/components/application/applicationTitle.vue @@ -63,7 +63,7 @@ export default { print() { window.print() }, contact() { window.location.href = 'mailto:' + this.$store.state.moduleApplications.currentApplication.application_data.personal_data.applicant_mail }, 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() { } } } diff --git a/canapGEST/Site/src/components/application/sheets/filesDataSheet.vue b/canapGEST/Site/src/components/application/sheets/filesDataSheet.vue index b9c2232bb9404ec5404a0ea198a52776cc0041a0..0e104d59ecbe223c9db24d88f6beb76f3be9490d 100644 --- a/canapGEST/Site/src/components/application/sheets/filesDataSheet.vue +++ b/canapGEST/Site/src/components/application/sheets/filesDataSheet.vue @@ -5,22 +5,30 @@ <h4>Annexes</h4> </v-card-title> <v-divider></v-divider> - <v-list dense> - <v-container fluid> - <v-layout row wrap> - <v-flex - v-for="file in $store.state.moduleApplications.currentApplication.application_data.files" - :key="file.file_id" - xs4 - > - <a @click="getFile(file.file_id)"> - <img src="@/assets/logo_pdf.png" height="75px"> - <u>{{ file.file_name }}</u> - </a> - </v-flex> - </v-layout> - </v-container> - </v-list> + <v-list-tile + avatar + v-for="file in $store.state.moduleApplications.currentApplication.application_data.files" + :key="file.file_id" + @click="getFile(file.file_id, file.file_name)" + > + <v-list-tile-avatar> + <img src="@/assets/logo_pdf.png" height="75px"> + </v-list-tile-avatar> + <v-list-tile-content> + <v-list-tile-title> + <a> + <u>{{ file.file_name }}</u> + </a> + </v-list-tile-title> + </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-sheet> </template> @@ -29,8 +37,13 @@ export default { name: 'files-data-sheet', methods: { - getFile(id) { - this.$store.dispatch('moduleApplications/getFile', { id: id }) + getFile(id, name) { + 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 }) + }) } } } diff --git a/canapGEST/Site/src/store/modules/applications/actions.js b/canapGEST/Site/src/store/modules/applications/actions.js index 0dd8f901934ad9f080b2c68acbbd2547b9997d6f..199a3fc7f2e5306aeae7ac56a7176b95927613cf 100644 --- a/canapGEST/Site/src/store/modules/applications/actions.js +++ b/canapGEST/Site/src/store/modules/applications/actions.js @@ -79,8 +79,30 @@ export function getFile(context, data) { axios({ method: 'get', url: '/file/' + data.id, + responseType: 'blob' }) .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 diff --git a/canapGEST/Site/src/views/ApplicationView.vue b/canapGEST/Site/src/views/ApplicationView.vue index a77f88210ac6ff103e7d06907477d0d900be03c3..a3da7dc521d6204b3ef6d0d89cc193f0476ff78f 100644 --- a/canapGEST/Site/src/views/ApplicationView.vue +++ b/canapGEST/Site/src/views/ApplicationView.vue @@ -18,7 +18,7 @@ <v-flex grow pa-1> <PersonalDataSheet/> </v-flex> - <v-flex shrink pa-1> + <v-flex grow pa-1> <FilesDataSheet/> </v-flex> </v-layout>