Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
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
04eae09e
authored
Jan 29, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: fix vm create network add/remove
parent
6bf11f0f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
24 deletions
+45
-24
circle/dashboard/forms.py
+3
-2
circle/dashboard/static/dashboard/dashboard.css
+5
-0
circle/dashboard/static/dashboard/vm-create.js
+35
-21
circle/firewall/models.py
+2
-1
No files found.
circle/dashboard/forms.py
View file @
04eae09e
...
...
@@ -209,7 +209,7 @@ class VmCreateForm(forms.Form):
Field
(
"networks"
,
css_class
=
"form-control"
,
id
=
"vm-create-network-add-
managed
"
,
id
=
"vm-create-network-add-
vlan
"
,
),
css_class
=
"js-hidden"
,
style
=
"padding-top: 15px; max-width: 450px;"
,
...
...
@@ -225,7 +225,8 @@ class VmCreateForm(forms.Form):
Div
(
AnyTag
(
"select"
,
css_class
=
"form-control"
,
css_class
=
(
"form-control "
"font-awesome-font"
),
css_id
=
"vm-create-network-add-select"
,
),
Div
(
...
...
circle/dashboard/static/dashboard/dashboard.css
View file @
04eae09e
...
...
@@ -258,3 +258,8 @@ a.hover-black {
.dashboard-vm-details-network-h3
{
margin-top
:
20px
;
}
/* font awesome font */
.font-awesome-font
{
font-family
:
"FontAwesome"
;
}
circle/dashboard/static/dashboard/vm-create.js
View file @
04eae09e
...
...
@@ -25,8 +25,10 @@ function vmCreateLoaded() {
/* add network */
$
(
'#vm-create-network-add-button'
).
click
(
function
()
{
var
vlan_pk
=
$
(
'#vm-create-network-add-select :selected'
).
val
();
var
managed
=
$
(
'#vm-create-network-add-
checkbox-managed'
).
prop
(
'check
ed'
);
var
managed
=
$
(
'#vm-create-network-add-
select :selected'
).
data
(
'manag
ed'
);
var
name
=
$
(
'#vm-create-network-add-select :selected'
).
text
();
// remove the hex chars
name
=
name
.
substring
(
name
.
indexOf
(
" "
),
name
.
length
);
if
(
$
(
'#vm-create-network-list'
).
children
(
'span'
).
length
<
1
)
{
$
(
'#vm-create-network-list'
).
html
(
''
);
...
...
@@ -34,20 +36,16 @@ function vmCreateLoaded() {
$
(
'#vm-create-network-list'
).
append
(
vmCreateNetworkLabel
(
vlan_pk
,
name
,
managed
)
);
/* select the network from the managed/unmanaged multiple select */
if
(
managed
)
{
$
(
'#vm-create-network-add-managed option[value="'
+
vlan_pk
+
'"]'
).
prop
(
'selected'
,
true
);
}
else
{
$
(
'#vm-create-network-add-unmanaged option[value="'
+
vlan_pk
+
'"]'
).
prop
(
'selected'
,
true
);
}
/* select the network in the hidden network select */
$
(
'#vm-create-network-add-vlan option[value="'
+
vlan_pk
+
'"]'
).
prop
(
'selected'
,
true
);
$
(
'option:selected'
,
$
(
'#vm-create-network-add-select'
)).
remove
();
/* add dummy text if no more networks are available */
if
(
$
(
'#vm-create-network-add-select option'
).
length
<
1
)
{
$
(
'#vm-create-network-add-button'
).
attr
(
'disabled'
,
true
);
$
(
'#vm-create-network-add-select'
).
html
(
'<option value="-1">
We are out of <options> hehe
</option>'
);
$
(
'#vm-create-network-add-select'
).
html
(
'<option value="-1">
No more networks!
</option>'
);
}
return
false
;
...
...
@@ -71,13 +69,13 @@ function vmCreateLoaded() {
$
(
this
).
remove
();
var
vlan_name
=
$
(
this
).
text
();
$
(
'#vm-create-network-add-select'
).
append
(
$
(
'<option>'
,
{
value
:
vlan_pk
,
text
:
vlan_name
})
);
var
html
=
'<option data-managed="'
+
(
managed
?
1
:
0
)
+
'" value="'
+
vlan_pk
+
'">'
+
(
managed
?
""
:
""
)
+
vlan_name
+
'</option>'
;
$
(
'#vm-create-network-add-select'
).
append
(
html
);
/* remove the selection from the multiple select */
$
(
'#vm-create-network-add-
'
+
(
managed
?
''
:
'un'
)
+
'managed
option[value="'
+
vlan_pk
+
'"]'
).
prop
(
'selected'
,
false
);
$
(
'#vm-create-network-add-
vlan
option[value="'
+
vlan_pk
+
'"]'
).
prop
(
'selected'
,
false
);
if
(
$
(
'#vm-create-network-list'
).
children
(
'span'
).
length
<
1
)
{
$
(
'#vm-create-network-list'
).
append
(
'Not added to any network!'
);
}
...
...
@@ -86,7 +84,18 @@ function vmCreateLoaded() {
});
/* copy networks from hidden select */
$
(
'#vm-create-network-add-select'
).
html
(
$
(
'#vm-create-network-add-managed'
).
html
());
$
(
'#vm-create-network-add-vlan option'
).
each
(
function
()
{
var
managed
=
$
(
this
).
text
().
indexOf
(
"mana"
)
==
0
;
var
text
=
$
(
this
).
text
();
var
pk
=
$
(
this
).
val
();
if
(
managed
)
{
text
=
text
.
replace
(
"managed -"
,
""
);
}
else
{
text
=
text
.
replace
(
"unmanaged -"
,
""
);
}
var
html
=
'<option data-managed="'
+
(
managed
?
1
:
0
)
+
'" value="'
+
pk
+
'">'
+
text
+
'</option>'
;
$
(
'#vm-create-network-add-select'
).
append
(
html
);
});
/* build up network list */
...
...
@@ -201,6 +210,10 @@ function vmCreateLoaded() {
});
return
false
;
});
/* for no js stuff */
$
(
'.no-js-hidden'
).
show
();
$
(
'.js-hidden'
).
hide
();
}
function
vmCreateTemplateChange
(
new_this
)
{
...
...
@@ -220,8 +233,8 @@ function vmCreateTemplateChange(new_this) {
refreshSliders
();
/* clear selections */
$
(
'select[id^="vm-create-network-add"], select[id$="managed"]'
).
find
(
'option'
).
prop
(
'selected'
,
false
);
$
(
'#vm-create-disk-add-form'
).
find
(
'option'
).
prop
(
'selected'
,
false
);
$
(
"#vm-create-network-add-vlan"
).
find
(
'option'
).
prop
(
'selected'
,
false
);
$
(
'#vm-create-disk-add-form'
).
find
(
'option'
).
prop
(
'selected'
,
false
);
/* append vlans from InterfaceTemplates */
$
(
'#vm-create-network-list'
).
html
(
''
);
...
...
@@ -232,12 +245,13 @@ function vmCreateTemplateChange(new_this) {
vmCreateNetworkLabel
(
nn
.
vlan_pk
,
nn
.
vlan
,
nn
.
managed
)
);
$
(
'#vm-create-network-add-
'
+
(
nn
.
managed
?
''
:
'un'
)
+
'managed
option[value="'
+
nn
.
vlan_pk
+
'"]'
).
prop
(
'selected'
,
true
);
$
(
'#vm-create-network-add-
vlan
option[value="'
+
nn
.
vlan_pk
+
'"]'
).
prop
(
'selected'
,
true
);
added_vlans
.
push
(
nn
.
vlan_pk
);
}
/* remove already added vlans from dropdown or add new ones */
$
(
'#vm-create-network-add-select'
).
html
(
''
);
// this is working because the vlans array already has the icon's hex code
for
(
var
i
=
0
;
i
<
vlans
.
length
;
i
++
)
if
(
added_vlans
.
indexOf
(
vlans
[
i
].
pk
)
==
-
1
)
$
(
'#vm-create-network-add-select'
).
append
(
$
(
'<option>'
,
{
...
...
@@ -245,11 +259,11 @@ function vmCreateTemplateChange(new_this) {
text
:
vlans
[
i
].
name
}));
/* ena
lb
e the network add button if there are not added vlans */
/* ena
bl
e the network add button if there are not added vlans */
if
(
added_vlans
.
length
!=
vlans
.
length
)
{
$
(
'#vm-create-network-add-button'
).
attr
(
'disabled'
,
false
);
}
else
{
$
(
'#vm-create-network-add-select'
).
html
(
'<option value="-1">
We are out of <options> hehe
</option>'
);
$
(
'#vm-create-network-add-select'
).
html
(
'<option value="-1">
No more networks!
</option>'
);
$
(
'#vm-create-network-add-button'
).
attr
(
'disabled'
,
true
);
}
...
...
@@ -276,7 +290,7 @@ function vmCreateTemplateChange(new_this) {
text
:
disks
[
i
].
name
}));
/* ena
lb
e the disk add button if there are not added disks */
/* ena
bl
e the disk add button if there are not added disks */
if
(
added_disks
.
length
!=
disks
.
length
)
{
$
(
'#vm-create-disk-add-button'
).
attr
(
'disabled'
,
false
);
}
else
{
...
...
circle/firewall/models.py
View file @
04eae09e
...
...
@@ -262,7 +262,8 @@ class Vlan(AclBase, models.Model):
verbose_name
=
_
(
'modified at'
))
def
__unicode__
(
self
):
return
self
.
name
return
"
%
s -
%
s"
%
(
"managed"
if
self
.
managed
else
"unmanaged"
,
self
.
name
)
@models.permalink
def
get_absolute_url
(
self
):
...
...
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