Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0a2066bb
authored
Feb 05, 2013
by
Dányi Bence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
store: ajax quota
parent
606f3842
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
6 deletions
+47
-6
cloud/urls.py
+1
-0
one/static/box.less
+6
-0
one/static/cloud.js
+29
-4
one/templates/box-filelist.html
+3
-2
store/views.py
+8
-0
No files found.
cloud/urls.py
View file @
0a2066bb
...
@@ -33,4 +33,5 @@ urlpatterns = patterns('',
...
@@ -33,4 +33,5 @@ urlpatterns = patterns('',
url
(
r'^ajax/store/upload$'
,
'store.views.ajax_upload'
,
name
=
'store_ajax_upload'
),
url
(
r'^ajax/store/upload$'
,
'store.views.ajax_upload'
,
name
=
'store_ajax_upload'
),
url
(
r'^ajax/store/delete$'
,
'store.views.ajax_delete'
,
name
=
'store_ajax_delete'
),
url
(
r'^ajax/store/delete$'
,
'store.views.ajax_delete'
,
name
=
'store_ajax_delete'
),
url
(
r'^ajax/store/newFolder$'
,
'store.views.ajax_new_folder'
,
name
=
'store_ajax_new_folder'
),
url
(
r'^ajax/store/newFolder$'
,
'store.views.ajax_new_folder'
,
name
=
'store_ajax_new_folder'
),
url
(
r'^ajax/store/quota$'
,
'store.views.ajax_quota'
,
name
=
'store_ajax_quota'
),
)
)
one/static/box.less
View file @
0a2066bb
...
@@ -83,6 +83,12 @@
...
@@ -83,6 +83,12 @@
height: 100%;
height: 100%;
.used{
.used{
height: 100%;
height: 100%;
position: absolute;
}
.softLimit{
height: 100%;
position: absolute;
border-left: 1px solid red;
}
}
}
}
.summary{
.summary{
...
...
one/static/cloud.js
View file @
0a2066bb
...
@@ -69,7 +69,7 @@ $(function() {
...
@@ -69,7 +69,7 @@ $(function() {
})
})
$
(
'#modal'
).
show
();
$
(
'#modal'
).
show
();
});
});
$
(
'#old-upload'
).
click
(
function
(
e
){
$
(
'#old-upload'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
$
(
this
).
parent
().
hide
().
next
(
'div'
).
show
();
$
(
this
).
parent
().
hide
().
next
(
'div'
).
show
();
return
false
;
return
false
;
...
@@ -236,8 +236,8 @@ $(function() {
...
@@ -236,8 +236,8 @@ $(function() {
function
readfiles
(
files
)
{
function
readfiles
(
files
)
{
var
formData
=
tests
.
formdata
?
new
FormData
()
:
null
;
var
formData
=
tests
.
formdata
?
new
FormData
()
:
null
;
for
(
var
i
=
0
;
i
<
files
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
files
.
length
;
i
++
)
{
if
(
tests
.
formdata
)
formData
.
append
(
'data'
,
files
[
i
]);
if
(
tests
.
formdata
)
formData
.
append
(
'data'
,
files
[
i
]);
}
}
// now post a new XHR request
// now post a new XHR request
if
(
tests
.
formdata
)
{
if
(
tests
.
formdata
)
{
...
@@ -254,7 +254,7 @@ $(function() {
...
@@ -254,7 +254,7 @@ $(function() {
if
(
event
.
lengthComputable
)
{
if
(
event
.
lengthComputable
)
{
var
complete
=
(
event
.
loaded
/
event
.
total
*
100
|
0
);
var
complete
=
(
event
.
loaded
/
event
.
total
*
100
|
0
);
//progress.value = progress.innerHTML = complete;
//progress.value = progress.innerHTML = complete;
self
.
uploadProgress
(
parseInt
(
complete
)
+
'%'
);
self
.
uploadProgress
(
parseInt
(
complete
)
+
'%'
);
}
}
}
}
}
}
...
@@ -270,6 +270,31 @@ $(function() {
...
@@ -270,6 +270,31 @@ $(function() {
readfiles
(
e
.
dataTransfer
.
files
);
readfiles
(
e
.
dataTransfer
.
files
);
return
false
;
return
false
;
});
});
self
.
quota
=
{
used
:
ko
.
observable
(),
soft
:
ko
.
observable
(),
hard
:
ko
.
observable
()
};
self
.
quota
.
usedBar
=
ko
.
computed
(
function
()
{
return
(
self
.
quota
.
used
()
/
self
.
quota
.
hard
()
*
100
).
toFixed
(
0
)
+
'%'
;
},
self
);
self
.
quota
.
softPos
=
ko
.
computed
(
function
()
{
return
(
self
.
quota
.
soft
()
/
self
.
quota
.
hard
()
*
100
).
toFixed
(
0
)
+
'%'
;
},
self
)
function
refreshQuota
()
{
$
.
ajax
({
'type'
:
'GET'
,
'url'
:
'/ajax/store/quota'
,
dataType
:
'json'
,
success
:
function
(
data
)
{
self
.
quota
.
used
(
parseInt
(
data
.
Used
));
self
.
quota
.
soft
(
parseInt
(
data
.
Soft
));
self
.
quota
.
hard
(
parseInt
(
data
.
Hard
));
}
})
}
refreshQuota
();
loadFolder
(
self
.
currentPath
());
loadFolder
(
self
.
currentPath
());
}
}
var
model
=
new
Model
();
var
model
=
new
Model
();
...
...
one/templates/box-filelist.html
View file @
0a2066bb
...
@@ -97,9 +97,10 @@
...
@@ -97,9 +97,10 @@
<li
class=
"wm small"
>
<li
class=
"wm small"
>
<div
class=
"summary"
>
<div
class=
"summary"
>
<div
class=
"quota"
>
<div
class=
"quota"
>
<div
class=
"used"
style=
"background-color: rgba(0,255,0,0.2); width: 2%"
></div>
<div
class=
"used"
style=
"background-color: rgba(0,255,0,0.2)"
data-bind=
"style: {width: quota.usedBar}"
></div>
<div
class=
"softLimit"
data-bind=
"style: {left: quota.softPos}"
></div>
</div>
</div>
<div
class=
"name"
>
Kvóta:
20MB/2GB
</div>
<div
class=
"name"
>
Kvóta:
<span
data-bind=
"text: quota.used"
></span>
/
<span
data-bind=
"text: quota.hard"
></span>
</div>
<div
class=
"clear"
></div>
<div
class=
"clear"
></div>
</div>
</div>
</li>
</li>
...
...
store/views.py
View file @
0a2066bb
...
@@ -98,6 +98,14 @@ def ajax_listfolder(request):
...
@@ -98,6 +98,14 @@ def ajax_listfolder(request):
return
HttpResponse
(
json
.
dumps
(
file_list
))
return
HttpResponse
(
json
.
dumps
(
file_list
))
@login_required
@login_required
def
ajax_quota
(
request
):
user
=
request
.
user
.
username
if
StoreApi
.
userexist
(
user
)
!=
True
:
estabilish_store_user
(
user
)
#return HttpResponse(json.dumps(StoreApi.requestquota(user)))
return
HttpResponse
(
json
.
dumps
({
'Used'
:
20
,
'Soft'
:
160
,
'Hard'
:
200
}))
@login_required
def
ajax_download
(
request
):
def
ajax_download
(
request
):
user
=
request
.
user
.
username
user
=
request
.
user
.
username
try
:
try
:
...
...
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