Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9eb35a7a
authored
Jan 15, 2014
by
Oláh István Gergely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add node enable-disable function
parent
76b8e42a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
86 additions
and
9 deletions
+86
-9
circle/dashboard/static/dashboard/node-list.js
+46
-5
circle/dashboard/templates/dashboard/node-detail.html
+4
-0
circle/dashboard/templates/dashboard/node-list.html
+4
-2
circle/dashboard/templates/dashboard/node-list/column-actions.html
+2
-2
circle/dashboard/views.py
+30
-0
No files found.
circle/dashboard/static/dashboard/node-list.js
View file @
9eb35a7a
...
...
@@ -59,14 +59,29 @@ $(function() {
return
retval
;
});
/*
$('.popover-link').popover();
$(':not(#anything)').on('click', function (e) {
$('.popover-link').each(function () {
//the 'is' for buttons that trigger popups
//the 'has' for icons and other elements within a button that triggers a popup
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
$(this).popover('hide');
return;
}
});
});
*/
$
(
':not(#anything)'
).
on
(
'click'
,
function
(
e
)
{
$
(
'.node-list-details'
).
each
(
function
()
{
//the 'is' for buttons that trigger popups
// //the 'has' for icons and other elements within a button that triggers a popup
if
(
!
$
(
this
).
is
(
e
.
target
)
&&
$
(
this
).
has
(
e
.
target
).
length
===
0
&&
$
(
'.popover'
).
has
(
e
.
target
).
length
===
0
)
{
$
(
this
).
popover
(
'hide'
);
return
;
}
$
(
this
).
popover
(
'hide'
);
return
;
}
});
});
...
...
@@ -80,6 +95,7 @@ $(':not(#anything)').on('click', function (e) {
'trigger'
:
'click'
});
$
(
'tbody a'
).
mousedown
(
function
(
e
)
{
// parent tr doesn't get selected when clicked
e
.
stopPropagation
();
...
...
@@ -127,8 +143,33 @@ $(':not(#anything)').on('click', function (e) {
});
return
false
;
});
$
(
'#table_container'
).
on
(
'click'
,
'#node-list-enable-button'
,
function
(){
enablenode
(
$
(
this
).
attr
(
'data-node-pk'
),
$
(
this
).
attr
(
'data-status'
));
});
// enabling / disabling node
function
enablenode
(
pk
,
new_status
)
{
var
url
=
'/dashboard/node/'
+
pk
+
'/'
;
console
.
log
(
'success'
);
$
.
ajax
({
method
:
'POST'
,
url
:
url
,
data
:
{
'new_status'
:
new_status
},
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
success
:
function
(
data
,
textStatus
,
xhr
)
{
$
(
'#table_container'
).
load
(
location
.
href
+
" "
+
'#rendered_table'
);
},
error
:
function
(
xhr
,
textStatus
,
error
)
{
addMessage
(
"uhoh"
,
"danger"
);
}
});
return
false
;
}
/* group actions */
/* select all */
...
...
circle/dashboard/templates/dashboard/node-detail.html
View file @
9eb35a7a
...
...
@@ -54,3 +54,7 @@
</div>
{% endblock %}
{% block extra_js %}
<script
src=
"{{ STATIC_URL}}dashboard/node-list.js"
></script>
{% endblock %}
circle/dashboard/templates/dashboard/node-list.html
View file @
9eb35a7a
...
...
@@ -26,9 +26,11 @@
<a
disabled
href=
"#"
class=
"btn btn-default btn-xs"
><i
class=
"icon-off"
></i>
Shutdown
</a>
<a
id=
"node-list-group-delete"
disabled
href=
"#"
class=
"btn btn-danger btn-xs"
><i
class=
"icon-remove"
></i>
Discard
</a>
</p>
</div>
<div
class=
"panel-body"
>
</div>
<div
id=
"table_container"
>
<div
id=
"rendered_table"
class=
"panel-body"
>
{% render_table table %}
</div>
</div>
</div>
</div>
...
...
circle/dashboard/templates/dashboard/node-list/column-actions.html
View file @
9eb35a7a
...
...
@@ -4,9 +4,9 @@
<ul
class=
"dropdown-menu"
role=
"menu"
>
<li><a
href=
"#"
><i
class=
"icon-cloud-upload"
></i>
Flush
</a></li>
{% if record.enabled %}
<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-remove"
></i>
Disable
</a></li>
<li><a
data-
status=
"disable"
data-node-pk=
"{{ record.pk }}"
class=
"real-link node-enable"
id=
"node-list-enable-button"
href=
"#"
><i
class=
"icon-remove"
></i>
Disable
</a></li>
{% else %}
<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-check"
></i>
Enable
</a></li>
<li><a
data-
status=
"enable"
data-node-pk=
"{{ record.pk }}"
class=
"real-link node-enable"
id=
"node-list-enable-button"
href=
"#"
><i
class=
"icon-check"
></i>
Enable
</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/views.py
View file @
9eb35a7a
...
...
@@ -286,6 +286,8 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
if
request
.
POST
.
get
(
'new_name'
):
return
self
.
__set_name
(
request
)
if
request
.
POST
.
get
(
'new_status'
):
return
self
.
__set_status
(
request
)
def
__set_name
(
self
,
request
):
self
.
object
=
self
.
get_object
()
...
...
@@ -309,6 +311,34 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
return
redirect
(
reverse_lazy
(
"dashboard.views.node-detail"
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
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
:
return
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
(
reverse_lazy
(
"dashboard.views.node-detail"
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
class
AclUpdateView
(
LoginRequiredMixin
,
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