Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
evm-store
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanli
evm-store
Commits
501aa1fb
Commit
501aa1fb
authored
Jul 19, 2021
by
wanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🐞
fix(文件管理模块后端):
修复文件管理模块后端获取tree数据接口bug
parent
9e6639ab
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
102 additions
and
59 deletions
+102
-59
tools/build_out/controllers/file.py
tools/build_out/controllers/file.py
+34
-20
tools/build_out/result.json
tools/build_out/result.json
+1
-1
tools/build_out/views/file.py
tools/build_out/views/file.py
+11
-8
tools/build_out/webcreator/response.py
tools/build_out/webcreator/response.py
+3
-3
tools/frontend/src/store/file-manager/actions.js
tools/frontend/src/store/file-manager/actions.js
+1
-1
tools/frontend/src/views/FileManager/FileManager.vue
tools/frontend/src/views/FileManager/FileManager.vue
+14
-3
tools/frontend/src/views/FileManager/components/manager/DiskList.vue
...end/src/views/FileManager/components/manager/DiskList.vue
+38
-23
No files found.
tools/build_out/controllers/file.py
View file @
501aa1fb
...
...
@@ -4,6 +4,7 @@ import shutil
from
pathlib
import
Path
import
json
import
mimetypes
from
models.user
import
UserModel
from
webcreator.log
import
logger
from
application.config
import
config
from
webcreator.response
import
ResponseCode
...
...
@@ -19,7 +20,7 @@ class FileManager(object):
@param {*} self
@return {*}
'''
def
initialize
(
self
):
def
initialize
(
self
,
jwt
):
'''
disks: {
files: {driver: "local"},
...
...
@@ -40,12 +41,18 @@ class FileManager(object):
}
# 这里需要过滤,有些目录只能管理员才能查看
user
=
UserModel
.
query
.
filter
(
UserModel
.
uuid
==
jwt
.
get
(
"uuid"
))
.
one_or_none
()
if
user
.
role
==
1
:
p
=
Path
(
disk_root
)
for
child
in
p
.
iterdir
():
if
child
.
is_dir
():
result
[
"disks"
]
.
update
({
child
.
name
:
{
"driver"
:
"local"
}
})
else
:
result
[
"disks"
]
.
update
({
"uploads"
:
{
"driver"
:
"local"
}
})
return
result
,
ResponseCode
.
HTTP_SUCCESS
...
...
@@ -84,22 +91,26 @@ class FileManager(object):
type: "file"
}
'''
if
target_path
==
None
:
target_path
=
''
target_path
=
Path
(
target_path
)
result
=
{
"directories"
:
[],
"files"
:
[]
}
if
target_path
==
None
:
target_path
=
''
disk_path
=
Path
(
disk_root
)
.
joinpath
(
disk
)
else
:
disk_path
=
Path
(
disk_root
)
if
not
disk_path
.
exists
():
return
result
logger
.
info
(
disk_path
)
return
result
,
ResponseCode
.
DIRECTORY_NOT_EXISTS
target_path
=
Path
(
target_path
)
target_path
=
disk_path
.
joinpath
(
target_path
)
if
not
target_path
.
exists
():
return
result
logger
.
info
(
target_path
)
return
result
,
ResponseCode
.
DIRECTORY_NOT_EXISTS
for
child
in
target_path
.
iterdir
():
if
child
.
is_dir
():
...
...
@@ -157,14 +168,16 @@ class FileManager(object):
rp
=
Path
(
disk_root
)
disk_path
=
rp
/
disk
if
not
disk_path
.
exists
():
return
result
return
result
,
ResponseCode
.
DIRECTORY_NOT_EXISTS
temp_path
=
disk_path
.
joinpath
(
target_path
)
if
not
temp_path
.
exists
():
return
result
temp_path
=
Path
(
disk_root
)
.
joinpath
(
target_path
)
if
not
temp_path
.
exists
():
return
result
,
ResponseCode
.
DIRECTORY_NOT_EXISTS
p
=
Path
(
disk_path
)
for
child
in
p
.
iterdir
():
#
p = Path(disk_path)
for
child
in
temp_path
.
iterdir
():
if
child
.
is_dir
():
result
.
append
({
"basename"
:
child
.
name
,
...
...
@@ -177,6 +190,7 @@ class FileManager(object):
"type"
:
"dir"
})
# pprint.pprint(result)
# logger.info(result)
return
result
,
ResponseCode
.
HTTP_SUCCESS
def
disk
(
self
,
disk
):
...
...
@@ -202,7 +216,6 @@ class FileManager(object):
def
upload
(
self
,
disk
,
path
,
overwrite
,
fileList
):
# upload
print
(
disk
)
target_dir
=
Path
(
disk_root
)
.
joinpath
(
disk
)
.
joinpath
(
path
)
if
not
target_dir
.
exists
():
target_dir
.
mkdir
()
...
...
@@ -210,9 +223,10 @@ class FileManager(object):
for
file
in
fileList
:
target_file
=
target_dir
.
joinpath
(
file
.
filename
)
if
target_file
.
exists
()
and
overwrite
==
0
:
target_file
.
unlink
()
elif
target_file
.
exists
():
continue
target_file
.
unlink
()
file
.
save
(
target_file
.
resolve
()
.
as_posix
())
return
True
,
ResponseCode
.
HTTP_SUCCESS
...
...
tools/build_out/result.json
View file @
501aa1fb
{
"directories"
:
[{
"basename"
:
"evueapps"
,
"dirname"
:
"."
,
"path"
:
"evueapps"
,
"timestamp"
:
1618901644
,
"type"
:
"dir"
}],
"files"
:
[{
"basename"
:
"appjs.c"
,
"dirname"
:
"."
,
"extension"
:
"c"
,
"filename"
:
"appjs"
,
"path"
:
"appjs.c"
,
"size"
:
2145
,
"timestamp"
:
1625480571
,
"type"
:
"file"
},
{
"basename"
:
"codefresh-build-3.yaml"
,
"dirname"
:
"."
,
"extension"
:
"yaml"
,
"filename"
:
"codefresh-build-3"
,
"path"
:
"codefresh-build-3.yaml"
,
"size"
:
268
,
"timestamp"
:
1626516235
,
"type"
:
"file"
},
{
"basename"
:
"result -
\u
526f
\u
672c.json"
,
"dirname"
:
"."
,
"extension"
:
"json"
,
"filename"
:
"result -
\u
526f
\u
672c"
,
"path"
:
"result -
\u
526f
\u
672c.json"
,
"size"
:
376
,
"timestamp"
:
1626524753
,
"type"
:
"file"
},
{
"basename"
:
"result.json"
,
"dirname"
:
"."
,
"extension"
:
"json"
,
"filename"
:
"result"
,
"path"
:
"result.json"
,
"size"
:
407
,
"timestamp"
:
1626520437
,
"type"
:
"file"
}]}
\ No newline at end of file
{
"directories"
:
[{
"basename"
:
"evm"
,
"dirname"
:
"uploads/evueapps"
,
"path"
:
"uploads/evueapps/evm"
,
"timestamp"
:
1625930440
,
"type"
:
"dir"
}],
"files"
:
[]}
\ No newline at end of file
tools/build_out/views/file.py
View file @
501aa1fb
'''
Author: your name
Date: 2021-07-09 12:39:40
LastEditTime: 2021-07-1
7 22:17:51
LastEditTime: 2021-07-1
9 09:32:48
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\v
iews
\f
ile.py
...
...
@@ -24,6 +24,7 @@ class FileInit(Resource):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
self
.
parser
=
RequestParser
()
@
jwt_required
(
locations
=
[
"headers"
])
def
get
(
self
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# self.parser.add_argument("page", type=int, location="args", default=1)
...
...
@@ -31,7 +32,8 @@ class FileInit(Resource):
# args = self.parser.parse_args()
try
:
result
,
message
=
signalManager
.
actionGetFileInit
.
emit
()
jwt
=
get_jwt_identity
()
result
,
message
=
signalManager
.
actionGetFileInit
.
emit
(
jwt
)
if
result
:
return
{
'config'
:
result
,
'result'
:
{
'message'
:
None
,
'status'
:
"success"
}
}
return
{
'information'
:
list
(
message
),
'result'
:
{
'message'
:
"no data"
,
'status'
:
"fail"
}
}
...
...
@@ -79,6 +81,7 @@ class FileTree(Resource):
try
:
result
,
message
=
signalManager
.
actionGetFileTree
.
emit
(
args
.
disk
,
args
.
path
)
if
result
:
logger
.
info
(
result
)
response
=
{
'result'
:
{
'message'
:
None
,
'status'
:
"success"
},
'directories'
:
None
}
response
.
update
({
'directories'
:
result
})
return
response
...
...
@@ -136,15 +139,15 @@ class FileUpload(Resource):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
self
.
parser
=
RequestParser
()
def
ge
t
(
self
):
self
.
parser
.
add_argument
(
"disk"
,
type
=
str
,
location
=
"
args
"
,
required
=
True
)
self
.
parser
.
add_argument
(
"path"
,
type
=
str
,
location
=
"
args
"
,
required
=
True
)
self
.
parser
.
add_argument
(
"overwrite"
,
type
=
int
,
location
=
"
args
"
,
default
=
0
,
required
=
True
)
self
.
parser
.
add_argument
(
"files"
,
type
=
FileStorage
,
location
=
"files"
,
required
=
True
)
def
pos
t
(
self
):
self
.
parser
.
add_argument
(
"disk"
,
type
=
str
,
location
=
"
form
"
,
required
=
True
)
self
.
parser
.
add_argument
(
"path"
,
type
=
str
,
location
=
"
form
"
,
required
=
True
)
self
.
parser
.
add_argument
(
"overwrite"
,
type
=
int
,
location
=
"
form
"
,
default
=
0
,
required
=
True
)
self
.
parser
.
add_argument
(
"files"
,
type
=
FileStorage
,
location
=
"files"
,
required
=
True
,
action
=
'append'
)
args
=
self
.
parser
.
parse_args
()
try
:
fileList
=
request
.
files
.
getlist
(
'file
List
'
)
fileList
=
request
.
files
.
getlist
(
'file
s
'
)
result
,
message
=
signalManager
.
actionPostFileUpload
.
emit
(
args
.
disk
,
args
.
path
,
args
.
overwrite
,
fileList
)
if
result
:
return
{
'config'
:
result
,
'result'
:
{
'message'
:
None
,
'status'
:
"success"
}
}
...
...
tools/build_out/webcreator/response.py
View file @
501aa1fb
'''
Author: your name
Date: 2021-07-15 09:33:39
LastEditTime: 2021-07-17 2
0:46:51
LastEditTime: 2021-07-17 2
2:41:29
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\b
uild_out
\
webcreator
\r
esponse.py
...
...
@@ -94,8 +94,8 @@ class ResponseCode(object):
# 文件管理模块
FILE_NOT_EXISTS
=
(
3010001
,
'file not exists'
)
FILE_EXISTS
=
(
3010002
,
'file already exists'
)
DIRECTORY_NOT_EXISTS
=
(
3010003
,
'
file
not exists'
)
DIRECTORY_EXISTS
=
(
3010004
,
'
file
already exists'
)
DIRECTORY_NOT_EXISTS
=
(
3010003
,
'
directory
not exists'
)
DIRECTORY_EXISTS
=
(
3010004
,
'
directory
already exists'
)
def
response_result
(
response
,
msg
=
None
,
data
=
None
,
**
kwargs
):
...
...
tools/frontend/src/store/file-manager/actions.js
View file @
501aa1fb
...
...
@@ -243,7 +243,7 @@ export default {
data
.
append
(
'
overwrite
'
,
overwrite
);
// add file or files
for
(
let
i
=
0
;
i
<
files
.
length
;
i
+=
1
)
{
data
.
append
(
'
files
[]
'
,
files
[
i
]);
data
.
append
(
'
files
'
,
files
[
i
]);
}
// axios config - progress bar
...
...
tools/frontend/src/views/FileManager/FileManager.vue
View file @
501aa1fb
...
...
@@ -73,9 +73,12 @@ export default {
response
:
null
,
},
settings
:
{
headers
:
{
// axios headers
headers
:
{
// axios headers
"
X-Requested-With
"
:
"
XMLHttpRequest
"
,
Authorization
:
`Bearer
${
window
.
sessionStorage
.
getItem
(
"
Authorization
"
)}
`
,
Authorization
:
`Bearer
${
window
.
sessionStorage
.
getItem
(
"
Authorization
"
)}
`
,
},
baseUrl
:
"
/api/v1/file-manager/
"
,
// overwrite base url Axios
windowsConfig
:
2
,
// overwrite config
...
...
@@ -84,7 +87,15 @@ export default {
};
},
created
()
{
console
.
log
(
this
.
$route
.
params
)
// disk and path
console
.
log
(
this
.
$route
.
params
);
const
params
=
this
.
$route
.
params
;
if
(
params
.
disk
&&
params
.
path
)
{
this
.
$store
.
dispatch
(
"
fm/selectDisk
"
,
{
disk
:
params
.
disk
,
manager
:
"
left
"
,
});
}
// manual settings
this
.
$store
.
commit
(
"
fm/settings/manualSettings
"
,
this
.
settings
);
...
...
tools/frontend/src/views/FileManager/components/manager/DiskList.vue
View file @
501aa1fb
<!--
* @Author: your name
* @Date: 2021-07-15 09:33:39
* @LastEditTime: 2021-07-19 09:21:43
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \evm-store\tools\frontend\src\views\FileManager\components\manager\DiskList.vue
-->
<
template
>
<div
class=
"fm-disk-list"
>
<ul
class=
"list-inline"
>
<li
class=
"list-inline-item"
v-for=
"(disk, index) in disks"
v-bind:key=
"index"
>
<span
class=
"badge"
<li
class=
"list-inline-item"
v-for=
"(disk, index) in disks"
v-bind:key=
"index"
>
<span
class=
"badge"
v-on:click=
"selectDisk(disk)"
v-bind:class=
"[disk === selectedDisk ? 'badge-secondary' : 'badge-light']"
>
<i
class=
"fa-fw far fa-hdd"
/>
{{
disk
}}
v-bind:class=
"[
disk === selectedDisk ? 'badge-secondary' : 'badge-light',
]"
>
<i
class=
"fa-fw far fa-hdd"
/>
{{
disk
}}
</span>
</li>
</ul>
...
...
@@ -14,7 +30,7 @@
<
script
>
export
default
{
name
:
'
DiskList
'
,
name
:
"
DiskList
"
,
props
:
{
// manager name - left or right
manager
:
{
type
:
String
,
required
:
true
},
...
...
@@ -25,7 +41,7 @@ export default {
* @returns {Array}
*/
disks
()
{
return
this
.
$store
.
getters
[
'
fm/diskList
'
];
return
this
.
$store
.
getters
[
"
fm/diskList
"
];
},
/**
...
...
@@ -43,7 +59,7 @@ export default {
*/
selectDisk
(
disk
)
{
if
(
this
.
selectedDisk
!==
disk
)
{
this
.
$store
.
dispatch
(
'
fm/selectDisk
'
,
{
this
.
$store
.
dispatch
(
"
fm/selectDisk
"
,
{
disk
,
manager
:
this
.
manager
,
});
...
...
@@ -54,8 +70,7 @@ export default {
</
script
>
<
style
lang=
"scss"
>
.fm-disk-list
{
.fm-disk-list
{
ul
.list-inline
{
margin-bottom
:
0
.5rem
;
}
...
...
@@ -63,5 +78,5 @@ export default {
.badge.badge-light
{
cursor
:
pointer
;
}
}
}
</
style
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment