Showing
4 changed files
with
237 additions
and
116 deletions
... | @@ -29,26 +29,17 @@ router.get('/show', function(req, res, next) { | ... | @@ -29,26 +29,17 @@ router.get('/show', function(req, res, next) { |
29 | parentPath += '/'; | 29 | parentPath += '/'; |
30 | } | 30 | } |
31 | } | 31 | } |
32 | - folders = {} | ||
33 | let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | 32 | let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; |
34 | connection.query(checkfolder, [curPath, user_id], function(err, rows, fields) { | 33 | connection.query(checkfolder, [curPath, user_id], function(err, rows, fields) { |
35 | if (err) { | 34 | if (err) { |
36 | console.log('select error'); | 35 | console.log('select error'); |
37 | res.status(404).send() | 36 | res.status(404).send() |
38 | } else { | 37 | } else { |
39 | - if (rows.length != 0) { | ||
40 | res.status(200).send({ | 38 | res.status(200).send({ |
41 | folders: rows, | 39 | folders: rows, |
42 | cur: curPath, | 40 | cur: curPath, |
43 | parentPath: parentPath | 41 | parentPath: parentPath |
44 | }) | 42 | }) |
45 | - } else { | ||
46 | - res.status(200).send({ | ||
47 | - folders: rows, | ||
48 | - cur: curPath, | ||
49 | - parentPath: parentPath | ||
50 | - }) | ||
51 | - } | ||
52 | } | 43 | } |
53 | }); | 44 | }); |
54 | }); | 45 | }); |
... | @@ -70,6 +61,9 @@ router.post('/makefolder', function(req, res, next) { | ... | @@ -70,6 +61,9 @@ router.post('/makefolder', function(req, res, next) { |
70 | let checksql = 'SELECT * FROM folders WHERE location = ? AND folder_name = ?;'; | 61 | let checksql = 'SELECT * FROM folders WHERE location = ? AND folder_name = ?;'; |
71 | console.log(req.body) | 62 | console.log(req.body) |
72 | connection.query(checksql, [cur, folder_name], function(err, rows, fields) { | 63 | connection.query(checksql, [cur, folder_name], function(err, rows, fields) { |
64 | + if (err) { | ||
65 | + | ||
66 | + } else { | ||
73 | if (rows.length == 0) { | 67 | if (rows.length == 0) { |
74 | s3.putObject(params, function(err, data) { | 68 | s3.putObject(params, function(err, data) { |
75 | if (err) { | 69 | if (err) { |
... | @@ -77,8 +71,6 @@ router.post('/makefolder', function(req, res, next) { | ... | @@ -77,8 +71,6 @@ router.post('/makefolder', function(req, res, next) { |
77 | throw err; | 71 | throw err; |
78 | } else { | 72 | } else { |
79 | console.log(data); | 73 | console.log(data); |
80 | - } | ||
81 | - }); | ||
82 | let sql = 'INSERT INTO folders (folder_name,location,user_id,created) values (?,?,?,?);'; | 74 | let sql = 'INSERT INTO folders (folder_name,location,user_id,created) values (?,?,?,?);'; |
83 | let values = [folder_name, cur, user_id, date]; | 75 | let values = [folder_name, cur, user_id, date]; |
84 | connection.query(sql, values, function(err, result, field) { | 76 | connection.query(sql, values, function(err, result, field) { |
... | @@ -86,172 +78,175 @@ router.post('/makefolder', function(req, res, next) { | ... | @@ -86,172 +78,175 @@ router.post('/makefolder', function(req, res, next) { |
86 | console.log('insert error'); | 78 | console.log('insert error'); |
87 | throw err; | 79 | throw err; |
88 | } else { | 80 | } else { |
89 | - folders = {} | ||
90 | let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | 81 | let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; |
91 | connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { | 82 | connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { |
92 | - if (rows.length != 0) { | 83 | + console.log(rows); |
93 | res.status(200).send({ | 84 | res.status(200).send({ |
94 | folders: rows | 85 | folders: rows |
95 | }) | 86 | }) |
96 | - } else { | 87 | + }); |
97 | - res.send({ error: "Does not exist" }); | ||
98 | } | 88 | } |
99 | }); | 89 | }); |
100 | } | 90 | } |
101 | }); | 91 | }); |
102 | - | ||
103 | - | ||
104 | } else { | 92 | } else { |
105 | res.status(404).send({ error: "same name error" }); | 93 | res.status(404).send({ error: "same name error" }); |
106 | } | 94 | } |
95 | + } | ||
107 | }); | 96 | }); |
108 | }); | 97 | }); |
109 | 98 | ||
110 | 99 | ||
111 | router.post('/delfolder', function(req, res, next) { | 100 | router.post('/delfolder', function(req, res, next) { |
112 | 101 | ||
113 | - user_id = req.body.user_id; | 102 | + user_id = req.body.id; |
114 | - curPath = user_id + req.body.cur; | 103 | + let cur = req.body.cur; |
104 | + curPath = user_id + cur; | ||
115 | let folder_name = req.body.folder_name; | 105 | let folder_name = req.body.folder_name; |
116 | let params = { | 106 | let params = { |
117 | - Bucket: BUCKET_NAME + curPath, | 107 | + Bucket: BUCKET_NAME, |
118 | - Key: folder_name + '/' | 108 | + Key: curPath + folder_name + '/' |
119 | }; | 109 | }; |
120 | - let checksql = 'SELECT * FROM folders WHERE location = ? AND folder_name = ?;'; | 110 | + let checksql = 'SELECT * FROM folders WHERE location = ? AND folder_name = ? AND user_id = ?;'; |
121 | - let values = [curPath, folder_name]; | 111 | + let values = [cur, folder_name, user_id]; |
122 | - | ||
123 | connection.query(checksql, values, function(err, rows, fields) { | 112 | connection.query(checksql, values, function(err, rows, fields) { |
113 | + if (err) { | ||
114 | + res.status(404).send({ error: "error" }); | ||
115 | + } else { | ||
124 | if (rows.length != 0) { | 116 | if (rows.length != 0) { |
125 | s3.deleteObject(params, function(err, data) { | 117 | s3.deleteObject(params, function(err, data) { |
126 | if (err) { | 118 | if (err) { |
119 | + console.log('s3 error'); | ||
127 | //throw err; | 120 | //throw err; |
128 | } else { | 121 | } else { |
129 | - let sql = 'DELETE FROM folders WHERE location = ? AND folder_name = ?;'; | 122 | + console.log(data); |
123 | + let sql = 'DELETE FROM folders WHERE location = ? AND folder_name = ? AND user_id = ?;'; | ||
130 | connection.query(sql, values, function(err, result, field) { | 124 | connection.query(sql, values, function(err, result, field) { |
131 | if (err) { | 125 | if (err) { |
132 | //throw err; | 126 | //throw err; |
133 | } else { | 127 | } else { |
134 | - folders = {} | 128 | + console.log(cur); |
129 | + console.log(user_id); | ||
135 | let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | 130 | let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; |
136 | connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { | 131 | connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { |
137 | - if (rows.length != 0) { | ||
138 | res.status(200).send({ | 132 | res.status(200).send({ |
139 | - folders: rows, | 133 | + folders: rows |
140 | - cur: curPath | ||
141 | }) | 134 | }) |
142 | - } else { | ||
143 | - res.send({ error: "Does not exist" }); | ||
144 | - } | ||
145 | }); | 135 | }); |
146 | 136 | ||
147 | } | 137 | } |
148 | }); | 138 | }); |
149 | } | 139 | } |
150 | }); | 140 | }); |
151 | - | ||
152 | - | ||
153 | } else { | 141 | } else { |
154 | - res.send({ error: "Does not exist" }); | 142 | + console.log(req.body); |
143 | + res.status(304).send({ error: "Does not exist" }); | ||
144 | + } | ||
155 | } | 145 | } |
156 | }); | 146 | }); |
157 | }); | 147 | }); |
158 | 148 | ||
159 | 149 | ||
160 | router.post('/move', function(req, res, next) { | 150 | router.post('/move', function(req, res, next) { |
161 | - | 151 | + console.log(req.body); |
162 | - user_id = req.body.user_id; | 152 | + user_id = req.body.id; |
163 | - curPath = user_id + req.body.cur; | 153 | + let cur = req.body.cur; |
164 | - let name = req.body.mfile; | 154 | + curPath = user_id + cur; |
165 | - let newPath = req.body.newPath; | 155 | + let name = req.body.folder_name; |
166 | - let checkfolder = 'SELECT * FROM folders WHERE location = ? AND folder_name = ?;'; | 156 | + let newPath = user_id + req.body.newPath; |
167 | if (req.body.isfolder) { | 157 | if (req.body.isfolder) { |
168 | - connection.query(checkfolder, [curPath, name], function(err1, rows, fields) { | 158 | + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND folder_name = ? AND user_id = ?;'; |
159 | + connection.query(checkfolder, [cur, name, user_id], function(err1, rows, fields) { | ||
160 | + console.log(rows); | ||
169 | if (rows.length != 0) { | 161 | if (rows.length != 0) { |
170 | let copy_params = { | 162 | let copy_params = { |
171 | - Bucket: BUCKET_NAME + curPath, | 163 | + Bucket: BUCKET_NAME, |
172 | - CopySource: BUCKET_NAME + curPath + file + '/', | 164 | + CopySource: BUCKET_NAME + '/' + curPath + name + '/', |
173 | - Key: newPath + file + '/' | 165 | + Key: newPath + name + '/' |
174 | }; | 166 | }; |
175 | - | ||
176 | let del_params = { | 167 | let del_params = { |
177 | - Bucket: BUCKET_NAME + curPath, | 168 | + Bucket: BUCKET_NAME, |
178 | - Key: file + '/' | 169 | + Key: curPath + name + '/' |
179 | }; | 170 | }; |
180 | s3.copyObject(copy_params, function(err, data) { | 171 | s3.copyObject(copy_params, function(err, data) { |
172 | + if (err) { | ||
181 | console.log(err, data); | 173 | console.log(err, data); |
182 | - }); | 174 | + console.log("copy error"); |
175 | + res.status(304).send({ error: "copy error" }); | ||
176 | + } else { | ||
183 | s3.deleteObject(del_params, function(err, data) { | 177 | s3.deleteObject(del_params, function(err, data) { |
178 | + if (err) { | ||
184 | console.log(err, data); | 179 | console.log(err, data); |
185 | - }); | 180 | + console.log("delete error"); |
186 | - let values = [newPath, curPath, name]; | 181 | + res.status(304).send({ error: "delete error" }); |
187 | - let updatesql = 'UPDATE folders SET location = ? WHERE location = ? AND folder_name = ?;'; | 182 | + } else { |
183 | + let values = [req.body.newPath, cur, name, user_id]; | ||
184 | + let updatesql = 'UPDATE folders SET location = ? WHERE location = ? AND folder_name = ? AND user_id = ?;'; | ||
188 | connection.query(updatesql, values, function(err3, result, field) { | 185 | connection.query(updatesql, values, function(err3, result, field) { |
189 | if (err3) { | 186 | if (err3) { |
190 | - throw err; | 187 | + console.log("updatesql error"); |
188 | + res.status(304).send({ error: "updatesql error" }); | ||
191 | } else { | 189 | } else { |
192 | - folders = {} | 190 | + let resultsql = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; |
193 | - connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { | 191 | + connection.query(resultsql, [cur, user_id], function(err, rows, fields) { |
194 | - if (rows.length != 0) { | ||
195 | res.status(200).send({ | 192 | res.status(200).send({ |
196 | - folders: rows, | 193 | + folders: rows |
197 | - cur: curPath | 194 | + }); |
198 | - }) | 195 | + }); |
199 | - } else { | 196 | + } |
200 | - res.send({ error: "Does not exist" }); | 197 | + }); |
201 | } | 198 | } |
202 | }); | 199 | }); |
203 | } | 200 | } |
204 | }); | 201 | }); |
205 | - | ||
206 | - | ||
207 | } else { | 202 | } else { |
208 | - res.send({ error: "Does not exist" }); | 203 | + console.log("Does not exist"); |
204 | + res.status(304).send({ error: "Does not exist" }); | ||
209 | } | 205 | } |
210 | }); | 206 | }); |
211 | } else { | 207 | } else { |
212 | - let checkfile = 'SELECT * FROM files WHERE location = ? AND file_name = ?'; | 208 | + let checkfile = 'SELECT * FROM files WHERE location = ? AND file_name = ? AND user_id = ?'; |
213 | - | 209 | + connection.query(checkfile, [curPath, name, user_id], function(err1, rows, fields) { |
214 | - connection.query(checkfile, [curPath, name], function(err1, rows, fields) { | ||
215 | if (rows.length != 0) { | 210 | if (rows.length != 0) { |
216 | let copy_params = { | 211 | let copy_params = { |
217 | - Bucket: BUCKET_NAME + curPath, | 212 | + Bucket: BUCKET_NAME, |
218 | - CopySource: BUCKET_NAME + curPath + file, | 213 | + CopySource: BUCKET_NAME + '/' + curPath + file, |
219 | Key: newPath + file | 214 | Key: newPath + file |
220 | }; | 215 | }; |
221 | - | ||
222 | let del_params = { | 216 | let del_params = { |
223 | - Bucket: BUCKET_NAME + curPath, | 217 | + Bucket: BUCKET_NAME, |
224 | - Key: file | 218 | + Key: curPath + file |
225 | }; | 219 | }; |
226 | s3.copyObject(copy_params, function(err, data) { | 220 | s3.copyObject(copy_params, function(err, data) { |
221 | + if (err) { | ||
227 | console.log(err, data); | 222 | console.log(err, data); |
228 | - }); | 223 | + res.status(304).send({ error: "copy error" }); |
224 | + } else { | ||
229 | s3.deleteObject(del_params, function(err, data) { | 225 | s3.deleteObject(del_params, function(err, data) { |
226 | + if (err) { | ||
230 | console.log(err, data); | 227 | console.log(err, data); |
231 | - }); | 228 | + res.status(304).send({ error: "delete error" }); |
232 | - let values = [newPath, curPath, name]; | 229 | + } else { |
233 | - let updatesql = 'UPDATE files SET location = ? WHERE location = ? AND file_name = ?;'; | 230 | + let values = [newPath, cur, name, user_id]; |
231 | + let updatesql = 'UPDATE files SET location = ? WHERE location = ? AND file_name = ? AND user_id = ?;'; | ||
234 | connection.query(updatesql, values, function(err3, result, field) { | 232 | connection.query(updatesql, values, function(err3, result, field) { |
235 | if (err3) { | 233 | if (err3) { |
236 | - throw err; | 234 | + res.status(304).send({ error: "updatesql error" }); |
237 | } else { | 235 | } else { |
238 | - folders = {} | 236 | + let resultsql = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; |
239 | - connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { | 237 | + connection.query(resultsql, [cur, user_id], function(err, rows, fields) { |
240 | - if (rows.length != 0) { | ||
241 | res.status(200).send({ | 238 | res.status(200).send({ |
242 | - folders: rows, | 239 | + folders: rows |
243 | - cur: curPath | 240 | + }); |
244 | - }) | 241 | + }); |
245 | - } else { | 242 | + } |
246 | - res.send({ error: "Does not exist" }); | 243 | + }); |
247 | } | 244 | } |
248 | }); | 245 | }); |
249 | } | 246 | } |
250 | }); | 247 | }); |
251 | - | ||
252 | - | ||
253 | } else { | 248 | } else { |
254 | - res.send({ error: "Does not exist" }); | 249 | + res.status(304).send({ error: "Does not exist" }); |
255 | } | 250 | } |
256 | }); | 251 | }); |
257 | 252 | ... | ... |
... | @@ -27,20 +27,14 @@ function makeFolder(folderData) { | ... | @@ -27,20 +27,14 @@ function makeFolder(folderData) { |
27 | return axios.post('/api/folder/makefolder', folderData); | 27 | return axios.post('/api/folder/makefolder', folderData); |
28 | } | 28 | } |
29 | 29 | ||
30 | -function file(userData){ | 30 | +function deleteFolder(folderData) { |
31 | - return axios.get('/api/file', userData, { | 31 | + return axios.post('/api/folder/delfolder', folderData); |
32 | - params: { | ||
33 | - user_id: userData.user_id | ||
34 | - } | ||
35 | - }) | ||
36 | } | 32 | } |
37 | 33 | ||
38 | - | 34 | +function moveFolder(folderData) { |
39 | -export { registerUser, loginUser, folder, makeFolder, file}; | 35 | + return axios.post('/api/folder/move', folderData); |
36 | +} | ||
40 | 37 | ||
41 | 38 | ||
42 | -function dropbox(userData){ | ||
43 | - return axios.get(`/api/folder/show/${userData}`); | ||
44 | -} | ||
45 | 39 | ||
46 | -// export { registerUser, loginUser, dropbox, makeFolder }; | 40 | +export { registerUser, loginUser, folder, makeFolder, deleteFolder, moveFolder }; | ... | ... |
... | @@ -14,26 +14,76 @@ | ... | @@ -14,26 +14,76 @@ |
14 | </v-toolbar> | 14 | </v-toolbar> |
15 | <v-list two-line subheader> | 15 | <v-list two-line subheader> |
16 | <v-subheader inset>Folders</v-subheader> | 16 | <v-subheader inset>Folders</v-subheader> |
17 | + <v-btn @click="moveParent">...</v-btn> | ||
17 | <v-list-item | 18 | <v-list-item |
18 | v-for="item in this.$store.getters.folderL" | 19 | v-for="item in this.$store.getters.folderL" |
19 | :key="item.title" | 20 | :key="item.title" |
20 | - @click="moveF(item.folder_name)" | 21 | + :search="search" |
22 | + @click.right="show(item.folder_name,$event)" | ||
23 | + @click.left="moveF(item.folder_name)" | ||
21 | > | 24 | > |
22 | - <v-list-item-avatar> | 25 | + <v-list-item-avatar > |
23 | <v-icon>mdi-folder</v-icon> | 26 | <v-icon>mdi-folder</v-icon> |
24 | </v-list-item-avatar> | 27 | </v-list-item-avatar> |
25 | - <v-list-item-content> | 28 | + <v-list-item-content > |
26 | <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> |
27 | </v-list-item-content> | 30 | </v-list-item-content> |
28 | - <v-list-item-action> | 31 | + |
29 | - <v-btn icon> | 32 | + |
30 | - <v-icon color="grey lighten-1">mdi-information</v-icon> | 33 | + |
31 | - </v-btn> | 34 | + <v-menu |
32 | - <v-btn icon> | 35 | + v-model="showMenu" |
33 | - <v-icon color="grey lighten-1">mdi-delete</v-icon> | 36 | + :position-x="x" |
34 | - </v-btn> | 37 | + :position-y="y" |
35 | - </v-list-item-action> | 38 | + absolute |
39 | + offset-y | ||
40 | + > | ||
41 | + <v-list dense> | ||
42 | + <v-list-item @click.prevent="dialog2 = !dialog2"> | ||
43 | + <v-list-item-title>이동</v-list-item-title> | ||
44 | + </v-list-item> | ||
45 | + <v-list-item @click.prevent="deleteF"> | ||
46 | + <v-list-item-title>삭제</v-list-item-title> | ||
36 | </v-list-item> | 47 | </v-list-item> |
48 | + </v-list> | ||
49 | + </v-menu> | ||
50 | + </v-list-item> | ||
51 | +<v-dialog | ||
52 | + v-model="dialog2" | ||
53 | + width="500px" | ||
54 | + > | ||
55 | + <v-card> | ||
56 | + <v-card-title class="grey darken-2"> | ||
57 | + Move Folder | ||
58 | + </v-card-title> | ||
59 | + <v-container> | ||
60 | + <v-list-item-group | ||
61 | + v-for="item2 in folders" | ||
62 | + :key="item2.folder_id" | ||
63 | + > | ||
64 | + <template v-if="!(item2.folder_name === curfName)"> | ||
65 | + <v-hover @click.left="transferF(item2.folder_name)"> | ||
66 | + <v-list-item-avatar> | ||
67 | + <v-icon>mdi-folder</v-icon> | ||
68 | + </v-list-item-avatar> | ||
69 | + <v-list-item-content> | ||
70 | + <v-list-item-title v-text="item2.folder_name"></v-list-item-title> | ||
71 | + </v-list-item-content> | ||
72 | + </v-hover> | ||
73 | + </template> | ||
74 | + <!-- <template v-else></template> --> | ||
75 | + </v-list-item-group> | ||
76 | + </v-container> | ||
77 | + <v-card-actions> | ||
78 | + <v-spacer></v-spacer> | ||
79 | + <v-btn | ||
80 | + text | ||
81 | + color="primary" | ||
82 | + @click="cancelMove" | ||
83 | + >Cancel</v-btn> | ||
84 | + </v-card-actions> | ||
85 | + </v-card> | ||
86 | + </v-dialog> | ||
37 | <v-divider inset></v-divider> | 87 | <v-divider inset></v-divider> |
38 | <v-subheader inset>Files</v-subheader> | 88 | <v-subheader inset>Files</v-subheader> |
39 | <v-list-item | 89 | <v-list-item |
... | @@ -98,7 +148,7 @@ | ... | @@ -98,7 +148,7 @@ |
98 | </v-btn> | 148 | </v-btn> |
99 | <v-dialog | 149 | <v-dialog |
100 | v-model="dialog" | 150 | v-model="dialog" |
101 | - width="800px" | 151 | + width="500px" |
102 | > | 152 | > |
103 | <v-card> | 153 | <v-card> |
104 | <v-card-title class="grey darken-2"> | 154 | <v-card-title class="grey darken-2"> |
... | @@ -127,16 +177,24 @@ | ... | @@ -127,16 +177,24 @@ |
127 | </div> | 177 | </div> |
128 | </template> | 178 | </template> |
129 | <script> | 179 | <script> |
130 | -import { folder, makeFolder } from '../api/index'; | 180 | +import { folder, makeFolder, deleteFolder, moveFolder } from '../api/index'; |
181 | +import Axios from 'axios'; | ||
131 | export default { | 182 | export default { |
132 | data() { | 183 | data() { |
133 | return { | 184 | return { |
134 | foldername:'', | 185 | foldername:'', |
186 | + curfName:'', | ||
135 | folders: [], | 187 | folders: [], |
136 | files: [], | 188 | files: [], |
137 | search:'', | 189 | search:'', |
138 | id: '', | 190 | id: '', |
139 | - dialog:false | 191 | + dialog:false, |
192 | + search: '', | ||
193 | + howMenu: false, | ||
194 | + showMenu: false, | ||
195 | + x: 0, | ||
196 | + y: 0, | ||
197 | + dialog2:false | ||
140 | } | 198 | } |
141 | }, | 199 | }, |
142 | async created(){ | 200 | async created(){ |
... | @@ -150,6 +208,7 @@ import { folder, makeFolder } from '../api/index'; | ... | @@ -150,6 +208,7 @@ import { folder, makeFolder } from '../api/index'; |
150 | this.$store.commit('setFolder', response.data.folders); | 208 | this.$store.commit('setFolder', response.data.folders); |
151 | this.$store.commit('setCur', response.data.cur); | 209 | this.$store.commit('setCur', response.data.cur); |
152 | this.$store.commit('setParent', response.data.parentPath); | 210 | this.$store.commit('setParent', response.data.parentPath); |
211 | + this.folders = this.$store.getters.folderL; | ||
153 | } catch (error) { | 212 | } catch (error) { |
154 | console.log("에러"); | 213 | console.log("에러"); |
155 | console.log(error.response.data); | 214 | console.log(error.response.data); |
... | @@ -159,6 +218,10 @@ import { folder, makeFolder } from '../api/index'; | ... | @@ -159,6 +218,10 @@ import { folder, makeFolder } from '../api/index'; |
159 | initFolderName(){ | 218 | initFolderName(){ |
160 | this.foldername = ''; | 219 | this.foldername = ''; |
161 | }, | 220 | }, |
221 | + cancelMove(){ | ||
222 | + this.curfName = ''; | ||
223 | + this.dialog2 = false; | ||
224 | + }, | ||
162 | async makeF(){ | 225 | async makeF(){ |
163 | try { | 226 | try { |
164 | const folderData = { | 227 | const folderData = { |
... | @@ -170,6 +233,7 @@ import { folder, makeFolder } from '../api/index'; | ... | @@ -170,6 +233,7 @@ import { folder, makeFolder } from '../api/index'; |
170 | console.log(response.data) | 233 | console.log(response.data) |
171 | console.log("폴더 생성 완료"); | 234 | console.log("폴더 생성 완료"); |
172 | this.$store.commit('setFolder', response.data.folders); | 235 | this.$store.commit('setFolder', response.data.folders); |
236 | + this.folders = respons.data.folders; | ||
173 | } catch (error) { | 237 | } catch (error) { |
174 | console.log("에러"); | 238 | console.log("에러"); |
175 | console.log(error.response.data); | 239 | console.log(error.response.data); |
... | @@ -189,10 +253,78 @@ import { folder, makeFolder } from '../api/index'; | ... | @@ -189,10 +253,78 @@ import { folder, makeFolder } from '../api/index'; |
189 | this.$store.commit('setFolder', response.data.folders); | 253 | this.$store.commit('setFolder', response.data.folders); |
190 | this.$store.commit('setCur', response.data.cur); | 254 | this.$store.commit('setCur', response.data.cur); |
191 | this.$store.commit('setParent', response.data.parentPath); | 255 | this.$store.commit('setParent', response.data.parentPath); |
256 | + this.folders = this.$store.getters.folderL; | ||
257 | + } catch (error) { | ||
258 | + console.log("에러"); | ||
259 | + console.log(error.response.data); | ||
260 | + } | ||
261 | + }, | ||
262 | + async moveParent(){ | ||
263 | + try { | ||
264 | + const cData = { | ||
265 | + id : this.$store.state.id, | ||
266 | + cur : this.$store.state.parent | ||
267 | + }; | ||
268 | + const response= await folder(cData); | ||
269 | + console.log(response.data); | ||
270 | + this.$store.commit('setFolder', response.data.folders); | ||
271 | + this.$store.commit('setCur', response.data.cur); | ||
272 | + this.$store.commit('setParent', response.data.parentPath); | ||
273 | + this.folders = this.$store.getters.folderL; | ||
192 | } catch (error) { | 274 | } catch (error) { |
193 | console.log("에러"); | 275 | console.log("에러"); |
194 | console.log(error.response.data); | 276 | console.log(error.response.data); |
195 | } | 277 | } |
278 | + }, | ||
279 | + async deleteF(){ | ||
280 | + try { | ||
281 | + const cData = { | ||
282 | + id: this.$store.state.id, | ||
283 | + cur : this.$store.state.cur, | ||
284 | + folder_name: this.curfName | ||
285 | + } | ||
286 | + const response = await deleteFolder(cData); | ||
287 | + console.log(response); | ||
288 | + this.$store.commit('setFolder', response.data.folders); | ||
289 | + this.folders = this.$store.getters.folderL; | ||
290 | + } catch (error) { | ||
291 | + console.log("에러"); | ||
292 | + console.log(error.response.data); | ||
293 | + } finally{ | ||
294 | + this.curfName = ''; | ||
295 | + } | ||
296 | + }, | ||
297 | + async transferF(folderName){ | ||
298 | + try { | ||
299 | + const cData = { | ||
300 | + id: this.$store.state.id, | ||
301 | + cur : this.$store.state.cur, | ||
302 | + folder_name: this.curfName, | ||
303 | + isfolder: true, | ||
304 | + newPath: this.$store.state.cur + folderName + '/' | ||
305 | + } | ||
306 | + const response = await moveFolder(cData); | ||
307 | + console.log(response); | ||
308 | + this.$store.commit('setFolder', response.data.folders); | ||
309 | + this.folders = this.$store.getters.folderL; | ||
310 | + } catch (error) { | ||
311 | + console.log("에러"); | ||
312 | + console.log(error.response.data); | ||
313 | + } finally{ | ||
314 | + this.initFolderName(); | ||
315 | + this.curfName = ''; | ||
316 | + this.dialog2 = false; | ||
317 | + } | ||
318 | + }, | ||
319 | + show (folderN, e) { | ||
320 | + e.preventDefault() | ||
321 | + this.curfName = folderN; | ||
322 | + this.showMenu = false | ||
323 | + this.x = e.clientX | ||
324 | + this.y = e.clientY | ||
325 | + this.$nextTick(() => { | ||
326 | + this.showMenu = true | ||
327 | + }) | ||
196 | } | 328 | } |
197 | } | 329 | } |
198 | } | 330 | } | ... | ... |
... | @@ -6,8 +6,8 @@ Vue.use(Vuex) | ... | @@ -6,8 +6,8 @@ Vue.use(Vuex) |
6 | export default new Vuex.Store({ | 6 | export default new Vuex.Store({ |
7 | state: { | 7 | state: { |
8 | id: '', | 8 | id: '', |
9 | - folders: {}, | 9 | + folders: [], |
10 | - files: {}, | 10 | + files: [], |
11 | cur: '/', | 11 | cur: '/', |
12 | parent: '/' | 12 | parent: '/' |
13 | }, | 13 | }, | ... | ... |
-
Please register or login to post a comment