Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
95ffcdb5
authored
Jul 23, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: store display quota on index
parent
4c9dd092
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
22 deletions
+42
-22
circle/dashboard/static/dashboard/store.js
+1
-0
circle/dashboard/store_api.py
+9
-3
circle/dashboard/templates/dashboard/store/_list-box.html
+2
-2
circle/dashboard/templates/dashboard/store/index-files.html
+13
-6
circle/dashboard/views.py
+17
-11
No files found.
circle/dashboard/static/dashboard/store.js
View file @
95ffcdb5
$
(
function
()
{
$
(
"#store-list-container"
).
on
(
"click"
,
".store-list-item"
,
function
()
{
if
(
$
(
this
).
data
(
"item-type"
)
==
"D"
)
{
$
(
"#store-list-up-icon"
).
removeClass
(
"fa-reply"
).
addClass
(
"fa-refresh fa-spin"
);
var
url
=
$
(
this
).
prop
(
"href"
);
$
.
get
(
url
,
function
(
result
)
{
$
(
"#store-list-container"
).
html
(
result
);
...
...
circle/dashboard/store_api.py
View file @
95ffcdb5
...
...
@@ -47,7 +47,7 @@ class Store(object):
url
=
urljoin
(
self
.
store_url
,
url
)
if
timeout
is
None
:
timeout
=
self
.
default_timeout
payload
=
json
.
dumps
(
kwargs
)
payload
=
json
.
dumps
(
kwargs
)
if
kwargs
else
None
try
:
headers
=
{
'content-type'
:
'application/json'
}
response
=
method
(
url
,
data
=
payload
,
headers
=
headers
,
...
...
@@ -84,7 +84,7 @@ class Store(object):
return
result
def
request_download
(
self
,
path
):
r
=
self
.
_request_cmd
(
"DOWNLOAD"
,
PATH
=
path
,
timeout
=
5
)
r
=
self
.
_request_cmd
(
"DOWNLOAD"
,
PATH
=
path
,
timeout
=
10
)
return
r
.
json
()[
'LINK'
]
def
request_upload
(
self
,
path
):
...
...
@@ -102,7 +102,13 @@ class Store(object):
def
get_quota
(
self
):
# no CMD? :o
r
=
self
.
_request
(
self
.
username
)
return
r
.
json
()
quota
=
r
.
json
()
quota
.
update
({
'readable_used'
:
filesizeformat
(
float
(
quota
[
'Used'
])),
'readable_soft'
:
filesizeformat
(
float
(
quota
[
'Soft'
])),
'readable_hard'
:
filesizeformat
(
float
(
quota
[
'Hard'
])),
})
return
quota
def
set_quota
(
self
,
quota
):
self
.
_request
(
"/quota/"
+
self
.
username
,
post
,
QUOTA
=
quota
)
...
...
circle/dashboard/templates/dashboard/store/_list-box.html
View file @
95ffcdb5
...
...
@@ -68,12 +68,12 @@
class=
"list-group-item store-list-item"
data-item-type=
"D"
>
{% if current == "/" %}
<div
class=
"store-list-item-icon"
>
<i
class=
"fa fa-refresh"
></i>
<i
class=
"fa fa-refresh"
id=
"store-list-up-icon"
></i>
</div>
{% trans "Refresh" %}
{% else %}
<div
class=
"store-list-item-icon"
>
<i
class=
"fa fa-reply"
></i>
<i
class=
"fa fa-reply"
id=
"store-list-up-icon"
></i>
</div>
..
{% endif %}
...
...
circle/dashboard/templates/dashboard/store/index-files.html
View file @
95ffcdb5
...
...
@@ -2,15 +2,22 @@
<div
class=
"panel panel-default"
>
<div
class=
"panel-heading"
>
<span
class=
"btn btn-default btn-xs infobtn pull-right"
title=
"
A list of your most recent files!
"
>
<span
class=
"btn btn-default btn-xs infobtn pull-right
store-action-button
"
title=
"
{% trans "
A
list
of
your
most
recent
files
."
%}
"
>
<i
class=
"fa fa-info-circle"
></i>
</span>
<h3
class=
"no-margin"
><i
class=
"icon-briefcase"
></i>
Files
<span
class=
"btn btn-default btn-xs infobtn pull-right"
title=
"
{% blocktrans with used=files.quota.readable_used soft=files.quota.readable_soft hard=files.quota.readable_hard %}
You are currently using {{ used }}, your soft limit is {{ soft }}, your hard limit is {{ hard }}.
{% endblocktrans %}"
>
<i
class=
"fa fa-adjust"
></i>
</span>
<h3
class=
"no-margin"
><i
class=
"fa fa-briefcase"
></i>
{% trans "Files" %}
</h3>
</div>
<div
class=
"list-group"
id=
"dashboard-files-toplist"
>
{% for t in toplist %}
{% for t in
files.
toplist %}
{% if t.TYPE == "F" %}
<div
class=
"list-group-item"
>
<i
class=
"fa fa-{{ t.icon }} dashboard-toplist-icon"
></i>
...
...
@@ -46,10 +53,10 @@
</button>
</form>
<a
href=
"{% url "
dashboard
.
views
.
store-list
"
%}"
class=
"btn btn-primary btn-xs"
>
<i
class=
"fa fa-chevron-circle-right"
></i>
{% trans "show my files" %}
<i
class=
"fa fa-chevron-circle-right"
></i>
{% trans "show my files" %}
</a>
<a
href=
"{% url "
dashboard
.
views
.
store-upload
"
%}"
class=
"btn btn-success btn-xs"
>
<i
class=
"fa fa-cloud-upload"
></i>
{% trans "upload" %}
<i
class=
"fa fa-cloud-upload"
></i>
{% trans "upload" %}
</a>
</div>
</div>
...
...
circle/dashboard/views.py
View file @
95ffcdb5
...
...
@@ -227,19 +227,22 @@ class IndexView(LoginRequiredMixin, TemplateView):
# toplist
if
settings
.
STORE_URL
:
cache_key
=
"
toplist
-
%
d"
%
self
.
request
.
user
.
pk
cache_key
=
"
files
-
%
d"
%
self
.
request
.
user
.
pk
cache
=
get_cache
(
"default"
)
toplist
=
cache
.
get
(
cache_key
)
if
not
toplist
:
files
=
cache
.
get
(
cache_key
)
if
not
files
:
try
:
toplist
=
Store
(
self
.
request
.
user
)
.
toplist
()
store
=
Store
(
self
.
request
.
user
)
toplist
=
store
.
toplist
()
quota
=
store
.
get_quota
()
files
=
{
'toplist'
:
toplist
,
'quota'
:
quota
}
except
Exception
:
logger
.
exception
(
"Unable to get tolist for
%
s"
,
unicode
(
self
.
request
.
user
))
toplist
=
[]
cache
.
set
(
cache_key
,
toplist
,
300
)
files
=
{
'toplist'
:
[]}
cache
.
set
(
cache_key
,
files
,
300
)
context
[
'
toplist'
]
=
toplist
context
[
'
files'
]
=
files
else
:
context
[
'no_store'
]
=
True
...
...
@@ -3232,13 +3235,16 @@ def store_new_directory(request):
@require_POST
@login_required
def
store_refresh_toplist
(
request
):
cache_key
=
"
toplist
-
%
d"
%
request
.
user
.
pk
cache_key
=
"
files
-
%
d"
%
request
.
user
.
pk
cache
=
get_cache
(
"default"
)
try
:
toplist
=
Store
(
request
.
user
)
.
toplist
()
store
=
Store
(
request
.
user
)
toplist
=
store
.
toplist
()
quota
=
store
.
get_quota
()
files
=
{
'toplist'
:
toplist
,
'quota'
:
quota
}
except
Exception
:
logger
.
exception
(
"Can't get toplist of
%
s"
,
unicode
(
request
.
user
))
toplist
=
[]
cache
.
set
(
cache_key
,
toplist
,
300
)
files
=
{
'toplist'
:
[]}
cache
.
set
(
cache_key
,
files
,
300
)
return
redirect
(
reverse
(
"dashboard.index"
))
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