Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
a8ed2ccf
authored
Mar 19, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: refresh disk download percentage via ajax
parent
6693f199
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
5 deletions
+51
-5
circle/dashboard/static/dashboard/disk-list.js
+23
-0
circle/dashboard/templates/dashboard/template-edit.html
+6
-2
circle/dashboard/templates/dashboard/vm-detail.html
+1
-0
circle/dashboard/urls.py
+6
-3
circle/dashboard/views.py
+15
-0
No files found.
circle/dashboard/static/dashboard/disk-list.js
0 → 100644
View file @
a8ed2ccf
$
(
function
()
{
$
(
".disk-list-disk-percentage"
).
each
(
function
()
{
var
disk
=
$
(
this
).
data
(
"disk-pk"
);
var
element
=
$
(
this
);
refreshDisk
(
disk
,
element
);
});
});
function
refreshDisk
(
disk
,
element
)
{
$
.
get
(
"/dashboard/disk/"
+
disk
+
"/status/"
,
function
(
result
)
{
if
(
result
.
percentage
==
null
||
result
.
failed
==
"True"
)
{
location
.
reload
();
}
else
{
var
diff
=
result
.
percentage
-
parseInt
(
element
.
html
());
var
refresh
=
5
-
diff
;
refresh
=
refresh
<
1
?
1
:
(
result
.
percentage
==
0
?
1
:
refresh
);
if
(
isNaN
(
refresh
))
refresh
=
2
;
// this should not happen
element
.
html
(
result
.
percentage
);
setTimeout
(
function
()
{
refreshDisk
(
disk
,
element
)},
refresh
*
1000
);
}
});
}
circle/dashboard/templates/dashboard/template-edit.html
View file @
a8ed2ccf
...
...
@@ -107,10 +107,14 @@
font-weight
:
bold
;
}
</style>
<script>
{% endblock %}
{% block extra_js %}
<script>
$
(
function
()
{
$
(
"#hint_id_num_cores, #hint_id_priority, #hint_id_ram_size"
).
hide
();
});
</script>
</script>
<script
src=
"{{ STATIC_URL }}dashboard/disk-list.js"
></script>
{% endblock %}
circle/dashboard/templates/dashboard/vm-detail.html
View file @
a8ed2ccf
...
...
@@ -205,4 +205,5 @@
<script
src=
"{{ STATIC_URL }}dashboard/vm-details.js"
></script>
<script
src=
"{{ STATIC_URL }}dashboard/vm-common.js"
></script>
<script
src=
"{{ STATIC_URL }}dashboard/vm-console.js"
></script>
<script
src=
"{{ STATIC_URL }}dashboard/disk-list.js"
></script>
{% endblock %}
circle/dashboard/urls.py
View file @
a8ed2ccf
...
...
@@ -10,7 +10,7 @@ from .views import (
TemplateDelete
,
TemplateDetail
,
TemplateList
,
TransferOwnershipConfirmView
,
TransferOwnershipView
,
vm_activity
,
VmCreate
,
VmDelete
,
VmDetailView
,
VmDetailVncTokenView
,
VmGraphView
,
VmList
,
VmMassDelete
,
VmMigrateView
,
VmRenewView
,
DiskRemoveView
VmRenewView
,
DiskRemoveView
,
get_disk_download_status
,
)
urlpatterns
=
patterns
(
...
...
@@ -97,8 +97,11 @@ urlpatterns = patterns(
url
(
r'^disk/add/$'
,
DiskAddView
.
as_view
(),
name
=
"dashboard.views.disk-add"
),
url
(
r'^profile/$'
,
MyPreferencesView
.
as_view
(),
name
=
"dashboard.views.profile"
),
url
(
r'^disk/(?P<pk>\d+)/remove/$'
,
DiskRemoveView
.
as_view
(),
name
=
"dashboard.views.disk-remove"
),
url
(
r'^disk/(?P<pk>\d+)/status/$'
,
get_disk_download_status
,
name
=
"dashboard.views.disk-status"
),
url
(
r'^profile/$'
,
MyPreferencesView
.
as_view
(),
name
=
"dashboard.views.profile"
),
)
circle/dashboard/views.py
View file @
a8ed2ccf
...
...
@@ -2146,3 +2146,18 @@ class DiskRemoveView(DeleteView):
else
:
messages
.
success
(
request
,
success_message
)
return
HttpResponseRedirect
(
"
%
s#resources"
%
success_url
)
@require_GET
def
get_disk_download_status
(
request
,
pk
):
disk
=
Disk
.
objects
.
get
(
pk
=
pk
)
if
not
disk
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
return
HttpResponse
(
json
.
dumps
({
'percentage'
:
disk
.
get_download_percentage
(),
'failed'
:
disk
.
failed
}),
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