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
4f1b8349
authored
Sep 11, 2013
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: include specific js files only where we need them
parent
a9e4ec53
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
77 deletions
+75
-77
circle/network/static/js/host.js
+69
-0
circle/network/static/js/network.js
+1
-75
circle/network/templates/network/base.html
+0
-1
circle/network/templates/network/host-edit.html
+4
-0
circle/network/templates/network/record-edit.html
+1
-1
No files found.
circle/network/static/js/host.js
0 → 100644
View file @
4f1b8349
$
(
'i[class="icon-remove"]'
).
click
(
function
()
{
href
=
$
(
this
).
parent
(
'a'
).
attr
(
'href'
);
csrf
=
getCookie
(
'csrftoken'
);
var
click_this
=
this
;
host
=
$
(
'.page-header'
).
children
(
'h2'
).
text
()
group
=
$
(
this
).
closest
(
'h4'
).
text
();
if
(
group
.
length
>
0
)
{
text
=
gettext
(
'Are you sure you want to remove host group <strong>"%(group)s"</strong> from <strong>"%(host)s"</strong>?'
);
s
=
interpolate
(
text
,
{
'group'
:
group
,
'host'
:
host
},
true
);
}
else
{
s
=
gettext
(
'Are you sure you want to delete this rule?'
);
}
bootbox
.
dialog
({
message
:
s
,
buttons
:
{
cancel
:
{
'label'
:
"Cancel"
,
'className'
:
"btn-info"
,
'callback'
:
function
()
{}
},
remove
:
{
'label'
:
"Remove"
,
'className'
:
"btn-danger"
,
'callback'
:
function
()
{
delete_rule_or_group
(
click_this
);
}
}
}
});
return
false
;
});
function
delete_rule_or_group
(
click_this
)
{
ajax
=
$
.
ajax
({
type
:
'POST'
,
url
:
href
,
headers
:
{
"X-CSRFToken"
:
csrf
},
context
:
click_this
,
success
:
function
(
data
,
textStatus
,
xhr
)
{
if
(
xhr
.
status
==
200
)
{
// we delete a row in a table
if
(
href
.
indexOf
(
"rules"
)
!=
-
1
)
{
$
(
this
).
closest
(
'tr'
).
fadeOut
(
500
,
function
()
{
$
(
this
).
remove
();
});
}
// we delete the whole div around the table
else
{
// we need to readd the deleted group to the select
group_pk
=
parseInt
(
$
(
this
).
closest
(
'h4'
).
attr
(
'id'
));
group_name
=
$
(
this
).
closest
(
'h4'
).
text
();
$
(
this
).
closest
(
'div'
).
fadeOut
(
500
,
function
()
{
$
(
this
).
remove
();
$
(
'#add_group'
)
.
append
(
$
(
"<option></option>"
)
.
attr
(
'value'
,
group_pk
)
.
text
(
group_name
));
});
}
}
}
});
return
false
;
}
circle/network/static/js/network.js
View file @
4f1b8349
$
(
'i[class="icon-remove"]'
).
click
(
function
()
{
href
=
$
(
this
).
parent
(
'a'
).
attr
(
'href'
);
csrf
=
getCookie
(
'csrftoken'
);
var
click_this
=
this
;
host
=
$
(
'.page-header'
).
children
(
'h2'
).
text
()
group
=
$
(
this
).
closest
(
'h4'
).
text
();
if
(
group
.
length
>
0
)
{
text
=
gettext
(
'Are you sure you want to remove host group <strong>"%(group)s"</strong> from <strong>"%(host)s"</strong>?'
);
s
=
interpolate
(
text
,
{
'group'
:
group
,
'host'
:
host
},
true
);
}
else
{
s
=
gettext
(
'Are you sure you want to delete this rule?'
);
}
bootbox
.
dialog
({
message
:
s
,
buttons
:
{
cancel
:
{
'label'
:
"Cancel"
,
'className'
:
"btn-info"
,
'callback'
:
function
()
{}
},
remove
:
{
'label'
:
"Remove"
,
'className'
:
"btn-danger"
,
'callback'
:
function
()
{
delete_rule_or_group
(
click_this
);
}
}
}
});
return
false
;
});
function
delete_rule_or_group
(
click_this
)
{
ajax
=
$
.
ajax
({
type
:
'POST'
,
url
:
href
,
headers
:
{
"X-CSRFToken"
:
csrf
},
context
:
click_this
,
success
:
function
(
data
,
textStatus
,
xhr
)
{
if
(
xhr
.
status
==
200
)
{
// we delete a row in a table
if
(
href
.
indexOf
(
"rules"
)
!=
-
1
)
{
$
(
this
).
closest
(
'tr'
).
fadeOut
(
500
,
function
()
{
$
(
this
).
remove
();
});
}
// we delete the whole div around the table
else
{
// we need to readd the deleted group to the select
group_pk
=
parseInt
(
$
(
this
).
closest
(
'h4'
).
attr
(
'id'
));
group_name
=
$
(
this
).
closest
(
'h4'
).
text
();
$
(
this
).
closest
(
'div'
).
fadeOut
(
500
,
function
()
{
$
(
this
).
remove
();
$
(
'#add_group'
)
.
append
(
$
(
"<option></option>"
)
.
attr
(
'value'
,
group_pk
)
.
text
(
group_name
));
});
}
}
}
});
return
false
;
}
// for AJAX calls
/**
* Getter for user cookies
...
...
circle/network/templates/network/base.html
View file @
4f1b8349
...
...
@@ -83,7 +83,6 @@
<script
src=
"{% url "
network
.
js_catalog
"
%}"
></script>
<script
src=
"//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"
></script>
<script
src=
"{% static "
js
/
bootbox
.
min
.
js
"
%}"
></script>
<!--<script src="{% static "js/select2-3.4.0/select2.min.js" %}"></script>-->
<script
src=
"{% static "
js
/
network
.
js
"
%}"
></script>
<script>
{
%
block
extra_js
%
}
...
...
circle/network/templates/network/host-edit.html
View file @
4f1b8349
...
...
@@ -69,3 +69,7 @@
</div>
<!-- row -->
{% endblock %}
{% block extra_etc %}
<script
src=
"{% static "
js
/
host
.
js
"
%}"
></script>
{% endblock %}
circle/network/templates/network/record-edit.html
View file @
4f1b8349
...
...
@@ -19,5 +19,5 @@
{% endblock %}
{% block extra_etc %}
<script
src=
"{% static "
js
/
record
.
js
"
%}"
></script>
<script
src=
"{% static "
js
/
record
.
js
"
%}"
></script>
{% endblock %}
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