Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9890bbc0
authored
Jul 08, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: no js file upload
parent
af5cedff
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
12 deletions
+78
-12
circle/dashboard/static/dashboard/store.js
+12
-6
circle/dashboard/templates/dashboard/store/list.html
+9
-4
circle/dashboard/templates/dashboard/store/upload.html
+37
-0
circle/dashboard/urls.py
+3
-1
circle/dashboard/views.py
+17
-1
No files found.
circle/dashboard/static/dashboard/store.js
View file @
9890bbc0
...
...
@@ -6,11 +6,12 @@ $(function() {
});
/* less js way, but at least works, tho redirection is bad */
$
(
'form input[type="submit"]'
).
click
(
function
()
{
var
current_dir
=
$
(
"form"
).
find
(
'[name="current_dir"]'
).
val
();
$
.
get
(
$
(
"form"
).
data
(
"action"
)
+
"?current_dir="
+
current_dir
,
function
(
result
)
{
$
(
"form"
).
get
(
0
).
setAttribute
(
"action"
,
result
[
'url'
]);
$
(
"form"
).
submit
();
$
(
'#store-upload-form input[type="submit"]'
).
click
(
function
()
{
var
current_dir
=
$
(
"#store-upload-form"
).
find
(
'[name="current_dir"]'
).
val
();
$
.
get
(
$
(
"#store-upload-form"
).
data
(
"action"
)
+
"?current_dir="
+
current_dir
,
function
(
result
)
{
$
(
"#store-upload-form"
).
get
(
0
).
setAttribute
(
"action"
,
result
[
'url'
]);
console
.
log
(
$
(
"#store-upload-form"
).
prop
(
"action"
));
$
(
"#store-upload-form"
).
submit
();
});
return
false
;
...
...
@@ -31,10 +32,15 @@ $(function() {
$
(
"#store-upload-file"
).
on
(
"fileselect"
,
function
(
event
,
numFiles
,
label
)
{
var
input
=
$
(
"#store-upload-filename"
);
var
log
=
numFiles
>
1
?
numFiles
+
' files selected'
:
label
;
if
(
input
.
length
)
{
input
.
val
(
log
);
}
if
(
log
)
{
$
(
'#store-upload-form input[type="submit"]'
).
prop
(
"disabled"
,
false
);
}
else
{
$
(
'#store-upload-form input[type="submit"]'
).
prop
(
"disabled"
,
true
);
}
});
...
...
circle/dashboard/templates/dashboard/store/list.html
View file @
9890bbc0
...
...
@@ -19,7 +19,7 @@
{% for f in root %}
<a
class=
"list-group-item store-list-item"
data-item-type=
"{{ f.TYPE }}"
href=
"{% if f.TYPE == "
D
"
%}?
directory=
{{
f
.
path
}}{%
else
%}
{
#
url
"
dashboard
.
views
.
store-download
"
#
}?
path=
{{
f
.
path
}}{%
endif
%}"
>
{
%
url
"
dashboard
.
views
.
store-download
"
%
}?
path=
{{
f
.
path
}}{%
endif
%}"
>
<div
class=
"store-list-item-icon"
>
<i
class=
"
icon-{% if f.TYPE == "
D
"
%}
folder-open-alt
{%
else
%}
file-alt
{%
endif
%}"
...
...
@@ -55,11 +55,16 @@
{% endfor %}
<div
class=
"list-group-item"
>
Upload file to this folder
<form
action=
""
data-action=
"{% url "
dashboard
.
views
.
store-upload
"
%}"
method=
"POST"
enctype=
"multipart/form-data"
class=
"pull-right"
<a
href=
"{% url "
dashboard
.
views
.
store-upload
"%}?
directory=
{{
current
}}"
class=
"btn btn-info btn-xs pull-right js-hidden"
>
{% trans "Upload" %}
</a>
<form
action=
""
data-action=
"{% url "
dashboard
.
views
.
store-upload-url
"
%}"
method=
"POST"
enctype=
"multipart/form-data"
class=
"pull-right no-js-hidden"
id=
"store-upload-form"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"current_dir"
value=
"{{ current }}"
/>
<input
type=
"hidden"
name=
"next"
value=
"{{ next_url }}"
/>
<div
class=
"input-group"
style=
"max-width: 400px;"
>
<span
class=
"input-group-btn"
id=
"store-upload-browse"
>
<span
class=
"btn btn-primary btn-xs"
>
...
...
@@ -69,7 +74,7 @@
<input
type=
"text"
class=
"form-control input-tags"
id=
"store-upload-filename"
/>
<span
class=
"input-group-btn"
>
<input
type=
"submit"
class=
"btn btn-primary btn-xs"
<input
type=
"submit"
class=
"btn btn-primary btn-xs"
disabled
value=
"{% trans "
Upload
"
%}"
/>
</span>
</div>
...
...
circle/dashboard/templates/dashboard/store/upload.html
0 → 100644
View file @
9890bbc0
{% extends "dashboard/base.html" %}
{% load i18n %}
{% block title-page %}{% trans "Upload" %} | {% trans "Store" %}{% endblock %}
{% block content %}
<div
class=
"row"
>
<div
class=
"col-md-12"
>
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<a
class=
"btn btn-default pull-right btn-xs"
href=
"{% url "
dashboard
.
views
.
store-list
"
%}"
>
Back
</a>
<h3
class=
"no-margin"
>
<i
class=
"icon-cloud-upload"
></i>
{% trans "File upload" %}
</h3>
</div>
<div
class=
"panel-body"
>
<div
style=
"text-align: center; margin: 0 0 20px 0;"
>
<div
class=
"label label-info"
style=
"padding: 5px;"
>
{% trans "Curently uploading to" %}: {{ directory }}
</div>
</div>
<form
method=
"POST"
action=
"{{ action }}"
enctype=
"multipart/form-data"
>
<input
type=
"hidden"
name=
"next"
value=
"{{ next_url }}"
/>
<div>
<input
class=
"btn btn-default btn-sm pull-right"
type=
"submit"
value=
"{% trans "
Upload
"
%}"
/>
<input
type=
"file"
name=
"data"
multiple
style=
"padding-top: 5px;"
/>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
circle/dashboard/urls.py
View file @
9890bbc0
...
...
@@ -37,7 +37,7 @@ from .views import (
get_vm_screenshot
,
ProfileView
,
toggle_use_gravatar
,
UnsubscribeFormView
,
UserKeyDelete
,
UserKeyDetail
,
UserKeyCreate
,
StoreList
,
store_download
,
store_upload
,
StoreList
,
store_download
,
store_upload
,
store_get_upload_url
,
)
urlpatterns
=
patterns
(
...
...
@@ -175,6 +175,8 @@ urlpatterns = patterns(
name
=
"dashboard.views.store-list"
),
url
(
r"^store/download/$"
,
store_download
,
name
=
"dashboard.views.store-download"
),
url
(
r"^store/upload/url$"
,
store_get_upload_url
,
name
=
"dashboard.views.store-upload-url"
),
url
(
r"^store/upload/$"
,
store_upload
,
name
=
"dashboard.views.store-upload"
),
)
circle/dashboard/views.py
View file @
9890bbc0
...
...
@@ -2946,6 +2946,9 @@ class StoreList(LoginRequiredMixin, TemplateView):
context
[
'root'
]
=
self
.
clean_directory_list
(
directory
)
context
[
'up_url'
]
=
self
.
create_up_directory
(
directory
)
context
[
'current'
]
=
directory
context
[
'next_url'
]
=
"
%
s
%
s?directory=
%
s"
%
(
settings
.
DJANGO_URL
[:
-
1
],
reverse
(
"dashboard.views.store-list"
),
directory
)
return
context
def
create_up_directory
(
self
,
directory
):
...
...
@@ -2987,7 +2990,20 @@ def store_download(request):
@require_GET
def
store_upload
(
request
):
directory
=
request
.
GET
.
get
(
"directory"
)
action
=
store_api
.
requestupload
(
"test"
,
directory
)
next_url
=
"
%
s
%
s?directory=
%
s"
%
(
settings
.
DJANGO_URL
[:
-
1
],
reverse
(
"dashboard.views.store-list"
),
directory
)
return
render
(
request
,
"dashboard/store/upload.html"
,
{
'directory'
:
directory
,
'action'
:
action
,
'next_url'
:
next_url
})
@require_GET
def
store_get_upload_url
(
request
):
current_dir
=
request
.
GET
.
get
(
"current_dir"
)
url
=
store_api
.
requestupload
(
"test"
,
current_dir
)
return
HttpResponse
(
json
.
dumps
({
'url'
:
url
}),
content_type
=
"application/json"
,
)
json
.
dumps
({
'url'
:
url
}),
content_type
=
"application/json"
)
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