최동원

.

......@@ -148,100 +148,105 @@ router.post('/delfolder', function(req, res, next) {
router.post('/move', function(req, res, next) {
user_id = req.body.user_id;
curPath = user_id + req.body.cur;
let name = req.body.mfile;
let newPath = req.body.newPath;
let checkfolder = 'SELECT * FROM folders WHERE location = ? AND folder_name = ?;';
console.log(req.body);
user_id = req.body.id;
let cur = req.body.cur;
curPath = user_id + cur;
let name = req.body.folder_name;
let newPath = user_id + req.body.newPath;
if (req.body.isfolder) {
connection.query(checkfolder, [curPath, name], function(err1, rows, fields) {
let checkfolder = 'SELECT * FROM folders WHERE location = ? AND folder_name = ? AND user_id = ?;';
connection.query(checkfolder, [cur, name, user_id], function(err1, rows, fields) {
console.log(rows);
if (rows.length != 0) {
let copy_params = {
Bucket: BUCKET_NAME + curPath,
CopySource: BUCKET_NAME + curPath + file + '/',
Key: newPath + file + '/'
Bucket: BUCKET_NAME,
CopySource: BUCKET_NAME + '/' + curPath + name + '/',
Key: newPath + name + '/'
};
let del_params = {
Bucket: BUCKET_NAME + curPath,
Key: file + '/'
Bucket: BUCKET_NAME,
Key: curPath + name + '/'
};
s3.copyObject(copy_params, function(err, data) {
console.log(err, data);
});
s3.deleteObject(del_params, function(err, data) {
console.log(err, data);
});
let values = [newPath, curPath, name];
let updatesql = 'UPDATE folders SET location = ? WHERE location = ? AND folder_name = ?;';
connection.query(updatesql, values, function(err3, result, field) {
if (err3) {
throw err;
if (err) {
console.log(err, data);
console.log("copy error");
res.status(304).send({ error: "copy error" });
} else {
folders = {}
connection.query(checkfolder, [cur, user_id], function(err, rows, fields) {
if (rows.length != 0) {
res.status(200).send({
folders: rows,
cur: curPath
})
s3.deleteObject(del_params, function(err, data) {
if (err) {
console.log(err, data);
console.log("delete error");
res.status(304).send({ error: "delete error" });
} else {
res.send({ error: "Does not exist" });
let values = [req.body.newPath, cur, name, user_id];
let updatesql = 'UPDATE folders SET location = ? WHERE location = ? AND folder_name = ? AND user_id = ?;';
connection.query(updatesql, values, function(err3, result, field) {
if (err3) {
console.log("updatesql error");
res.status(304).send({ error: "updatesql error" });
} else {
let resultsql = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;';
connection.query(resultsql, [cur, user_id], function(err, rows, fields) {
res.status(200).send({
folders: rows
});
});
}
});
}
});
}
});
} else {
res.send({ error: "Does not exist" });
console.log("Does not exist");
res.status(304).send({ error: "Does not exist" });
}
});
} else {
let checkfile = 'SELECT * FROM files WHERE location = ? AND file_name = ?';
connection.query(checkfile, [curPath, name], function(err1, rows, fields) {
let checkfile = 'SELECT * FROM files WHERE location = ? AND file_name = ? AND user_id = ?';
connection.query(checkfile, [curPath, name, user_id], function(err1, rows, fields) {
if (rows.length != 0) {
let copy_params = {
Bucket: BUCKET_NAME + curPath,
CopySource: BUCKET_NAME + curPath + file,
Bucket: BUCKET_NAME,
CopySource: BUCKET_NAME + '/' + curPath + file,
Key: newPath + file
};
let del_params = {
Bucket: BUCKET_NAME + curPath,
Key: file
Bucket: BUCKET_NAME,
Key: curPath + file
};
s3.copyObject(copy_params, function(err, data) {
console.log(err, data);
});
s3.deleteObject(del_params, function(err, data) {
console.log(err, data);
});
let values = [newPath, curPath, name];
let updatesql = 'UPDATE files SET location = ? WHERE location = ? AND file_name = ?;';
connection.query(updatesql, values, function(err3, result, field) {
if (err3) {
throw err;
if (err) {
console.log(err, data);
res.status(304).send({ error: "copy error" });
} else {
folders = {}
connection.query(checkfolder, [cur, user_id], function(err, rows, fields) {
if (rows.length != 0) {
res.status(200).send({
folders: rows,
cur: curPath
})
s3.deleteObject(del_params, function(err, data) {
if (err) {
console.log(err, data);
res.status(304).send({ error: "delete error" });
} else {
res.send({ error: "Does not exist" });
let values = [newPath, cur, name, user_id];
let updatesql = 'UPDATE files SET location = ? WHERE location = ? AND file_name = ? AND user_id = ?;';
connection.query(updatesql, values, function(err3, result, field) {
if (err3) {
res.status(304).send({ error: "updatesql error" });
} else {
let resultsql = 'SELECT * FROM folders WHERE location = ? AND user_id = ?;';
connection.query(resultsql, [cur, user_id], function(err, rows, fields) {
res.status(200).send({
folders: rows
});
});
}
});
}
});
}
});
} else {
res.send({ error: "Does not exist" });
res.status(304).send({ error: "Does not exist" });
}
});
......
......@@ -27,8 +27,14 @@ function makeFolder(folderData) {
return axios.post('/api/folder/makefolder', folderData);
}
function deleteFolder(folderData){
function deleteFolder(folderData) {
return axios.post('/api/folder/delfolder', folderData);
}
export { registerUser, loginUser, folder, makeFolder, deleteFolder };
\ No newline at end of file
function moveFolder(folderData) {
return axios.post('/api/folder/move', folderData);
}
export { registerUser, loginUser, folder, makeFolder, deleteFolder, moveFolder };
\ No newline at end of file
......
......@@ -72,12 +72,28 @@
>Cancel</v-btn>
<v-btn
text
@click=""
@click="transferF(item.folder_name)"
>Move</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-menu
v-model="showMenu"
:position-x="x"
:position-y="y"
absolute
offset-y
>
<v-list dense>
<v-list-item @click.prevent="dialog2 = !dialog2">
<v-list-item-title>이동</v-list-item-title>
</v-list-item>
<v-list-item @click.prevent="deleteF(item.folder_name)">
<v-list-item-title>삭제</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</v-list-item>
<v-divider inset></v-divider>
<v-subheader inset>Files</v-subheader>
......@@ -173,7 +189,7 @@
</div>
</template>
<script>
import { folder, makeFolder, deleteFolder } from '../api/index';
import { folder, makeFolder, deleteFolder, moveFolder } from '../api/index';
import Axios from 'axios';
export default {
data() {
......@@ -278,6 +294,26 @@ import Axios from 'axios';
console.log(error.response.data);
}
},
async transferF(folderName){
try {
const cData = {
id: this.$store.state.id,
cur : this.$store.state.cur,
folder_name: folderName,
isfolder: true,
newPath: this.foldername
}
const response = await moveFolder(cData);
console.log(response);
this.$store.commit('setFolder', response.data.folders);
} catch (error) {
console.log("에러");
console.log(error.response.data);
} finally{
this.initFolderName();
this.dialog2 = false;
}
},
show (e) {
e.preventDefault()
this.showMenu = false
......