Merge remote-tracking branch 'origin/file_front' into new_file
Showing
3 changed files
with
79 additions
and
4 deletions
... | @@ -35,6 +35,50 @@ function moveFolder(folderData) { | ... | @@ -35,6 +35,50 @@ function moveFolder(folderData) { |
35 | return axios.post('/api/folder/move', folderData); | 35 | return axios.post('/api/folder/move', folderData); |
36 | } | 36 | } |
37 | 37 | ||
38 | +function file(curData){ | ||
39 | + return axios.get('/api/file', { | ||
40 | + params: { | ||
41 | + id: curData.id, | ||
42 | + cur: curData.cur | ||
43 | + } | ||
44 | + }); | ||
45 | +} | ||
46 | + | ||
47 | + | ||
48 | +function uploadFile(fileData){ | ||
49 | + return axios.post('/api/file/upload', fileData); | ||
50 | +} | ||
51 | + | ||
52 | +function detailFile(fileData){ | ||
53 | + return axios.get(`/api/file/${fileData.name}`, { | ||
54 | + params:{ | ||
55 | + id: fileData.id, | ||
56 | + cur: fileData.cur | ||
57 | + } | ||
58 | + }) | ||
59 | +} | ||
60 | +function deleteFile(fileData){ | ||
61 | + return axios.get('/api/file/delete', { | ||
62 | + params:{ | ||
63 | + //현재 접속한 사람의 id와 삭제할 파일의 이름, 현재 폴더위치를 파라미터로 넘긴다. | ||
64 | + id: fileData.id, | ||
65 | + name: fileData.fileName, | ||
66 | + cur: fileData.cur | ||
67 | + } | ||
68 | + }); | ||
69 | +} | ||
70 | +function downloadFile(fileData){ | ||
71 | + return axios.get('api/file/download', { | ||
72 | + params:{ | ||
73 | + //현재 접속한 사람의 id와 다운로드를 위해 선택한 파일의 이름을 파라미터로 넘긴다. | ||
74 | + id: fileData.id, | ||
75 | + name: fileData.fileName, | ||
76 | + cur: fileData.cur | ||
77 | + } | ||
78 | + }); | ||
79 | +} | ||
80 | + | ||
38 | 81 | ||
39 | 82 | ||
40 | -export { registerUser, loginUser, folder, makeFolder, deleteFolder, moveFolder }; | 83 | +export { registerUser, loginUser, folder, makeFolder, deleteFolder, moveFolder, |
84 | + file, uploadFile, deleteFile, downloadFile }; | ... | ... |
... | @@ -29,7 +29,7 @@ | ... | @@ -29,7 +29,7 @@ |
29 | <v-list-item-title v-text="item.folder_name"></v-list-item-title> | 29 | <v-list-item-title v-text="item.folder_name"></v-list-item-title> |
30 | </v-list-item-content> | 30 | </v-list-item-content> |
31 | 31 | ||
32 | - | 32 | + |
33 | 33 | ||
34 | <v-menu | 34 | <v-menu |
35 | v-model="showMenu" | 35 | v-model="showMenu" |
... | @@ -134,7 +134,9 @@ | ... | @@ -134,7 +134,9 @@ |
134 | +{{ files.length - 2 }} File(s) | 134 | +{{ files.length - 2 }} File(s) |
135 | </span> | 135 | </span> |
136 | </template> | 136 | </template> |
137 | + | ||
137 | </v-file-input> | 138 | </v-file-input> |
139 | + <v-btn color="blue" @click = "upload_file">upload</v-btn> | ||
138 | <v-btn | 140 | <v-btn |
139 | bottom | 141 | bottom |
140 | color="blue" | 142 | color="blue" |
... | @@ -177,7 +179,7 @@ | ... | @@ -177,7 +179,7 @@ |
177 | </div> | 179 | </div> |
178 | </template> | 180 | </template> |
179 | <script> | 181 | <script> |
180 | -import { folder, makeFolder, deleteFolder, moveFolder } from '../api/index'; | 182 | +import { folder, makeFolder, deleteFolder, moveFolder, file, uploadFile, deleteFile, downloadFile } from '../api/index'; |
181 | import Axios from 'axios'; | 183 | import Axios from 'axios'; |
182 | export default { | 184 | export default { |
183 | data() { | 185 | data() { |
... | @@ -203,12 +205,17 @@ import Axios from 'axios'; | ... | @@ -203,12 +205,17 @@ import Axios from 'axios'; |
203 | id : this.$store.state.id, | 205 | id : this.$store.state.id, |
204 | cur: '/' | 206 | cur: '/' |
205 | } | 207 | } |
208 | + console.log(curData); | ||
206 | const response = await folder(curData); | 209 | const response = await folder(curData); |
210 | + const {file_response} = await file(curData); | ||
207 | console.log(response.data); | 211 | console.log(response.data); |
212 | + console.log(file_response); | ||
208 | this.$store.commit('setFolder', response.data.folders); | 213 | this.$store.commit('setFolder', response.data.folders); |
209 | this.$store.commit('setCur', response.data.cur); | 214 | this.$store.commit('setCur', response.data.cur); |
210 | this.$store.commit('setParent', response.data.parentPath); | 215 | this.$store.commit('setParent', response.data.parentPath); |
211 | this.folders = this.$store.getters.folderL; | 216 | this.folders = this.$store.getters.folderL; |
217 | + this.$store.commit('setFile', file_response.data.files); | ||
218 | + this.files = this.$store.getters.fileL; | ||
212 | } catch (error) { | 219 | } catch (error) { |
213 | console.log("에러"); | 220 | console.log("에러"); |
214 | console.log(error.response.data); | 221 | console.log(error.response.data); |
... | @@ -316,6 +323,30 @@ import Axios from 'axios'; | ... | @@ -316,6 +323,30 @@ import Axios from 'axios'; |
316 | this.dialog2 = false; | 323 | this.dialog2 = false; |
317 | } | 324 | } |
318 | }, | 325 | }, |
326 | + async upload_file(){ | ||
327 | + try{ | ||
328 | + const fileData={ | ||
329 | + file: this.files, | ||
330 | + user_id: this.$store.state.id, | ||
331 | + cur: this.$store.state.cur | ||
332 | + } | ||
333 | + console.log(fileData) | ||
334 | + const response = await uploadFile(fileData); | ||
335 | + const filelist = await file(fileData.user_id); | ||
336 | + console.log(response.message); | ||
337 | + this.$store.commit('setFile', filelist.data.files); | ||
338 | + this.files = this.$store.getters.fileL; | ||
339 | + }catch(error){ | ||
340 | + const fileData={ | ||
341 | + file: this.files, | ||
342 | + user_id: this.$store.state.id, | ||
343 | + cur: this.$store.state.cur | ||
344 | + } | ||
345 | + console.log(fileData); | ||
346 | + console.log("에러"); | ||
347 | + console.log(error.reponse.err); | ||
348 | + } | ||
349 | + }, | ||
319 | show (folderN, e) { | 350 | show (folderN, e) { |
320 | e.preventDefault() | 351 | e.preventDefault() |
321 | this.curfName = folderN; | 352 | this.curfName = folderN; |
... | @@ -328,4 +359,4 @@ import Axios from 'axios'; | ... | @@ -328,4 +359,4 @@ import Axios from 'axios'; |
328 | } | 359 | } |
329 | } | 360 | } |
330 | } | 361 | } |
331 | -</script> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
362 | +</script> | ... | ... |
front-end/src/views/FolderPage.vue
0 → 100644
File mode changed
-
Please register or login to post a comment