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
909f6f1c
authored
Nov 20, 2013
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: set resources in vm detail
parent
91763ce1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
4 deletions
+65
-4
circle/dashboard/static/dashboard/vm-details.js
+24
-1
circle/dashboard/templates/dashboard/vm-detail-resources.html
+12
-3
circle/dashboard/views.py
+29
-0
No files found.
circle/dashboard/static/dashboard/vm-details.js
View file @
909f6f1c
$
(
function
()
{
if
(
$
(
'.timeline .activity:first i:first'
).
hasClass
(
'icon-spin'
))
checkNewActivity
();
/* save resources */
$
(
'#vm-details-resources-save'
).
click
(
function
()
{
$
(
'i.icon-save'
,
this
).
removeClass
(
"icon-save"
).
addClass
(
"icon-refresh icon-spin"
);
$
.
ajax
({
type
:
'POST'
,
url
:
location
.
href
,
data
:
$
(
'#vm-details-resources-form'
).
serialize
(),
success
:
function
(
data
,
textStatus
,
xhr
)
{
addMessage
(
data
[
'message'
],
'success'
);
$
(
"#vm-details-resources-save i"
).
removeClass
(
'icon-refresh icon-spin'
).
addClass
(
"icon-save"
);
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
$
(
"#vm-details-resources-save i"
).
removeClass
(
'icon-refresh icon-spin'
).
addClass
(
"icon-save"
);
addMessage
(
"Eww, something is wrong"
,
'danger'
);
if
(
xhr
.
status
==
500
)
{
// alert("uhuhuhuhuhuh");
}
else
{
// alert("unknown error");
}
}
});
return
false
;
});
});
function
checkNewActivity
()
{
...
...
circle/dashboard/templates/dashboard/vm-detail-resources.html
View file @
909f6f1c
{% load i18n %}
<form
id=
"vm-details-resources-form"
method=
"POST"
action=
""
>
{% csrf_token %}
<p
class=
"row"
>
<div
class=
"col-sm-3"
>
<label
for=
"vm-cpu-priority-slider"
><i
class=
"icon-trophy"
></i>
CPU priority
</label>
<label
for=
"vm-cpu-priority-slider"
><i
class=
"icon-trophy"
></i>
{% trans "CPU priority" %}
</label>
</div>
<div
class=
"col-sm-9"
>
<input
name=
"cpu-priority"
type=
"text"
id=
"vm-cpu-priority-slider"
class=
"vm-slider"
value=
"{{ instance.priority }}"
data-slider-min=
"0"
data-slider-max=
"100"
data-slider-step=
"1"
data-slider-value=
"{{ instance.priority }}"
data-slider-orientation=
"horizontal"
data-slider-handle=
"square"
data-slider-tooltip=
"hide"
/>
...
...
@@ -10,7 +13,7 @@
<p
class=
"row"
>
<div
class=
"col-sm-3"
>
<label
for=
"cpu-count-slider"
><i
class=
"icon-cogs"
></i>
CPU count
</label>
<label
for=
"cpu-count-slider"
><i
class=
"icon-cogs"
></i>
{% trans "CPU count" %}
</label>
</div>
<div
class=
"col-sm-9"
>
<input
name=
"cpu-count"
type=
"text"
id=
"vm-cpu-count-slider"
class=
"vm-slider"
value=
" {{ instance.num_cores }}"
data-slider-min=
"0"
data-slider-max=
"8"
data-slider-step=
"1"
data-slider-value=
"{{ instance.num_cores }}"
data-slider-orientation=
"horizontal"
data-slider-handle=
"square"
data-slider-tooltip=
"hide"
/>
...
...
@@ -20,13 +23,19 @@
<p
class=
"row"
>
<div
class=
"col-sm-3"
>
<label
for=
"ram-slider"
><i
class=
"icon-ticket"
></i>
RAM amount
</label>
<label
for=
"ram-slider"
><i
class=
"icon-ticket"
></i>
{% trans "RAM amount" %}
</label>
</div>
<div
class=
"col-sm-9"
>
<input
name=
"ram-size"
type=
"text"
id=
"vm-ram-size-slider"
class=
"vm-slider"
value=
"{{ instance.ram_size }}"
data-slider-min=
"128"
data-slider-max=
"4096"
data-slider-step=
"128"
data-slider-value=
"{{ instance.ram_size }}"
data-slider-orientation=
"horizontal"
data-slider-handle=
"square"
data-slider-tooltip=
"hide"
/>
MiB
</div>
</p>
<p
class=
"row"
>
<div
class=
"col-sm-12"
>
<button
type=
"submit"
class=
"btn btn-success btn-sm"
id=
"vm-details-resources-save"
><i
class=
"icon-save"
></i>
{% trans "Save resources" %}
</button>
</div>
</p>
</form>
{% block extra_js %}
<style>
label
{
padding-top
:
6px
;}
...
...
circle/dashboard/views.py
View file @
909f6f1c
...
...
@@ -99,6 +99,35 @@ class VmDetailView(CheckedDetailView):
context
[
'acl'
]
=
get_acl_data
(
instance
)
return
context
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
if
(
request
.
POST
.
get
(
'ram-size'
)
and
request
.
POST
.
get
(
'cpu-count'
)
and
request
.
POST
.
get
(
'cpu-priority'
)):
return
self
.
__set_resources
(
request
)
def
__set_resources
(
self
,
request
):
self
.
object
=
self
.
get_object
()
if
not
self
.
object
.
has_level
(
request
.
user
,
'owner'
):
raise
PermissionDenied
()
resources
=
{
'num_cores'
:
request
.
POST
.
get
(
'cpu-count'
),
'ram_size'
:
request
.
POST
.
get
(
'ram-size'
),
'priority'
:
request
.
POST
.
get
(
'cpu-priority'
)
}
Instance
.
objects
.
filter
(
pk
=
self
.
object
.
pk
)
.
update
(
**
resources
)
success_message
=
_
(
"Resources successfully updated!"
)
if
request
.
is_ajax
():
response
=
{
'message'
:
success_message
}
return
HttpResponse
(
json
.
dumps
(
response
),
content_type
=
"application/json"
)
else
:
messages
.
success
(
request
,
success_message
)
return
redirect
(
reverse_lazy
(
"dashboard.views.detail"
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
class
AclUpdateView
(
View
,
SingleObjectMixin
):
...
...
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