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
91d2da9d
Commit
91d2da9d
authored
Apr 16, 2011
by
Markos Gogoulos
Browse files
Merge branch 'ui-0.2' of
https://code.grnet.gr/git/synnefo
into ui-0.2
parents
6bbb5d04
2604e505
Changes
3
Hide whitespace changes
Inline
Side-by-side
ui/static/synnefo.js
View file @
91d2da9d
var
flavors
=
[],
images
=
[],
servers
=
[],
disks
=
[],
cpus
=
[],
ram
=
[];
var
changes_since
=
0
,
deferred
=
0
,
update_request
=
false
,
load_request
=
false
,
pending_actions
=
[];
var
API_URL
=
"
/api/v1.1
"
;
var
serverlength
=
0
;
function
ISODateString
(
d
){
//return a date in an ISO 8601 format using UTC.
...
...
@@ -71,6 +72,7 @@ function update_confirmations(){
}
function
list_view
()
{
serverlength
=
0
;
// reset server length
changes_since
=
0
;
// to reload full list
pending_actions
=
[];
// clear pending actions
update_confirmations
();
...
...
@@ -101,6 +103,7 @@ function list_view() {
}
function
standard_view
()
{
serverlength
=
0
;
// reset server length
changes_since
=
0
;
// to reload full list
pending_actions
=
[];
// clear pending actions
update_confirmations
();
...
...
@@ -702,6 +705,7 @@ function get_metadata(serverID) {
// show the welcome screen
function
showWelcome
()
{
$
(
"
#view-select
"
).
fadeOut
(
"
fast
"
);
$
(
"
#machinesview.standard
"
).
fadeOut
(
"
fast
"
);
$
(
"
#createcontainer
"
).
addClass
(
'
emptycreatecontainer
'
)
$
(
"
#create
"
).
addClass
(
'
emptycreate
'
)
$
(
"
#emptymachineslist
"
).
fadeIn
(
"
fast
"
);
...
...
@@ -716,6 +720,7 @@ function hideWelcome() {
$
(
"
#createcontainer
"
).
removeClass
(
'
emptycreatecontainer
'
)
$
(
"
#create
"
).
removeClass
(
'
emptycreate
'
)
$
(
"
#view-select
"
).
fadeIn
(
"
fast
"
);
$
(
"
#machinesview.standard
"
).
fadeIn
(
"
fast
"
);
$
(
"
div#view-select
"
).
show
();
$
(
"
#create
"
).
css
(
"
display
"
,
"
inline
"
);
}
...
...
ui/templates/list.html
View file @
91d2da9d
...
...
@@ -122,6 +122,7 @@ $("a.enabled#action-destroy").live('click', function() {
checked
.
each
(
function
(
i
,
c
)
{
serverID
=
c
.
id
;
serverName
=
$
(
'
#
'
+
serverID
+
'
span.name
'
).
text
();
serverlength
-=
1
;
pending_actions
.
push
([
destroy
,
serverID
]);
});
update_confirmations
();
...
...
@@ -170,12 +171,15 @@ $("a.enabled#action-shutdown").live('click', function() {
return
false
;
});
function
update_machines_view
(
data
){
/*
Go through the servers in the input data. Update existing entries, add
new ones to the list
*/
tableData
=
vmTable
.
fnGetData
();
$
.
each
(
data
.
servers
.
values
,
function
(
i
,
server
){
current
=
-
1
;
// check server status to select the appropriate OS icon
...
...
@@ -189,7 +193,7 @@ function update_machines_view(data){
current
=
index
;
}
});
serverlength
+=
1
;
if
(
current
!=
-
1
)
{
// if it's there, update the values
// get current status description, including non api states
var
server_row
=
$
(
'
#
'
+
server
.
id
).
parent
().
parent
();
...
...
@@ -198,14 +202,10 @@ function update_machines_view(data){
try
{
console
.
info
(
server
.
name
+
'
from
'
+
status_desc
+
'
to
'
+
STATUS_MESSAGES
[
server
.
status
]);
}
catch
(
err
)
{}
serverlength
-=
1
;
// when server is in deleted status it must be removed from the list
if
(
server
.
status
==
"
DELETED
"
)
{
vmTable
.
fnDeleteRow
(
current
);
// Reload the page to check if server list is empty
if
(
tableData
.
length
==
1
)
{
hideWelcome
()
standard_view
();
}
}
else
{
// when server is not be deleted, it should be updated
if
([
'
BUILD
'
,
'
ACTIVE
'
,
'
REBOOT
'
].
indexOf
(
server
.
status
)
>=
0
&&
[
STATUS_MESSAGES
[
'
STOPPED
'
],
STATUS_MESSAGES
[
'
ERROR
'
],
...
...
@@ -286,6 +286,8 @@ function update_machines_view(data){
"
group
"
,
"
<span class=status>
"
+
STATUS_MESSAGES
[
server
.
status
]
+
"
</span>
"
]);
}
else
if
(
server
.
status
==
"
DELETED
"
)
{
serverlength
-=
1
;
}
});
updateActions
();
...
...
@@ -299,9 +301,11 @@ function update_machines_view(data){
}
// show message in case user has no servers!
if
(
servers
.
length
>
0
)
{
if
(
serverlength
==
0
)
{
standard_view
();
}
else
{
hideWelcome
();
$
(
"
#machinesview_content
"
).
fadeIn
(
"
fast
"
)
$
(
"
#machinesview_content
"
).
fadeIn
(
"
fast
"
)
;
}
// set confirm box position
...
...
ui/templates/standard.html
View file @
91d2da9d
...
...
@@ -141,6 +141,7 @@ $("div.actions a.action-destroy").live('click', function(){
$
(
this
).
addClass
(
'
selected
'
);
$
(
this
).
parent
().
addClass
(
'
display
'
)
$
(
this
).
parent
().
parent
().
find
(
'
.action_error
'
).
hide
();
serverlength
-=
1
;
for
(
i
=
0
;
i
<
pending_actions
.
length
;
i
++
){
// if there is already a pending action for this server replace it
if
(
pending_actions
[
i
][
1
]
==
serverID
){
...
...
@@ -212,8 +213,7 @@ function update_machines_view(data){
/*
Go through the servers in the input data. Update existing entries, add
new ones to the list
*/
*/
$
.
each
(
data
.
servers
.
values
,
function
(
i
,
server
){
existing
=
$
(
'
#
'
+
server
.
id
);
...
...
@@ -225,27 +225,25 @@ function update_machines_view(data){
var
server_image
=
os_icon
(
server
.
metadata
);
serverlength
+=
1
;
// server already exists in DOM
if
(
existing
.
length
){
serverlength
-=
1
;
$
(
"
div.machine:last-child
"
).
find
(
"
div.separator
"
).
show
();
// if the status is deleted, delete it from the DOM
if
(
server
.
status
==
'
DELETED
'
)
{
existing
.
remove
();
// Reload the page to check if server list is empty
standard_view
()
try
{
console
.
info
(
existing
.
find
(
"
a.name span.name
"
).
text
()
+
'
removed
'
);
}
catch
(
err
)
{}
}
else
if
(
existing
.
find
(
"
.status
"
).
text
()
!=
STATUS_MESSAGES
[
server
.
status
])
{
try
{
// firebug console logging
console
.
info
(
existing
.
find
(
"
a.name span.name
"
).
text
()
+
'
from
'
+
existing
.
find
(
"
.status
"
).
text
()
+
'
to
'
+
STATUS_MESSAGES
[
server
.
status
]);
}
catch
(
err
)
{}
//show reboot and shutdown actions
if
(
server
.
status
==
'
ACTIVE
'
||
server
.
status
==
'
REBOOT
'
)
{
$
(
'
div.#
'
+
server
.
id
+
'
a.action-reboot
'
).
attr
(
'
style
'
,
''
);
$
(
'
div.#
'
+
server
.
id
+
'
a.action-shutdown
'
).
attr
(
'
style
'
,
''
);
$
(
'
div.#
'
+
server
.
id
+
'
a.action-destroy
'
).
removeClass
(
'
destroy-padding
'
);
...
...
@@ -318,6 +316,8 @@ function update_machines_view(data){
$
(
'
div.#
'
+
server
.
id
+
'
a.action-shutdown
'
).
hide
();
$
(
'
div.#
'
+
server
.
id
+
'
a.action-destroy
'
).
addClass
(
'
destroy-padding
'
);
}
}
else
if
(
server
.
status
==
'
DELETED
'
)
{
serverlength
-=
1
;
}
});
...
...
@@ -334,10 +334,10 @@ function update_machines_view(data){
}
// show message in case user has no servers!
if
(
server
s
.
length
==
0
)
{
showWelcome
()
if
(
serverlength
==
0
)
{
showWelcome
()
;
}
else
{
hideWelcome
()
hideWelcome
()
;
}
// set confirm box position
...
...
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