Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-CloudComputing
/
D_Team_Khuloud
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
최동원
2020-05-29 00:36:11 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
675ff3d886325ad13ab1b51d4f2ec880ea4361e8
675ff3d8
2 parents
b1405ad3
a5b637dc
.
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
105 additions
and
58 deletions
backend/routes/folders.js
front-end/src/api/index.js
front-end/src/components/FileList.vue
backend/routes/folders.js
View file @
675ff3d
...
...
@@ -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
n
ewPath
=
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
n
ame
=
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
+
fil
e
+
'/'
,
Key
:
newPath
+
fil
e
+
'/'
Bucket
:
BUCKET_NAME
,
CopySource
:
BUCKET_NAME
+
'/'
+
curPath
+
nam
e
+
'/'
,
Key
:
newPath
+
nam
e
+
'/'
};
let
del_params
=
{
Bucket
:
BUCKET_NAME
+
curPath
,
Key
:
fil
e
+
'/'
Bucket
:
BUCKET_NAME
,
Key
:
curPath
+
nam
e
+
'/'
};
s3
.
copyObject
(
copy_params
,
function
(
err
,
data
)
{
if
(
err
)
{
console
.
log
(
err
,
data
);
});
console
.
log
(
"copy error"
);
res
.
status
(
304
).
send
({
error
:
"copy error"
});
}
else
{
s3
.
deleteObject
(
del_params
,
function
(
err
,
data
)
{
if
(
err
)
{
console
.
log
(
err
,
data
);
});
let
values
=
[
newPath
,
curPath
,
name
];
let
updatesql
=
'UPDATE folders SET location = ? WHERE location = ? AND folder_name = ?;'
;
console
.
log
(
"delete error"
);
res
.
status
(
304
).
send
({
error
:
"delete error"
});
}
else
{
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
)
{
throw
err
;
console
.
log
(
"updatesql error"
);
res
.
status
(
304
).
send
({
error
:
"updatesql error"
});
}
else
{
folders
=
{}
connection
.
query
(
checkfolder
,
[
cur
,
user_id
],
function
(
err
,
rows
,
fields
)
{
if
(
rows
.
length
!=
0
)
{
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
,
cur
:
curPath
})
}
else
{
res
.
send
({
error
:
"Does not exist"
});
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
)
{
if
(
err
)
{
console
.
log
(
err
,
data
);
});
res
.
status
(
304
).
send
({
error
:
"copy error"
});
}
else
{
s3
.
deleteObject
(
del_params
,
function
(
err
,
data
)
{
if
(
err
)
{
console
.
log
(
err
,
data
);
});
let
values
=
[
newPath
,
curPath
,
name
];
let
updatesql
=
'UPDATE files SET location = ? WHERE location = ? AND file_name = ?;'
;
res
.
status
(
304
).
send
({
error
:
"delete error"
});
}
else
{
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
)
{
throw
err
;
res
.
status
(
304
).
send
({
error
:
"updatesql error"
})
;
}
else
{
folders
=
{}
connection
.
query
(
checkfolder
,
[
cur
,
user_id
],
function
(
err
,
rows
,
fields
)
{
if
(
rows
.
length
!=
0
)
{
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
,
cur
:
curPath
})
}
else
{
res
.
send
({
error
:
"Does not exist"
});
folders
:
rows
});
});
}
});
}
});
}
});
}
else
{
res
.
send
({
error
:
"Does not exist"
});
res
.
s
tatus
(
304
).
s
end
({
error
:
"Does not exist"
});
}
});
...
...
front-end/src/api/index.js
View file @
675ff3d
...
...
@@ -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
...
...
front-end/src/components/FileList.vue
View file @
675ff3d
...
...
@@ -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
...
...
Please
register
or
login
to post a comment