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
82a96649
authored
Feb 09, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webui: Added stop,restart,resume functions
parent
caef159a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
9 deletions
+73
-9
one/static/cloud.js
+64
-0
one/templates/box-vmlist.html
+9
-9
No files found.
one/static/cloud.js
View file @
82a96649
...
...
@@ -37,6 +37,18 @@ $(function() {
}
}
$
(
'.wm .summary'
).
unbind
(
'click'
).
click
(
toggleDetails
);
$
(
'.stop-vm-button'
).
click
(
function
()
{
stop_vm
(
$
(
this
).
data
(
'id'
),
$
(
this
).
data
(
'name'
));
});
$
(
'.resume-vm-button'
).
click
(
function
()
{
manage_vm
(
$
(
this
).
data
(
'id'
),
"resume"
);
});
$
(
'.delete-vm-button'
).
click
(
function
()
{
delete_vm
(
$
(
this
).
data
(
'id'
),
$
(
this
).
data
(
'name'
));
});
$
(
'.restart-vm-button'
).
click
(
function
()
{
restart_vm
(
$
(
this
).
data
(
'id'
),
$
(
this
).
data
(
'name'
));
});
$
(
'#new-wm-button'
).
click
(
function
()
{
$
(
'#modal'
).
show
();
$
(
'#modal-container'
).
html
(
$
(
'#new-wm'
).
html
());
...
...
@@ -89,6 +101,58 @@ $(function() {
$
(
'#new-group-semester'
).
change
(
updateSummary
);
$
(
'#new-group-members'
).
change
(
updateSummary
);
});
/**
* Confirm pop-up window
*/
function
vm_confirm_popup
(
confirm_message
,
button_text
)
{
return
confirm
(
confirm_message
);
}
/**
* Manage VM State (STOP)
*/
function
stop_vm
(
id
,
name
)
{
confirm_message
=
interpolate
(
gettext
(
"Are you sure stopping %s?"
),
[
name
])
if
(
vm_confirm_popup
(
confirm_message
,
gettext
(
"Stop"
)))
{
manage_vm
(
id
,
"stop"
)
}
}
/**
* Manage VM State (DELETE)
*/
function
delete_vm
(
id
,
name
)
{
confirm_message
=
interpolate
(
gettext
(
"Are you sure deleting %s?"
),
[
name
])
if
(
vm_confirm_popup
(
confirm_message
,
gettext
(
"Delete"
)))
{
manage_vm
(
id
,
"delete"
)
}
}
/**
* Manage VM State (RESET)
*/
function
restart_vm
(
id
,
name
)
{
confirm_message
=
interpolate
(
gettext
(
"Are you sure restarting %s?"
),
[
name
])
if
(
vm_confirm_popup
(
confirm_message
,
gettext
(
"Restart"
)))
{
manage_vm
(
id
,
"restart"
)
}
}
/**
* Manage VM State (RESUME)
*/
function
resume_vm
(
id
,
name
)
{
manage_vm
(
id
,
"resume"
)
}
/**
* Manage VM State generic
*/
function
manage_vm
(
id
,
state
)
{
$
.
ajax
({
type
:
'POST'
,
data
:
''
,
url
:
'/vm/'
+
state
+
'/'
+
id
+
'/'
,
success
:
function
(
data
)
{
}
})
}
/**
* Convert bytes to human readable format
...
...
one/templates/box-vmlist.html
View file @
82a96649
...
...
@@ -16,29 +16,29 @@
<a
href=
"{{i.get_connect_uri}}"
title=
"{% trans "
Connect
"
%}"
>
<img
src=
"/static/icons/plug.png"
alt=
"{% trans "
Connect
"
%}"
/>
</a>
<a
href=
"
/vm/suspend/{{i.id}}/"
onclick=
"alert('Hamarosan a mozikban.'); return false"
title=
"{% trans "
Suspend
"
%}"
>
<a
href=
"
#"
class=
"stop-vm-button"
data-name=
"{{ i.name}}"
data-id=
"{{ i.id }}"
title=
"{% trans "
Stop
"
%}"
>
<img
src=
"/static/icons/control-pause.png"
alt=
"{% trans "
Suspend
"
%}"
/>
</
a
>
<a
href=
"
/vm/delete/{{i.id}}/"
onclick=
"return confirm('Biztosan törli a gépet?')
"
title=
"{% trans "
Delete
"
%}"
>
</
span
>
<a
href=
"
#"
class=
"delete-vm-button"
data-name=
"{{ i.name}}"
data-id=
"{{ i.id }}
"
title=
"{% trans "
Delete
"
%}"
>
<img
src=
"/static/icons/minus-circle.png"
alt=
"{% trans "
Delete
"
%}"
/>
</a>
<a
href=
"
/vm/reset/{{i.id}}/"
onclick=
"alert('Hamarosan a mozikban.'); return false"
title=
"{% trans "
Reboo
t
"
%}"
>
<a
href=
"
#"
class=
"restart-vm-button"
data-name=
"{{ i.name}}"
data-id=
"{{ i.id }}"
title=
"{% trans "
Restar
t
"
%}"
>
<img
src=
"/static/icons/arrow-circle-double.png"
alt=
"↺"
/>
</a>
{% endif %}
{% if i.state == 'PENDING' %}
<img
src=
"/static/load-2.gif"
/>
{% trans "starting…" %}
{% endif %}
{% if i.state == 'S
USPEND
ED' %}
<a
href=
"
/vm/continue/{{i.id}}/
"
title=
"{% trans "
Resume
"
%}"
>
{% if i.state == 'S
TOPP
ED' %}
<a
href=
"
#"
class=
"resume-vm-button"
data-name=
"{{ i.name}}"
data-id=
"{{ i.id }}
"
title=
"{% trans "
Resume
"
%}"
>
<img
src=
"/static/icons/control.png"
alt=
"{% trans "
Resume
"
%}"
/>
</
a
>
<a
href=
"
/vm/delete/{{i.id}}/"
onclick=
"return confirm('Biztosan törli a gépet?')
"
title=
"{% trans "
Delete
"
%}"
>
</
span
>
<a
href=
"
#"
class=
"delete-vm-button"
data-name=
"{{ i.name}}"
data-id=
"{{ i.id }}
"
title=
"{% trans "
Delete
"
%}"
>
<img
src=
"/static/icons/minus-circle.png"
alt=
"{% trans "
Delete
"
%}"
/>
</a>
{% endif %}
{% if i.state == 'FAILED' %}
<a
href=
"
/vm/delete/{{i.id}}/
"
title=
"{% trans "
Delete
"
%}"
>
<a
href=
"
#"
class=
"delete-vm-button"
data-name=
"{{ i.name}}"
data-id=
"{{ i.id }}
"
title=
"{% trans "
Delete
"
%}"
>
<img
src=
"/static/icons/minus-circle.png"
alt=
"{% trans "
Delete
"
%}"
/>
</a>
{% endif %}
...
...
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