Hong

상위폴더구현

......@@ -6,6 +6,7 @@ const moment = require("moment");
const BUCKET_NAME = "hong-s3-cloud";
let curPath = "";
let user_id = "";
let parentPath = "";
const s3 = new AWS.S3({
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
......@@ -17,6 +18,17 @@ router.get('/show', function(req, res, next) {
console.log(req.query);
user_id = req.query.id;
curPath = req.query.cur;
if (curPath == '/') {
parentPath = '/';
} else {
let pathSplit = curPath.split('/')
console.log(pathSplit);
parentPath = '/';
for (let i = 1; i < pathSplit.length - 2; i++) {
parentPath += pathSplit[i];
parentPath += '/';
}
}
folders = {}
let checkfolder = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;';
connection.query(checkfolder, [curPath, user_id], function(err, rows, fields) {
......@@ -27,12 +39,14 @@ router.get('/show', function(req, res, next) {
if (rows.length != 0) {
res.status(200).send({
folders: rows,
cur: curPath
cur: curPath,
parentPath: parentPath
})
} else {
res.status(200).send({
folders: rows,
cur: curPath
cur: curPath,
parentPath: parentPath
})
}
}
......@@ -77,8 +91,7 @@ router.post('/makefolder', function(req, res, next) {
connection.query(checkfolder, [cur, user_id], function(err, rows, fields) {
if (rows.length != 0) {
res.status(200).send({
folders: rows,
cur: curPath
folders: rows
})
} else {
res.send({ error: "Does not exist" });
......
......@@ -142,9 +142,10 @@ import { folder, makeFolder } from '../api/index';
cur: '/'
}
const response = await folder(curData);
console.log(response);
console.log(response.data);
this.$store.commit('setFolder', response.data.folders);
this.$store.commit('setCur', response.data.cur);
this.$store.commit('setParent', response.data.parentPath);
} catch (error) {
console.log("에러");
console.log(error.response.data);
......@@ -162,9 +163,9 @@ import { folder, makeFolder } from '../api/index';
folder_name : this.foldername
};
const response = await makeFolder(folderData);
console.log(response.data)
console.log("폴더 생성 완료");
this.$store.commit('setFolder', response.data.folders);
console.log(response.data)
console.log("폴더 생성 완료");
this.$store.commit('setFolder', response.data.folders);
} catch (error) {
console.log("에러");
console.log(error.response.data);
......@@ -180,9 +181,10 @@ import { folder, makeFolder } from '../api/index';
cur: this.$store.state.cur + move_folder_name + '/'
}
const response = await folder(curData);
console.log(response);
console.log(response.data);
this.$store.commit('setFolder', response.data.folders);
this.$store.commit('setCur', response.data.cur);
this.$store.commit('setParent', response.data.parentPath);
} catch (error) {
console.log("에러");
console.log(error.response.data);
......
......@@ -9,6 +9,7 @@ export default new Vuex.Store({
folders: {},
files: {},
cur: '/',
parent: '/'
},
mutations: {
setId(state, userid) {
......@@ -25,6 +26,9 @@ export default new Vuex.Store({
},
setCur(state, cur) {
state.cur = cur;
},
setParent(state, parent) {
state.parent = parent;
}
},
getters: {
......@@ -42,6 +46,9 @@ export default new Vuex.Store({
},
cur(state) {
return state.cur;
},
parent(state) {
return state.parent;
}
}
})
\ No newline at end of file
......