Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Klaus Wölfel
slapos.toolbox
Commits
1a3a0773
Commit
1a3a0773
authored
Oct 16, 2013
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix fileTreeView in slaprunner editor
parent
783e35f3
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
624 additions
and
593 deletions
+624
-593
slapos/runner/fileBrowser.py
slapos/runner/fileBrowser.py
+7
-7
slapos/runner/static/css/ui.fancytree.css
slapos/runner/static/css/ui.fancytree.css
+546
-520
slapos/runner/static/js/scripts/softwareFolder.js
slapos/runner/static/js/scripts/softwareFolder.js
+15
-11
slapos/runner/templates/softwareFolder.html
slapos/runner/templates/softwareFolder.html
+1
-1
slapos/runner/views.py
slapos/runner/views.py
+55
-54
No files found.
slapos/runner/fileBrowser.py
View file @
1a3a0773
...
...
@@ -58,7 +58,7 @@ class FileBrowser(object):
html += 'gsdirs.push(new gsItem("
2
", "
%
s
", "
%
s
", "
0
", "
%
s
", "
dir
", "
%
s
"));' % (f, ff, md5sum, mdate)
return html
def fancylistDirs(self, dir, key, all=False):
def fancylistDirs(self, dir, key,
listfiles,
all=False):
dir = urllib.unquote(dir)
realdir = realpath(self.config, dir)
if not realdir:
...
...
@@ -73,18 +73,18 @@ class FileBrowser(object):
ff = os.path.join(dir, f)
realfile = os.path.join(realdir, f)
identity = "
%
s
%
s
" % (key, i)
if not os.path.isdir(realfile):
if os.path.isdir(realfile):
dirList.append({"
title
": f, "
key
": identity,
"
folder
":True, "
lazy
":True, "
path
": ff})
elif listfiles:
regex = re.compile("
(
^
.
*
)
\
.(.
*
)
", re.VERBOSE)
ext = regex.sub(r'
\
2
', f)
if ext == f:
ext = ""
dirList.append({"
title
": f, "
key
": identity,
"
extraClasses
": "
ext_
"+ext, "
path
": ff})
else:
fileList.append({"
title
": f, "
key
": identity,
"
folder
":True, "
lazy
":True
, "
path
": ff})
"
extraClasses
": "
ext_
"+ext
, "
path
": ff})
i+=1
return (
fileList + dir
List)
return (
dirList + file
List)
def makeDirectory(self, dir, filename):
"""Create a directory"""
...
...
slapos/runner/static/css/ui.fancytree.css
View file @
1a3a0773
This diff is collapsed.
Click to expand it.
slapos/runner/static/js/scripts/softwareFolder.js
View file @
1a3a0773
...
...
@@ -11,7 +11,6 @@ $(document).ready(function () {
CurrentMode
,
script
=
"
/readFolder
"
,
softwareDisplay
=
true
,
fileTree
,
Mode
,
modes
,
projectDir
=
$
(
"
input#project
"
).
val
(),
...
...
@@ -86,7 +85,7 @@ $(document).ready(function () {
function
selectFile
(
file
)
{
$
(
"
#info
"
).
empty
();
$
(
"
#info
"
).
append
(
"
Selection
:
"
+
file
);
$
(
"
#info
"
).
append
(
"
Current work tree
:
"
+
file
);
selection
=
file
;
return
;
}
...
...
@@ -117,7 +116,7 @@ $(document).ready(function () {
$
(
'
#fileTreeFull
'
).
hide
();
}
$
(
"
#info
"
).
empty
();
$
(
"
#info
"
).
append
(
"
Selection
:
"
+
base_path
());
$
(
"
#info
"
).
append
(
"
Current work tree
:
"
+
base_path
());
selection
=
""
;
}
...
...
@@ -296,7 +295,7 @@ $(document).ready(function () {
success
:
function
(
data
)
{
$
(
"
#inline_content
"
).
empty
();
$
(
"
#inline_content
"
).
append
(
'
<h2 style="color: #4c6172; font: 18px
\'
Helvetica Neue
\'
, Helvetica, Arial, sans-serif;">Content of file:
'
+
node
.
title
+
'
</h2>
'
);
node
.
title
+
'
</h2>
'
);
$
(
"
#inline_content
"
).
append
(
'
<br/><div class="main_content"><pre id="editorViewer"></pre></div>
'
);
viewer
=
ace
.
edit
(
"
editorViewer
"
);
viewer
.
setTheme
(
"
ace/theme/crimson_editor
"
);
...
...
@@ -390,8 +389,11 @@ $(document).ready(function () {
};
// --- Init fancytree during startup ----------------------------------------
$
(
function
(){
$
(
"
#fileTree
"
).
fancytree
({
function
initTree
(
tree
,
path
,
key
){
if
(
!
key
){
key
=
'
0
'
;
}
$
(
tree
).
fancytree
({
activate
:
function
(
event
,
data
)
{
var
node
=
data
.
node
;
},
...
...
@@ -404,14 +406,14 @@ $(document).ready(function () {
},
source
:
{
url
:
$SCRIPT_ROOT
+
"
/fileBrowser
"
,
data
:{
opt
:
20
,
dir
:
currentProject
,
key
:
0
},
data
:{
opt
:
20
,
dir
:
path
,
key
:
key
,
listfiles
:
'
yes
'
},
cache
:
false
},
lazyload
:
function
(
event
,
data
)
{
var
node
=
data
.
node
;
data
.
result
=
{
url
:
$SCRIPT_ROOT
+
"
/fileBrowser
"
,
data
:
{
opt
:
20
,
dir
:
node
.
data
.
path
,
key
:
node
.
key
}
data
:
{
opt
:
20
,
dir
:
node
.
data
.
path
,
key
:
node
.
key
,
listfiles
:
'
yes
'
}
}
},
keydown
:
function
(
event
,
data
)
{
...
...
@@ -461,7 +463,7 @@ $(document).ready(function () {
bindContextMenu
(
data
.
node
.
span
,
!
data
.
node
.
isFolder
());
}
});
}
);
}
editor
.
setTheme
(
"
ace/theme/crimson_editor
"
);
...
...
@@ -494,7 +496,9 @@ $(document).ready(function () {
/*$('#fileTreeFull').fileTree({ root: currentProject, script: $SCRIPT_ROOT + script, folderEvent: 'click', expandSpeed: 750, collapseSpeed: 750, multiFolder: false, selectFolder: true }, function (file) {
selectFile(file);
}, function (file) { openFile(file); });*/
$
(
"
#info
"
).
append
(
"
Selection:
"
+
base_path
());
initTree
(
'
#fileTree
'
,
projectDir
,
'
pfolder
'
);
initTree
(
'
#fileTreeFull
'
,
currentProject
);
$
(
"
#info
"
).
append
(
"
Current work tree:
"
+
base_path
());
/*setDetailBox();*/
editor
.
on
(
"
change
"
,
function
(
e
)
{
...
...
@@ -549,7 +553,7 @@ $(document).ready(function () {
$
(
"
#clearselect
"
).
click
(
function
()
{
edit
=
false
;
$
(
"
#info
"
).
empty
();
$
(
"
#info
"
).
append
(
"
Selection
:
"
+
base_path
());
$
(
"
#info
"
).
append
(
"
Current work tree
:
"
+
base_path
());
$
(
"
input#subfolder
"
).
val
(
""
);
$
(
"
#edit_info
"
).
empty
();
$
(
"
#edit_info
"
).
append
(
"
No file in editor
"
);
...
...
slapos/runner/templates/softwareFolder.html
View file @
1a3a0773
...
...
@@ -48,7 +48,7 @@
</div>
<div
id=
"details_box"
>
<div
id=
"fileTree"
class=
"file_tree_short"
></div>
<div
id=
"fileTreeFull"
style=
'display:none'
class=
"file_tree_short"
title=
"Double click to edit selected file..."
></div>
<div
id=
"fileTreeFull"
style=
'display:none'
class=
"file_tree_short"
></div>
</div>
</div>
<div
id=
"code"
>
...
...
slapos/runner/views.py
View file @
1a3a0773
...
...
@@ -637,60 +637,61 @@ def fileBrowser():
else
:
opt
=
int
(
request
.
args
.
get
(
'opt'
))
# try:
if
opt
==
1
:
#list files and directories
result
=
file_request
.
listDirs
(
dir
)
elif
opt
==
2
:
#Create file
result
=
file_request
.
makeFile
(
dir
,
filename
)
elif
opt
==
3
:
#Create directory
result
=
file_request
.
makeDirectory
(
dir
,
filename
)
elif
opt
==
4
:
#Delete a list of files or/and directories
result
=
file_request
.
deleteItem
(
dir
,
files
)
elif
opt
==
5
:
#copy a lis of files or/and directories
result
=
file_request
.
copyItem
(
dir
,
files
)
elif
opt
==
6
:
#rename file or directory
result
=
file_request
.
rename
(
dir
,
filename
,
newfilename
)
elif
opt
==
7
:
result
=
file_request
.
copyItem
(
dir
,
files
,
del_source
=
True
)
elif
opt
==
8
:
#donwload file
filename
=
request
.
args
.
get
(
'filename'
).
encode
(
'utf-8'
)
result
=
file_request
.
downloadFile
(
request
.
args
.
get
(
'dir'
).
encode
(
'utf-8'
),
filename
)
try
:
return
send_file
(
result
,
attachment_filename
=
filename
,
as_attachment
=
True
)
except
:
abort
(
404
)
elif
opt
==
9
:
result
=
file_request
.
readFile
(
dir
,
filename
,
False
)
elif
opt
==
11
:
#Upload file
result
=
file_request
.
uploadFile
(
dir
,
request
.
files
)
elif
opt
==
14
:
#Copy file or directory as ...
result
=
file_request
.
copyAsFile
(
dir
,
filename
,
newfilename
)
elif
opt
==
16
:
#zip file
result
=
file_request
.
zipFile
(
dir
,
filename
,
newfilename
)
elif
opt
==
17
:
#zip file
result
=
file_request
.
unzipFile
(
dir
,
filename
,
newfilename
)
elif
opt
==
20
:
#Fancy Load folder
key
=
int
(
request
.
args
.
get
(
'key'
))
dir
=
request
.
args
.
get
(
'dir'
).
encode
(
'utf-8'
)
data
=
file_request
.
fancylistDirs
(
dir
,
key
)
result
=
json
.
dumps
(
data
)
else
:
result
=
"ARGS PARSE ERROR: Bad option..."
# except Exception as e:
# return str(e)
try
:
if
opt
==
1
:
#list files and directories
result
=
file_request
.
listDirs
(
dir
)
elif
opt
==
2
:
#Create file
result
=
file_request
.
makeFile
(
dir
,
filename
)
elif
opt
==
3
:
#Create directory
result
=
file_request
.
makeDirectory
(
dir
,
filename
)
elif
opt
==
4
:
#Delete a list of files or/and directories
result
=
file_request
.
deleteItem
(
dir
,
files
)
elif
opt
==
5
:
#copy a lis of files or/and directories
result
=
file_request
.
copyItem
(
dir
,
files
)
elif
opt
==
6
:
#rename file or directory
result
=
file_request
.
rename
(
dir
,
filename
,
newfilename
)
elif
opt
==
7
:
result
=
file_request
.
copyItem
(
dir
,
files
,
del_source
=
True
)
elif
opt
==
8
:
#donwload file
filename
=
request
.
args
.
get
(
'filename'
).
encode
(
'utf-8'
)
result
=
file_request
.
downloadFile
(
request
.
args
.
get
(
'dir'
).
encode
(
'utf-8'
),
filename
)
try
:
return
send_file
(
result
,
attachment_filename
=
filename
,
as_attachment
=
True
)
except
:
abort
(
404
)
elif
opt
==
9
:
result
=
file_request
.
readFile
(
dir
,
filename
,
False
)
elif
opt
==
11
:
#Upload file
result
=
file_request
.
uploadFile
(
dir
,
request
.
files
)
elif
opt
==
14
:
#Copy file or directory as ...
result
=
file_request
.
copyAsFile
(
dir
,
filename
,
newfilename
)
elif
opt
==
16
:
#zip file
result
=
file_request
.
zipFile
(
dir
,
filename
,
newfilename
)
elif
opt
==
17
:
#zip file
result
=
file_request
.
unzipFile
(
dir
,
filename
,
newfilename
)
elif
opt
==
20
:
#Fancy Load folder
key
=
request
.
args
.
get
(
'key'
)
dir
=
request
.
args
.
get
(
'dir'
).
encode
(
'utf-8'
)
listfiles
=
request
.
args
.
get
(
'listfiles'
,
''
)
data
=
file_request
.
fancylistDirs
(
dir
,
key
,
listfiles
)
result
=
json
.
dumps
(
data
)
else
:
result
=
"ARGS PARSE ERROR: Bad option..."
except
Exception
as
e
:
return
str
(
e
)
return
result
...
...
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