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
30e7f843
Commit
30e7f843
authored
Apr 17, 2011
by
Mike Muzurakis
Browse files
renaming function and button, Refs #307
parent
641136fc
Changes
2
Show whitespace changes
Inline
Side-by-side
ui/static/synnefo.js
View file @
30e7f843
...
...
@@ -675,20 +675,19 @@ function start(serverIDs){
}
// rename action
function
rename
(
serverID
s
){
if
(
!
serverID
s
.
length
){
function
rename
(
serverID
,
serverName
){
if
(
!
serverID
.
length
){
//ajax_success('DEFAULT');
return
false
;
}
// ajax post rename call
var
payload
=
{
"
rename
"
:
{
"
typ
e
"
:
"
PUT
"
}
"
server
"
:
{
"
nam
e
"
:
serverName
}
};
var
serverID
=
serverIDs
.
pop
()
$
.
ajax
({
url
:
API_URL
+
'
/servers/
'
+
serverID
+
'
/action
'
,
type
:
"
P
OS
T
"
,
type
:
"
P
U
T
"
,
contentType
:
"
application/json
"
,
dataType
:
"
json
"
,
data
:
JSON
.
stringify
(
payload
),
...
...
@@ -703,8 +702,6 @@ function rename(serverIDs){
}
catch
(
err
)
{}
// indicate that the action succeeded
display_success
(
serverID
);
// continue with the rest of the servers
start
(
serverIDs
);
}
else
{
ajax_error
(
jqXHR
.
status
,
serverID
,
'
Rename
'
,
jqXHR
.
responseText
);
}
...
...
ui/templates/standard.html
View file @
30e7f843
...
...
@@ -73,7 +73,7 @@ $("a.show-metadata").live('click', function() {
return
false
;
});
//
renam
e machine
//
initiat
e machine
renaming
$
(
"
.rename, h5.editable span.name
"
).
live
(
'
click
'
,
function
()
{
$
(
this
).
parent
().
find
(
'
.name
'
).
html
(
"
<input id=
\"
txtEdit
\"
type=
\"
text
\"
class=
\"
nametextbox
\"
value=
\"
"
+
$
(
this
).
parent
().
find
(
'
.name
'
).
text
()
+
"
\"
/ ><span class=
\"
oldValue
\"
style=
\"
display:none;
\"
>
"
+
$
(
this
).
parent
().
find
(
'
.name
'
).
text
()
+
"
</span>
"
);
$
(
this
).
parent
().
find
(
'
.rename
'
).
hide
();
...
...
@@ -82,9 +82,27 @@ $(".rename, h5.editable span.name").live('click', function() {
return
false
;
});
//rename machine
$
(
"
.editbuttons .save
"
).
live
(
'
click
'
,
function
()
{
serverID
=
$
(
this
).
parent
().
parent
().
parent
().
attr
(
"
id
"
);
serverName
=
$
(
this
).
parent
().
parent
().
find
(
'
.name
'
).
find
(
'
.nametextbox
'
).
val
();
var
found
=
false
;
$
(
this
).
parent
().
parent
().
find
(
'
.name
'
).
html
(
$
(
this
).
parent
().
parent
().
find
(
'
.nametextbox
'
).
val
());
$
(
this
).
parent
().
parent
().
find
(
"
.editbuttons
"
).
fadeOut
(
"
fast
"
);
$
(
this
).
parent
().
parent
().
find
(
"
.rename
"
).
fadeIn
(
"
slow
"
);
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
){
pending_actions
[
i
][
0
]
=
rename
;
found
=
true
}
}
if
(
!
found
)
// no pending action for this server was found, so let's just add it to the list
pending_actions
.
push
([
rename
,
serverID
,
serverName
])
return
false
;
});
//cancel renaming
$
(
"
.editbuttons .cancel
"
).
live
(
'
click
'
,
function
()
{
console
.
info
(
$
(
this
).
parent
().
parent
().
find
(
'
.name
'
).
find
(
'
.oldValue
'
).
text
());
$
(
this
).
parent
().
parent
().
find
(
'
.name
'
).
html
(
$
(
this
).
parent
().
parent
().
find
(
'
.name
'
).
find
(
'
.oldValue
'
).
text
());
$
(
this
).
parent
().
parent
().
find
(
"
.editbuttons
"
).
hide
();
$
(
this
).
parent
().
parent
().
find
(
"
.rename
"
).
fadeIn
();
...
...
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