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
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
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
3 deletions
+80
-3
circle/dashboard/static/dashboard/node-list.js
+41
-0
circle/dashboard/templates/dashboard/node-detail.html
+4
-0
circle/dashboard/templates/dashboard/node-list.html
+3
-1
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,6 +59,21 @@ $(function() {
...
@@ -59,6 +59,21 @@ $(function() {
return
retval
;
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
)
{
$
(
':not(#anything)'
).
on
(
'click'
,
function
(
e
)
{
$
(
'.node-list-details'
).
each
(
function
()
{
$
(
'.node-list-details'
).
each
(
function
()
{
//the 'is' for buttons that trigger popups
//the 'is' for buttons that trigger popups
...
@@ -80,6 +95,7 @@ $(':not(#anything)').on('click', function (e) {
...
@@ -80,6 +95,7 @@ $(':not(#anything)').on('click', function (e) {
'trigger'
:
'click'
'trigger'
:
'click'
});
});
$
(
'tbody a'
).
mousedown
(
function
(
e
)
{
$
(
'tbody a'
).
mousedown
(
function
(
e
)
{
// parent tr doesn't get selected when clicked
// parent tr doesn't get selected when clicked
e
.
stopPropagation
();
e
.
stopPropagation
();
...
@@ -129,6 +145,31 @@ $(':not(#anything)').on('click', function (e) {
...
@@ -129,6 +145,31 @@ $(':not(#anything)').on('click', function (e) {
});
});
$
(
'#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 */
/* group actions */
/* select all */
/* select all */
...
...
circle/dashboard/templates/dashboard/node-detail.html
View file @
9eb35a7a
...
@@ -54,3 +54,7 @@
...
@@ -54,3 +54,7 @@
</div>
</div>
{% endblock %}
{% endblock %}
{% block extra_js %}
<script
src=
"{{ STATIC_URL}}dashboard/node-list.js"
></script>
{% endblock %}
circle/dashboard/templates/dashboard/node-list.html
View file @
9eb35a7a
...
@@ -27,11 +27,13 @@
...
@@ -27,11 +27,13 @@
<a
id=
"node-list-group-delete"
disabled
href=
"#"
class=
"btn btn-danger btn-xs"
><i
class=
"icon-remove"
></i>
Discard
</a>
<a
id=
"node-list-group-delete"
disabled
href=
"#"
class=
"btn btn-danger btn-xs"
><i
class=
"icon-remove"
></i>
Discard
</a>
</p>
</p>
</div>
</div>
<div
class=
"panel-body"
>
<div
id=
"table_container"
>
<div
id=
"rendered_table"
class=
"panel-body"
>
{% render_table table %}
{% render_table table %}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<style>
<style>
...
...
circle/dashboard/templates/dashboard/node-list/column-actions.html
View file @
9eb35a7a
...
@@ -4,9 +4,9 @@
...
@@ -4,9 +4,9 @@
<ul
class=
"dropdown-menu"
role=
"menu"
>
<ul
class=
"dropdown-menu"
role=
"menu"
>
<li><a
href=
"#"
><i
class=
"icon-cloud-upload"
></i>
Flush
</a></li>
<li><a
href=
"#"
><i
class=
"icon-cloud-upload"
></i>
Flush
</a></li>
{% if record.enabled %}
{% 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 %}
{% 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%}
{% 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>
<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>
</ul>
...
...
circle/dashboard/views.py
View file @
9eb35a7a
...
@@ -286,6 +286,8 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
...
@@ -286,6 +286,8 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
if
request
.
POST
.
get
(
'new_name'
):
if
request
.
POST
.
get
(
'new_name'
):
return
self
.
__set_name
(
request
)
return
self
.
__set_name
(
request
)
if
request
.
POST
.
get
(
'new_status'
):
return
self
.
__set_status
(
request
)
def
__set_name
(
self
,
request
):
def
__set_name
(
self
,
request
):
self
.
object
=
self
.
get_object
()
self
.
object
=
self
.
get_object
()
...
@@ -309,6 +311,34 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
...
@@ -309,6 +311,34 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
return
redirect
(
reverse_lazy
(
"dashboard.views.node-detail"
,
return
redirect
(
reverse_lazy
(
"dashboard.views.node-detail"
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}))
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
):
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