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
064dbddf
authored
Jun 25, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: js modal for all vm operations
parent
82a3942b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
circle/dashboard/static/dashboard/vm-common.js
+5
-1
circle/dashboard/templates/dashboard/operate.html
+1
-3
circle/dashboard/views.py
+13
-0
No files found.
circle/dashboard/static/dashboard/vm-common.js
View file @
064dbddf
...
@@ -34,6 +34,7 @@ $(function() {
...
@@ -34,6 +34,7 @@ $(function() {
/* if the operation fails show the modal again */
/* if the operation fails show the modal again */
$
(
"body"
).
on
(
"click"
,
"#op-form-send"
,
function
()
{
$
(
"body"
).
on
(
"click"
,
"#op-form-send"
,
function
()
{
var
url
=
$
(
this
).
closest
(
"form"
).
prop
(
"action"
);
var
url
=
$
(
this
).
closest
(
"form"
).
prop
(
"action"
);
$
.
ajax
({
$
.
ajax
({
url
:
url
,
url
:
url
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
...
@@ -44,9 +45,12 @@ $(function() {
...
@@ -44,9 +45,12 @@ $(function() {
if
(
data
.
redirect
)
{
if
(
data
.
redirect
)
{
$
(
'a[href="#activity"]'
).
trigger
(
"click"
);
$
(
'a[href="#activity"]'
).
trigger
(
"click"
);
if
(
data
.
messages
.
length
>
0
)
{
addMessage
(
data
.
messages
.
join
(
"<br />"
),
"danger"
);
}
}
}
else
{
else
{
var
r
=
$
(
'#confirmation-modal'
);
r
.
next
(
'div'
).
remove
();
r
.
remove
();
$
(
'body'
).
append
(
data
);
$
(
'body'
).
append
(
data
);
$
(
'#confirmation-modal'
).
modal
(
'show'
);
$
(
'#confirmation-modal'
).
modal
(
'show'
);
$
(
'#confirmation-modal'
).
on
(
'hidden.bs.modal'
,
function
()
{
$
(
'#confirmation-modal'
).
on
(
'hidden.bs.modal'
,
function
()
{
...
...
circle/dashboard/templates/dashboard/operate.html
View file @
064dbddf
...
@@ -19,9 +19,7 @@ Do you want to do the following operation on {{obj}}:
...
@@ -19,9 +19,7 @@ Do you want to do the following operation on {{obj}}:
<div
class=
"pull-right"
>
<div
class=
"pull-right"
>
<a
class=
"btn btn-default"
href=
"{{object.get_absolute_url}}"
<a
class=
"btn btn-default"
href=
"{{object.get_absolute_url}}"
data-dismiss=
"modal"
>
{% trans "Cancel" %}
</a>
data-dismiss=
"modal"
>
{% trans "Cancel" %}
</a>
<button
class=
"btn btn-danger"
type=
"submit"
<button
class=
"btn btn-danger"
type=
"submit"
id=
"op-form-send"
>
{%
if
form
%}
id=
"op-form-send"
{%
endif
%}
>
{% if op.icon %}
<i
class=
"icon-{{op.icon}}"
></i>
{% endif %}{{ op|capfirst }}
{% if op.icon %}
<i
class=
"icon-{{op.icon}}"
></i>
{% endif %}{{ op|capfirst }}
</button>
</button>
</div>
</div>
...
...
circle/dashboard/views.py
View file @
064dbddf
...
@@ -573,6 +573,19 @@ class VmOperationView(OperationView):
...
@@ -573,6 +573,19 @@ class VmOperationView(OperationView):
model
=
Instance
model
=
Instance
context_object_name
=
'instance'
# much simpler to mock object
context_object_name
=
'instance'
# much simpler to mock object
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
resp
=
super
(
VmOperationView
,
self
)
.
post
(
request
,
*
args
,
**
kwargs
)
if
request
.
is_ajax
():
store
=
messages
.
get_messages
(
request
)
store
.
used
=
True
return
HttpResponse
(
json
.
dumps
({
'redirect'
:
resp
.
url
,
'messages'
:
[
unicode
(
m
)
for
m
in
store
]}),
content_type
=
"application=json"
)
else
:
return
resp
class
FormOperationMixin
(
object
):
class
FormOperationMixin
(
object
):
...
...
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