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
8a94925d
authored
Apr 16, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: delete unused js file
parent
45d9f242
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 additions
and
389 deletions
+1
-389
circle/locale/hu/LC_MESSAGES/djangojs.po
+1
-44
circle/network/static/js/record.js
+0
-345
No files found.
circle/locale/hu/LC_MESSAGES/djangojs.po
View file @
8a94925d
...
@@ -8,7 +8,7 @@ msgid ""
...
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-04-1
0 12:20
+0200\n"
"POT-Creation-Date: 2014-04-1
6 08:59
+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
...
@@ -176,49 +176,6 @@ msgstr ""
...
@@ -176,49 +176,6 @@ msgstr ""
msgid "Remove"
msgid "Remove"
msgstr ""
msgstr ""
#: network/static/js/record.js:109
msgid "Address must be specified!"
msgstr ""
#: network/static/js/record.js:119
#, c-format
msgid "%s - not an IPv4 address"
msgstr ""
#: network/static/js/record.js:129
#, c-format
msgid "%s - not an IPv6 address"
msgstr ""
#: network/static/js/record.js:140
msgid "Bad MX address format. "
msgstr ""
#: network/static/js/record.js:151 network/static/js/record.js.c:186
#, c-format
msgid "%s - invalid domain name"
msgstr ""
#: network/static/js/record.js:161
msgid "Unknown record type."
msgstr ""
#: network/static/js/record.js:169 network/static/js/record.js.c:339
msgid "You must choose a type"
msgstr ""
#: network/static/js/record.js:196
msgid "You must choose a domain"
msgstr ""
#: network/static/js/record.js:203
msgid "You must specify an owner!"
msgstr ""
#: network/static/js/record.js:321
msgid "Specify a type!"
msgstr ""
#: network/static/js/switch-port.js:8
#: network/static/js/switch-port.js:8
msgid "Are you sure you want to delete this device?"
msgid "Are you sure you want to delete this device?"
msgstr ""
msgstr ""
circle/network/static/js/record.js
deleted
100644 → 0
View file @
45d9f242
// regexes
mac_re
=
/^
([
0-9a-fA-F
]{2}(
:|$
)){6}
$/
;
alfanum_re
=
'^[A-Za-z0-9_-]+$'
;
domain_re
=
/^
([
A-Za-z0-9_-
]\.?)
+$/
;
ipv4_re
=
/^
[
0-9
]
+
\.([
0-9
]
+
)\.([
0-9
]
+
)\.([
0-9
]
+
)
$/
;
ipv6_re
=
/^
((?=
.*::
)(?!
.*::.+::
)(
::
)?([\d
A-F
]{1,4}
:
(
:|
\b)
|
){5}
|
([\d
A-F
]{1,4}
:
){6})((([\d
A-F
]{1,4}((?!\3)
::|:
\b
|$
))
|
(?!\2\3)){2}
|
(((
2
[
0-4
]
|1
\d
|
[
1-9
])?\d
|25
[
0-5
])\.?\b){4})
$/i
reverse_domain_re
=
/^
(
%
\([
abcd
]\)
d|
[
a-z0-9.-
])
+$/
;
// is this a new record?
var
new_record
=
false
;
// handles type change
// if we are currently creating a new one, call type_next()
$
(
'#id_type'
).
change
(
function
()
{
type
=
$
(
":selected"
,
this
).
text
();
resetForm
();
resetName
();
if
(
new_record
)
{
type_next
();
new_record
=
false
;
}
});
// handles hostname change
$
(
'#id_host'
).
change
(
function
()
{
host_id
=
$
(
"#id_host :selected"
).
val
();
// if user selected "----" reset the inputs
if
(
!
host_id
)
{
resetForm
();
}
else
{
setNameAndAddress
();
resetErrors
();
}
});
// sets the name and address if necessary
function
setNameAndAddress
()
{
var
type
=
$
(
"#id_type :selected"
).
text
();
host_id
=
$
(
"#id_host :selected"
).
val
();
host_name
=
$
(
"#id_host :selected"
).
text
();
// if A or AAAA record
if
(
type
[
0
]
===
"A"
)
{
promise
=
getHostData
(
host_id
);
promise
.
success
(
function
(
data
)
{
hostname
=
document
.
getElementById
(
"id_name"
);
hostname
.
disabled
=
true
;
hostname
.
value
=
data
.
hostname
;
addr
=
document
.
getElementById
(
"id_address"
)
addr
.
disabled
=
true
;
if
(
type
===
"A"
)
{
addr
.
value
=
data
.
ipv4
;
}
else
{
addr
.
value
=
data
.
ipv6
;
}
});
}
// if CNAME
else
if
(
type
===
"CNAME"
)
{
promise
=
getHostData
(
host_id
);
promise
.
success
(
function
(
data
)
{
addr
=
document
.
getElementById
(
'id_address'
);
addr
.
disabled
=
true
;
addr
.
value
=
data
.
fqdn
;
});
}
// if MX
else
if
(
type
===
"MX"
)
{
if
(
!
$
(
'#id_address'
).
val
())
{
promise
=
getHostData
(
host_id
);
promise
.
success
(
function
(
data
)
{
addr
=
document
.
getElementById
(
'id_address'
);
addr
.
value
=
"10:"
+
data
.
fqdn
;
});
}
}
}
// if we submit the form validate the form
$
(
'#submit-id-submit'
).
click
(
function
()
{
return
validateForm
();
});
// validates the form
// validation is like the one in firewall/model.py
function
validateForm
()
{
type
=
$
(
"#id_type :selected"
).
text
();
host
=
$
(
'#id_host :selected'
).
val
();
messages
=
[]
// if host is set
if
(
host
&&
type
[
0
]
!=
"-"
)
{
if
(
type
===
"CNAME"
)
{
if
(
!
$
(
'#id_name'
).
val
())
{
messages
.
push
({
'message'
:
'Name must be specified for '
+
'CNAME records if host is set!'
,
'id'
:
'name'
});
}
}
// if host is not set
}
else
if
(
!
host
&&
type
[
0
]
!=
"-"
)
{
if
(
!
$
(
'#id_address'
).
val
())
{
messages
.
push
({
'message'
:
gettext
(
'Address must be specified!'
),
'id'
:
'address'
});
}
// address is set
else
{
var
addr
=
$
(
'#id_address'
).
val
();
// ipv4
if
(
type
===
"A"
)
{
if
(
!
addr
.
match
(
ipv4_re
))
{
text
=
gettext
(
'%s - not an IPv4 address'
);
messages
.
push
({
'message'
:
interpolate
(
text
,
[
addr
]),
'id'
:
'address'
})
}
}
// ipv6
else
if
(
type
[
0
]
===
"A"
)
{
if
(
!
addr
.
match
(
ipv6_re
))
{
text
=
gettext
(
'%s - not an IPv6 address'
);
messages
.
push
({
'message'
:
interpolate
(
text
,
[
addr
]),
'id'
:
'address'
});
}
}
// MX
else
if
(
type
===
"MX"
)
{
mx
=
addr
.
split
(
':'
);
if
(
!
(
mx
.
length
===
2
&&
mx
[
0
].
match
(
"^[0-9]+$"
)
&&
domain_re
.
test
(
mx
[
1
])))
{
text
=
gettext
(
'Bad MX address format. '
+
'Should be: <priority>:<hostname>'
)
messages
.
push
({
'message'
:
text
,
'id'
:
'address'
});
}
}
// CNAME / NS / PTR / TXT
else
if
([
'CNAME'
,
'NS'
,
'PTR'
,
'TXT'
].
indexOf
(
type
)
!=
-
1
)
{
if
(
!
domain_re
.
test
(
addr
))
{
text
=
gettext
(
'%s - invalid domain name'
);
messages
.
push
({
'message'
:
interpolate
(
text
,
[
addr
]),
'id'
:
'address'
});
}
}
// we doesn't really need this, but better safe than sorry
else
{
messages
.
push
({
'message'
:
gettext
(
'Unknown record type.'
),
'id'
:
'type'
});
}
}
// we didn't choose a type
}
else
{
messages
.
push
({
'message'
:
gettext
(
'You must choose a type'
),
'id'
:
'type'
});
}
// check other inputs
// name
record_name
=
$
(
'#id_name'
).
val
()
if
(
!
record_name
)
{
//messages.push({
// 'message': gettext("You must specify a name!"),
// 'id': 'name'
//});
}
else
if
(
!
domain_re
.
test
(
record_name
))
{
text
=
gettext
(
'%s - invalid domain name'
),
messages
.
push
({
'message'
:
interpolate
(
text
,
[
record_name
]),
'id'
:
'name'
});
}
// domain
if
(
!
$
(
'#id_domain :selected'
).
val
())
{
messages
.
push
({
'message'
:
gettext
(
'You must choose a domain'
),
'id'
:
'domain'
});
}
// owner
if
(
!
$
(
'#id_owner :selected'
).
val
())
{
messages
.
push
({
'message'
:
gettext
(
'You must specify an owner!'
),
'id'
:
'owner'
});
}
if
(
messages
.
length
<
1
)
{
return
true
;
}
else
{
appendMessage
(
'error'
,
messages
);
return
false
;
}
}
// makes the ajax call
function
getHostData
(
pk
)
{
return
$
.
ajax
({
type
:
"GET"
,
url
:
"/network/hosts/"
+
pk
+
"/"
,
});
}
// enables fields, resets them and removes error messages
function
resetForm
()
{
hostname
=
document
.
getElementById
(
'id_name'
);
addr
=
document
.
getElementById
(
'id_address'
);
hostname
.
disabled
=
false
;
addr
.
disabled
=
false
;
hostname
.
value
=
""
;
addr
.
value
=
""
;
resetErrors
();
}
// removes all error messages / classes
function
resetErrors
()
{
// reset invalid inputs too
$
(
'div[id^="div_id_"][class*="has-error"]'
).
each
(
function
()
{
$
(
this
).
removeClass
(
'has-error'
);
});
// remove the error messages
$
(
"#js_error"
).
fadeOut
();
}
// reset the hostname select
function
resetName
()
{
$
(
"#id_host option"
).
filter
(
function
()
{
return
$
(
this
).
text
()[
0
]
==
"-"
;
}).
prop
(
'selected'
,
true
);
}
/*
* error creating function
*
* first it removes the current error message, then it iterates through
* all the given messages
*/
function
appendMessage
(
type
,
messages
,
id
)
{
$
(
'#js_error'
).
remove
();
resetErrors
();
message
=
'<div id="js_error" style="display: none;" class="alert alert-danger"><ul>'
for
(
var
i
=
0
;
i
<
messages
.
length
;
i
++
)
{
message
+=
"<li>"
+
messages
[
i
].
message
+
"</li>"
;
if
(
messages
[
i
].
id
)
{
$
(
'#id_'
+
messages
[
i
].
id
).
closest
(
'div[class="form-group"]'
).
addClass
(
"has-error"
);
}
}
message
+=
'</ul></div>'
;
$
(
'form'
).
before
(
message
);
$
(
'html, body'
).
animate
({
scrollTop
:
0
},
'slow'
,
function
()
{
$
(
'#js_error'
).
fadeIn
();
});
}
// remove error class from forms if we click on them
// it also removes the help-inline span that shouldn't really appear
$
(
'* [id^="id_"]'
).
focus
(
function
()
{
id
=
"#div_"
+
$
(
this
).
prop
(
'id'
);
if
(
$
(
id
).
hasClass
(
'has-error'
))
{
$
(
id
).
removeClass
(
'has-error'
);
$
(
'span[id="error_1_'
+
$
(
this
).
attr
(
'id'
)
+
'"]'
).
remove
();
}
});
// on page load
// if we are upadting
// - set the name and address
// else it's a new rule so we "create" the wizard thingy
$
(
function
()
{
// type is set, so it's an existing record
if
(
$
(
'#id_type :selected'
).
val
())
{
if
(
$
(
'#id_host :selected'
).
val
())
{
setNameAndAddress
();
}
}
// else we are creaing a new
else
{
domain
=
getURLParameter
(
'domain'
);
if
(
domain
!=
'null'
&&
domain
.
length
>
0
)
{
new_record
=
false
;
}
else
{
new_record
=
true
;
// hide all input containers
$
(
'div[id^="div_id_"]'
).
hide
();
// hide the save button
$
(
'#submit-id-submit'
).
hide
();
//
$
(
'#div_id_type .controls'
)
.
addClass
(
'input-group'
)
.
append
(
//' <a id="type_next" onclick="type_next()" class="btn btn-info">Next</a>'
'<span id="type_next" class="input-group-addon"><strong>'
+
gettext
(
'Specify a type!'
)
+
'</strong></span>'
);
$
(
'#div_id_type'
).
fadeIn
();
}
}
});
// if the user choose a type
function
type_next
()
{
if
(
$
(
'#div_id_type :selected'
).
val
())
{
$
(
'#div_id_type .controls'
).
removeClass
(
'input-group'
);
$
(
'#type_next'
).
remove
();
$
(
'div[id^="div_id_"]'
).
fadeIn
();
$
(
'#submit-id-submit'
).
fadeIn
();
// this shouldn't be called ...
}
else
{
message
=
[{
'message'
:
gettext
(
'You must choose a type'
),
'id'
:
'type'
}];
appendMessage
(
'error'
,
message
);
}
return
false
;
}
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