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
efcda103
authored
Feb 18, 2014
by
Oláh István Gergely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add remove_trait js script, add data-pk to template
parent
85ae443d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
3 deletions
+27
-3
circle/dashboard/static/dashboard/node-list.js
+25
-0
circle/dashboard/templates/dashboard/node-detail-home.html
+1
-1
circle/dashboard/views.py
+1
-2
No files found.
circle/dashboard/static/dashboard/node-list.js
View file @
efcda103
...
...
@@ -196,6 +196,31 @@ $(function() {
}
// remove trait
$
(
'.node-details-remove-trait'
).
click
(
function
()
{
var
to_remove
=
$
(
this
).
data
(
"trait-pk"
);
var
clicked
=
$
(
this
);
$
.
ajax
({
type
:
'POST'
,
url
:
location
.
href
,
headers
:
{
"X-CSRFToken"
:
getCookie
(
'csrftoken'
)},
data
:
{
'to_remove'
:
to_remove
},
success
:
function
(
re
)
{
if
(
re
[
'message'
].
toLowerCase
()
==
"success"
)
{
$
(
clicked
).
closest
(
".label"
).
fadeOut
(
500
,
function
()
{
$
(
this
).
remove
();
});
}
},
error
:
function
()
{
addMessage
(
re
[
'message'
],
'danger'
);
}
});
return
false
;
});
// refresh the given contents, parameter is the array of contents, in pair
function
contentrefresh
(
elements
,
callbacks
){
for
(
var
i
=
0
;
i
<
elements
.
length
;
i
+=
2
)
{
...
...
circle/dashboard/templates/dashboard/node-detail-home.html
View file @
efcda103
...
...
@@ -14,7 +14,7 @@
{% for t in node.traits.all %}
<div
class=
"label label-success label-tag"
style=
"display: inline-block"
>
{{ t }}
<a
href=
"#"
class=
"node-details-remove-trait"
><i
class=
"icon-remove"
></i></a>
<a
data-trait-pk=
"{{ t.pk }}"
href=
"#"
class=
"node-details-remove-trait"
><i
class=
"icon-remove"
></i></a>
</div>
{% endfor %}
{% else %}
...
...
circle/dashboard/views.py
View file @
efcda103
...
...
@@ -531,8 +531,7 @@ class NodeDetailView(LoginRequiredMixin, SuperuserRequiredMixin, DetailView):
try
:
to_remove
=
request
.
POST
.
get
(
'to_remove'
)
self
.
object
=
self
.
get_object
()
self
.
object
.
tags
.
remove
(
to_remove
)
self
.
object
.
traits
.
remove
(
to_remove
)
message
=
u"Success"
except
:
# note this won't really happen
message
=
u"Not success"
...
...
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