Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
751bd22c
Commit
751bd22c
authored
Apr 15, 2011
by
Christodoulos Psaltis
Browse files
Move functions to machine template for better code context
parent
91740bba
Changes
2
Hide whitespace changes
Inline
Side-by-side
ui/templates/machines.html
View file @
751bd22c
...
...
@@ -386,51 +386,6 @@ $('.radio').live('click' ,function() {
}
});
// confirm all actions
$
(
"
div.confirm_multiple .yes
"
).
live
(
'
click
'
,
function
(){
while
(
pending_actions
.
length
>
0
){
// if there is a pending action for this server execute it
action
=
pending_actions
.
pop
();
// extract action
var
serverID
=
action
[
1
];
if
(
$
.
cookie
(
"
list
"
)
!=
'
1
'
)
{
// standard view
$
(
'
#
'
+
serverID
+
'
.selected
'
).
removeClass
(
'
selected
'
);
$
(
'
#
'
+
serverID
+
'
.display
'
).
removeClass
(
'
display
'
);
if
(
action
[
0
]
==
shutdown
)
{
$
(
'
#
'
+
serverID
+
'
.status
'
).
text
(
'
Shutting down
'
);
}
else
if
(
action
[
0
]
==
start
)
{
$
(
'
#
'
+
serverID
+
'
.status
'
).
text
(
'
Starting
'
);
}
else
if
(
action
[
0
]
==
reboot
)
{
$
(
'
#
'
+
serverID
+
'
.status
'
).
text
(
'
Rebooting
'
);
}
else
if
(
action
[
0
]
==
destroy
)
{
$
(
'
#
'
+
serverID
+
'
.status
'
).
text
(
'
Destroying
'
);
}
$
(
'
#
'
+
serverID
+
'
.spinner
'
).
show
();
}
else
{
// list view
osIcon
=
$
(
'
#
'
+
serverID
).
parent
().
parent
().
find
(
'
.list-logo
'
);
osIcon
.
attr
(
'
os
'
,
osIcon
.
attr
(
'
src
'
));
osIcon
.
attr
(
'
src
'
,
'
static/progress.gif
'
);
if
(
action
[
0
]
==
shutdown
)
{
$
(
'
#
'
+
serverID
).
parent
().
parent
().
find
(
'
span.status
'
).
text
(
'
Shutting down
'
);
}
else
if
(
action
[
0
]
==
start
)
{
$
(
'
#
'
+
serverID
).
parent
().
parent
().
find
(
'
span.status
'
).
text
(
'
Starting
'
);
}
else
if
(
action
[
0
]
==
reboot
)
{
$
(
'
#
'
+
serverID
).
parent
().
parent
().
find
(
'
span.status
'
).
text
(
'
Rebooting
'
);
}
else
if
(
action
[
0
]
==
destroy
)
{
$
(
'
#
'
+
serverID
).
parent
().
parent
().
find
(
'
span.status
'
).
text
(
'
Destroying
'
);
}
}
action
[
0
]([
serverID
]);
// execute action
}
update_confirmations
();
});
// cancel all actions
$
(
"
div.confirm_multiple .no
"
).
live
(
'
click
'
,
function
(){
pending_actions
=
[];
$
(
'
.machine .selected
'
).
removeClass
(
'
selected
'
);
$
(
'
.machine .display
'
).
removeClass
(
'
display
'
);
update_confirmations
();
});
// validate cpu input box
$
(
"
#cpu-indicator
"
).
live
(
'
change
'
,
function
(){
var
v
=
Number
(
this
.
value
);
...
...
@@ -582,6 +537,125 @@ $("#start").click(function(){
$
(
"
#wizard
"
).
hide
();
});
// confirm all actions
$
(
"
div.confirm_multiple .yes
"
).
live
(
'
click
'
,
function
(){
while
(
pending_actions
.
length
>
0
){
// if there is a pending action for this server execute it
action
=
pending_actions
.
pop
();
// extract action
var
serverID
=
action
[
1
];
if
(
$
.
cookie
(
"
list
"
)
!=
'
1
'
)
{
// standard view
$
(
'
#
'
+
serverID
+
'
.selected
'
).
removeClass
(
'
selected
'
);
$
(
'
#
'
+
serverID
+
'
.display
'
).
removeClass
(
'
display
'
);
if
(
action
[
0
]
==
shutdown
)
{
$
(
'
#
'
+
serverID
+
'
.status
'
).
text
(
'
Shutting down
'
);
}
else
if
(
action
[
0
]
==
start
)
{
$
(
'
#
'
+
serverID
+
'
.status
'
).
text
(
'
Starting
'
);
}
else
if
(
action
[
0
]
==
reboot
)
{
$
(
'
#
'
+
serverID
+
'
.status
'
).
text
(
'
Rebooting
'
);
}
else
if
(
action
[
0
]
==
destroy
)
{
$
(
'
#
'
+
serverID
+
'
.status
'
).
text
(
'
Destroying
'
);
}
$
(
'
#
'
+
serverID
+
'
.spinner
'
).
show
();
}
else
{
// list view
osIcon
=
$
(
'
#
'
+
serverID
).
parent
().
parent
().
find
(
'
.list-logo
'
);
osIcon
.
attr
(
'
os
'
,
osIcon
.
attr
(
'
src
'
));
osIcon
.
attr
(
'
src
'
,
'
static/progress.gif
'
);
if
(
action
[
0
]
==
shutdown
)
{
$
(
'
#
'
+
serverID
).
parent
().
parent
().
find
(
'
span.status
'
).
text
(
'
Shutting down
'
);
}
else
if
(
action
[
0
]
==
start
)
{
$
(
'
#
'
+
serverID
).
parent
().
parent
().
find
(
'
span.status
'
).
text
(
'
Starting
'
);
}
else
if
(
action
[
0
]
==
reboot
)
{
$
(
'
#
'
+
serverID
).
parent
().
parent
().
find
(
'
span.status
'
).
text
(
'
Rebooting
'
);
}
else
if
(
action
[
0
]
==
destroy
)
{
$
(
'
#
'
+
serverID
).
parent
().
parent
().
find
(
'
span.status
'
).
text
(
'
Destroying
'
);
}
}
action
[
0
]([
serverID
]);
// execute action
}
update_confirmations
();
});
// cancel all actions
$
(
"
div.confirm_multiple .no
"
).
live
(
'
click
'
,
function
(){
pending_actions
=
[];
$
(
'
.machine .selected
'
).
removeClass
(
'
selected
'
);
$
(
'
.machine .display
'
).
removeClass
(
'
display
'
);
update_confirmations
();
});
// bring up edit metadata overlay
function
editMetadata
(
serverID
,
serverName
)
{
// set server name in box's title
$
(
"
#editor-1 h3 span
"
).
text
(
serverName
);
var
triggers
=
$
(
"
a#meta-editor-1
"
).
overlay
({
// some mask tweaks suitable for modal dialogs
mask
:
'
#000
'
,
effect
:
'
default
'
,
top
:
'
10%
'
,
closeOnClick
:
false
,
oneInstance
:
false
,
load
:
false
});
// get metadata for current server
// TODO
$
(
"
a#meta-editor-1
"
).
data
(
'
overlay
'
).
load
();
return
false
;
}
// bring up add metadata overlay
function
addMetadata
(
serverID
,
serverName
)
{
// set server name in box's title
$
(
"
#editor-2 h3 span
"
).
text
(
serverName
);
var
triggers
=
$
(
"
a#meta-editor-2
"
).
overlay
({
// some mask tweaks suitable for modal dialogs
mask
:
'
#000
'
,
effect
:
'
default
'
,
top
:
'
10%
'
,
closeOnClick
:
false
,
oneInstance
:
false
,
load
:
false
});
$
(
"
a#meta-editor-2
"
).
data
(
'
overlay
'
).
load
();
return
false
;
}
// intercept click on create button in metadata edit dialog
$
(
'
#editor-1.meta-modal button.create
'
).
click
(
function
(){
// go from edit metadata to add metadata
$
(
'
a#meta-editor-1
'
).
data
(
'
overlay
'
).
close
();
addMetadata
(
'
1
'
,
'
name
'
);
});
// intercept click on remove button in metadata edit dialog
$
(
'
#editor-1.meta-modal button.create
'
).
click
(
function
(){
// ajax call to delete selected metadata key-value pair
// if successful remove it from the overlay
// TODO
});
// intercept click on edit button in metadata edit dialog
$
(
'
#editor-1.meta-modal button.create
'
).
click
(
function
(){
// inline editing of selected key-value pair
// on submission ajax call from updating
// on success update the overlay
// TODO
});
// intercept click on cancel button in metadata add dialog
$
(
'
#editor-2.meta-modal button.cancel
'
).
click
(
function
(){
// go from add meatata to edit metadata
$
(
'
a#meta-editor-2
'
).
data
(
'
overlay
'
).
close
();
editMetadata
(
'
1
'
,
'
name
'
);
});
// intercept click on save button in metadata add dialog
$
(
'
#editor-2.meta-modal button.save
'
).
click
(
function
(){
// ajax call to save metadata
//TODO
// go from add meatata to edit metadata
$
(
'
a#meta-editor-2
'
).
data
(
'
overlay
'
).
close
();
editMetadata
(
'
1
'
,
'
name
'
);
});
// basic functions executed on page load
if
(
images
.
length
>
0
)
{
// populate image list
...
...
ui/templates/standard.html
View file @
751bd22c
...
...
@@ -52,24 +52,13 @@
<script>
// intercept metadata click
// intercept
edit
metadata click
$
(
"
a.show-metadata
"
).
live
(
'
click
'
,
function
()
{
// get server name and server ID
var
serverID
=
$
(
this
).
parent
().
parent
().
attr
(
"
id
"
);
var
serverName
=
$
(
this
).
parent
().
prevAll
(
"
a.name
"
).
find
(
"
span.name
"
).
text
();
// set server name in box's title
$
(
"
#editor-1 h3 span
"
).
text
(
serverName
);
var
triggers
=
$
(
"
a#meta-editor-1
"
).
overlay
({
// some mask tweaks suitable for modal dialogs
mask
:
'
#000
'
,
effect
:
'
default
'
,
top
:
'
10%
'
,
closeOnClick
:
false
,
oneInstance
:
false
,
load
:
false
});
$
(
"
a#meta-editor-1
"
).
data
(
'
overlay
'
).
load
();
return
false
;
editMetadata
(
serverID
,
serverName
);
});
// intercept create new metadata entry click
...
...
@@ -77,19 +66,7 @@ $("a.show-group").live('click', function() {
// get server name and server ID
var
serverID
=
$
(
this
).
parent
().
parent
().
attr
(
"
id
"
);
var
serverName
=
$
(
this
).
parent
().
prevAll
(
"
a.name
"
).
find
(
"
span.name
"
).
text
();
// set server name in box's title
$
(
"
#editor-2 h3 span
"
).
text
(
serverName
);
var
triggers
=
$
(
"
a#meta-editor-2
"
).
overlay
({
// some mask tweaks suitable for modal dialogs
mask
:
'
#000
'
,
effect
:
'
default
'
,
top
:
'
10%
'
,
closeOnClick
:
false
,
oneInstance
:
false
,
load
:
false
});
$
(
"
a#meta-editor-2
"
).
data
(
'
overlay
'
).
load
();
return
false
;
addMetadata
(
serverID
,
serverName
);
});
// intercept reboot click
...
...
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