Commit 06e01d9b authored by Ryan Herbert's avatar Ryan Herbert

file.py jstree artificial root node

If the referenced root contains a large amount of files, le page will be
immediately expanded when jstree loads.
Adding an artificial root simply makes it a little less aggressive.
parent de3c6231
......@@ -617,16 +617,18 @@ def restart_pre_process():
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def filesystem():
id = "" if request.vars["node"] is None else request.vars["node"] + '/'
root_folder = defs.FILE_SOURCE + id
json = []
for idx, f in enumerate(os.listdir(root_folder)):
correct_type = f.split('.')[-1] in defs.FILE_TYPES
is_dir = os.path.isdir(root_folder + f)
if correct_type or is_dir:
json_node = jstree.Node(f, id + f).jsonData()
if is_dir : json_node['children'] = True
if correct_type: json_node['icon'] = 'jstree-file'
json.append(json_node)
res = json
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
id = "" if request.vars["node"] is None else request.vars["node"] + '/'
if id == "":
json = [{"text": "/", "id": "/", "children": True}]
else:
root_folder = defs.FILE_SOURCE + id
for idx, f in enumerate(os.listdir(root_folder)):
correct_type = f.split('.')[-1] in defs.FILE_TYPES
is_dir = os.path.isdir(root_folder + f)
if correct_type or is_dir:
json_node = jstree.Node(f, id + f).jsonData()
if is_dir : json_node['children'] = True
if correct_type: json_node['icon'] = 'jstree-file'
json.append(json_node)
return gluon.contrib.simplejson.dumps(json, separators=(',',':'))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment