Showing
10 changed files
with
771 additions
and
194 deletions
... | @@ -13,6 +13,8 @@ var fileRouter = require('./routes/file/router'); | ... | @@ -13,6 +13,8 @@ var fileRouter = require('./routes/file/router'); |
13 | //var trashcanRouter = require('./routes/trashcan/router'); | 13 | //var trashcanRouter = require('./routes/trashcan/router'); |
14 | var folderRouter = require('./routes/folders'); | 14 | var folderRouter = require('./routes/folders'); |
15 | var quickRouter = require('./routes/quick'); | 15 | var quickRouter = require('./routes/quick'); |
16 | +var favoritesRouter = require('./routes/favorites'); | ||
17 | +var shareRouter = require('./routes/share'); | ||
16 | 18 | ||
17 | 19 | ||
18 | var passport = require('passport'); | 20 | var passport = require('passport'); |
... | @@ -60,6 +62,8 @@ app.use('/api/user', userRouter); | ... | @@ -60,6 +62,8 @@ app.use('/api/user', userRouter); |
60 | app.use('/api/login', loginRouter); | 62 | app.use('/api/login', loginRouter); |
61 | app.use('/api/RegistUser', registerRouter); | 63 | app.use('/api/RegistUser', registerRouter); |
62 | app.use('/api/folder', folderRouter); | 64 | app.use('/api/folder', folderRouter); |
65 | +app.use('/api/favorites', favoritesRouter); | ||
66 | +app.use('/api/share', shareRouter); | ||
63 | //app.use('/users', usersRouter); | 67 | //app.use('/users', usersRouter); |
64 | app.use('/api/file', fileRouter); | 68 | app.use('/api/file', fileRouter); |
65 | app.use('/api/quick', quickRouter); | 69 | app.use('/api/quick', quickRouter); | ... | ... |
backend/routes/favorites.js
0 → 100644
1 | +const express = require('express'); | ||
2 | +const router = express.Router(); | ||
3 | + | ||
4 | +router.get('/show', function(req, res, next) { | ||
5 | + console.log(req.query); | ||
6 | + user_id = req.query.id; | ||
7 | + let folders = []; | ||
8 | + let files = []; | ||
9 | + | ||
10 | + let checkfolder = 'SELECT * FROM folders WHERE user_id = ? AND favorite = 1;'; | ||
11 | + let checkfiles = 'SELECT * FROM files WHERE user_id = ? AND favorite = 1;'; | ||
12 | + connection.query(checkfolder, [user_id], function(err, folder, fields) { | ||
13 | + if (err) { | ||
14 | + console.log('select error'); | ||
15 | + res.status(404).send(); | ||
16 | + } else { | ||
17 | + folders.push(folder); | ||
18 | + connection.query(checkfiles, [user_id], function(err, file, fields) { | ||
19 | + if (err) { | ||
20 | + console.log('select error'); | ||
21 | + res.status(404).send(); | ||
22 | + } else { | ||
23 | + files.push(file); | ||
24 | + res.status(200).send({ | ||
25 | + folders: folders, | ||
26 | + files: files | ||
27 | + }); | ||
28 | + } | ||
29 | + }); | ||
30 | + } | ||
31 | + }); | ||
32 | +}); | ||
33 | + | ||
34 | +router.post('/addfolder', function(req, res, next) { | ||
35 | + let user_id = req.body.id; | ||
36 | + let folder_name = req.body.name; | ||
37 | + let cur = req.body.cur; | ||
38 | + console.log(req.body); | ||
39 | + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ? AND folder_name = ? AND favorite = 1;'; | ||
40 | + connection.query(checkfolder, [cur, user_id, folder_name], function(err, rows, fields) { | ||
41 | + if (err) { | ||
42 | + console.log('select error'); | ||
43 | + res.status(400).send({ error: err }); | ||
44 | + } else { | ||
45 | + if (rows.length == 0) { | ||
46 | + let sql = 'UPDATE folders SET favorite = 1 WHERE location = ? AND folder_name = ? AND user_id = ?;'; | ||
47 | + connection.query(sql, [cur, folder_name, user_id], function(err, result, fields) { | ||
48 | + if (err) { | ||
49 | + console.log('update error'); | ||
50 | + res.status(400).send({ error: err }); | ||
51 | + } else { | ||
52 | + let getfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | ||
53 | + connection.query(getfolder, [cur, user_id], function(err, folders, fields) { | ||
54 | + res.status(200).send({ | ||
55 | + folders: folders | ||
56 | + }) | ||
57 | + }); | ||
58 | + } | ||
59 | + }); | ||
60 | + } else { | ||
61 | + console.log('already exist error'); | ||
62 | + res.status(400).send({ error: err }); | ||
63 | + } | ||
64 | + } | ||
65 | + }); | ||
66 | +}); | ||
67 | + | ||
68 | +router.post('/addfile', function(req, res, next) { | ||
69 | + let user_id = req.body.id; | ||
70 | + let file_name = req.body.name; | ||
71 | + let cur = req.body.cur; | ||
72 | + console.log(req.body); | ||
73 | + let checkfolder = 'SELECT * FROM files WHERE location = ? AND user_id = ? AND file_name = ? AND favorite = 1;'; | ||
74 | + connection.query(checkfolder, [cur, user_id, file_name], function(err, rows, fields) { | ||
75 | + if (err) { | ||
76 | + console.log('select error'); | ||
77 | + res.status(400).send({ error: err }); | ||
78 | + } else { | ||
79 | + if (rows.length == 0) { | ||
80 | + let sql = 'UPDATE files SET favorite = 1 WHERE location = ? AND file_name = ? AND user_id = ?;'; | ||
81 | + connection.query(sql, [cur, file_name, user_id], function(err, result, fields) { | ||
82 | + if (err) { | ||
83 | + console.log('update error'); | ||
84 | + res.status(400).send({ error: err }); | ||
85 | + } else { | ||
86 | + let getfolder = 'SELECT * FROM files WHERE location = ? AND user_id = ?;'; | ||
87 | + connection.query(getfolder, [cur, user_id], function(err, files, fields) { | ||
88 | + res.status(200).send({ | ||
89 | + files: files | ||
90 | + }) | ||
91 | + }); | ||
92 | + } | ||
93 | + }); | ||
94 | + } else { | ||
95 | + console.log('already exist error'); | ||
96 | + res.status(400).send({ error: err }); | ||
97 | + } | ||
98 | + } | ||
99 | + }); | ||
100 | +}); | ||
101 | + | ||
102 | +router.post('/delfolder', function(req, res, next) { | ||
103 | + let user_id = req.body.id; | ||
104 | + let folder_name = req.body.name; | ||
105 | + let cur = req.body.cur; | ||
106 | + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ? AND folder_name = ? AND favorite = 1;'; | ||
107 | + | ||
108 | + connection.query(checkfolder, [cur, user_id, folder_name], function(err, rows, fields) { | ||
109 | + if (err) { | ||
110 | + console.log('select error'); | ||
111 | + res.status(400).send({ error: err }); | ||
112 | + } else { | ||
113 | + if (rows.length != 0) { | ||
114 | + let sql = 'UPDATE folders SET favorite = 0 WHERE location = ? AND folder_name = ? AND user_id = ?;'; | ||
115 | + connection.query(sql, [cur, folder_name, user_id], function(err, result, fields) { | ||
116 | + if (err) { | ||
117 | + console.log('update error'); | ||
118 | + res.status(400).send({ error: err }); | ||
119 | + } else { | ||
120 | + let getfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | ||
121 | + connection.query(getfolder, [cur, user_id], function(err, folders, fields) { | ||
122 | + res.status(200).send({ | ||
123 | + folders: folders | ||
124 | + }) | ||
125 | + }); | ||
126 | + } | ||
127 | + }); | ||
128 | + } else { | ||
129 | + console.log('dont exist error'); | ||
130 | + res.status(400).send({ error: err }); | ||
131 | + } | ||
132 | + } | ||
133 | + }); | ||
134 | +}); | ||
135 | + | ||
136 | +router.post('/delfile', function(req, res, next) { | ||
137 | + let user_id = req.body.id; | ||
138 | + let file_name = req.body.name; | ||
139 | + let cur = req.body.cur; | ||
140 | + let checkfile = 'SELECT * FROM files WHERE location = ? AND user_id = ? AND file_name = ? AND favorite = 1;'; | ||
141 | + | ||
142 | + connection.query(checkfile, [cur, user_id, file_name], function(err, rows, fields) { | ||
143 | + if (err) { | ||
144 | + console.log('select error'); | ||
145 | + res.status(400).send({ error: err }); | ||
146 | + } else { | ||
147 | + if (rows.length != 0) { | ||
148 | + let sql = 'UPDATE files SET favorite = 0 WHERE location = ? AND file_name = ? AND user_id = ?;'; | ||
149 | + connection.query(sql, [cur, file_name, user_id], function(err, result, fields) { | ||
150 | + if (err) { | ||
151 | + console.log('update error'); | ||
152 | + res.status(400).send({ error: err }); | ||
153 | + } else { | ||
154 | + let getfile = 'SELECT * FROM files WHERE location = ? AND user_id = ?;'; | ||
155 | + connection.query(getfile, [cur, user_id], function(err, files, fields) { | ||
156 | + res.status(200).send({ | ||
157 | + files: files | ||
158 | + }) | ||
159 | + }); | ||
160 | + } | ||
161 | + }); | ||
162 | + } else { | ||
163 | + console.log('dont exist error'); | ||
164 | + res.status(400).send({ error: err }); | ||
165 | + } | ||
166 | + } | ||
167 | + }); | ||
168 | +}); | ||
169 | + | ||
170 | + | ||
171 | + | ||
172 | +module.exports = router; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -3,7 +3,7 @@ const router = express.Router(); | ... | @@ -3,7 +3,7 @@ const router = express.Router(); |
3 | const AWS = require("aws-sdk"); | 3 | const AWS = require("aws-sdk"); |
4 | const moment = require("moment"); | 4 | const moment = require("moment"); |
5 | 5 | ||
6 | -const BUCKET_NAME = "hong-s3-cloud"; | 6 | +const BUCKET_NAME = "qkrrlqja-test"; |
7 | let curPath = ""; | 7 | let curPath = ""; |
8 | let user_id = ""; | 8 | let user_id = ""; |
9 | let parentPath = ""; | 9 | let parentPath = ""; |
... | @@ -33,7 +33,7 @@ router.get('/show', function(req, res, next) { | ... | @@ -33,7 +33,7 @@ router.get('/show', function(req, res, next) { |
33 | connection.query(checkfolder, [curPath, user_id], function(err, rows, fields) { | 33 | connection.query(checkfolder, [curPath, user_id], function(err, rows, fields) { |
34 | if (err) { | 34 | if (err) { |
35 | console.log('select error'); | 35 | console.log('select error'); |
36 | - res.status(404).send() | 36 | + res.status(400).send({ err: err }); |
37 | } else { | 37 | } else { |
38 | res.status(200).send({ | 38 | res.status(200).send({ |
39 | folders: rows, | 39 | folders: rows, |
... | @@ -54,7 +54,7 @@ router.post('/makefolder', function(req, res, next) { | ... | @@ -54,7 +54,7 @@ router.post('/makefolder', function(req, res, next) { |
54 | let date = moment().format(); | 54 | let date = moment().format(); |
55 | let params = { | 55 | let params = { |
56 | Bucket: BUCKET_NAME, | 56 | Bucket: BUCKET_NAME, |
57 | - Key: curPath + folder_name + '/', | 57 | + Key: 'drive/' + curPath + folder_name + '/', |
58 | Body: "", | 58 | Body: "", |
59 | ACL: "public-read-write" | 59 | ACL: "public-read-write" |
60 | }; | 60 | }; |
... | @@ -62,13 +62,13 @@ router.post('/makefolder', function(req, res, next) { | ... | @@ -62,13 +62,13 @@ router.post('/makefolder', function(req, res, next) { |
62 | console.log(req.body) | 62 | console.log(req.body) |
63 | connection.query(checksql, [cur, folder_name], function(err, rows, fields) { | 63 | connection.query(checksql, [cur, folder_name], function(err, rows, fields) { |
64 | if (err) { | 64 | if (err) { |
65 | - | 65 | + res.status(400).send({ err: err }); |
66 | } else { | 66 | } else { |
67 | if (rows.length == 0) { | 67 | if (rows.length == 0) { |
68 | s3.putObject(params, function(err, data) { | 68 | s3.putObject(params, function(err, data) { |
69 | if (err) { | 69 | if (err) { |
70 | console.log('s3 error'); | 70 | console.log('s3 error'); |
71 | - throw err; | 71 | + res.status(400).send({ err: err }); |
72 | } else { | 72 | } else { |
73 | console.log(data); | 73 | console.log(data); |
74 | 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 (?,?,?,?);'; |
... | @@ -76,7 +76,7 @@ router.post('/makefolder', function(req, res, next) { | ... | @@ -76,7 +76,7 @@ router.post('/makefolder', function(req, res, next) { |
76 | connection.query(sql, values, function(err, result, field) { | 76 | connection.query(sql, values, function(err, result, field) { |
77 | if (err) { | 77 | if (err) { |
78 | console.log('insert error'); | 78 | console.log('insert error'); |
79 | - throw err; | 79 | + res.status(400).send({ err: err }); |
80 | } else { | 80 | } else { |
81 | let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | 81 | let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; |
82 | connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { | 82 | connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { |
... | @@ -105,7 +105,7 @@ router.post('/delfolder', function(req, res, next) { | ... | @@ -105,7 +105,7 @@ router.post('/delfolder', function(req, res, next) { |
105 | let folder_name = req.body.folder_name; | 105 | let folder_name = req.body.folder_name; |
106 | let params = { | 106 | let params = { |
107 | Bucket: BUCKET_NAME, | 107 | Bucket: BUCKET_NAME, |
108 | - Key: curPath + folder_name + '/' | 108 | + Key: 'drive/' + curPath + folder_name + '/' |
109 | }; | 109 | }; |
110 | let checksql = 'SELECT * FROM folders WHERE location = ? AND folder_name = ? AND user_id = ?;'; | 110 | let checksql = 'SELECT * FROM folders WHERE location = ? AND folder_name = ? AND user_id = ?;'; |
111 | let values = [cur, folder_name, user_id]; | 111 | let values = [cur, folder_name, user_id]; |
... | @@ -117,13 +117,13 @@ router.post('/delfolder', function(req, res, next) { | ... | @@ -117,13 +117,13 @@ router.post('/delfolder', function(req, res, next) { |
117 | s3.deleteObject(params, function(err, data) { | 117 | s3.deleteObject(params, function(err, data) { |
118 | if (err) { | 118 | if (err) { |
119 | console.log('s3 error'); | 119 | console.log('s3 error'); |
120 | - //throw err; | 120 | + res.status(400).send({ err: err }); |
121 | } else { | 121 | } else { |
122 | console.log(data); | 122 | console.log(data); |
123 | let sql = 'DELETE FROM folders WHERE location = ? AND folder_name = ? AND user_id = ?;'; | 123 | let sql = 'DELETE FROM folders WHERE location = ? AND folder_name = ? AND user_id = ?;'; |
124 | connection.query(sql, values, function(err, result, field) { | 124 | connection.query(sql, values, function(err, result, field) { |
125 | if (err) { | 125 | if (err) { |
126 | - //throw err; | 126 | + res.status(400).send({ err: err }); |
127 | } else { | 127 | } else { |
128 | console.log(cur); | 128 | console.log(cur); |
129 | console.log(user_id); | 129 | console.log(user_id); |
... | @@ -152,7 +152,7 @@ router.post('/move', function(req, res, next) { | ... | @@ -152,7 +152,7 @@ router.post('/move', function(req, res, next) { |
152 | user_id = req.body.id; | 152 | user_id = req.body.id; |
153 | let cur = req.body.cur; | 153 | let cur = req.body.cur; |
154 | curPath = user_id + cur; | 154 | curPath = user_id + cur; |
155 | - let name = req.body.folder_name; | 155 | + let name = req.body.name; |
156 | let newPath = user_id + req.body.newPath; | 156 | let newPath = user_id + req.body.newPath; |
157 | if (req.body.isfolder) { | 157 | if (req.body.isfolder) { |
158 | let checkfolder = 'SELECT * FROM folders WHERE location = ? AND folder_name = ? AND user_id = ?;'; | 158 | let checkfolder = 'SELECT * FROM folders WHERE location = ? AND folder_name = ? AND user_id = ?;'; |
... | @@ -161,12 +161,12 @@ router.post('/move', function(req, res, next) { | ... | @@ -161,12 +161,12 @@ router.post('/move', function(req, res, next) { |
161 | if (rows.length != 0) { | 161 | if (rows.length != 0) { |
162 | let copy_params = { | 162 | let copy_params = { |
163 | Bucket: BUCKET_NAME, | 163 | Bucket: BUCKET_NAME, |
164 | - CopySource: BUCKET_NAME + '/' + curPath + name + '/', | 164 | + CopySource: BUCKET_NAME + '/drive/' + curPath + name + '/', |
165 | - Key: newPath + name + '/' | 165 | + Key: 'drive/' + newPath + name + '/' |
166 | }; | 166 | }; |
167 | let del_params = { | 167 | let del_params = { |
168 | Bucket: BUCKET_NAME, | 168 | Bucket: BUCKET_NAME, |
169 | - Key: curPath + name + '/' | 169 | + Key: 'drive/' + curPath + name + '/' |
170 | }; | 170 | }; |
171 | s3.copyObject(copy_params, function(err, data) { | 171 | s3.copyObject(copy_params, function(err, data) { |
172 | if (err) { | 172 | if (err) { |
... | @@ -200,22 +200,22 @@ router.post('/move', function(req, res, next) { | ... | @@ -200,22 +200,22 @@ router.post('/move', function(req, res, next) { |
200 | } | 200 | } |
201 | }); | 201 | }); |
202 | } else { | 202 | } else { |
203 | - console.log("Does not exist"); | 203 | + console.log("Does not exist folder"); |
204 | res.status(304).send({ error: "Does not exist" }); | 204 | res.status(304).send({ error: "Does not exist" }); |
205 | } | 205 | } |
206 | }); | 206 | }); |
207 | } else { | 207 | } else { |
208 | - let checkfile = 'SELECT * FROM files WHERE location = ? AND file_name = ? AND user_id = ?'; | 208 | + let checkfile = 'SELECT * FROM files WHERE location = ? AND file_name = ? AND user_id = ?;'; |
209 | - connection.query(checkfile, [curPath, name, user_id], function(err1, rows, fields) { | 209 | + connection.query(checkfile, [cur, name, user_id], function(err1, rows, fields) { |
210 | if (rows.length != 0) { | 210 | if (rows.length != 0) { |
211 | let copy_params = { | 211 | let copy_params = { |
212 | Bucket: BUCKET_NAME, | 212 | Bucket: BUCKET_NAME, |
213 | - CopySource: BUCKET_NAME + '/' + curPath + file, | 213 | + CopySource: BUCKET_NAME + '/drive/' + curPath + name, |
214 | - Key: newPath + file | 214 | + Key: 'drive/' + newPath + name |
215 | }; | 215 | }; |
216 | let del_params = { | 216 | let del_params = { |
217 | Bucket: BUCKET_NAME, | 217 | Bucket: BUCKET_NAME, |
218 | - Key: curPath + file | 218 | + Key: 'drive/' + curPath + name |
219 | }; | 219 | }; |
220 | s3.copyObject(copy_params, function(err, data) { | 220 | s3.copyObject(copy_params, function(err, data) { |
221 | if (err) { | 221 | if (err) { |
... | @@ -227,7 +227,7 @@ router.post('/move', function(req, res, next) { | ... | @@ -227,7 +227,7 @@ router.post('/move', function(req, res, next) { |
227 | console.log(err, data); | 227 | console.log(err, data); |
228 | res.status(304).send({ error: "delete error" }); | 228 | res.status(304).send({ error: "delete error" }); |
229 | } else { | 229 | } else { |
230 | - let values = [newPath, cur, name, user_id]; | 230 | + let values = [req.body.newPath, cur, name, user_id]; |
231 | let updatesql = 'UPDATE files SET location = ? WHERE location = ? AND file_name = ? AND user_id = ?;'; | 231 | let updatesql = 'UPDATE files SET location = ? WHERE location = ? AND file_name = ? AND user_id = ?;'; |
232 | connection.query(updatesql, values, function(err3, result, field) { | 232 | connection.query(updatesql, values, function(err3, result, field) { |
233 | if (err3) { | 233 | if (err3) { |
... | @@ -246,6 +246,7 @@ router.post('/move', function(req, res, next) { | ... | @@ -246,6 +246,7 @@ router.post('/move', function(req, res, next) { |
246 | } | 246 | } |
247 | }); | 247 | }); |
248 | } else { | 248 | } else { |
249 | + console.log("Does not exist file"); | ||
249 | res.status(304).send({ error: "Does not exist" }); | 250 | res.status(304).send({ error: "Does not exist" }); |
250 | } | 251 | } |
251 | }); | 252 | }); |
... | @@ -254,20 +255,89 @@ router.post('/move', function(req, res, next) { | ... | @@ -254,20 +255,89 @@ router.post('/move', function(req, res, next) { |
254 | }); | 255 | }); |
255 | 256 | ||
256 | 257 | ||
257 | -router.post('/search/:target', function(req, res, next) { | 258 | +router.post('/modify', function(req, res, next) { |
258 | - user_id = req.params.id; | 259 | + console.log(req.body); |
259 | - let cur = req.params.cur; | 260 | + user_id = req.body.id; |
260 | - folders = {} | 261 | + let cur = req.body.cur; |
261 | - let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | 262 | + curPath = user_id + cur; |
262 | - connection.query(checkfolder, [cur, user_id], function(err, rows, fields) { | 263 | + let name = req.body.folder_name; |
264 | + let newName = req.body.newName; | ||
265 | + | ||
266 | + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND folder_name = ? AND user_id = ?;'; | ||
267 | + connection.query(checkfolder, [cur, name, user_id], function(err1, rows, fields) { | ||
268 | + console.log(rows); | ||
263 | if (rows.length != 0) { | 269 | if (rows.length != 0) { |
270 | + let copy_params = { | ||
271 | + Bucket: BUCKET_NAME, | ||
272 | + CopySource: BUCKET_NAME + '/drive/' + curPath + name + '/', | ||
273 | + Key: 'drive/' + curPath + newName + '/' | ||
274 | + }; | ||
275 | + let del_params = { | ||
276 | + Bucket: BUCKET_NAME, | ||
277 | + Key: 'drive/' + curPath + name + '/' | ||
278 | + }; | ||
279 | + s3.copyObject(copy_params, function(err, data) { | ||
280 | + if (err) { | ||
281 | + console.log(err, data); | ||
282 | + console.log("copy error"); | ||
283 | + res.status(304).send({ error: "copy error" }); | ||
284 | + } else { | ||
285 | + s3.deleteObject(del_params, function(err, data) { | ||
286 | + if (err) { | ||
287 | + console.log(err, data); | ||
288 | + console.log("delete error"); | ||
289 | + res.status(304).send({ error: "delete error" }); | ||
290 | + } else { | ||
291 | + let date = moment().format(); | ||
292 | + let values = [newName, date, cur, name, user_id]; | ||
293 | + let updatesql = 'UPDATE folders SET folder_name = ? AND modify = ? WHERE location = ? AND folder_name = ? AND user_id = ?;'; | ||
294 | + connection.query(updatesql, values, function(err3, result, field) { | ||
295 | + if (err3) { | ||
296 | + console.log("updatesql error"); | ||
297 | + res.status(304).send({ error: "updatesql error" }); | ||
298 | + } else { | ||
299 | + let resultsql = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;'; | ||
300 | + connection.query(resultsql, [cur, user_id], function(err, rows, fields) { | ||
264 | res.status(200).send({ | 301 | res.status(200).send({ |
265 | - folders: folders | 302 | + folders: rows |
266 | - }) | 303 | + }); |
304 | + }); | ||
305 | + } | ||
306 | + }); | ||
307 | + } | ||
308 | + }); | ||
309 | + } | ||
310 | + }); | ||
267 | } else { | 311 | } else { |
268 | - res.send({ error: "Does not exist" }); | 312 | + console.log("Does not exist"); |
313 | + res.status(304).send({ error: "Does not exist" }); | ||
269 | } | 314 | } |
270 | }); | 315 | }); |
316 | + | ||
317 | +}); | ||
318 | + | ||
319 | +router.get('/search', function(req, res, next) { | ||
320 | + console.log(req.query); | ||
321 | + user_id = req.query.id; | ||
322 | + let target = connection.escape('%' + req.query.target + '%'); | ||
323 | + console.log(target); | ||
324 | + let folders = [] | ||
325 | + let files = [] | ||
326 | + let checkfolder = 'SELECT * FROM folders WHERE folder_name LIKE ' + target + ' AND user_id = ?;'; | ||
327 | + connection.query(checkfolder, [user_id], function(err, folder, fields) { | ||
328 | + console.log(folder); | ||
329 | + folders.push(folder) | ||
330 | + let checkfile = 'SELECT * FROM files WHERE file_name LIKE ' + target + ' AND user_id = ?;'; | ||
331 | + connection.query(checkfile, [user_id], function(err, file, fields) { | ||
332 | + console.log(file); | ||
333 | + files.push(file) | ||
334 | + res.status(200).send({ | ||
335 | + folders: folders, | ||
336 | + files: files | ||
337 | + }) | ||
338 | + }); | ||
339 | + }); | ||
340 | + | ||
271 | }); | 341 | }); |
272 | 342 | ||
273 | module.exports = router; | 343 | module.exports = router; | ... | ... |
1 | { | 1 | { |
2 | - "accessKeyId": "ASIAXZL2SWFE2KIQ3YTL", | 2 | + "accessKeyId": "ASIAXZL2SWFEZSIHHRDT", |
3 | - "secretAccessKey": "BqniXH7AqxjndKHjxBWKjRkBOgRmSN8J6mgldm7C", | 3 | + "secretAccessKey": "cdcXCezNz9OhFowZxE2KSftDmT3xSYAtiLJl1dFk", |
4 | - "sessionToken": "FwoGZXIvYXdzEIL//////////wEaDC6uNIWZKpDL9FekbiLDAb7ckeHQwp1tV2wu236TIia7VBtYMFQrLzkEm6sU7GiamzWfzrTCsQOOJXYMKzElNXD7dRckn30aVaw8xfNDgimqWdtk9O3x8jgCOp4gXk4KIUgtIFpN46qdGNxy28gL43voIf4O6n3boJaUum9bmejzmNlR8U4d6NfqMzrtJENs47Nl4fAiK8bIGlsznhr7MC5AUeZbV0d9uK7bkx1rn5zRRpR9WbbwofVIlK+YSEEHfQIJyLeJKDlprBXfqSTynCqkAyj8ovT2BTItQ8+cOmQXWuzPMA/Rbru2naLM3Hd2H8jEW6CMfPXvNAS+leVNDXuCY5r5Ebo9", | 4 | + "sessionToken": "FwoGZXIvYXdzEJf//////////wEaDG1NOyJj0/Xdzqu+uyLDAa8vgymCVldXPpET+AOsq5CXhMzhMEDmWogIaq6lWJVy8sdnK9tOXY/u9vz8p6cTm7xWb0YiX6TKDhlfFZX6ynv0Xw/p/qvbn4lPsoT8K9PpdDOWJUMA8qX/5RrKNO4OAolUkw+EMjQbK38u+g3HEVP8mo+DiGLrBGj+0Ar0xhGiU/Lg5qKRdp+tEYIn0ypDNu/2q13apRiMH7n+OVFzilil10g1qq8NLaW98QvVC4xRIgkjAMcRqA9yPdVrhc9yFyqjrCjA+vj2BTIt8CDkFsEAFqJR3W0YPDbsu2YdTq3SKgpOsxNXGsEFMaEhFxodp5/Qsk7tfMsO", |
5 | "region": "us-east-1" | 5 | "region": "us-east-1" |
6 | } | 6 | } | ... | ... |
backend/routes/share.js
0 → 100644
1 | +const express = require('express'); | ||
2 | +const router = express.Router(); | ||
3 | +const AWS = require("aws-sdk"); | ||
4 | +const moment = require("moment"); | ||
5 | + | ||
6 | +const BUCKET_NAME = "hong-s3-cloud"; | ||
7 | + | ||
8 | +const s3 = new AWS.S3({ | ||
9 | + accessKeyId: process.env.AWS_ACCESS_KEY_ID, | ||
10 | + secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, | ||
11 | + region: "ap-northeast-2" | ||
12 | +}); | ||
13 | + | ||
14 | + | ||
15 | +router.post('/', function(req, res, next) { | ||
16 | + console.log(req.body); | ||
17 | + let user_id = req.body.id; | ||
18 | + let cur = req.body.cur; | ||
19 | + let curPath = user_id + cur; | ||
20 | + let name = req.body.file_name; | ||
21 | + let target_id = req.body.target_id; | ||
22 | + | ||
23 | + let checkfile = 'SELECT * FROM files WHERE location = ? AND file_name = ? AND user_id = ?'; | ||
24 | + connection.query(checkfile, [curPath, name, user_id], function(err1, rows, fields) { | ||
25 | + if (rows.length != 0) { | ||
26 | + let copy_params = { | ||
27 | + Bucket: BUCKET_NAME, | ||
28 | + CopySource: BUCKET_NAME + '/' + curPath + name, | ||
29 | + Key: target_id + '/share/' + name | ||
30 | + }; | ||
31 | + s3.copyObject(copy_params, function(err, data) { | ||
32 | + if (err) { | ||
33 | + console.log(err, data); | ||
34 | + res.status(304).send({ error: "copy error" }); | ||
35 | + } else { | ||
36 | + let values = [name, cur, target_id]; | ||
37 | + let sharesql = 'INSERT INTO files (file_name,location,user_id) values (?,?,?);'; | ||
38 | + connection.query(sharesql, values, function(err3, result, field) { | ||
39 | + if (err3) { | ||
40 | + console.log("sharesql error"); | ||
41 | + res.status(304).send({ error: "sharesql error" }); | ||
42 | + } else { | ||
43 | + res.status(200).send({}); | ||
44 | + } | ||
45 | + }); | ||
46 | + } | ||
47 | + }); | ||
48 | + } else { | ||
49 | + res.status(304).send({ error: "Does not exist" }); | ||
50 | + } | ||
51 | + }); | ||
52 | + | ||
53 | +}); | ||
54 | + | ||
55 | +module.exports = router; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | var express = require('express'); | 1 | var express = require('express'); |
2 | var request = require('request'); | 2 | var request = require('request'); |
3 | var async = require('async'); | 3 | var async = require('async'); |
4 | - | 4 | +const AWS = require("aws-sdk"); |
5 | +AWS.config.loadFromPath(__dirname + "/../modules/awsconfig.json"); | ||
5 | var cryptoM = require('./../../routes/modules/cryptoM.js'); | 6 | var cryptoM = require('./../../routes/modules/cryptoM.js'); |
7 | +const moment = require("moment"); | ||
8 | + | ||
9 | +const BUCKET_NAME = "hong-s3-cloud"; | ||
10 | +const s3 = new AWS.S3(); | ||
6 | 11 | ||
7 | var router = express.Router(); | 12 | var router = express.Router(); |
8 | 13 | ||
... | @@ -14,25 +19,83 @@ router.get('/', function(req, res, next) { | ... | @@ -14,25 +19,83 @@ router.get('/', function(req, res, next) { |
14 | 19 | ||
15 | router.post('/', function(req, res, next) { | 20 | router.post('/', function(req, res, next) { |
16 | console.log(req.body); | 21 | console.log(req.body); |
17 | - var user_id=req.body.user_id; | 22 | + var user_id = req.body.user_id; |
18 | - var user_pw=req.body.user_pw; | 23 | + var user_pw = req.body.user_pw; |
19 | - var user_email=req.body.user_email; | 24 | + var user_email = req.body.user_email; |
20 | - var user_name=req.body.user_name; | 25 | + var user_name = req.body.user_name; |
21 | - var user_phone=req.body.user_phone; | 26 | + var user_phone = req.body.user_phone; |
22 | 27 | ||
23 | var sqlquery = "SELECT * FROM users WHERE user_id = ?"; | 28 | var sqlquery = "SELECT * FROM users WHERE user_id = ?"; |
24 | - connection.query(sqlquery, [user_id], function (err, rows) { | 29 | + connection.query(sqlquery, [user_id], function(err, rows) { |
25 | if (rows.length == 0) { | 30 | if (rows.length == 0) { |
26 | - user_pw=cryptoM.encrypt(user_pw); | 31 | + user_pw = cryptoM.encrypt(user_pw); |
27 | console.log(user_pw); | 32 | console.log(user_pw); |
28 | var sql = 'INSERT INTO users(user_id,user_pw, user_email, user_phone, user_name) values (?,?,?,?,?)'; | 33 | var sql = 'INSERT INTO users(user_id,user_pw, user_email, user_phone, user_name) values (?,?,?,?,?)'; |
29 | - var values = [user_id, user_pw, user_email, user_phone,user_name]; | 34 | + var values = [user_id, user_pw, user_email, user_phone, user_name]; |
30 | - connection.query(sql, values, function (err) { | 35 | + connection.query(sql, values, function(err) { |
31 | if (err) { | 36 | if (err) { |
32 | console.log("inserting user failed"); | 37 | console.log("inserting user failed"); |
33 | - throw err; | 38 | + res.status(400).send({ err: err }); |
39 | + } else { | ||
40 | + let params = { | ||
41 | + Bucket: BUCKET_NAME, | ||
42 | + Key: 'drive/' + user_id + '/', | ||
43 | + Body: "", | ||
44 | + ACL: "public-read-write" | ||
45 | + }; | ||
46 | + s3.putObject(params, function(err, data) { | ||
47 | + if (err) { | ||
48 | + console.log('s3 error'); | ||
49 | + res.status(400).send({ err: err }); | ||
50 | + } else { | ||
51 | + let params2 = { | ||
52 | + Bucket: BUCKET_NAME, | ||
53 | + Key: 'drive/' + user_id + '/share/', | ||
54 | + Body: "", | ||
55 | + ACL: "public-read-write" | ||
56 | + }; | ||
57 | + s3.putObject(params2, function(err, data) { | ||
58 | + if (err) { | ||
59 | + console.log('s3 error'); | ||
60 | + res.status(400).send({ err: err }); | ||
61 | + } else { | ||
62 | + let params3 = { | ||
63 | + Bucket: BUCKET_NAME, | ||
64 | + Key: 'drive/' + user_id + '/trashcan/', | ||
65 | + Body: "", | ||
66 | + ACL: "public-read-write" | ||
67 | + }; | ||
68 | + s3.putObject(params3, function(err, data) { | ||
69 | + if (err) { | ||
70 | + console.log('s3 error'); | ||
71 | + res.status(400).send({ err: err }); | ||
72 | + } else { | ||
73 | + let date = moment().format(); | ||
74 | + let root = '/'; | ||
75 | + let sql = "INSERT INTO folders (folder_name,location,user_id,created) values (?,?,?,?);"; | ||
76 | + connection.query(sql, ['share', root, user_id, date], function(err, result, field) { | ||
77 | + if (err) { | ||
78 | + console.log('insert1 error'); | ||
79 | + res.status(400).send({ err: err }); | ||
80 | + } else { | ||
81 | + let sql = "INSERT INTO folders (folder_name,location,user_id,created) values (?,?,?,?);"; | ||
82 | + connection.query(sql, ['trashcan', root, user_id, date], function(err, result, field) { | ||
83 | + if (err) { | ||
84 | + console.log('insert2 error'); | ||
85 | + res.status(400).send({ err: err }); | ||
34 | } else { | 86 | } else { |
35 | res.status(200).send('saved'); | 87 | res.status(200).send('saved'); |
88 | + } | ||
89 | + }); | ||
90 | + } | ||
91 | + }); | ||
92 | + } | ||
93 | + }); | ||
94 | + } | ||
95 | + }); | ||
96 | + } | ||
97 | + }); | ||
98 | + | ||
36 | 99 | ||
37 | } | 100 | } |
38 | }); | 101 | }); | ... | ... |
... | @@ -79,25 +79,35 @@ function downloadFile(fileData) { | ... | @@ -79,25 +79,35 @@ function downloadFile(fileData) { |
79 | }, | 79 | }, |
80 | }); | 80 | }); |
81 | } | 81 | } |
82 | -function accessedList(curData) { | 82 | +function accessedList(curData){ |
83 | - return axios.get(`api/quick`, { | 83 | + return axios.get('api/quick', { |
84 | - params: { | 84 | + params:{ |
85 | - //현재 접속한 사람의 id와 다운로드를 위해 선택한 파일의 이름을 파라미터로 넘긴다. | ||
86 | id: curData.id | 85 | id: curData.id |
87 | }, | 86 | }, |
88 | }); | 87 | }); |
89 | } | 88 | } |
90 | function modifyFile(fileData){ | 89 | function modifyFile(fileData){ |
91 | - return axios.post(`/api/file/modify/${fileName}`, { | 90 | + return axios.post(`/api/file/modify/${fileData.name}`, fileData) |
92 | - params: { | 91 | +} |
93 | - user_id: fileData.id, | 92 | +function delFavorite(folderData) { |
94 | - cur: fileData.cur, | 93 | + return axios.post('api/favorites/delfolder', folderData); |
95 | - name: fileData.rename, | ||
96 | - content: fileData.content | ||
97 | - }, | ||
98 | - }); | ||
99 | } | 94 | } |
100 | 95 | ||
96 | +function addFavorite(folderData) { | ||
97 | + return axios.post('api/favorites/addfolder', folderData); | ||
98 | +} | ||
99 | + | ||
100 | +function moveFile(fileData) { | ||
101 | + return axios.post('/api/folder/move', fileData); | ||
102 | +} | ||
103 | + | ||
104 | +function delFavoriteFile(fileData) { | ||
105 | + return axios.post('api/favorites/delfile', fileData); | ||
106 | +} | ||
107 | + | ||
108 | +function addFavoriteFile(fileData) { | ||
109 | + return axios.post('api/favorites/addfile', fileData); | ||
110 | +} | ||
101 | 111 | ||
102 | export { | 112 | export { |
103 | registerUser, | 113 | registerUser, |
... | @@ -110,6 +120,11 @@ export { | ... | @@ -110,6 +120,11 @@ export { |
110 | uploadFile, | 120 | uploadFile, |
111 | deleteFile, | 121 | deleteFile, |
112 | downloadFile, | 122 | downloadFile, |
123 | + delFavorite, | ||
124 | + addFavorite, | ||
125 | + moveFile, | ||
126 | + delFavoriteFile, | ||
127 | + addFavoriteFile, | ||
113 | accessedList, | 128 | accessedList, |
114 | detailFile, | 129 | detailFile, |
115 | modifyFile | 130 | modifyFile | ... | ... |
1 | <template> | 1 | <template> |
2 | <div> | 2 | <div> |
3 | <v-toolbar flat> | 3 | <v-toolbar flat> |
4 | - <v-toolbar-title>파일 </v-toolbar-title> | 4 | + <v-toolbar-title>내 드라이브</v-toolbar-title> |
5 | <v-spacer></v-spacer> | 5 | <v-spacer></v-spacer> |
6 | <v-text-field | 6 | <v-text-field |
7 | v-model="search" | 7 | v-model="search" |
8 | append-icon="mdi-magnify" | 8 | append-icon="mdi-magnify" |
9 | - label="파일 검색" | 9 | + label="검색" |
10 | single-line | 10 | single-line |
11 | hide-details | 11 | hide-details |
12 | ></v-text-field> | 12 | ></v-text-field> |
13 | </v-toolbar> | 13 | </v-toolbar> |
14 | <v-list two-line subheader> | 14 | <v-list two-line subheader> |
15 | - <v-subheader inset>Folders</v-subheader> | 15 | + <!-- <v-subheader inset>Folders</v-subheader> --> |
16 | - <v-btn @click="moveParent">...</v-btn> | 16 | + <!-- Folder view --> |
17 | + <v-list-item v-if="this.$store.state.cur !== '/'" @click="moveParent" | ||
18 | + >...</v-list-item | ||
19 | + > | ||
17 | <v-list-item | 20 | <v-list-item |
18 | v-for="item in this.$store.getters.folderL" | 21 | v-for="item in this.$store.getters.folderL" |
19 | :key="item.title" | 22 | :key="item.title" |
20 | :search="search" | 23 | :search="search" |
21 | - @click.right="show(item.folder_name, $event)" | 24 | + @click.right="show(item, $event)" |
22 | - @click.left="moveF(item.folder_name)" | 25 | + @click="" |
26 | + @dblclick="moveF(item.folder_name)" | ||
23 | > | 27 | > |
24 | <v-list-item-avatar> | 28 | <v-list-item-avatar> |
25 | <v-icon>mdi-folder</v-icon> | 29 | <v-icon>mdi-folder</v-icon> |
... | @@ -27,7 +31,95 @@ | ... | @@ -27,7 +31,95 @@ |
27 | <v-list-item-content> | 31 | <v-list-item-content> |
28 | <v-list-item-title v-text="item.folder_name"></v-list-item-title> | 32 | <v-list-item-title v-text="item.folder_name"></v-list-item-title> |
29 | </v-list-item-content> | 33 | </v-list-item-content> |
30 | - | 34 | + <v-list-item-action> |
35 | + <v-icon v-if="item.favorite === 0"> | ||
36 | + mdi-star-outline | ||
37 | + </v-icon> | ||
38 | + <v-icon v-else> | ||
39 | + mdi-star | ||
40 | + </v-icon> | ||
41 | + </v-list-item-action> | ||
42 | + </v-list-item> | ||
43 | + <!-- File view --> | ||
44 | + <v-list-item | ||
45 | + v-for="item in this.$store.getters.fileL" | ||
46 | + :key="item.title" | ||
47 | + @click.right="showF(item, $event)" | ||
48 | + @dblclick="detailF(item, $event); file_detail(item);" | ||
49 | + @click="" | ||
50 | + > | ||
51 | + <v-list-item-avatar> | ||
52 | + <v-icon> mdi-file</v-icon> | ||
53 | + </v-list-item-avatar> | ||
54 | + <v-list-item-content> | ||
55 | + <v-list-item-title v-text="item.file_name"></v-list-item-title> | ||
56 | + </v-list-item-content> | ||
57 | + <v-list-item-action> | ||
58 | + <v-icon v-if="item.favorite === 0"> | ||
59 | + mdi-star-outline | ||
60 | + </v-icon> | ||
61 | + <v-icon v-else> | ||
62 | + mdi-star | ||
63 | + </v-icon> | ||
64 | + </v-list-item-action> | ||
65 | + </v-list-item> | ||
66 | + </v-list> | ||
67 | + <!--file detial --> | ||
68 | + <v-dialog | ||
69 | + v-model="showdetailF" | ||
70 | + max-width="290" | ||
71 | + > | ||
72 | + <v-card> | ||
73 | + <v-card-title class="headline"> | ||
74 | + <v-text-field v-model="current_filename" ></v-text-field> | ||
75 | + </v-card-title> | ||
76 | + <v-card-text> | ||
77 | + <v-text-field v-model="current_filedata" ></v-text-field> | ||
78 | + </v-card-text> | ||
79 | + <v-card-actions> | ||
80 | + <v-spacer></v-spacer> | ||
81 | + <v-btn | ||
82 | + color="green darken-1" | ||
83 | + text | ||
84 | + @click="showdetailF = false; modify_file();" | ||
85 | + > | ||
86 | + save | ||
87 | + </v-btn> | ||
88 | + </v-card-actions> | ||
89 | + </v-card> | ||
90 | + </v-dialog> | ||
91 | + <!-- Move Folder --> | ||
92 | + <v-dialog v-model="dialog2" width="500px"> | ||
93 | + <v-card> | ||
94 | + <v-card-title class="grey darken-2"> | ||
95 | + Move Folder | ||
96 | + </v-card-title> | ||
97 | + <v-container> | ||
98 | + <v-list> | ||
99 | + <v-list-item | ||
100 | + v-for="item2 in folders" | ||
101 | + :key="item2.folder_id" | ||
102 | + @click.left="transferF(item2.folder_name)" | ||
103 | + v-if="item2.folder_name !== curfName.folder_name" | ||
104 | + > | ||
105 | + <v-list-item-avatar> | ||
106 | + <v-icon>mdi-folder</v-icon> | ||
107 | + </v-list-item-avatar> | ||
108 | + <v-list-item-content> | ||
109 | + <v-list-item-title | ||
110 | + v-text="item2.folder_name" | ||
111 | + ></v-list-item-title> | ||
112 | + </v-list-item-content> | ||
113 | + </v-list-item> | ||
114 | + </v-list> | ||
115 | + </v-container> | ||
116 | + <v-card-actions> | ||
117 | + <v-spacer></v-spacer> | ||
118 | + <v-btn text color="primary" @click="cancelMove">Cancel</v-btn> | ||
119 | + </v-card-actions> | ||
120 | + </v-card> | ||
121 | + </v-dialog> | ||
122 | + <!-- sub menu for folder --> | ||
31 | <v-menu | 123 | <v-menu |
32 | v-model="showMenu" | 124 | v-model="showMenu" |
33 | :position-x="x" | 125 | :position-x="x" |
... | @@ -37,23 +129,53 @@ | ... | @@ -37,23 +129,53 @@ |
37 | > | 129 | > |
38 | <v-list dense> | 130 | <v-list dense> |
39 | <v-list-item @click.prevent="dialog2 = !dialog2"> | 131 | <v-list-item @click.prevent="dialog2 = !dialog2"> |
132 | + <v-list-item-icon> | ||
133 | + <v-icon>mdi-send</v-icon> | ||
134 | + </v-list-item-icon> | ||
135 | + <v-list-item-content> | ||
40 | <v-list-item-title>이동</v-list-item-title> | 136 | <v-list-item-title>이동</v-list-item-title> |
137 | + </v-list-item-content> | ||
41 | </v-list-item> | 138 | </v-list-item> |
42 | <v-list-item @click.prevent="deleteF"> | 139 | <v-list-item @click.prevent="deleteF"> |
140 | + <v-list-item-icon> | ||
141 | + <v-icon>mdi-delete</v-icon> | ||
142 | + </v-list-item-icon> | ||
143 | + <v-list-item-content> | ||
43 | <v-list-item-title>삭제</v-list-item-title> | 144 | <v-list-item-title>삭제</v-list-item-title> |
145 | + </v-list-item-content> | ||
146 | + </v-list-item> | ||
147 | + <v-list-item v-if="curfName.favorite === 1" @click="delete_favorite"> | ||
148 | + <v-list-item-icon> | ||
149 | + <v-icon>mdi-star-outline</v-icon> | ||
150 | + </v-list-item-icon> | ||
151 | + <v-list-item-content> | ||
152 | + <v-list-item-title>즐겨 찾기 삭제</v-list-item-title> | ||
153 | + </v-list-item-content> | ||
154 | + </v-list-item> | ||
155 | + <v-list-item v-if="curfName.favorite === 0" @click="add_favorite"> | ||
156 | + <v-list-item-icon> | ||
157 | + <v-icon>mdi-star</v-icon> | ||
158 | + </v-list-item-icon> | ||
159 | + <v-list-item-content> | ||
160 | + <v-list-item-title>즐겨 찾기 추가</v-list-item-title> | ||
161 | + </v-list-item-content> | ||
44 | </v-list-item> | 162 | </v-list-item> |
45 | </v-list> | 163 | </v-list> |
46 | </v-menu> | 164 | </v-menu> |
47 | - </v-list-item> | 165 | + <!-- --> |
48 | - <v-dialog v-model="dialog2" width="500px"> | 166 | + <!-- Move File --> |
167 | + <v-dialog v-model="dialog3" width="500px"> | ||
49 | <v-card> | 168 | <v-card> |
50 | <v-card-title class="grey darken-2"> | 169 | <v-card-title class="grey darken-2"> |
51 | - Move Folder | 170 | + Move File |
52 | </v-card-title> | 171 | </v-card-title> |
53 | <v-container> | 172 | <v-container> |
54 | - <v-list-item-group v-for="item2 in folders" :key="item2.folder_id"> | 173 | + <v-list> |
55 | - <template v-if="!(item2.folder_name === curfName)"> | 174 | + <v-list-item |
56 | - <v-hover @click.left="transferF(item2.folder_name)"> | 175 | + v-for="item2 in folders" |
176 | + :key="item2.folder_id" | ||
177 | + @click.left="transferFile(item2.folder_name)" | ||
178 | + > | ||
57 | <v-list-item-avatar> | 179 | <v-list-item-avatar> |
58 | <v-icon>mdi-folder</v-icon> | 180 | <v-icon>mdi-folder</v-icon> |
59 | </v-list-item-avatar> | 181 | </v-list-item-avatar> |
... | @@ -62,10 +184,8 @@ | ... | @@ -62,10 +184,8 @@ |
62 | v-text="item2.folder_name" | 184 | v-text="item2.folder_name" |
63 | ></v-list-item-title> | 185 | ></v-list-item-title> |
64 | </v-list-item-content> | 186 | </v-list-item-content> |
65 | - </v-hover> | 187 | + </v-list-item> |
66 | - </template> | 188 | + </v-list> |
67 | - <!-- <template v-else></template> --> | ||
68 | - </v-list-item-group> | ||
69 | </v-container> | 189 | </v-container> |
70 | <v-card-actions> | 190 | <v-card-actions> |
71 | <v-spacer></v-spacer> | 191 | <v-spacer></v-spacer> |
... | @@ -73,46 +193,60 @@ | ... | @@ -73,46 +193,60 @@ |
73 | </v-card-actions> | 193 | </v-card-actions> |
74 | </v-card> | 194 | </v-card> |
75 | </v-dialog> | 195 | </v-dialog> |
76 | - <v-divider inset></v-divider> | 196 | + <!-- sub menu for file --> |
77 | - <v-subheader inset>Files</v-subheader> | 197 | + <v-menu |
78 | - <v-list-item v-for="item in this.$store.getters.fileL" :key="item.title" @click.stop="dialog_file = true; file_detail(item)"> | 198 | + v-model="showMenuF" |
79 | - <v-list-item-avatar> | 199 | + :position-x="x" |
80 | - <v-icon> mdi-file</v-icon> | 200 | + :position-y="y" |
81 | - </v-list-item-avatar> | 201 | + absolute |
202 | + offset-y | ||
203 | + > | ||
204 | + <v-list dense> | ||
205 | + <v-list-item @click.prevent="dialog3 = !dialog3"> | ||
206 | + <v-list-item-icon> | ||
207 | + <v-icon>mdi-send</v-icon> | ||
208 | + </v-list-item-icon> | ||
82 | <v-list-item-content> | 209 | <v-list-item-content> |
83 | - <v-list-item-title v-text="item.file_name"></v-list-item-title> | 210 | + <v-list-item-title>이동</v-list-item-title> |
84 | </v-list-item-content> | 211 | </v-list-item-content> |
85 | - <v-list-item-action> | 212 | + </v-list-item> |
86 | - </v-list-item-action> | 213 | + <v-list-item @click.prevent="delete_file"> |
87 | - <v-dialog | 214 | + <v-list-item-icon> |
88 | - v-model="dialog_file" | 215 | + <v-icon>mdi-delete</v-icon> |
89 | - max-width="290" | 216 | + </v-list-item-icon> |
90 | - > | 217 | + <v-list-item-content> |
91 | - <v-card> | 218 | + <v-list-item-title>삭제</v-list-item-title> |
92 | - <v-card-title class="headline"> | 219 | + </v-list-item-content> |
93 | - <v-text-field v-model="current_filename" v-text="current_filename"></v-text-field> | 220 | + </v-list-item> |
94 | - </v-card-title> | 221 | + <v-list-item @click.prevent="download_file"> |
95 | - <v-card-text v-model="current_filedata" v-text="current_filedata"></v-card-text> | 222 | + <v-list-item-icon> |
96 | - <v-card-actions> | 223 | + <v-icon>mdi-download</v-icon> |
97 | - <v-spacer></v-spacer> | 224 | + </v-list-item-icon> |
98 | - <v-btn | 225 | + <v-list-item-content> |
99 | - color="green darken-1" | 226 | + <v-list-item-title>다운로드</v-list-item-title> |
100 | - text | 227 | + </v-list-item-content> |
101 | - @click="dialog_file = false; modify_file(item);" | 228 | + </v-list-item> |
229 | + <v-list-item | ||
230 | + v-if="cfilename.favorite === 1" | ||
231 | + @click="delete_favorite_file" | ||
102 | > | 232 | > |
103 | - save | 233 | + <v-list-item-icon> |
104 | - </v-btn> | 234 | + <v-icon>mdi-star-outline</v-icon> |
105 | - </v-card-actions> | 235 | + </v-list-item-icon> |
106 | - </v-card> | 236 | + <v-list-item-content> |
107 | - </v-dialog> | 237 | + <v-list-item-title>즐겨 찾기 삭제</v-list-item-title> |
108 | - <v-btn icon @click="download_file(item.file_name)"> | 238 | + </v-list-item-content> |
109 | - <v-icon color="grey lighten-1">mdi-download</v-icon> | 239 | + </v-list-item> |
110 | - </v-btn> | 240 | + <v-list-item v-if="cfilename.favorite === 0" @click="add_favorite_file"> |
111 | - <v-btn icon @click="delete_file(item.file_name)"> | 241 | + <v-list-item-icon> |
112 | - <v-icon color="grey lighten-1">mdi-delete</v-icon> | 242 | + <v-icon>mdi-star</v-icon> |
113 | - </v-btn> | 243 | + </v-list-item-icon> |
244 | + <v-list-item-content> | ||
245 | + <v-list-item-title>즐겨 찾기 추가</v-list-item-title> | ||
246 | + </v-list-item-content> | ||
114 | </v-list-item> | 247 | </v-list-item> |
115 | </v-list> | 248 | </v-list> |
249 | + </v-menu> | ||
116 | <input | 250 | <input |
117 | id="file-selector" | 251 | id="file-selector" |
118 | ref="uploadedfile" | 252 | ref="uploadedfile" |
... | @@ -120,42 +254,11 @@ | ... | @@ -120,42 +254,11 @@ |
120 | v-on:change="handleFileUpload()" | 254 | v-on:change="handleFileUpload()" |
121 | /> | 255 | /> |
122 | <br /> | 256 | <br /> |
123 | - <!-- | ||
124 | - <v-file-input | ||
125 | - v-model="files" | ||
126 | - color="deep-purple accent-4" | ||
127 | - counter | ||
128 | - label="업로드" | ||
129 | - multiple | ||
130 | - placeholder="파일을 화면으로 드래그앤 드롭 하거나, 이곳을 클릭하세요." | ||
131 | - prepend-icon="mdi-paperclip" | ||
132 | - outlined | ||
133 | - :show-size="1000" | ||
134 | - > | ||
135 | - <template v-slot:selection="{ index, text }"> | ||
136 | - <v-chip | ||
137 | - v-if="index < 2" | ||
138 | - color="deep-purple accent-4" | ||
139 | - dark | ||
140 | - label | ||
141 | - small | ||
142 | - > | ||
143 | - {{ text }} | ||
144 | - </v-chip> | ||
145 | - <span | ||
146 | - v-else-if="index === 2" | ||
147 | - class="overline grey--text text--darken-3 mx-2" | ||
148 | - > | ||
149 | - +{{ files.length - 2 }} File(s) | ||
150 | - </span> | ||
151 | - </template> | ||
152 | - | ||
153 | - </v-file-input> | ||
154 | ---> | ||
155 | <v-btn color="blue" @click="upload_file">upload</v-btn> | 257 | <v-btn color="blue" @click="upload_file">upload</v-btn> |
156 | <v-btn bottom color="blue" dark fab fixed right @click="dialog = !dialog"> | 258 | <v-btn bottom color="blue" dark fab fixed right @click="dialog = !dialog"> |
157 | <v-icon>mdi-plus</v-icon> | 259 | <v-icon>mdi-plus</v-icon> |
158 | </v-btn> | 260 | </v-btn> |
261 | + <!-- Create Folder --> | ||
159 | <v-dialog v-model="dialog" width="500px"> | 262 | <v-dialog v-model="dialog" width="500px"> |
160 | <v-card> | 263 | <v-card> |
161 | <v-card-title class="grey darken-2"> | 264 | <v-card-title class="grey darken-2"> |
... | @@ -191,31 +294,37 @@ import { | ... | @@ -191,31 +294,37 @@ import { |
191 | uploadFile, | 294 | uploadFile, |
192 | deleteFile, | 295 | deleteFile, |
193 | downloadFile, | 296 | downloadFile, |
297 | + delFavorite, | ||
298 | + addFavorite, | ||
299 | + moveFile, | ||
300 | + delFavoriteFile, | ||
301 | + addFavoriteFile, | ||
194 | detailFile, | 302 | detailFile, |
195 | modifyFile | 303 | modifyFile |
196 | } from '../api/index'; | 304 | } from '../api/index'; |
197 | import Axios from 'axios'; | 305 | import Axios from 'axios'; |
198 | - | ||
199 | - | ||
200 | export default { | 306 | export default { |
201 | data() { | 307 | data() { |
202 | return { | 308 | return { |
203 | uploadedfile: null, | 309 | uploadedfile: null, |
204 | foldername: '', | 310 | foldername: '', |
205 | - curfName: '', | 311 | + curfName: {}, |
312 | + cfilename: {}, | ||
206 | folders: [], | 313 | folders: [], |
207 | files: [], | 314 | files: [], |
208 | search: '', | 315 | search: '', |
209 | id: '', | 316 | id: '', |
317 | + current_filename: null, //파일 상세정보 (이름) | ||
318 | + current_filedata: null, //파일 상세정보 (내용) | ||
210 | dialog: false, | 319 | dialog: false, |
211 | howMenu: false, | 320 | howMenu: false, |
212 | showMenu: false, | 321 | showMenu: false, |
322 | + showMenuF: false, //파일 관련 메뉴 | ||
323 | + showdetailF:false, //txt 파일 상세정보 및 수정 | ||
213 | x: 0, | 324 | x: 0, |
214 | y: 0, | 325 | y: 0, |
215 | dialog2: false, | 326 | dialog2: false, |
216 | - dialog_file: false, | 327 | + dialog3: false, //파일 관련 메뉴 |
217 | - current_filename: null, | ||
218 | - current_filedata: null, | ||
219 | detail: { | 328 | detail: { |
220 | dataname: null, | 329 | dataname: null, |
221 | date: null, | 330 | date: null, |
... | @@ -237,7 +346,6 @@ export default { | ... | @@ -237,7 +346,6 @@ export default { |
237 | this.$store.commit('setFolder', response.data.folders); | 346 | this.$store.commit('setFolder', response.data.folders); |
238 | this.$store.commit('setCur', response.data.cur); | 347 | this.$store.commit('setCur', response.data.cur); |
239 | this.$store.commit('setParent', response.data.parentPath); | 348 | this.$store.commit('setParent', response.data.parentPath); |
240 | - this.folders = this.$store.getters.folderL; | ||
241 | this.$store.commit('setFile', file_response.data.files); | 349 | this.$store.commit('setFile', file_response.data.files); |
242 | this.folders = this.$store.getters.folderL; | 350 | this.folders = this.$store.getters.folderL; |
243 | console.log(this.$store.getters.fileL); | 351 | console.log(this.$store.getters.fileL); |
... | @@ -256,8 +364,10 @@ export default { | ... | @@ -256,8 +364,10 @@ export default { |
256 | this.foldername = ''; | 364 | this.foldername = ''; |
257 | }, | 365 | }, |
258 | cancelMove() { | 366 | cancelMove() { |
259 | - this.curfName = ''; | 367 | + this.curfName = {}; |
368 | + this.cfilename = {}; | ||
260 | this.dialog2 = false; | 369 | this.dialog2 = false; |
370 | + this.dialog3 = false; | ||
261 | }, | 371 | }, |
262 | async makeF() { | 372 | async makeF() { |
263 | try { | 373 | try { |
... | @@ -286,11 +396,14 @@ export default { | ... | @@ -286,11 +396,14 @@ export default { |
286 | cur: this.$store.state.cur + move_folder_name + '/', | 396 | cur: this.$store.state.cur + move_folder_name + '/', |
287 | }; | 397 | }; |
288 | const response = await folder(curData); | 398 | const response = await folder(curData); |
399 | + const file_response = await file(curData); | ||
289 | console.log(response.data); | 400 | console.log(response.data); |
290 | this.$store.commit('setFolder', response.data.folders); | 401 | this.$store.commit('setFolder', response.data.folders); |
402 | + this.$store.commit('setFile', file_response.data.files); | ||
291 | this.$store.commit('setCur', response.data.cur); | 403 | this.$store.commit('setCur', response.data.cur); |
292 | this.$store.commit('setParent', response.data.parentPath); | 404 | this.$store.commit('setParent', response.data.parentPath); |
293 | this.folders = this.$store.getters.folderL; | 405 | this.folders = this.$store.getters.folderL; |
406 | + this.files = this.$store.getters.fileL; | ||
294 | } catch (error) { | 407 | } catch (error) { |
295 | console.log('에러'); | 408 | console.log('에러'); |
296 | console.log(error.response.data); | 409 | console.log(error.response.data); |
... | @@ -303,11 +416,14 @@ export default { | ... | @@ -303,11 +416,14 @@ export default { |
303 | cur: this.$store.state.parent, | 416 | cur: this.$store.state.parent, |
304 | }; | 417 | }; |
305 | const response = await folder(cData); | 418 | const response = await folder(cData); |
419 | + const file_response = await file(cData); | ||
306 | console.log(response.data); | 420 | console.log(response.data); |
307 | this.$store.commit('setFolder', response.data.folders); | 421 | this.$store.commit('setFolder', response.data.folders); |
422 | + this.$store.commit('setFile', file_response.data.files); | ||
308 | this.$store.commit('setCur', response.data.cur); | 423 | this.$store.commit('setCur', response.data.cur); |
309 | this.$store.commit('setParent', response.data.parentPath); | 424 | this.$store.commit('setParent', response.data.parentPath); |
310 | this.folders = this.$store.getters.folderL; | 425 | this.folders = this.$store.getters.folderL; |
426 | + this.files = this.$store.getters.fileL; | ||
311 | } catch (error) { | 427 | } catch (error) { |
312 | console.log('에러'); | 428 | console.log('에러'); |
313 | console.log(error.response.data); | 429 | console.log(error.response.data); |
... | @@ -318,7 +434,7 @@ export default { | ... | @@ -318,7 +434,7 @@ export default { |
318 | const cData = { | 434 | const cData = { |
319 | id: this.$store.state.id, | 435 | id: this.$store.state.id, |
320 | cur: this.$store.state.cur, | 436 | cur: this.$store.state.cur, |
321 | - folder_name: this.curfName, | 437 | + folder_name: this.curfName.folder_name, |
322 | }; | 438 | }; |
323 | const response = await deleteFolder(cData); | 439 | const response = await deleteFolder(cData); |
324 | console.log(response); | 440 | console.log(response); |
... | @@ -336,7 +452,7 @@ export default { | ... | @@ -336,7 +452,7 @@ export default { |
336 | const cData = { | 452 | const cData = { |
337 | id: this.$store.state.id, | 453 | id: this.$store.state.id, |
338 | cur: this.$store.state.cur, | 454 | cur: this.$store.state.cur, |
339 | - folder_name: this.curfName, | 455 | + name: this.curfName.folder_name, |
340 | isfolder: true, | 456 | isfolder: true, |
341 | newPath: this.$store.state.cur + folderName + '/', | 457 | newPath: this.$store.state.cur + folderName + '/', |
342 | }; | 458 | }; |
... | @@ -348,8 +464,7 @@ export default { | ... | @@ -348,8 +464,7 @@ export default { |
348 | console.log('에러'); | 464 | console.log('에러'); |
349 | console.log(error.response.data); | 465 | console.log(error.response.data); |
350 | } finally { | 466 | } finally { |
351 | - this.initFolderName(); | 467 | + this.curfName = {}; |
352 | - this.curfName = ''; | ||
353 | this.dialog2 = false; | 468 | this.dialog2 = false; |
354 | } | 469 | } |
355 | }, | 470 | }, |
... | @@ -375,20 +490,16 @@ export default { | ... | @@ -375,20 +490,16 @@ export default { |
375 | console.log(error); | 490 | console.log(error); |
376 | } | 491 | } |
377 | }, | 492 | }, |
378 | - async delete_file(itemName) { | 493 | + async delete_file() { |
379 | try { | 494 | try { |
380 | var itemlist = this.$store.getters.fileL; | 495 | var itemlist = this.$store.getters.fileL; |
381 | - console.log(itemlist); | ||
382 | - console.log(itemName); | ||
383 | const currentData = { | 496 | const currentData = { |
384 | fileName: null, | 497 | fileName: null, |
385 | user_id: null, | 498 | user_id: null, |
386 | cur: this.$store.state.cur, | 499 | cur: this.$store.state.cur, |
387 | }; | 500 | }; |
388 | - | ||
389 | for (var i = 0; i < itemlist.length; i++) { | 501 | for (var i = 0; i < itemlist.length; i++) { |
390 | - console.log(itemlist[i].file_name); | 502 | + if (itemlist[i].file_name == this.cfilename.file_name) { |
391 | - if (itemlist[i].file_name == itemName) { | ||
392 | currentData.fileName = itemlist[i].file_name; | 503 | currentData.fileName = itemlist[i].file_name; |
393 | currentData.user_id = itemlist[i].user_id; | 504 | currentData.user_id = itemlist[i].user_id; |
394 | } | 505 | } |
... | @@ -397,23 +508,20 @@ export default { | ... | @@ -397,23 +508,20 @@ export default { |
397 | id: currentData.user_id, | 508 | id: currentData.user_id, |
398 | cur: currentData.cur, | 509 | cur: currentData.cur, |
399 | }; | 510 | }; |
400 | - console.log(currentData); | ||
401 | const response = await deleteFile(currentData); | 511 | const response = await deleteFile(currentData); |
402 | setTimeout(function() {}, 500); | 512 | setTimeout(function() {}, 500); |
403 | const filelist = await file(filelistData); | 513 | const filelist = await file(filelistData); |
404 | - console.log(filelist.data.files); | ||
405 | this.$store.commit('setFile', filelist.data.files); | 514 | this.$store.commit('setFile', filelist.data.files); |
406 | - console.log(this.$store.getters.fileL); | ||
407 | this.files = this.$store.getters.fileL; | 515 | this.files = this.$store.getters.fileL; |
408 | } catch (error) { | 516 | } catch (error) { |
409 | console.log('에러'); | 517 | console.log('에러'); |
410 | console.log(error); | 518 | console.log(error); |
411 | } | 519 | } |
412 | }, | 520 | }, |
413 | - async download_file(namedata) { | 521 | + async download_file() { |
414 | try { | 522 | try { |
415 | const currentData = { | 523 | const currentData = { |
416 | - fileName: namedata, | 524 | + fileName: this.cfilename.file_name, |
417 | id: this.$store.state.id, | 525 | id: this.$store.state.id, |
418 | cur: this.$store.state.cur, | 526 | cur: this.$store.state.cur, |
419 | }; | 527 | }; |
... | @@ -424,49 +532,123 @@ export default { | ... | @@ -424,49 +532,123 @@ export default { |
424 | console.log(error); | 532 | console.log(error); |
425 | } | 533 | } |
426 | }, | 534 | }, |
427 | - async file_detail(fileData){ | 535 | + async delete_favorite() { |
536 | + try { | ||
537 | + const cData = { | ||
538 | + id: this.$store.state.id, | ||
539 | + cur: this.$store.state.cur, | ||
540 | + name: this.curfName.folder_name, | ||
541 | + }; | ||
542 | + console.log(cData); | ||
543 | + const response = await delFavorite(cData); | ||
544 | + this.$store.commit('setFolder', response.data.folders); | ||
545 | + } catch (error) { | ||
546 | + console.log('에러'); | ||
547 | + } | ||
548 | + }, | ||
549 | + async add_favorite() { | ||
550 | + try { | ||
551 | + const cData = { | ||
552 | + id: this.$store.state.id, | ||
553 | + cur: this.$store.state.cur, | ||
554 | + name: this.curfName.folder_name, | ||
555 | + }; | ||
556 | + console.log(cData); | ||
557 | + const response = await addFavorite(cData); | ||
558 | + this.$store.commit('setFolder', response.data.folders); | ||
559 | + } catch (error) { | ||
560 | + console.log('에러'); | ||
561 | + } | ||
562 | + }, | ||
563 | + async delete_favorite_file() { | ||
564 | + try { | ||
565 | + const fData = { | ||
566 | + id: this.$store.state.id, | ||
567 | + cur: this.$store.state.cur, | ||
568 | + name: this.cfilename.file_name, | ||
569 | + }; | ||
570 | + console.log(fData); | ||
571 | + const response = await delFavoriteFile(fData); | ||
572 | + this.$store.commit('setFile', response.data.files); | ||
573 | + } catch (error) { | ||
574 | + console.log('에러'); | ||
575 | + } | ||
576 | + }, | ||
577 | + async add_favorite_file() { | ||
578 | + try { | ||
579 | + const fData = { | ||
580 | + id: this.$store.state.id, | ||
581 | + cur: this.$store.state.cur, | ||
582 | + name: this.cfilename.file_name, | ||
583 | + }; | ||
584 | + console.log(fData); | ||
585 | + const response = await addFavoriteFile(fData); | ||
586 | + this.$store.commit('setFile', response.data.files); | ||
587 | + } catch (error) { | ||
588 | + console.log('에러'); | ||
589 | + } | ||
590 | + }, | ||
591 | + async transferFile(folderName) { | ||
592 | + try { | ||
593 | + const fData = { | ||
594 | + id: this.$store.state.id, | ||
595 | + cur: this.$store.state.cur, | ||
596 | + name: this.cfilename.file_name, | ||
597 | + isfolder: false, | ||
598 | + newPath: this.$store.state.cur + folderName + '/', | ||
599 | + }; | ||
600 | + const response = await moveFile(fData); | ||
601 | + console.log(response); | ||
602 | + this.$store.commit('setFile', response.data.files); | ||
603 | + this.files = this.$store.getters.fileL; | ||
604 | + } catch (error) { | ||
605 | + console.log('에러'); | ||
606 | + console.log(error.response.data); | ||
607 | + } finally { | ||
608 | + this.cfilename = {}; | ||
609 | + this.dialog3 = false; | ||
610 | + } | ||
611 | + }, | ||
612 | + async file_detail(){ | ||
428 | try{ | 613 | try{ |
429 | const currentData = { | 614 | const currentData = { |
430 | - id: fileData.user_id, | 615 | + id: this.cfilename.user_id, |
431 | - cur: fileData.location, | 616 | + cur: this.cfilename.location, |
432 | - fileName: fileData.file_name | 617 | + fileName: this.cfilename.file_name |
433 | } | 618 | } |
434 | const detailData = await detailFile(currentData) | 619 | const detailData = await detailFile(currentData) |
435 | - console.log(detailData) | 620 | + this.current_filename = detailData.data.file_name; |
436 | - this.current_filename = detailData.file_name; | 621 | + this.current_filedata = detailData.data.content; |
437 | - this.current_filedata = detailFile.content; | 622 | + console.log(this.current_filename); |
623 | + console.log(this.current_filedata); | ||
438 | }catch(error){ | 624 | }catch(error){ |
439 | console.log('에러'); | 625 | console.log('에러'); |
440 | console.log(error); | 626 | console.log(error); |
441 | } | 627 | } |
442 | }, | 628 | }, |
443 | - async modify_file(fileData){ | 629 | + async modify_file(){ |
444 | try{ | 630 | try{ |
445 | const modifyData = { | 631 | const modifyData = { |
446 | - user_id: fileData.user_id, | 632 | + user_id: cfilename.user_id, |
447 | - cur: fileData.location, | 633 | + cur: cfilename.location, |
448 | name: this.current_filename, | 634 | name: this.current_filename, |
449 | content: this.current_filedata | 635 | content: this.current_filedata |
450 | } | 636 | } |
451 | - | ||
452 | const result = await modifyFile(modifyData); | 637 | const result = await modifyFile(modifyData); |
453 | const after_data={ | 638 | const after_data={ |
454 | - id: fileData.user_id, | 639 | + id: cfilename.user_id, |
455 | - cur: fileData.location, | 640 | + cur: cfilename.location, |
456 | fileName: this.current_filename | 641 | fileName: this.current_filename |
457 | } | 642 | } |
458 | - const detailData = await detailFile(after_data) | 643 | + const detailData = await detailFile() |
459 | - this.current_filename = detailData.file_name; | ||
460 | - this.current_filedata = detailData.content; | ||
461 | }catch(error){ | 644 | }catch(error){ |
462 | console.log('에러'); | 645 | console.log('에러'); |
463 | console.log(error); | 646 | console.log(error); |
464 | } | 647 | } |
465 | - } | ||
466 | }, | 648 | }, |
467 | - show(folderN, e) { | 649 | + show(folderObj, e) { |
468 | e.preventDefault(); | 650 | e.preventDefault(); |
469 | - this.curfName = folderN; | 651 | + this.curfName = folderObj; |
470 | this.showMenu = false; | 652 | this.showMenu = false; |
471 | this.x = e.clientX; | 653 | this.x = e.clientX; |
472 | this.y = e.clientY; | 654 | this.y = e.clientY; |
... | @@ -474,5 +656,26 @@ export default { | ... | @@ -474,5 +656,26 @@ export default { |
474 | this.showMenu = true; | 656 | this.showMenu = true; |
475 | }); | 657 | }); |
476 | }, | 658 | }, |
659 | + showF(fileObj, e) { | ||
660 | + e.preventDefault(); | ||
661 | + this.cfilename = fileObj; | ||
662 | + this.showMenuF = false; | ||
663 | + this.x = e.clientX; | ||
664 | + this.y = e.clientY; | ||
665 | + this.$nextTick(() => { | ||
666 | + this.showMenuF = true; | ||
667 | + }); | ||
668 | + }, | ||
669 | + detailF(fileObj, e) { | ||
670 | + e.preventDefault(); | ||
671 | + this.cfilename = fileObj; | ||
672 | + this.showdetailF = false; | ||
673 | + this.x = e.clientX; | ||
674 | + this.y = e.clientY; | ||
675 | + this.$nextTick(() => { | ||
676 | + this.showdetailF = true; | ||
677 | + }); | ||
678 | + }, | ||
679 | + }, | ||
477 | }; | 680 | }; |
478 | </script> | 681 | </script> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -5,7 +5,9 @@ | ... | @@ -5,7 +5,9 @@ |
5 | <template v-slot:default> | 5 | <template v-slot:default> |
6 | <thead> | 6 | <thead> |
7 | <tr> | 7 | <tr> |
8 | + <th class="text-left">File ID</th> | ||
8 | <th class="text-left">Name</th> | 9 | <th class="text-left">Name</th> |
10 | + <th class="text-left">Dir</th> | ||
9 | <th class="text-left">Date</th> | 11 | <th class="text-left">Date</th> |
10 | </tr> | 12 | </tr> |
11 | </thead> | 13 | </thead> | ... | ... |
1 | -import Vue from 'vue' | 1 | +import Vue from 'vue'; |
2 | -import Vuex from 'vuex' | 2 | +import Vuex from 'vuex'; |
3 | 3 | ||
4 | -Vue.use(Vuex) | 4 | +Vue.use(Vuex); |
5 | 5 | ||
6 | export default new Vuex.Store({ | 6 | export default new Vuex.Store({ |
7 | state: { | 7 | state: { |
... | @@ -10,7 +10,6 @@ export default new Vuex.Store({ | ... | @@ -10,7 +10,6 @@ export default new Vuex.Store({ |
10 | files: [], | 10 | files: [], |
11 | cur: '/', | 11 | cur: '/', |
12 | parent: '/', | 12 | parent: '/', |
13 | - recentList:[] | ||
14 | }, | 13 | }, |
15 | mutations: { | 14 | mutations: { |
16 | setId(state, userid) { | 15 | setId(state, userid) { |
... | @@ -31,9 +30,6 @@ export default new Vuex.Store({ | ... | @@ -31,9 +30,6 @@ export default new Vuex.Store({ |
31 | setParent(state, parent) { | 30 | setParent(state, parent) { |
32 | state.parent = parent; | 31 | state.parent = parent; |
33 | }, | 32 | }, |
34 | - setRecentList(state, list){ | ||
35 | - state.recentList = list; | ||
36 | - } | ||
37 | }, | 33 | }, |
38 | getters: { | 34 | getters: { |
39 | isLogin(state) { | 35 | isLogin(state) { |
... | @@ -48,17 +44,14 @@ export default new Vuex.Store({ | ... | @@ -48,17 +44,14 @@ export default new Vuex.Store({ |
48 | fileL(state) { | 44 | fileL(state) { |
49 | return state.files; | 45 | return state.files; |
50 | }, | 46 | }, |
51 | - recentL(state){ | ||
52 | - return state.recentList; | ||
53 | - }, | ||
54 | cur(state) { | 47 | cur(state) { |
55 | return state.cur; | 48 | return state.cur; |
56 | }, | 49 | }, |
57 | - setFolder(state, folderlist){ | 50 | + setFolder(state, folderlist) { |
58 | state.folders = folderlist; | 51 | state.folders = folderlist; |
59 | }, | 52 | }, |
60 | - setFile(state, filelist){ | 53 | + setFile(state, filelist) { |
61 | state.files = filelist; | 54 | state.files = filelist; |
62 | }, | 55 | }, |
63 | }, | 56 | }, |
64 | -}) | 57 | +}); | ... | ... |
-
Please register or login to post a comment