최예리

directory modify 기능 추가, directory remove 기능 개선

......@@ -73,10 +73,43 @@ app.get('/home/:directoryName/upload', (req, res) => {
});
// Modify Directory name
app.get('/home/:directoryName/modify', (req, res) => {
// exist query.newName
var directoryName = new String(req.params.directoryName);
var newName = new String(req.query.newName);
if (req.query.newName) {
// modify Directory name and Files
var path = dataFolder + '/' + directoryName;
fs.readdirSync(path).forEach(function(file,index){
var curPath = path + "/" + file;
var fileNameArr = string.split("_");
var newPath = path + "/" + newName + "_" + fileNameArr[1];
fs.rename(curPath, newPath, function (err) {
if (err) {
console.log("File Rename error: " + err);
}
});
});
fs.rename(path, dataFolder + '/' + newName, function (err) {
if (err) {
console.log("Directory Rename error: " + err);
} else {
console.log("Directory Rename: " + directoryName + " -> " + newName);
}
});
res.redirect('/');
}
else {
res.render('directoryModifyCheck', {directoryName:JSON.stringify(directoryName)});
}
});
// Delete Directory
app.get('/home/:directoryName/delete', (req, res) => {
// exist query.real
var directoryName = req.params.directoryName;
var directoryName = new String(req.params.directoryName);
if (req.query.real) {
// Remove Directory and Files
var path = dataFolder + '/' + directoryName;
......@@ -88,7 +121,7 @@ app.get('/home/:directoryName/delete', (req, res) => {
res.redirect('/');
}
else {
res.render('directoryDeleteCheck');
res.render('directoryDeleteCheck', {directoryName:JSON.stringify(directoryName)});
}
});
......
script.
confirm("모든 이미지가 삭제됩니다. 정말 분류를 삭제하시겠습니까?") ? location.href = location + 'real=true' : history.back();
var directoryName= !{directoryName};
confirm('모든 이미지가 삭제됩니다.\n정말 ' + directoryName + ' 분류를 삭제하시겠습니까?')
? location.href = location + 'real=true' : history.back();
\ No newline at end of file
......
script.
var directoryName= !{directoryName};
var result = prompt('새 분류명을 입력하세요. (기존: ' + directoryName + ')');
if (result) {
location.href = location + 'newName=' + result;
} else {
alert('분류명을 수정하지 않습니다.');
history.back();
}
\ No newline at end of file
script.
alert("이미 존재하는 분류입니다.");
var msg = '이미 존재하는 분류입니다.'
alert(msg);
history.back();
\ No newline at end of file
......
......@@ -3,22 +3,36 @@ html
head
meta(charset='utf-8')
title 분류 리스트
body
form(action="directory_check" method="post")
p 새로 만들 분류명:
input(name="directoryName", type="text")
input(type="submit", value="생성")
br
form(action="test" method="post" enctype="multipart/form-data")
p 테스트할 이미지:
input(name="ImageTest", type="file")
input(type="submit", value="테스트")
br
ul
- var folderList=fileList
each folder in folderList
li=folder
form(action="home/"+folder method="get")
input(type="submit", value="편집")
div(style="margin-right:30px; float:left;")
li
a(href=location+folder)=folder
div(style="margin-right:5px; float:left;")
form(action="home/"+folder+"/modify" method="get")
input(type="submit", value="수정")
div
form(action="home/"+folder+"/delete" method="get")
input(type="submit", value="삭제")
br
\ No newline at end of file
......