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
Commit
6bf11f0f
authored
Jan 26, 2014
by
Oláh István Gergely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: enable-disable node without javascript, css menu
parent
e63bb8ce
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
6 deletions
+67
-6
circle/dashboard/static/dashboard/node-list.js
+2
-1
circle/dashboard/templates/dashboard/base.html
+1
-0
circle/dashboard/templates/dashboard/node-list/column-actions.html
+5
-4
circle/dashboard/urls.py
+3
-1
circle/dashboard/views.py
+56
-0
No files found.
circle/dashboard/static/dashboard/node-list.js
View file @
6bf11f0f
...
...
@@ -168,13 +168,14 @@ $(function() {
$
(
'#table_container'
).
on
(
'click'
,
'.node-enable'
,
function
()
{
enablenode
(
$
(
this
).
attr
(
'data-node-pk'
),
$
(
this
).
attr
(
'data-status'
),
enabletableSuccess
,
this
);
return
false
;
});
// on node details, change node status, with calling enable node, refresh status span, resources div
$
(
'#node-info-pane'
).
on
(
'click'
,
'.node-enable'
,
function
(){
// post, change node status
enablenode
(
$
(
this
).
attr
(
'data-node-pk'
),
$
(
this
).
attr
(
'data-status'
),
enabledetailsSuccess
);
return
false
;
});
...
...
circle/dashboard/templates/dashboard/base.html
View file @
6bf11f0f
...
...
@@ -18,6 +18,7 @@
<script
src=
"{{ STATIC_URL}}dashboard/bootstrap-slider/bootstrap-slider.js"
></script>
<link
rel=
"stylesheet"
href=
"{{ STATIC_URL }}dashboard/bootstrap-slider/slider.css"
/>
<link
href=
"{{ STATIC_URL }}dashboard/dashboard.css"
rel=
"stylesheet"
>
<link
href=
"{{ STATIC_URL }}dashboard/node.css"
rel=
"stylesheet"
>
<script
src=
"{{ STATIC_URL }}dashboard/dashboard.js"
></script>
</head>
...
...
circle/dashboard/templates/dashboard/node-list/column-actions.html
View file @
6bf11f0f
...
...
@@ -4,11 +4,12 @@
<ul
class=
"dropdown-menu"
role=
"menu"
>
<li><a
href=
"#"
><i
class=
"icon-cloud-upload"
></i>
Flush
</a></li>
{% if record.enabled %}
<li><a
style=
"display:none"
data-status=
"enable"
data-node-pk=
"{{ record.pk }}"
class=
"real-link node-enable"
href=
"
#"
><i
class=
"icon-remove
"
></i>
Enable
</a>
<a
style=
"display:block"
data-status=
"disable"
data-node-pk=
"{{ record.pk }}"
class=
"real-link node-enable"
href=
"
#"
><i
class=
"icon-remove"
></i>
Disable
</a></li>
<li><a
style=
"display:none"
data-status=
"enable"
data-node-pk=
"{{ record.pk }}"
class=
"real-link node-enable"
href=
"
{% url "
dashboard
.
views
.
status-node
"
pk=
record.pk
%}?
next=
{{
request
.
path
}}&
status=
enable"
><i
class=
"icon-check
"
></i>
Enable
</a>
<a
style=
"display:block"
data-status=
"disable"
data-node-pk=
"{{ record.pk }}"
class=
"real-link node-enable"
href=
"
{% url "
dashboard
.
views
.
status-node
"
pk=
record.pk
%}?
next=
{{
request
.
path
}}&
status=
disable"
><i
class=
"icon-remove"
></i>
Disable
</a></li>
{% else %}
<li><a
style=
"display:block"
data-status=
"enable"
data-node-pk=
"{{ record.pk }}"
class=
"real-link node-enable"
href=
"#"
><i
class=
"icon-remove"
></i>
Enable
</a>
<a
style=
"display:none"
data-status=
"disable"
data-node-pk=
"{{ record.pk }}"
class=
"real-link node-enable"
href=
"#"
><i
class=
"icon-remove"
></i>
Disable
</a></li>
<li><a
style=
"display:block"
data-status=
"enable"
data-node-pk=
"{{ record.pk }}"
class=
"real-link node-enable"
href=
"{% url "
dashboard
.
views
.
status-node
"
pk=
record.pk
%}?
next=
{{
request
.
path
}}&
status=
enable"
>
<i
class=
"icon-check"
></i>
Enable
</a>
<a
style=
"display:none"
data-status=
"disable"
data-node-pk=
"{{ record.pk }}"
class=
"real-link node-enable"
href=
"{% url "
dashboard
.
views
.
status-node
"
pk=
record.pk
%}?
next=
{{
request
.
path
}}&
status=
disable"
><i
class=
"icon-remove"
></i>
Disable
</a></li>
{% endif %}
<li><a
data-node-pk=
"{{ record.pk }}"
class=
"real-link node-delete"
href=
"{% url "
dashboard
.
views
.
delete-node
"
pk=
record.pk
%}?
next=
{{
request
.
path
}}"
><i
class=
"icon-trash"
></i>
Delete
</a></li>
</ul>
...
...
circle/dashboard/urls.py
View file @
6bf11f0f
...
...
@@ -6,7 +6,7 @@ from .views import (
VmDelete
,
VmMassDelete
,
vm_activity
,
NodeList
,
NodeDetailView
,
PortDelete
,
TransferOwnershipView
,
TransferOwnershipConfirmView
,
NodeDelete
,
TemplateList
,
LeaseDetail
,
NodeCreate
,
LeaseCreate
,
TemplateCreate
,
FavouriteView
,
FavouriteView
,
NodeStatus
,
)
urlpatterns
=
patterns
(
...
...
@@ -45,6 +45,8 @@ urlpatterns = patterns(
name
=
'dashboard.views.vm-transfer-ownership-confirm'
),
url
(
r'^node/delete/(?P<pk>\d+)/$'
,
NodeDelete
.
as_view
(),
name
=
"dashboard.views.delete-node"
),
url
(
r'^node/status/(?P<pk>\d+)/$'
,
NodeStatus
.
as_view
(),
name
=
"dashboard.views.status-node"
),
url
(
r'^node/create/$'
,
NodeCreate
.
as_view
(),
name
=
'dashboard.views.node-create'
),
url
(
r'^favourite/$'
,
FavouriteView
.
as_view
(),
...
...
circle/dashboard/views.py
View file @
6bf11f0f
...
...
@@ -787,6 +787,62 @@ class NodeDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
return
reverse_lazy
(
'dashboard.index'
)
class
NodeStatus
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
DetailView
):
template_name
=
"dashboard/confirm/node-status.html"
model
=
Node
def
get_success_url
(
self
):
next
=
self
.
request
.
GET
.
get
(
'next'
)
if
next
:
return
next
else
:
return
reverse_lazy
(
"dashboard.views.node-detail"
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
})
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
NodeStatus
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'status'
]
=
self
.
request
.
GET
.
get
(
'status'
)
return
context
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
if
request
.
POST
.
get
(
'new_status'
):
print
self
.
request
.
GET
.
get
(
'next'
)
return
self
.
__set_status
(
request
)
def
__set_status
(
self
,
request
):
self
.
object
=
self
.
get_object
()
new_status
=
request
.
POST
.
get
(
"new_status"
)
if
new_status
==
"enable"
:
Node
.
objects
.
filter
(
pk
=
self
.
object
.
pk
)
.
update
(
**
{
'enabled'
:
True
})
elif
new_status
==
"disable"
:
Node
.
objects
.
filter
(
pk
=
self
.
object
.
pk
)
.
update
(
**
{
'enabled'
:
False
})
else
:
if
request
.
is_ajax
():
return
HttpResponse
(
content_type
=
"application/json"
)
else
:
return
redirect
(
self
.
get_success_url
())
success_message
=
_
(
"Node successfully changed status!"
)
if
request
.
is_ajax
():
response
=
{
'message'
:
success_message
,
'new_status'
:
new_status
,
'node_pk'
:
self
.
object
.
pk
}
return
HttpResponse
(
json
.
dumps
(
response
),
content_type
=
"application/json"
)
else
:
messages
.
success
(
request
,
success_message
)
return
redirect
(
self
.
get_success_url
())
class
PortDelete
(
LoginRequiredMixin
,
DeleteView
):
model
=
Rule
pk_url_kwarg
=
'rule'
...
...
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