Showing
3 changed files
with
28 additions
and
6 deletions
... | @@ -6,6 +6,7 @@ const moment = require("moment"); | ... | @@ -6,6 +6,7 @@ const moment = require("moment"); |
6 | const BUCKET_NAME = "hong-s3-cloud"; | 6 | const BUCKET_NAME = "hong-s3-cloud"; |
7 | let curPath = ""; | 7 | let curPath = ""; |
8 | let user_id = ""; | 8 | let user_id = ""; |
9 | +let parentPath = ""; | ||
9 | 10 | ||
10 | const s3 = new AWS.S3({ | 11 | const s3 = new AWS.S3({ |
11 | accessKeyId: process.env.AWS_ACCESS_KEY_ID, | 12 | accessKeyId: process.env.AWS_ACCESS_KEY_ID, |
... | @@ -17,6 +18,17 @@ router.get('/show', function(req, res, next) { | ... | @@ -17,6 +18,17 @@ router.get('/show', function(req, res, next) { |
17 | console.log(req.query); | 18 | console.log(req.query); |
18 | user_id = req.query.id; | 19 | user_id = req.query.id; |
19 | curPath = req.query.cur; | 20 | curPath = req.query.cur; |
21 | + if (curPath == '/') { | ||
22 | + parentPath = '/'; | ||
23 | + } else { | ||
24 | + let pathSplit = curPath.split('/') | ||
25 | + console.log(pathSplit); | ||
26 | + parentPath = '/'; | ||
27 | + for (let i = 1; i < pathSplit.length - 2; i++) { | ||
28 | + parentPath += pathSplit[i]; | ||
29 | + parentPath += '/'; | ||
30 | + } | ||
31 | + } | ||
20 | folders = {} | 32 | folders = {} |
21 | let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | 33 | let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; |
22 | connection.query(checkfolder, [curPath, user_id], function(err, rows, fields) { | 34 | connection.query(checkfolder, [curPath, user_id], function(err, rows, fields) { |
... | @@ -27,12 +39,14 @@ router.get('/show', function(req, res, next) { | ... | @@ -27,12 +39,14 @@ router.get('/show', function(req, res, next) { |
27 | if (rows.length != 0) { | 39 | if (rows.length != 0) { |
28 | res.status(200).send({ | 40 | res.status(200).send({ |
29 | folders: rows, | 41 | folders: rows, |
30 | - cur: curPath | 42 | + cur: curPath, |
43 | + parentPath: parentPath | ||
31 | }) | 44 | }) |
32 | } else { | 45 | } else { |
33 | res.status(200).send({ | 46 | res.status(200).send({ |
34 | folders: rows, | 47 | folders: rows, |
35 | - cur: curPath | 48 | + cur: curPath, |
49 | + parentPath: parentPath | ||
36 | }) | 50 | }) |
37 | } | 51 | } |
38 | } | 52 | } |
... | @@ -77,8 +91,7 @@ router.post('/makefolder', function(req, res, next) { | ... | @@ -77,8 +91,7 @@ router.post('/makefolder', function(req, res, next) { |
77 | connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { | 91 | connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { |
78 | if (rows.length != 0) { | 92 | if (rows.length != 0) { |
79 | res.status(200).send({ | 93 | res.status(200).send({ |
80 | - folders: rows, | 94 | + folders: rows |
81 | - cur: curPath | ||
82 | }) | 95 | }) |
83 | } else { | 96 | } else { |
84 | res.send({ error: "Does not exist" }); | 97 | res.send({ error: "Does not exist" }); | ... | ... |
... | @@ -142,9 +142,10 @@ import { folder, makeFolder } from '../api/index'; | ... | @@ -142,9 +142,10 @@ import { folder, makeFolder } from '../api/index'; |
142 | cur: '/' | 142 | cur: '/' |
143 | } | 143 | } |
144 | const response = await folder(curData); | 144 | const response = await folder(curData); |
145 | - console.log(response); | 145 | + console.log(response.data); |
146 | this.$store.commit('setFolder', response.data.folders); | 146 | this.$store.commit('setFolder', response.data.folders); |
147 | this.$store.commit('setCur', response.data.cur); | 147 | this.$store.commit('setCur', response.data.cur); |
148 | + this.$store.commit('setParent', response.data.parentPath); | ||
148 | } catch (error) { | 149 | } catch (error) { |
149 | console.log("에러"); | 150 | console.log("에러"); |
150 | console.log(error.response.data); | 151 | console.log(error.response.data); |
... | @@ -180,9 +181,10 @@ import { folder, makeFolder } from '../api/index'; | ... | @@ -180,9 +181,10 @@ import { folder, makeFolder } from '../api/index'; |
180 | cur: this.$store.state.cur + move_folder_name + '/' | 181 | cur: this.$store.state.cur + move_folder_name + '/' |
181 | } | 182 | } |
182 | const response = await folder(curData); | 183 | const response = await folder(curData); |
183 | - console.log(response); | 184 | + console.log(response.data); |
184 | this.$store.commit('setFolder', response.data.folders); | 185 | this.$store.commit('setFolder', response.data.folders); |
185 | this.$store.commit('setCur', response.data.cur); | 186 | this.$store.commit('setCur', response.data.cur); |
187 | + this.$store.commit('setParent', response.data.parentPath); | ||
186 | } catch (error) { | 188 | } catch (error) { |
187 | console.log("에러"); | 189 | console.log("에러"); |
188 | console.log(error.response.data); | 190 | console.log(error.response.data); | ... | ... |
... | @@ -9,6 +9,7 @@ export default new Vuex.Store({ | ... | @@ -9,6 +9,7 @@ export default new Vuex.Store({ |
9 | folders: {}, | 9 | folders: {}, |
10 | files: {}, | 10 | files: {}, |
11 | cur: '/', | 11 | cur: '/', |
12 | + parent: '/' | ||
12 | }, | 13 | }, |
13 | mutations: { | 14 | mutations: { |
14 | setId(state, userid) { | 15 | setId(state, userid) { |
... | @@ -25,6 +26,9 @@ export default new Vuex.Store({ | ... | @@ -25,6 +26,9 @@ export default new Vuex.Store({ |
25 | }, | 26 | }, |
26 | setCur(state, cur) { | 27 | setCur(state, cur) { |
27 | state.cur = cur; | 28 | state.cur = cur; |
29 | + }, | ||
30 | + setParent(state, parent) { | ||
31 | + state.parent = parent; | ||
28 | } | 32 | } |
29 | }, | 33 | }, |
30 | getters: { | 34 | getters: { |
... | @@ -42,6 +46,9 @@ export default new Vuex.Store({ | ... | @@ -42,6 +46,9 @@ export default new Vuex.Store({ |
42 | }, | 46 | }, |
43 | cur(state) { | 47 | cur(state) { |
44 | return state.cur; | 48 | return state.cur; |
49 | + }, | ||
50 | + parent(state) { | ||
51 | + return state.parent; | ||
45 | } | 52 | } |
46 | } | 53 | } |
47 | }) | 54 | }) |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment