Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
PUBLIC
/
surfer-okd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d3312ed1
authored
Mar 01, 2016
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make directory listing navigatable
1 parent
6eb72d64
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
13 deletions
app/css/style.css
app/index.html
app/js/app.js
app/css/style.css
View file @
d3312ed
...
...
@@ -29,3 +29,7 @@ pre {
[
v-cloak
]
{
display
:
none
;
}
.hand
{
cursor
:
hand
;
}
\ No newline at end of file
app/index.html
View file @
d3312ed
...
...
@@ -2,6 +2,7 @@
<head>
<title>
Cloudron Surfer
</title>
<link
rel=
"stylesheet"
href=
"/admin/css/font-awesome.min.css"
>
<link
rel=
"stylesheet"
href=
"/admin/css/bootstrap.min.css"
>
<link
rel=
"stylesheet"
href=
"/admin/css/style.css"
>
...
...
@@ -63,27 +64,39 @@
<div
class=
"row"
>
<div
class=
"col-lg-12"
>
<ol
class=
"breadcrumb"
>
<li><a
href=
"#"
>
Home
</a></li>
<li><a
href=
"#"
>
Library
</a></li>
<li
class=
"active"
>
Data
</li>
<li><i
class=
"fa fa-home"
></i>
</li>
<li
v-for=
"part in pathParts"
>
{{ part }}
</li>
</ol>
</div>
<div
class=
"col-lg-12"
>
<table
class=
"table table-hover"
>
<table
class=
"table table-hover
table-condensed
"
>
<thead>
<tr>
<th>
Type
</th>
<th>
Name
</th>
<th>
Size
</th>
<th>
Modified
</th>
<th
style=
"text-align: right;"
>
Action
</th>
</tr>
</thead>
<tbody>
<tr>
<th>
Type
</th>
<th>
Name
</th>
<th>
Size
</th>
<th>
Modified
</th>
<tr
v-show=
"path !== '/'"
v-on:click=
"up()"
class=
"hand"
>
<th><i
class=
"fa fa-chevron-up"
></i></th>
<th>
..
</th>
<th></th>
<th></th>
</tr>
<tr
v-for=
"entry in entries"
v-on:click=
"open(entry)"
class=
"hand"
>
<th>
<i
class=
"fa fa-folder-o"
v-show=
"entry.isDirectory"
></i>
<i
class=
"fa fa-file-o"
v-show=
"entry.isFile"
></i>
</th>
<th>
{{ entry.filePath }}
</th>
<th>
{{ entry.size }}
</th>
<th>
{{ entry.mtime }}
</th>
<th
style=
"text-align: right;"
><button
class=
"btn btn-sm btn-danger"
><i
class=
"fa fa-trash"
></i></button></th>
</tr>
</tbody>
</table>
...
...
app/js/app.js
View file @
d3312ed
...
...
@@ -20,6 +20,8 @@ function login(username, password) {
// clearly not the best option
localStorage
.
username
=
username
;
localStorage
.
password
=
password
;
loadDirectory
(
app
.
path
);
});
}
...
...
@@ -32,20 +34,61 @@ function logout() {
delete
localStorage
.
password
;
}
function
sanitize
(
filePath
)
{
filePath
=
'/'
+
filePath
;
return
filePath
.
replace
(
/
\/
+/g
,
'/'
);
}
function
loadDirectory
(
filePath
)
{
app
.
busy
=
true
;
filePath
=
filePath
?
sanitize
(
filePath
)
:
'/'
;
console
.
log
(
filePath
);
superagent
.
get
(
'/api/files/'
+
filePath
).
query
({
username
:
app
.
session
.
username
,
password
:
app
.
session
.
password
}).
end
(
function
(
error
,
result
)
{
app
.
busy
=
false
;
if
(
error
)
return
console
.
error
(
error
);
if
(
result
.
statusCode
===
401
)
return
logout
();
app
.
entries
=
result
.
body
.
entries
;
app
.
path
=
filePath
;
app
.
pathParts
=
filePath
.
split
(
'/'
).
filter
(
function
(
e
)
{
return
!!
e
;
});
console
.
log
(
app
.
pathParts
)
});
}
function
open
(
entry
)
{
var
path
=
sanitize
(
app
.
path
+
'/'
+
entry
.
filePath
);
if
(
entry
.
isDirectory
)
return
loadDirectory
(
path
);
window
.
location
.
href
=
window
.
location
.
origin
+
path
;
}
function
up
()
{
loadDirectory
(
app
.
path
.
split
(
'/'
).
slice
(
0
,
-
1
).
filter
(
function
(
p
)
{
return
!!
p
;
}).
join
(
'/'
));
}
var
app
=
new
Vue
({
el
:
'#app'
,
data
:
{
busy
:
true
,
path
:
'/'
,
pathParts
:
[],
session
:
{
valid
:
false
},
loginData
:
{
}
loginData
:
{},
entries
:
[]
},
methods
:
{
login
:
login
,
logout
:
logout
logout
:
logout
,
loadDirectory
:
loadDirectory
,
open
:
open
,
up
:
up
}
});
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment