Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
File Transfer Service
fts-rest
Commits
5c1bdc0a
Commit
5c1bdc0a
authored
Nov 12, 2018
by
Andrea Manzi
Browse files
FTS-1100
: fix handling of update/save links
parent
89266d46
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/fts3rest/fts3rest/public/js/config/links.js
View file @
5c1bdc0a
...
...
@@ -14,12 +14,14 @@
* limitations under the License.
**/
/**
* Updates the list of link configurations
*/
function
refreshLinks
()
{
var
tbody
=
$
(
"
#link-config-list
"
);
$
.
ajax
({
url
:
"
/config/links?
"
,
headers
:
{
...
...
@@ -32,7 +34,7 @@ function refreshLinks()
$
.
each
(
data
,
function
(
i
,
link
)
{
var
tr
=
$
(
"
<tr></tr>
"
);
var
deleteBtn
=
$
(
"
<button class='btn btn-link' type='button'></button>
"
)
var
deleteBtn
=
$
(
"
<button class='btn btn-link' type='button'
id='button_delete_link' name='lndel_
"
+
link
.
symbolicname
+
"
'
></button>
"
)
.
append
(
"
<i class='glyphicon glyphicon-trash'></i>
"
);
deleteBtn
.
click
(
function
()
{
...
...
@@ -50,41 +52,40 @@ function refreshLinks()
tr
.
css
(
"
background
"
,
"
#ffffff
"
);
});
});
var
updateBtn
=
$
(
"
<button class='btn btn-link' type='button'></button>
"
)
.
append
(
"
<i class='glyphicon glyphicon-floppy-disk'></i>
"
);
tr
.
append
(
$
(
"
<td></td>
"
).
append
(
deleteBtn
))
.
append
(
$
(
"
<td></td>
"
).
append
(
updateBtn
))
var
updateBtn
=
$
(
"
<button class='btn btn-link' type='button'></button>
"
)
.
append
(
"
<i class='glyphicon glyphicon-floppy-disk'></i>
"
);
tr
.
append
(
$
(
"
<td></td>
"
).
append
(
deleteBtn
).
append
(
updateBtn
))
.
append
(
$
(
"
<td></td>
"
)
.
append
(
$
(
"
<input type='text' name='symbolicname' class='form-control'/>
"
).
val
(
link
.
symbolicname
)))
.
append
(
$
(
"
<input type='text' name='symbolicname
_
"
+
link
.
symbolicname
+
"
' class='form-control'/>
"
).
val
(
link
.
symbolicname
)))
.
append
(
$
(
"
<td></td>
"
)
.
append
(
$
(
"
<input type='text' name='source' class='form-control'/>
"
).
val
(
link
.
source
)))
.
append
(
$
(
"
<input type='text' name='source
_
"
+
link
.
symbolicname
+
"
' class='form-control'/>
"
).
val
(
link
.
source
)))
.
append
(
$
(
"
<td></td>
"
)
.
append
(
$
(
"
<input type='text' name='destination' class='form-control'/>
"
).
val
(
link
.
destination
)))
.
append
(
$
(
"
<input type='text' name='destination
_
"
+
link
.
symbolicname
+
"
' class='form-control'/>
"
).
val
(
link
.
destination
)))
.
append
(
$
(
"
<td></td>
"
)
.
append
(
$
(
"
<input type='number' name='nostreams' min='0' max='16' class='form-control'/>
"
).
val
(
link
.
nostreams
)))
.
append
(
$
(
"
<input type='number' name='nostreams
_
"
+
link
.
symbolicname
+
"
' min='0' max='16' class='form-control'/>
"
).
val
(
link
.
nostreams
)))
.
append
(
$
(
"
<td></td>
"
)
.
append
(
$
(
"
<input type='number' name='min_active' class='form-control'/>
"
).
val
(
link
.
min_active
)))
.
append
(
$
(
"
<input type='number' name='min_active
_
"
+
link
.
symbolicname
+
"
' class='form-control'/>
"
).
val
(
link
.
min_active
)))
.
append
(
$
(
"
<td></td>
"
)
.
append
(
$
(
"
<input type='number' name='max_active' class='form-control'/>
"
).
val
(
link
.
max_active
)))
.
append
(
$
(
"
<input type='number' name='max_active
_
"
+
link
.
symbolicname
+
"
' class='form-control'/>
"
).
val
(
link
.
max_active
)))
.
append
(
$
(
"
<td></td>
"
)
.
append
(
$
(
"
<input type='number' name='optimizer_mode' min='0' max='3' class='form-control'/>
"
).
val
(
link
.
optimizer_mode
)))
.
append
(
$
(
"
<input type='number' name='optimizer_mode
_
"
+
link
.
symbolicname
+
"
' min='0' max='3' class='form-control'/>
"
).
val
(
link
.
optimizer_mode
)))
.
append
(
$
(
"
<td></td>
"
)
.
append
(
$
(
"
<input type='number' name='tcp_buffer_size' class='form-control'/>
"
).
val
(
link
.
tcp_buffer_size
)));
.
append
(
$
(
"
<input type='number' name='tcp_buffer_size
_
"
+
link
.
symbolicname
+
"
' class='form-control'/>
"
).
val
(
link
.
tcp_buffer_size
)));
tbody
.
append
(
tr
);
updateBtn
.
click
(
function
()
{
// tr.css("background", "#3CB371");
var
saveload
=
{
symbolicname
:
tr
.
find
(
"
input[name='symbolicname']
"
).
val
(),
source
:
tr
.
find
(
"
input[name='source']
"
).
val
(),
destination
:
tr
.
find
(
"
input[name='destination']
"
).
val
(),
nostreams
:
tr
.
find
(
"
input[name='nostreams']
"
).
val
(),
min_active
:
tr
.
find
(
"
input[name='min_active']
"
).
val
(),
max_active
:
tr
.
find
(
"
input[name='max_active']
"
).
val
(),
optimizer_mode
:
tr
.
find
(
"
input[name='optimizer_mode']
"
).
val
(),
tcp_buffer_size
:
tr
.
find
(
"
input[name='tcp_buffer_size']
"
).
val
()
symbolicname
:
tr
.
find
(
"
input[name='symbolicname
_
"
+
link
.
symbolicname
+
"
']
"
).
val
(),
source
:
tr
.
find
(
"
input[name='source
_
"
+
link
.
symbolicname
+
"
']
"
).
val
(),
destination
:
tr
.
find
(
"
input[name='destination
_
"
+
link
.
symbolicname
+
"
']
"
).
val
(),
nostreams
:
tr
.
find
(
"
input[name='nostreams
_
"
+
link
.
symbolicname
+
"
']
"
).
val
(),
min_active
:
tr
.
find
(
"
input[name='min_active
_
"
+
link
.
symbolicname
+
"
']
"
).
val
(),
max_active
:
tr
.
find
(
"
input[name='max_active
_
"
+
link
.
symbolicname
+
"
']
"
).
val
(),
optimizer_mode
:
tr
.
find
(
"
input[name='optimizer_mode
_
"
+
link
.
symbolicname
+
"
']
"
).
val
(),
tcp_buffer_size
:
tr
.
find
(
"
input[name='tcp_buffer_size
_
"
+
link
.
symbolicname
+
"
']
"
).
val
()
};
console
.
log
(
saveload
);
$
.
ajax
({
...
...
@@ -96,8 +97,8 @@ function refreshLinks()
})
.
done
(
function
()
{
tr
.
find
(
"
input
"
).
prop
(
"
disabled
"
,
false
)
tr
.
css
(
"
background
"
,
"
#3CB371
"
);
refreshLinks
();
tr
.
css
(
"
background
"
,
"
#3CB371
"
);
refreshLinks
();
})
.
fail
(
function
(
jqXHR
)
{
...
...
@@ -130,18 +131,18 @@ function refreshShares()
$
.
each
(
data
,
function
(
i
,
share
)
{
var
tr
=
$
(
"
<tr></tr>
"
);
var
deleteBtn
=
$
(
"
<a class='btn btn-link'><i class='glyphicon glyphicon-trash'></i></a>
"
);
tr
.
append
(
$
(
"
<td></td>
"
).
append
(
deleteBtn
))
.
append
(
$
(
"
<td></td>
"
).
text
(
share
.
source
)
.
append
(
$
(
"
<input type='hidden' name='source'/>
"
).
val
(
share
.
source
)))
.
append
(
$
(
"
<td></td>
"
).
text
(
share
.
destination
)
.
append
(
$
(
"
<input type='hidden' name='destination'/>
"
).
val
(
share
.
destination
)))
.
append
(
$
(
"
<td></td>
"
).
text
(
share
.
vo
)
.
append
(
$
(
"
<input type='hidden' name='vo'/>
"
).
val
(
share
.
vo
)))
.
append
(
$
(
"
<td></td>
"
)
.
append
(
$
(
"
<input type='number' name='share' class='form-control'/>
"
).
val
(
share
.
share
))
var
deleteBtn
=
$
(
"
<a class='btn btn-link'
id='button_delete_share' name='shdel_
"
+
share
.
source
+
"
_
"
+
share
.
vo
+
"
'
><i class='glyphicon glyphicon-trash'></i></a>
"
);
var
saveBtn
=
$
(
"
<a class='btn btn-link' id='button_save_share'><i class='glyphicon glyphicon-floppy-disk'></i></a>
"
);
tr
.
append
(
$
(
"
<td></td>
"
).
append
(
deleteBtn
,
saveBtn
))
.
append
(
$
(
"
<td
id='share_name'
></td>
"
).
text
(
share
.
source
)
.
append
(
$
(
"
<input type='hidden' name='source
-saved
'/>
"
).
val
(
share
.
source
)))
.
append
(
$
(
"
<td
id='dn_name'
></td>
"
).
text
(
share
.
destination
)
.
append
(
$
(
"
<input type='hidden' name='destination
-saved
'/>
"
).
val
(
share
.
destination
)))
.
append
(
$
(
"
<td
id='vo_name'
></td>
"
).
text
(
share
.
vo
)
.
append
(
$
(
"
<input type='hidden' name='vo
-saved
'/>
"
).
val
(
share
.
vo
)))
.
append
(
$
(
"
<td
id='sh_name'
></td>
"
)
.
append
(
$
(
"
<input type='number' name='share
-saved
' class='form-control'
min='1'
/>
"
).
val
(
share
.
share
))
);
tbody
.
append
(
tr
);
...
...
@@ -163,6 +164,49 @@ function refreshShares()
});
});
saveBtn
.
click
(
function
(
event
)
{
var
share_wrong
=
tr
.
find
(
"
input[name='share-saved']
"
)
//console.log(encodeURIComponent(share.share))
tr
.
css
(
"
background
"
,
"
#3c763d
"
);
tr
.
find
(
"
input
"
).
prop
(
"
disabled
"
,
true
);
tr
.
find
(
"
select
"
).
prop
(
"
disabled
"
,
true
);
if
(
tr
.
find
(
"
input[name='share-saved']
"
).
val
()
<
0
){
errorMessage
(
jqXHR
);
tr
.
find
(
"
input
"
).
prop
(
"
disabled
"
,
false
);
tr
.
find
(
"
select
"
).
prop
(
"
disabled
"
,
false
);
tr
.
css
(
"
background
"
,
"
#ffffff
"
);
share_wrong
.
val
(
encodeURIComponent
(
share
.
share
));
}
else
{
$
.
ajax
({
url
:
"
/config/shares?
"
,
type
:
"
POST
"
,
dataType
:
"
json
"
,
contentType
:
"
application/json
"
,
data
:
JSON
.
stringify
({
source
:
share
.
source
,
destination
:
share
.
destination
,
vo
:
share
.
vo
,
share
:
tr
.
find
(
"
input[name='share-saved']
"
).
val
()
})
})
.
done
(
function
(
data
,
textStatus
,
jqXHR
)
{
tr
.
css
(
"
background
"
,
"
none
"
);
tr
.
find
(
"
input
"
).
prop
(
"
disabled
"
,
false
);
tr
.
find
(
"
select
"
).
prop
(
"
disabled
"
,
false
);
})
.
fail
(
function
(
jqXHR
)
{
errorMessage
(
jqXHR
);
tr
.
find
(
"
input
"
).
prop
(
"
disabled
"
,
false
);
tr
.
find
(
"
select
"
).
prop
(
"
disabled
"
,
false
);
tr
.
css
(
"
background
"
,
"
#ffffff
"
);
share_wrong
.
val
(
encodeURIComponent
(
share
.
share
))
})};
});
});
})
.
fail
(
function
(
jqXHR
)
{
...
...
@@ -222,7 +266,8 @@ function setupLinks()
symbolicname
:
addFrm
.
find
(
"
[name=symbolicname]
"
).
val
(),
source
:
addFrm
.
find
(
"
[name=source]
"
).
val
(),
destination
:
addFrm
.
find
(
"
[name=destination]
"
).
val
(),
nostreams
:
addFrm
.
find
(
"
[name=nostreams]
"
).
val
(),
min_active
:
addFrm
.
find
(
"
[name=min_active]
"
).
val
(),
max_active
:
addFrm
.
find
(
"
[name=max_active]
"
).
val
(),
optimizer_mode
:
addFrm
.
find
(
"
[name=optimizer_mode]
"
).
val
(),
tcp_buffer_size
:
addFrm
.
find
(
"
[name=tcp_buffer_size]
"
).
val
(),
...
...
@@ -242,7 +287,7 @@ function setupLinks()
$
(
"
#link-config-add-frm
"
).
trigger
(
"
reset
"
);
})
.
fail
(
function
(
jqXHR
)
{
alert
(
jqXHR
.
responseJSON
.
message
);
errorMessage
(
jqXHR
);
})
.
always
(
function
()
{
$
(
"
#link-config-add-frm input
"
).
prop
(
"
disabled
"
,
false
);
...
...
@@ -269,5 +314,3 @@ function setupLinks()
source
:
"
/autocomplete/destination
"
});
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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