leeseohyeon

db에 파일 위치 분리

...@@ -11,6 +11,7 @@ var loginRouter = require('./routes/userlogin/login'); ...@@ -11,6 +11,7 @@ var loginRouter = require('./routes/userlogin/login');
11 var registerRouter = require('./routes/userlogin/register'); 11 var registerRouter = require('./routes/userlogin/register');
12 var fileRouter = require('./routes/file/router'); 12 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 15
15 16
16 var passport = require('passport'); 17 var passport = require('passport');
...@@ -19,19 +20,19 @@ var config = require('./routes/modules/config'); ...@@ -19,19 +20,19 @@ var config = require('./routes/modules/config');
19 20
20 //port 21 //port
21 passport.serializeUser(function(user, done) { 22 passport.serializeUser(function(user, done) {
22 - console.log('serialized'); 23 + console.log('serialized');
23 - done(null, user); 24 + done(null, user);
24 }); 25 });
25 passport.deserializeUser(function(user, done) { 26 passport.deserializeUser(function(user, done) {
26 - console.log('deserialized'); 27 + console.log('deserialized');
27 - done(null, user); 28 + done(null, user);
28 }); 29 });
29 30
30 31
31 var app = express(); 32 var app = express();
32 33
33 // view engine setup 34 // view engine setup
34 -app.set('views', [path.join(__dirname, 'views'),path.join(__dirname ,'dist')]); 35 +app.set('views', [path.join(__dirname, 'views'), path.join(__dirname, 'dist')]);
35 // app.set('view engine', 'ejs'); 36 // app.set('view engine', 'ejs');
36 app.set('view engine', 'pug'); 37 app.set('view engine', 'pug');
37 38
...@@ -42,9 +43,9 @@ app.use(cookieParser()); ...@@ -42,9 +43,9 @@ app.use(cookieParser());
42 app.use(express.static(path.join(__dirname, 'public'))); 43 app.use(express.static(path.join(__dirname, 'public')));
43 44
44 app.use(session({ 45 app.use(session({
45 - secret: 'mykey', 46 + secret: 'mykey',
46 - saveUninitialized: true, 47 + saveUninitialized: true,
47 - resave: true 48 + resave: true
48 })); 49 }));
49 50
50 app.use(express.static('public')); 51 app.use(express.static('public'));
...@@ -53,28 +54,29 @@ app.use(express.static('views')); ...@@ -53,28 +54,29 @@ app.use(express.static('views'));
53 app.use(passport.initialize()); 54 app.use(passport.initialize());
54 app.use(passport.session()); 55 app.use(passport.session());
55 56
56 -app.use('/', indexRouter); 57 +app.use('/api/', indexRouter);
57 -app.use('/user', userRouter); 58 +app.use('/api/user', userRouter);
58 -app.use('/login', loginRouter); 59 +app.use('/api/login', loginRouter);
59 -app.use('/RegistUser', registerRouter); 60 +app.use('/api/RegistUser', registerRouter);
61 +app.use('/api/folder', folderRouter);
60 //app.use('/users', usersRouter); 62 //app.use('/users', usersRouter);
61 -app.use('/file', fileRouter); 63 +app.use('/api/file', fileRouter);
62 -//app.use('/trashcan', trashcanRouter); 64 +//app.use('/api/trashcan', trashcanRouter);
63 65
64 // catch 404 and forward to error handler 66 // catch 404 and forward to error handler
65 app.use(function(req, res, next) { 67 app.use(function(req, res, next) {
66 - next(createError(404)); 68 + next(createError(404));
67 }); 69 });
68 70
69 // error handler 71 // error handler
70 app.use(function(err, req, res, next) { 72 app.use(function(err, req, res, next) {
71 - // set locals, only providing error in development 73 + // set locals, only providing error in development
72 - res.locals.message = err.message; 74 + res.locals.message = err.message;
73 - res.locals.error = req.app.get('env') === 'development' ? err : {}; 75 + res.locals.error = req.app.get('env') === 'development' ? err : {};
74 76
75 - // render the error page 77 + // render the error page
76 - res.status(err.status || 500); 78 + res.status(err.status || 500);
77 - res.render('error'); 79 + res.render('error');
78 }); 80 });
79 81
80 -module.exports = app; 82 +module.exports = app;
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -127,13 +127,6 @@ ...@@ -127,13 +127,6 @@
127 "url": "0.10.3", 127 "url": "0.10.3",
128 "uuid": "3.3.2", 128 "uuid": "3.3.2",
129 "xml2js": "0.4.19" 129 "xml2js": "0.4.19"
130 - },
131 - "dependencies": {
132 - "uuid": {
133 - "version": "3.3.2",
134 - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
135 - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
136 - }
137 } 130 }
138 }, 131 },
139 "aws-sign2": { 132 "aws-sign2": {
...@@ -887,6 +880,11 @@ ...@@ -887,6 +880,11 @@
887 "brace-expansion": "^1.1.7" 880 "brace-expansion": "^1.1.7"
888 } 881 }
889 }, 882 },
883 + "moment": {
884 + "version": "2.26.0",
885 + "resolved": "https://registry.npmjs.org/moment/-/moment-2.26.0.tgz",
886 + "integrity": "sha512-oIixUO+OamkUkwjhAVE18rAMfRJNsNe/Stid/gwHSOfHrOtw9EhAY2AHvdKZ/k/MggcYELFCJz/Sn2pL8b8JMw=="
887 + },
890 "morgan": { 888 "morgan": {
891 "version": "1.9.1", 889 "version": "1.9.1",
892 "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz", 890 "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz",
...@@ -1124,9 +1122,9 @@ ...@@ -1124,9 +1122,9 @@
1124 "integrity": "sha512-GMu3M5nUL3fju4/egXwZO0XLi6fW/K3T3VTgFQ14GxNi8btlxgT5qZL//JwZFm/2Fa64J/PNS8AZeys3wiMkVA==" 1122 "integrity": "sha512-GMu3M5nUL3fju4/egXwZO0XLi6fW/K3T3VTgFQ14GxNi8btlxgT5qZL//JwZFm/2Fa64J/PNS8AZeys3wiMkVA=="
1125 }, 1123 },
1126 "punycode": { 1124 "punycode": {
1127 - "version": "2.1.1", 1125 + "version": "1.3.2",
1128 - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", 1126 + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz",
1129 - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" 1127 + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0="
1130 }, 1128 },
1131 "qs": { 1129 "qs": {
1132 "version": "6.5.2", 1130 "version": "6.5.2",
...@@ -1344,6 +1342,13 @@ ...@@ -1344,6 +1342,13 @@
1344 "requires": { 1342 "requires": {
1345 "psl": "^1.1.28", 1343 "psl": "^1.1.28",
1346 "punycode": "^2.1.1" 1344 "punycode": "^2.1.1"
1345 + },
1346 + "dependencies": {
1347 + "punycode": {
1348 + "version": "2.1.1",
1349 + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
1350 + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
1351 + }
1347 } 1352 }
1348 }, 1353 },
1349 "tunnel-agent": { 1354 "tunnel-agent": {
...@@ -1410,6 +1415,13 @@ ...@@ -1410,6 +1415,13 @@
1410 "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", 1415 "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==",
1411 "requires": { 1416 "requires": {
1412 "punycode": "^2.1.0" 1417 "punycode": "^2.1.0"
1418 + },
1419 + "dependencies": {
1420 + "punycode": {
1421 + "version": "2.1.1",
1422 + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
1423 + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
1424 + }
1413 } 1425 }
1414 }, 1426 },
1415 "url": { 1427 "url": {
...@@ -1419,13 +1431,6 @@ ...@@ -1419,13 +1431,6 @@
1419 "requires": { 1431 "requires": {
1420 "punycode": "1.3.2", 1432 "punycode": "1.3.2",
1421 "querystring": "0.2.0" 1433 "querystring": "0.2.0"
1422 - },
1423 - "dependencies": {
1424 - "punycode": {
1425 - "version": "1.3.2",
1426 - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz",
1427 - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0="
1428 - }
1429 } 1434 }
1430 }, 1435 },
1431 "util-deprecate": { 1436 "util-deprecate": {
...@@ -1439,9 +1444,9 @@ ...@@ -1439,9 +1444,9 @@
1439 "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" 1444 "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
1440 }, 1445 },
1441 "uuid": { 1446 "uuid": {
1442 - "version": "3.4.0", 1447 + "version": "3.3.2",
1443 - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", 1448 + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
1444 - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" 1449 + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
1445 }, 1450 },
1446 "vary": { 1451 "vary": {
1447 "version": "1.1.2", 1452 "version": "1.1.2",
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 "express-session": "^1.17.1", 15 "express-session": "^1.17.1",
16 "formidable": "^1.2.2", 16 "formidable": "^1.2.2",
17 "http-errors": "~1.6.3", 17 "http-errors": "~1.6.3",
18 + "moment": "^2.26.0",
18 "morgan": "~1.9.1", 19 "morgan": "~1.9.1",
19 "mysql": "^2.18.1", 20 "mysql": "^2.18.1",
20 "passport": "^0.4.1", 21 "passport": "^0.4.1",
......
...@@ -8,24 +8,28 @@ var S3 = require('../modules/s3/s3'); ...@@ -8,24 +8,28 @@ var S3 = require('../modules/s3/s3');
8 8
9 // /file/delete/:name 9 // /file/delete/:name
10 router.get('/:name', function (req, res) { 10 router.get('/:name', function (req, res) {
11 - var file_name = req.params.name;
12 //var user_id = req.session.user_id; 11 //var user_id = req.session.user_id;
13 var user_id = 'shlee'; 12 var user_id = 'shlee';
14 13
15 - var sourceFile = file_name; 14 + var sourceFile = req.params.name;
16 var targetPath = 'trashcan'; 15 var targetPath = 'trashcan';
17 16
18 - var sql1 = 'DELETE FROM files WHERE file_name = (?) AND user_Id = (?)'; 17 + var paths = sourceFile.split('/');
19 - var sql2 = 'INSERT INTO trashcan (trash_name, user_Id) VALUES (?, ?)'; 18 + var index = sourceFile.length - (paths[paths.length - 1].length + 1);
19 + var file_name = paths[paths.length - 1];
20 + var location = sourceFile.substring(6 + user_id.length, index);
20 21
22 + var sql1 = 'DELETE FROM files WHERE file_name = (?) AND location=(?) AND user_Id = (?)';
23 + var sql2 = 'INSERT INTO trashcan (trash_name, location, user_Id) VALUES (?, ?, ?)';
21 24
22 - connection.query(sql1, [file_name, user_id], function (err) { 25 +
26 + connection.query(sql1, [file_name, location, user_id], function (err) {
23 if (err) { 27 if (err) {
24 console.log('delete db error'); 28 console.log('delete db error');
25 throw err; 29 throw err;
26 } 30 }
27 else { 31 else {
28 - connection.query(sql2, [file_name, user_id], function (err) { 32 + connection.query(sql2, [file_name, location, user_id], function (err) {
29 if (err) { 33 if (err) {
30 console.log('insert in trashcan db error'); 34 console.log('insert in trashcan db error');
31 throw err; 35 throw err;
...@@ -35,7 +39,7 @@ router.get('/:name', function (req, res) { ...@@ -35,7 +39,7 @@ router.get('/:name', function (req, res) {
35 S3.moveFile(S3.BUCKET_NAME, user_id, sourceFile, targetPath, function (result) { 39 S3.moveFile(S3.BUCKET_NAME, user_id, sourceFile, targetPath, function (result) {
36 if (result) { 40 if (result) {
37 console.log("file move to trashcan success"); 41 console.log("file move to trashcan success");
38 - res.send(result); 42 + res.send("Upload Success");
39 } 43 }
40 }) 44 })
41 } 45 }
......
...@@ -7,18 +7,14 @@ var S3 = require('../modules/s3/s3'); ...@@ -7,18 +7,14 @@ var S3 = require('../modules/s3/s3');
7 7
8 8
9 router.get('/', function (req, res) { 9 router.get('/', function (req, res) {
10 - //var userId = req.session.user_id; 10 + var user_id = req.query.user_id;
11 - var userId = 'shlee';
12 11
13 var sql = 'SELECT * FROM files WHERE user_id = (?) ORDER BY date DESC'; 12 var sql = 'SELECT * FROM files WHERE user_id = (?) ORDER BY date DESC';
14 - connection.query(sql, [userId], function (err, result) { 13 + connection.query(sql, user_id, function (err, result) {
15 - if (err){ 14 + if (result.length == 0){
16 - console.log('bringing fileList failed'); 15 + res.send({error: 'Exist Nothing'});
17 - } 16 + }else{
18 - else { 17 + res.status(200).send({files: result});
19 - console.log('bringing fileList success');
20 - res.send(result);
21 - //res.render('file/files');
22 } 18 }
23 }) 19 })
24 }); 20 });
...@@ -26,8 +22,7 @@ router.get('/', function (req, res) { ...@@ -26,8 +22,7 @@ router.get('/', function (req, res) {
26 // /file/:name 22 // /file/:name
27 router.get('/:name', function (req, res) { 23 router.get('/:name', function (req, res) {
28 var file_name = req.params.name; 24 var file_name = req.params.name;
29 - //var user_id = req.session.user_id; 25 + var user_id = req.query.user_id;
30 - var user_id = 'shlee';
31 26
32 var s3 = new AWS.S3(); 27 var s3 = new AWS.S3();
33 28
......
...@@ -11,8 +11,8 @@ var S3 = require('../modules/s3/s3'); ...@@ -11,8 +11,8 @@ var S3 = require('../modules/s3/s3');
11 11
12 // /file/upload 12 // /file/upload
13 router.post('/', function (req, res) { 13 router.post('/', function (req, res) {
14 - //var userId = req.user.userId; 14 + //var user_id = req.body.user_id;
15 - var userId = 'shlee'; 15 + var user_id = 'shlee';
16 16
17 var sourceFiles = []; 17 var sourceFiles = [];
18 var errFiles = []; 18 var errFiles = [];
...@@ -33,7 +33,7 @@ router.post('/', function (req, res) { ...@@ -33,7 +33,7 @@ router.post('/', function (req, res) {
33 } 33 }
34 } 34 }
35 35
36 - S3.uploadFiles(0, errFiles, S3.BUCKET_NAME, userId, sourceFiles, targetPath, bodies, function (result, errFiles) { 36 + S3.uploadFiles(0, errFiles, S3.BUCKET_NAME, user_id, sourceFiles, targetPath, bodies, function (result, errFiles) {
37 var newSourceFiles = []; 37 var newSourceFiles = [];
38 if (!result) { // 에러 파일이 있는 경우 38 if (!result) { // 에러 파일이 있는 경우
39 for (var sourceFile of sourceFiles) { 39 for (var sourceFile of sourceFiles) {
...@@ -43,14 +43,14 @@ router.post('/', function (req, res) { ...@@ -43,14 +43,14 @@ router.post('/', function (req, res) {
43 } 43 }
44 } 44 }
45 for (var sourceFile of sourceFiles) { 45 for (var sourceFile of sourceFiles) {
46 - var sql = 'INSERT INTO files (file_name, user_id) VALUES (?, ?)'; 46 + var sql = 'INSERT INTO files (file_name, user_id, location) VALUES (?, ?, ?)';
47 - connection.query(sql, [sourceFile, userId], function (err, result) { 47 + connection.query(sql, [file_name, user_id, targetPath], function (err, result) {
48 if (err) { 48 if (err) {
49 console.log('insert file {', sourceFile, '} in db failed'); 49 console.log('insert file {', sourceFile, '} in db failed');
50 } 50 }
51 }) 51 })
52 } 52 }
53 - res.end("Errfiles: ", errFiles); 53 + res.send({Errfiles: errFiles});
54 }) 54 })
55 }) 55 })
56 }) 56 })
......
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 +let curPath = "";
8 +let user_id = "";
9 +
10 +const s3 = new AWS.S3({
11 + accessKeyId: process.env.AWS_ACCESS_KEY_ID,
12 + secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
13 + region: "ap-northeast-2"
14 +});
15 +
16 +router.get('/show', function(req, res, next) {
17 + console.log(req.query);
18 + user_id = req.query.id;
19 + curPath = req.query.cur;
20 + folders = {}
21 + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;';
22 + connection.query(checkfolder, [curPath, user_id], function(err, rows, fields) {
23 + if (rows.length != 0) {
24 + res.status(200).send({
25 + folders: rows,
26 + cur: curPath
27 + })
28 + } else {
29 + res.send({ error: "Does not exist" });
30 + }
31 + });
32 +});
33 +
34 +
35 +router.post('/makefolder', function(req, res, next) {
36 +
37 + user_id = req.body.user_id;
38 + let cur = req.body.cur;
39 + curPath = user_id + cur;
40 + let folder_name = req.body.folder_name;
41 + let date = moment().format();
42 + let params = {
43 + Bucket: BUCKET_NAME,
44 + Key: curPath + folder_name + '/',
45 + Body: "",
46 + ACL: "public-read-write"
47 + };
48 + let checksql = 'SELECT * FROM folders WHERE location = ? AND folder_name = ?;';
49 + console.log(req.body)
50 + connection.query(checksql, [cur, folder_name], function(err, rows, fields) {
51 + if (rows.length == 0) {
52 + s3.putObject(params, function(err, data) {
53 + if (err) {
54 + console.log('s3 error');
55 + throw err;
56 + } else {
57 + console.log(data);
58 + }
59 + });
60 + let sql = 'INSERT INTO folders (folder_name,location,user_id,created) values (?,?,?,?);';
61 + let values = [folder_name, cur, user_id, date];
62 + connection.query(sql, values, function(err, result, field) {
63 + if (err) {
64 + console.log('insert error');
65 + throw err;
66 + } else {
67 + folders = {}
68 + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;';
69 + connection.query(checkfolder, [cur, user_id], function(err, rows, fields) {
70 + if (rows.length != 0) {
71 + res.status(200).send({
72 + folders: rows,
73 + cur: curPath
74 + })
75 + } else {
76 + res.send({ error: "Does not exist" });
77 + }
78 + });
79 + }
80 + });
81 +
82 +
83 + } else {
84 + res.status(404).send({ error: "same name error" });
85 + }
86 + });
87 +});
88 +
89 +
90 +router.post('/delfolder', function(req, res, next) {
91 +
92 + user_id = req.body.user_id;
93 + curPath = user_id + req.body.cur;
94 + let folder_name = req.body.folder_name;
95 + let params = {
96 + Bucket: BUCKET_NAME + curPath,
97 + Key: folder_name + '/'
98 + };
99 + let checksql = 'SELECT * FROM folders WHERE location = ? AND folder_name = ?;';
100 + let values = [curPath, folder_name];
101 +
102 + connection.query(checksql, values, function(err, rows, fields) {
103 + if (rows.length != 0) {
104 + s3.deleteObject(params, function(err, data) {
105 + if (err) {
106 + //throw err;
107 + } else {
108 + let sql = 'DELETE FROM folders WHERE location = ? AND folder_name = ?;';
109 + connection.query(sql, values, function(err, result, field) {
110 + if (err) {
111 + //throw err;
112 + } else {
113 + folders = {}
114 + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;';
115 + connection.query(checkfolder, [cur, user_id], function(err, rows, fields) {
116 + if (rows.length != 0) {
117 + res.status(200).send({
118 + folders: rows,
119 + cur: curPath
120 + })
121 + } else {
122 + res.send({ error: "Does not exist" });
123 + }
124 + });
125 +
126 + }
127 + });
128 + }
129 + });
130 +
131 +
132 + } else {
133 + res.send({ error: "Does not exist" });
134 + }
135 + });
136 +});
137 +
138 +
139 +router.post('/move', function(req, res, next) {
140 +
141 + user_id = req.body.user_id;
142 + curPath = user_id + req.body.cur;
143 + let name = req.body.mfile;
144 + let newPath = req.body.newPath;
145 + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND folder_name = ?;';
146 + if (req.body.isfolder) {
147 + connection.query(checkfolder, [curPath, name], function(err1, rows, fields) {
148 + if (rows.length != 0) {
149 + let copy_params = {
150 + Bucket: BUCKET_NAME + curPath,
151 + CopySource: BUCKET_NAME + curPath + file + '/',
152 + Key: newPath + file + '/'
153 + };
154 +
155 + let del_params = {
156 + Bucket: BUCKET_NAME + curPath,
157 + Key: file + '/'
158 + };
159 + s3.copyObject(copy_params, function(err, data) {
160 + console.log(err, data);
161 + });
162 + s3.deleteObject(del_params, function(err, data) {
163 + console.log(err, data);
164 + });
165 + let values = [newPath, curPath, name];
166 + let updatesql = 'UPDATE folders SET location = ? WHERE location = ? AND folder_name = ?;';
167 + connection.query(updatesql, values, function(err3, result, field) {
168 + if (err3) {
169 + throw err;
170 + } else {
171 + folders = {}
172 + connection.query(checkfolder, [cur, user_id], function(err, rows, fields) {
173 + if (rows.length != 0) {
174 + res.status(200).send({
175 + folders: rows,
176 + cur: curPath
177 + })
178 + } else {
179 + res.send({ error: "Does not exist" });
180 + }
181 + });
182 + }
183 + });
184 +
185 +
186 + } else {
187 + res.send({ error: "Does not exist" });
188 + }
189 + });
190 + } else {
191 + let checkfile = 'SELECT * FROM files WHERE location = ? AND file_name = ?';
192 +
193 + connection.query(checkfile, [curPath, name], function(err1, rows, fields) {
194 + if (rows.length != 0) {
195 + let copy_params = {
196 + Bucket: BUCKET_NAME + curPath,
197 + CopySource: BUCKET_NAME + curPath + file,
198 + Key: newPath + file
199 + };
200 +
201 + let del_params = {
202 + Bucket: BUCKET_NAME + curPath,
203 + Key: file
204 + };
205 + s3.copyObject(copy_params, function(err, data) {
206 + console.log(err, data);
207 + });
208 + s3.deleteObject(del_params, function(err, data) {
209 + console.log(err, data);
210 + });
211 + let values = [newPath, curPath, name];
212 + let updatesql = 'UPDATE files SET location = ? WHERE location = ? AND file_name = ?;';
213 + connection.query(updatesql, values, function(err3, result, field) {
214 + if (err3) {
215 + throw err;
216 + } else {
217 + folders = {}
218 + connection.query(checkfolder, [cur, user_id], function(err, rows, fields) {
219 + if (rows.length != 0) {
220 + res.status(200).send({
221 + folders: rows,
222 + cur: curPath
223 + })
224 + } else {
225 + res.send({ error: "Does not exist" });
226 + }
227 + });
228 + }
229 + });
230 +
231 +
232 + } else {
233 + res.send({ error: "Does not exist" });
234 + }
235 + });
236 +
237 + }
238 +});
239 +
240 +
241 +router.post('/search/:target', function(req, res, next) {
242 + user_id = req.params.id;
243 + let cur = req.params.cur;
244 + folders = {}
245 + let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;';
246 + connection.query(checkfolder, [cur, user_id], function(err, rows, fields) {
247 + if (rows.length != 0) {
248 + res.status(200).send({
249 + folders: folders
250 + })
251 + } else {
252 + res.send({ error: "Does not exist" });
253 + }
254 + });
255 +});
256 +
257 +module.exports = router;
...\ No newline at end of file ...\ No newline at end of file
1 { 1 {
2 - "accessKeyId": "ASIAZQ5XTMMF7TDZAE65", 2 + "accessKeyId": "ASIAZQ5XTMMFRBJO2LG5",
3 - "secretAccessKey": "6S8IoEaPLaml9KHDb1UrS6mewFm7xEizdUMJZWBe", 3 + "secretAccessKey": "ltsYvzKAoQ5UnNWEk13Zf8n4wJdkQkemsJ7GdsbS",
4 - "sessionToken": "FwoGZXIvYXdzEHgaDCqtdh2Y9+DetJSd6SLDAbpPE85YYhubMVWMpX8h4BvyzZZxZOaEHjlk4ix1KeVihUFvxgr7QHOWBEDIXeQBxlq7s/1pP/BzWU/rGZ6ykWPl/SEHXw9myP3KjeBiGLauHnF28CSZScLDHyTZPmIEa7e7xt1LQD3FKeifiH5fn2qEGqe+j0fG09SM8LfUz2NSxtEVhaDZGblK0hp3/lB7bPm25qz30FcxGmdKj1k7dKKvvRCvKTyi78eyz+8Y1rYbCzlSEgJcJHaZwWoGVpK7TFYxmCi48Ln2BTIt8hCtBEpDDbGf/9Y+ixIraevKKLXHM4JuJsL52URse2hMcTdnBRdyTVIDAyyK", 4 + "sessionToken": "FwoGZXIvYXdzEI///////////wEaDLleFCvWDhdhFpXCvCLDAX/Hka6vXTZKxdyEBUh7ZSxPYLH184u1Tpo2qWHYFziUVKWJSCm5wqPNv0QWoAp8sL5NB0W5kty8hoeKv16SYB9Z+yzT1qtfuKTmrro2jGSo7AnxDSBla6UQHAv82yVetiGwu+IKhm6tHUvdNSlkIV0Qi9rNrDc9eynhFN/emFI/6NsocbQ47mmW6BZx0Z4/hHKW9TL6Uec/E87Z+oxVRFsVOGyNtow980bQgZFYJMbh3AN6poTlofP1q/qn2nUWwAdsDCjfhr/2BTItlcDfO5PEH5Gwffzv69JMTVBIemfIpS/Ybx6F6i7GbI2fZKGtGfRSecobbj4m",
5 "region": "us-east-1" 5 "region": "us-east-1"
6 } 6 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -20,7 +20,7 @@ router.post('/', function(req, res, next) { ...@@ -20,7 +20,7 @@ router.post('/', function(req, res, next) {
20 if(bytes===user_pw) { 20 if(bytes===user_pw) {
21 console.log("user login successfully"); 21 console.log("user login successfully");
22 req.session.user_id=result[0].user_id; 22 req.session.user_id=result[0].user_id;
23 - res.redirect('/main'); 23 + res.status(200).send({ user_id: result[0].user_id });
24 }else{ 24 }else{
25 console.log("wrong password!"); 25 console.log("wrong password!");
26 } 26 }
......
...@@ -21,7 +21,7 @@ router.post('/', function(req, res, next) { ...@@ -21,7 +21,7 @@ router.post('/', function(req, res, next) {
21 var user_phone=req.body.user_phone; 21 var user_phone=req.body.user_phone;
22 22
23 var sqlquery = "SELECT * FROM users WHERE user_id = ?"; 23 var sqlquery = "SELECT * FROM users WHERE user_id = ?";
24 - connection.query(sqlquery, [user_id], function (err, result) { 24 + connection.query(sqlquery, [user_id], function (err, rows) {
25 if (rows.length == 0) { 25 if (rows.length == 0) {
26 user_pw=cryptoM.encrypt(user_pw); 26 user_pw=cryptoM.encrypt(user_pw);
27 console.log(user_pw); 27 console.log(user_pw);
...@@ -32,13 +32,12 @@ router.post('/', function(req, res, next) { ...@@ -32,13 +32,12 @@ router.post('/', function(req, res, next) {
32 console.log("inserting user failed"); 32 console.log("inserting user failed");
33 throw err; 33 throw err;
34 } else { 34 } else {
35 - res.redirect('/login'); 35 + res.status(200).send('saved');
36 36
37 } 37 }
38 }); 38 });
39 } else { 39 } else {
40 - res.redirect("/login"); 40 + res.status(404).send(err);
41 - throw err;
42 } 41 }
43 }); 42 });
44 }); 43 });
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
8 <title><%= htmlWebpackPlugin.options.title %></title> 8 <title><%= htmlWebpackPlugin.options.title %></title>
9 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"> 9 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
10 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css"> 10 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css">
11 + <meta name="viewport" content="width=device-width,initial-scale=1.0">
11 </head> 12 </head>
12 <body> 13 <body>
13 <noscript> 14 <noscript>
......
...@@ -5,11 +5,42 @@ const instance = axios.create({ ...@@ -5,11 +5,42 @@ const instance = axios.create({
5 }); 5 });
6 6
7 function registerUser(userData) { 7 function registerUser(userData) {
8 - return instance.post('RegistUser', userData); 8 + // const url = 'http://localhost:3000/api/signup'
9 - } 9 + return axios.post('/api/RegistUser', userData);
10 - 10 +}
11 - function loginUser(userData) { 11 +
12 - return instance.post('login', userData); 12 +function loginUser(userData) {
13 - } 13 + // const url = 'http://localhost:3000/api/login'
14 + return axios.post('/api/login', userData);
15 +}
16 +
17 +function folder(curData) {
18 + return axios.get('/api/folder/show', {
19 + params: {
20 + id: curData.id,
21 + cur: curData.cur
22 + }
23 + });
24 +}
25 +
26 +function makeFolder(folderData) {
27 + return axios.post('/api/folder/makefolder', folderData);
28 +}
29 +
30 +function file(userData){
31 + return axios.get('/api/file', userData, {
32 + params: {
33 + user_id: userData.user_id
34 + }
35 + })
36 +}
37 +
38 +
39 +export { registerUser, loginUser, folder, makeFolder, file};
40 +
14 41
15 - export { registerUser, loginUser };
...\ No newline at end of file ...\ No newline at end of file
42 +function dropbox(userData){
43 + return axios.get(`/api/folder/show/${userData}`);
44 +}
45 +
46 +// export { registerUser, loginUser, dropbox, makeFolder };
......
...@@ -12,51 +12,37 @@ ...@@ -12,51 +12,37 @@
12 hide-details 12 hide-details
13 ></v-text-field> 13 ></v-text-field>
14 </v-toolbar> 14 </v-toolbar>
15 -
16 <v-list two-line subheader> 15 <v-list two-line subheader>
17 <v-subheader inset>Folders</v-subheader> 16 <v-subheader inset>Folders</v-subheader>
18 -
19 <v-list-item 17 <v-list-item
20 - v-for="item in items" 18 + v-for="item in this.$store.getters.folderL"
21 :key="item.title" 19 :key="item.title"
22 - @click="" 20 + @click="$router.push({name: 'Folder'})"
23 > 21 >
24 <v-list-item-avatar> 22 <v-list-item-avatar>
25 - <v-icon 23 + <v-icon>mdi-folder</v-icon>
26 -
27 - >{{item.iconClass}}</v-icon>
28 </v-list-item-avatar> 24 </v-list-item-avatar>
29 -
30 <v-list-item-content> 25 <v-list-item-content>
31 - <v-list-item-title v-text="item.title"></v-list-item-title> 26 + <v-list-item-title v-text="item.folder_name"></v-list-item-title>
32 - <v-list-item-subtitle v-text="item.subtitle"></v-list-item-subtitle>
33 </v-list-item-content> 27 </v-list-item-content>
34 -
35 <v-list-item-action> 28 <v-list-item-action>
36 <v-btn icon> 29 <v-btn icon>
37 <v-icon color="grey lighten-1">mdi-information</v-icon> 30 <v-icon color="grey lighten-1">mdi-information</v-icon>
38 </v-btn> 31 </v-btn>
39 </v-list-item-action> 32 </v-list-item-action>
40 </v-list-item> 33 </v-list-item>
41 -
42 <v-divider inset></v-divider> 34 <v-divider inset></v-divider>
43 -
44 <v-subheader inset>Files</v-subheader> 35 <v-subheader inset>Files</v-subheader>
45 -
46 <v-list-item 36 <v-list-item
47 - v-for="item in items2" 37 + v-for="item in this.$store.getters.fileL"
48 :key="item.title" 38 :key="item.title"
49 - @click=""
50 > 39 >
51 <v-list-item-avatar> 40 <v-list-item-avatar>
52 - <v-icon> {{item.iconClass}}</v-icon> 41 + <v-icon> mdi-file</v-icon>
53 </v-list-item-avatar> 42 </v-list-item-avatar>
54 -
55 <v-list-item-content> 43 <v-list-item-content>
56 - <v-list-item-title v-text="item.title"></v-list-item-title> 44 + <v-list-item-title v-text="item"></v-list-item-title>
57 - <v-list-item-subtitle v-text="item.subtitle"></v-list-item-subtitle>
58 </v-list-item-content> 45 </v-list-item-content>
59 -
60 <v-list-item-action> 46 <v-list-item-action>
61 <v-btn icon> 47 <v-btn icon>
62 <v-icon color="grey lighten-1">mdi-information</v-icon> 48 <v-icon color="grey lighten-1">mdi-information</v-icon>
...@@ -85,7 +71,6 @@ ...@@ -85,7 +71,6 @@
85 > 71 >
86 {{ text }} 72 {{ text }}
87 </v-chip> 73 </v-chip>
88 -
89 <span 74 <span
90 v-else-if="index === 2" 75 v-else-if="index === 2"
91 class="overline grey--text text--darken-3 mx-2" 76 class="overline grey--text text--darken-3 mx-2"
...@@ -94,21 +79,99 @@ ...@@ -94,21 +79,99 @@
94 </span> 79 </span>
95 </template> 80 </template>
96 </v-file-input> 81 </v-file-input>
82 + <v-btn
83 + bottom
84 + color="blue"
85 + dark
86 + fab
87 + fixed
88 + right
89 + @click="dialog = !dialog"
90 + >
91 + <v-icon>mdi-plus</v-icon>
92 + </v-btn>
93 + <v-dialog
94 + v-model="dialog"
95 + width="800px"
96 + >
97 + <v-card>
98 + <v-card-title class="grey darken-2">
99 + Create Folder
100 + </v-card-title>
101 + <v-container>
102 + <div>
103 + <v-icon>mdi-folder</v-icon>
104 + <v-text-field placeholder="name" id="foldername" type="text" v-model="foldername" ></v-text-field>
105 + </div>
106 + </v-container>
107 + <v-card-actions>
108 + <v-spacer></v-spacer>
109 + <v-btn
110 + text
111 + color="primary"
112 + @click="dialog = false"
113 + >Cancel</v-btn>
114 + <v-btn
115 + text
116 + @click="makeF"
117 + >Create</v-btn>
118 + </v-card-actions>
119 + </v-card>
120 + </v-dialog>
97 </div> 121 </div>
98 </template> 122 </template>
99 123
100 <script> 124 <script>
125 +import { folder, makeFolder } from '../api/index';
101 export default { 126 export default {
102 - data: () => ({ 127 + data() {
103 - items: [ 128 + return {
104 - { icon: 'folder', iconClass: 'mdi-folder', title: 'Photos', subtitle: 'Jan 9, 2014' }, 129 + foldername:'',
105 - { icon: 'folder', iconClass: 'mdi-folder', title: 'Recipes', subtitle: 'Jan 17, 2014' }, 130 + folders: [],
106 - { icon: 'folder', iconClass: 'mdi-folder', title: 'Work', subtitle: 'Jan 28, 2014' }, 131 + files: [],
107 - ], 132 + search:'',
108 - items2: [ 133 + id: '',
109 - { icon: 'assignment', iconClass: 'mdi-file', title: 'Vacation itinerary', subtitle: 'Jan 20, 2014' }, 134 + dialog:false
110 - { icon: 'call_to_action', iconClass: 'mdi-PdfBox', title: 'Kitchen remodel', subtitle: 'Jan 10, 2014' }, 135 + }
111 - ], 136 + },
112 - }), 137 + async created(){
138 + try {
139 + const curData = {
140 + id : this.$store.state.id,
141 + cur: this.$store.state.cur
142 + }
143 + const response = await dropbox(userData);
144 + this.$store.commit('setFolder', response.data.folders);
145 + this.$store.commit('setFile', response.data.files);
146 + } catch (error) {
147 + console.log("에러");
148 + console.log(error.response.data);
149 + }
150 + },
151 + methods: {
152 + initFolderName(){
153 + this.foldername = '';
154 + },
155 + async makeF(){
156 + try {
157 + const folderData = {
158 + user_id : this.$store.state.id,
159 + cur : this.$store.state.cur,
160 + folder_name : this.foldername
161 + };
162 + const response = await makeFolder(folderData);
163 + console.log(response.data)
164 + console.log("폴더 생성 완료");
165 + this.$store.commit('setFolder', response.data.folders);
166 + } catch (error) {
167 + console.log("에러");
168 + console.log(error.response.data);
169 + } finally{
170 + this.initFolderName();
171 + this.dialog = false;
172 + }
173 + }
174 +
175 + }
113 } 176 }
114 </script> 177 </script>
......
1 +<template>
2 + <div>
3 + <v-list>
4 + <v-icon>mdi-folder</v-icon>
5 + <v-header>Folders</v-header>
6 + <v-list-item
7 + v-for="item in items"
8 + :key="item.files">
9 +
10 + </v-list-item>
11 + </v-list>
12 + </div>
13 +</template>
14 +
15 +<script>
16 +export default {
17 + props:{
18 +
19 + }
20 +}
21 +</script>
22 +
23 +<style>
24 +
25 +</style>
...\ No newline at end of file ...\ No newline at end of file
...@@ -22,23 +22,10 @@ ...@@ -22,23 +22,10 @@
22 > 22 >
23 <v-toolbar-title>KhuLoud</v-toolbar-title> 23 <v-toolbar-title>KhuLoud</v-toolbar-title>
24 <v-spacer></v-spacer> 24 <v-spacer></v-spacer>
25 - <!-- <v-tooltip bottom> 25 +
26 - <template v-slot:activator="{ on }">
27 - <v-btn
28 - :href="source"
29 - icon
30 - large
31 - target="_blank"
32 - v-on="on"
33 - >
34 - <v-icon>mdi-code-tags</v-icon>
35 - </v-btn>
36 - </template>
37 - <span>Source</span>
38 - </v-tooltip> -->
39 </v-toolbar> 26 </v-toolbar>
40 <v-card-text> 27 <v-card-text>
41 - <v-form @submit.prevent="submitForm"> 28 + <v-form >
42 <v-text-field 29 <v-text-field
43 label="ID" 30 label="ID"
44 name="ID" 31 name="ID"
...@@ -57,8 +44,7 @@ ...@@ -57,8 +44,7 @@
57 </v-card-text> 44 </v-card-text>
58 <v-card-actions> 45 <v-card-actions>
59 <v-spacer></v-spacer> 46 <v-spacer></v-spacer>
60 - <!-- <v-btn color="primary" @click = "$router.push({name: 'RegistUser'})">Regist</v-btn> --> 47 + <v-btn color="primary" :disabled="!id || !password" @click="submitForm">Login</v-btn>
61 - <v-btn color="primary" :disabled="!id || !password" router :to="{name: 'Main'}" exact>Login</v-btn>
62 </v-card-actions> 48 </v-card-actions>
63 </v-card> 49 </v-card>
64 </v-col> 50 </v-col>
...@@ -69,7 +55,7 @@ ...@@ -69,7 +55,7 @@
69 </template> 55 </template>
70 56
71 <script> 57 <script>
72 - 58 +import { loginUser } from '../api/index'
73 59
74 export default { 60 export default {
75 data() { 61 data() {
...@@ -81,24 +67,27 @@ ...@@ -81,24 +67,27 @@
81 methods: { 67 methods: {
82 async submitForm(){ 68 async submitForm(){
83 try { 69 try {
84 - const usderData = { 70 + const userData = {
85 - id: this.id, 71 + user_id: this.id,
86 - password: this.password 72 + user_pw: this.password
87 }; 73 };
88 const { data } = await loginUser(userData); 74 const { data } = await loginUser(userData);
89 - this.$store.commit('setid', data.user.userid); 75 + console.log(data);
76 +
77 + this.$store.commit('setId', data.user_id);
90 this.$router.push('/main'); 78 this.$router.push('/main');
91 79
92 } catch (error) { 80 } catch (error) {
81 + console.log("에러");
93 console.log(error.response.data); 82 console.log(error.response.data);
94 } finally { 83 } finally {
95 this.initForm(); 84 this.initForm();
96 } 85 }
97 - } 86 + },
98 - }, 87 + initForm(){
99 - initForm(){
100 this.id =''; 88 this.id ='';
101 this.password=''; 89 this.password='';
102 - } 90 + }
91 + },
103 } 92 }
104 </script> 93 </script>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
24 <v-spacer></v-spacer> 24 <v-spacer></v-spacer>
25 </v-toolbar> 25 </v-toolbar>
26 <v-card-text> 26 <v-card-text>
27 - <v-form @submit.prevent="submitForm"> 27 + <v-form>
28 <v-text-field 28 <v-text-field
29 label="ID" 29 label="ID"
30 v-model="id" 30 v-model="id"
...@@ -49,7 +49,6 @@ ...@@ -49,7 +49,6 @@
49 <v-text-field 49 <v-text-field
50 label="E-mail" 50 label="E-mail"
51 v-model="email" 51 v-model="email"
52 - :rules="emailRules"
53 name="Email" 52 name="Email"
54 ></v-text-field> 53 ></v-text-field>
55 54
...@@ -62,7 +61,7 @@ ...@@ -62,7 +61,7 @@
62 </v-card-text> 61 </v-card-text>
63 <v-card-actions> 62 <v-card-actions>
64 <v-spacer></v-spacer> 63 <v-spacer></v-spacer>
65 - <v-btn color="primary" :disabled="!id || !password || !name || !email || !contact" @click = "$router.push({name: 'Login'})">Regist</v-btn> 64 + <v-btn color="primary" :disabled="!id || !password || !name || !email || !contact" @click="submitForm">Regist</v-btn>
66 </v-card-actions> 65 </v-card-actions>
67 </v-card> 66 </v-card>
68 </v-col> 67 </v-col>
...@@ -73,6 +72,8 @@ ...@@ -73,6 +72,8 @@
73 </template> 72 </template>
74 73
75 <script> 74 <script>
75 +import { registerUser } from '../api/index'
76 +
76 export default { 77 export default {
77 data() { 78 data() {
78 return { 79 return {
...@@ -86,17 +87,19 @@ ...@@ -86,17 +87,19 @@
86 methods: { 87 methods: {
87 async submitForm() { 88 async submitForm() {
88 try { 89 try {
89 - const usderData = { 90 + const userData = {
90 - id: this.id, 91 + user_id: this.id,
91 - password: this.password, 92 + user_pw: this.password,
92 - name: this.name, 93 + user_name: this.name,
93 - email: this.email, 94 + user_email: this.email,
94 - contact: this.contact 95 + user_phone: this.contact
95 }; 96 };
96 const { data } = await registerUser(userData); 97 const { data } = await registerUser(userData);
97 console.log("회원가입 완료"); 98 console.log("회원가입 완료");
98 this.$router.push('/'); 99 this.$router.push('/');
99 } catch (error) { 100 } catch (error) {
101 + console.log("에러");
102 +
100 console.log(error.response.data); 103 console.log(error.response.data);
101 } finally{ 104 } finally{
102 this.initForm(); 105 this.initForm();
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
4 v-model="drawer" 4 v-model="drawer"
5 :clipped="$vuetify.breakpoint.lgAndUp" 5 :clipped="$vuetify.breakpoint.lgAndUp"
6 app 6 app
7 + v-if="isUserLogin"
7 > 8 >
8 <v-list dense> 9 <v-list dense>
9 <v-list-item router :to="{name: 'Main'}" exact> 10 <v-list-item router :to="{name: 'Main'}" exact>
...@@ -88,10 +89,8 @@ ...@@ -88,10 +89,8 @@
88 color="blue darken-3" 89 color="blue darken-3"
89 dark 90 dark
90 > 91 >
91 - <!-- <template v-if="isUserLogin"> 92 +
92 - <v-app-bar-nav-icon @click.stop="drawer = !drawer"></v-app-bar-nav-icon> 93 + <v-app-bar-nav-icon @click.stop="drawer = !drawer" v-if="isUserLogin"></v-app-bar-nav-icon>
93 - </template> -->
94 - <v-app-bar-nav-icon @click.stop="drawer = !drawer"></v-app-bar-nav-icon>
95 <v-toolbar-title 94 <v-toolbar-title
96 style="width: 300px" 95 style="width: 300px"
97 class="ml-0 pl-4" 96 class="ml-0 pl-4"
...@@ -111,32 +110,20 @@ ...@@ -111,32 +110,20 @@
111 <template v-else> 110 <template v-else>
112 <div></div> 111 <div></div>
113 </template> 112 </template>
114 - <!-- <v-text-field
115 - v-if="isUserLogin"
116 - flat
117 - solo-inverted
118 - hide-details
119 - prepend-inner-icon="mdi-magnify"
120 - label="전체 검색"
121 - class="hidden-sm-and-down"
122 - ></v-text-field> -->
123 <v-spacer></v-spacer> 113 <v-spacer></v-spacer>
124 <template v-if="isUserLogin"> 114 <template v-if="isUserLogin">
125 <v-btn icon @click = "logoutUser"> 115 <v-btn icon @click = "logoutUser">
126 - <v-icon>mid-login</v-icon> 116 + <v-icon>mdi-login</v-icon>
127 </v-btn> 117 </v-btn>
128 </template> 118 </template>
129 <template v-else> 119 <template v-else>
130 <v-btn icon @click = "$router.push({name: 'Login'})"> 120 <v-btn icon @click = "$router.push({name: 'Login'})">
131 <v-icon>mdi-login</v-icon> 121 <v-icon>mdi-login</v-icon>
132 </v-btn> 122 </v-btn>
133 - <v-btn icon @click="$router.push({name: 'RegistUser'})"> 123 + <v-btn icon @click = "$router.push({name: 'RegistUser'})">
134 <v-icon>mdi-account</v-icon> 124 <v-icon>mdi-account</v-icon>
135 </v-btn> 125 </v-btn>
136 </template> 126 </template>
137 - <!-- <v-btn icon @click = "$router.push({name: 'Login'})">
138 - <v-icon>mdi-login</v-icon>
139 - </v-btn> -->
140 </v-app-bar> 127 </v-app-bar>
141 <v-content> 128 <v-content>
142 <v-container 129 <v-container
...@@ -145,112 +132,6 @@ ...@@ -145,112 +132,6 @@
145 <router-view></router-view> 132 <router-view></router-view>
146 </v-container> 133 </v-container>
147 </v-content> 134 </v-content>
148 - <template v-if="isUserLogin">
149 - <v-btn
150 - bottom
151 - color="pink"
152 - dark
153 - fab
154 - fixed
155 - right
156 - @click="dialog = !dialog"
157 - >
158 - <v-icon>mdi-plus</v-icon>
159 - </v-btn>
160 - </template>
161 - <!-- <v-btn
162 - bottom
163 - color="pink"
164 - dark
165 - fab
166 - fixed
167 - right
168 - @click="dialog = !dialog"
169 - >
170 - <v-icon>mdi-plus</v-icon>
171 - </v-btn> -->
172 - <v-dialog
173 - v-model="dialog"
174 - width="800px"
175 - >
176 - <v-card>
177 - <v-card-title class="grey darken-2">
178 - Create contact
179 - </v-card-title>
180 - <v-container>
181 - <v-row class="mx-2">
182 - <v-col
183 - class="align-center justify-space-between"
184 - cols="12"
185 - >
186 - <v-row
187 - align="center"
188 - class="mr-0"
189 - >
190 - <v-avatar
191 - size="40px"
192 - class="mx-3"
193 - >
194 - <img
195 - src="//ssl.gstatic.com/s2/oz/images/sge/grey_silhouette.png"
196 - alt=""
197 - >
198 - </v-avatar>
199 - <v-text-field
200 - placeholder="Name"
201 - ></v-text-field>
202 - </v-row>
203 - </v-col>
204 - <v-col cols="6">
205 - <v-text-field
206 - prepend-icon="mdi-account-card-details-outline"
207 - placeholder="Company"
208 - ></v-text-field>
209 - </v-col>
210 - <v-col cols="6">
211 - <v-text-field
212 - placeholder="Job title"
213 - ></v-text-field>
214 - </v-col>
215 - <v-col cols="12">
216 - <v-text-field
217 - prepend-icon="mdi-mail"
218 - placeholder="Email"
219 - ></v-text-field>
220 - </v-col>
221 - <v-col cols="12">
222 - <v-text-field
223 - type="tel"
224 - prepend-icon="mdi-phone"
225 - placeholder="(000) 000 - 0000"
226 - ></v-text-field>
227 - </v-col>
228 - <v-col cols="12">
229 - <v-text-field
230 - prepend-icon="mdi-text"
231 - placeholder="Notes"
232 - ></v-text-field>
233 - </v-col>
234 - </v-row>
235 - </v-container>
236 - <v-card-actions>
237 - <v-btn
238 - text
239 - color="primary"
240 - >More</v-btn>
241 - <v-spacer></v-spacer>
242 - <v-btn
243 - text
244 - color="primary"
245 - @click="dialog = false"
246 - >Cancel</v-btn>
247 - <v-btn
248 - text
249 - @click="dialog = false"
250 - >Save</v-btn>
251 - </v-card-actions>
252 - </v-card>
253 - </v-dialog>
254 </v-app> 135 </v-app>
255 </template> 136 </template>
256 137
...@@ -272,7 +153,7 @@ export default { ...@@ -272,7 +153,7 @@ export default {
272 }), 153 }),
273 computed: { 154 computed: {
274 isUserLogin(){ 155 isUserLogin(){
275 - return this.$store.getters.isUserLogin; 156 + return this.$store.getters.isLogin;
276 }, 157 },
277 }, 158 },
278 methods: { 159 methods: {
......
...@@ -66,7 +66,11 @@ export default new VueRouter ({ ...@@ -66,7 +66,11 @@ export default new VueRouter ({
66 path:'/feedback', 66 path:'/feedback',
67 name:'Feedback', 67 name:'Feedback',
68 component: () => import('../views/Feedback.vue') 68 component: () => import('../views/Feedback.vue')
69 - } 69 + },
70 - 70 + {
71 + path: '/folder',
72 + name: 'Folder',
73 + component: () => import('../views/FolderPage.vue')
74 + },
71 ] 75 ]
72 }) 76 })
......
...@@ -4,20 +4,50 @@ import Vuex from 'vuex' ...@@ -4,20 +4,50 @@ import Vuex from 'vuex'
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: {
8 - id: '', 8 + id: '',
9 - }, 9 + folders: {},
10 - mutations: { 10 + files: {},
11 - setId(state, userid){ 11 + cur: '/',
12 - state.id = id; 12 + },
13 + mutations: {
14 + setId(state, userid) {
15 + state.id = userid;
16 + },
17 + clearid(state) {
18 + state.id = '';
19 + },
20 + setFolder(state, folderlist) {
21 + state.folders = folderlist;
22 + },
23 + setFile(state, filelist) {
24 + state.files = filelist;
25 + },
26 + setCur(state, cur) {
27 + state.cur = cur;
28 + }
13 }, 29 },
14 - clearid(state){ 30 + getters: {
15 - state.id= ''; 31 + isLogin(state) {
16 - } 32 + return state.id !== '';
33 + },
34 + userID(state) {
35 + return state.id;
36 + },
37 + folderL(state) {
38 + return state.folders;
39 + },
40 + fileL(state) {
41 + return state.files;
42 + },
43 + cur(state) {
44 + return state.cur;
45 + },
46 + setFolder(state, folderlist){
47 + state.folders = folderlist;
48 + },
49 + setFile(state, filelist){
50 + state.files = filelist;
51 + },
17 }, 52 },
18 - getters: { 53 +})
19 - isLogin(state){
20 - return state.id !== '';
21 - }
22 - }
23 -})
...\ No newline at end of file ...\ No newline at end of file
......
1 +<template>
2 + <div>
3 + <FolderList></FolderList>
4 + </div>
5 +</template>
6 +
7 +<script>
8 +import FolderList from '../components/FolderList'
9 +
10 +export default {
11 + components: {
12 + FolderList,
13 + }
14 +}
15 +</script>
16 +
17 +<style>
18 +
19 +</style>
...\ No newline at end of file ...\ No newline at end of file
...@@ -2,16 +2,16 @@ module.exports = { ...@@ -2,16 +2,16 @@ module.exports = {
2 "transpileDependencies": [ 2 "transpileDependencies": [
3 "vuetify" 3 "vuetify"
4 ], 4 ],
5 - // devServer: { 5 + devServer: {
6 - // proxy: { 6 + proxy: {
7 - // '/api': { 7 + '/api': {
8 - // target: 'http://localhost:3000/api', 8 + target: 'http://localhost:3000/api',
9 - // changeOrigin: true, 9 + changeOrigin: true,
10 - // pathRewrite: { 10 + pathRewrite: {
11 - // '^/api': '' 11 + '^/api': ''
12 - // } 12 + }
13 - // } 13 + }
14 - // } 14 + }
15 - // }, 15 + },
16 - // outputDir: '../backend/public', 16 + outputDir: '../backend/public',
17 } 17 }
......