Commit 6cca1c52 authored by Alejandro Alvarez Ayllon's avatar Alejandro Alvarez Ayllon
Browse files

FTS-886: Adapt WebUI to config per VO

parent a3e41d22
Pipeline #161698 passed with stage
in 14 minutes and 5 seconds
......@@ -59,7 +59,7 @@ class GlobalConfigController(BaseController):
if r.vo_name in (None, '*'):
result['*'] = r
else:
result[r.vo_name] = dict(retry=r.retry)
result[r.vo_name] = r
return result
@doc.response(400, 'Invalid values passed in the request')
......
......@@ -14,6 +14,39 @@
* limitations under the License.
**/
var globalConfigRowHtml = '\
<tr> \
<td> \
<button class="btn btn-link bt-delete" type="button" title="Delete"> \
<i class="glyphicon glyphicon-trash"></i> \
</button> \
<button class="btn btn-link bt-save" type="button" title="Save"> \
\<i class="glyphicon glyphicon-floppy-disk"></i> \
</button> \
</td> \
<td class="vo_name"> \
VO NAME \
</td> \
<td> \
<input type="number" name="retry" value="0" min="1" max="10" class="form-control"/> \
</td> \
<td> \
<input type="number" name="global_timeout" class="form-control"/> \
</td> \
<td> \
<input type="number" name="max_time_queue" class="form-control"/> \
</td> \
<td> \
<input type="number" name="sec_per_mb" class="form-control"/> \
</td> \
<td> \
<select name="show_user_dn" id="show_user_dn" class="form-control"> \
<option value="true">Yes</option> \
<option value="false">No</option> \
</select> \
</td> \
</tr>';
/**
* Updates the list of configured globals per VO
......@@ -32,54 +65,63 @@ function refreshVoConfigList()
tbody.empty();
$.each(data, function(vo_name, vo) {
if (vo_name && vo_name != "*") {
var tr = $("<tr></tr>");
var deleteBtn = $("<button class='btn btn-link' type='button'></button>")
.append("<i class='glyphicon glyphicon-trash'></i>");
deleteBtn.click(function() {
tr.css("background", "#d9534f");
$.ajax({
url: "/config/global?vo_name=" + encodeURIComponent(vo_name),
type: "DELETE",
contentType: "application/json"
})
.done(function(data, textStatus, jqXHR) {
tr.fadeOut(300, function() {tr.remove();})
})
.fail(function(jqXHR) {
errorMessage(jqXHR);
tr.css("background", "#ffffff");
});
});
var retryForm = $("<input type='number' min='0' max='10' class='form-control'></input>")
.attr("value", vo.retry).
change(function() {
var retryInput = $(this);
retryInput.prop("disabled", true);
$.ajax({
url: "/config/global?",
type: "POST",
dataType: "json",
contentType: "application/json",
data: JSON.stringify({vo_name: vo_name, retry: retryInput.val()})
})
.done(function() {
retryInput.prop("disabled", false);
})
.fail(function(jqXHR) {
errorMessage(jqXHR);
});
});
tbody.append(
tr.append($("<td></td>").append(deleteBtn))
.append($("<td></td>").append($("<span></span>").text(vo_name)))
.append($("<td></td>").append(retryForm))
);
}
var tr = $(globalConfigRowHtml);
tr.find(".vo_name").text(vo_name);
$.each(vo, function(op_name, op_value) {
if (op_name != "show_user_dn") {
tr.find("input[name='" + op_name + "']").val(op_value);
}
else {
tr.find("select[name='" + op_name + "']").val(op_value.toString());
}
});
tr.find(".bt-delete").click(function() {
tr.css("background", "#d9534f");
$.ajax({
url: "/config/global?vo_name=" + encodeURIComponent(vo_name),
type: "DELETE",
contentType: "application/json"
})
.done(function(data, textStatus, jqXHR) {
tr.fadeOut(300, function() {tr.remove();})
})
.fail(function(jqXHR) {
errorMessage(jqXHR);
tr.css("background", "#ffffff");
});
});
tr.find(".bt-save").click(function() {
tr.find("input").prop("disabled", true);
tr.find("select").prop("disabled", true);
$.ajax({
url: "/config/global?",
type: "POST",
dataType: "json",
contentType: "application/json",
data: JSON.stringify({
vo_name: vo_name,
retry: tr.find("input[name='retry']").val(),
max_time_queue: tr.find("input[name='max_time_queue']").val(),
global_timeout: tr.find("input[name='global_timeout']").val(),
sec_per_mb: tr.find("input[name='sec_per_mb']").val(),
sec_per_mb: tr.find("input[name='sec_per_mb']").val(),
show_user_dn: tr.find("select[name='show_user_dn']").val()
})
})
.done(function() {
tr.find("input").prop("disabled", false);
tr.find("select").prop("disabled", false);
})
.fail(function(jqXHR) {
errorMessage(jqXHR);
});
});
tbody.append(tr);
});
})
.fail(function(jqXHR) {
......
......@@ -12,12 +12,24 @@
<table class="table">
<thead>
<tr>
<th style="width: 5em"></th>
<th></th>
<th>VO</th>
<th title="The retry of a transfer also depends on the error code">
Retries
<i class="glyphicon glyphicon-question-sign"></i>
</th>
<th>
Global transfer timeout
</th>
<th>
Queue timeout
</th>
<th>
Add seconds/MB
</th>
<th>
Show user DN
</th>
</tr>
</thead>
<tbody id="vo-config-list">
......@@ -34,81 +46,26 @@
id="vo-config-add-field-vo"/>
</td>
<td>
<input type="number" name="retry" value="1" min="1" max="10" class="form-control"/>
<input type="number" name="retry" value="0" min="1" max="10" class="form-control"/>
</td>
</tr>
</tbody>
</table>
</form>
<h3>Global configuration</h3>
<p>
These settings apply to all transfers equally.
</p>
<form method="POST" id="global-config-frm">
<div class="row">
<div class="col-md-6">
<p class="form-group">
<label for="global_timeout">
Timeout
<i class="glyphicon glyphicon-question-sign"
title="Default timeout. Can be overriden per job"></i>
</label>
<span class="input-group">
<input type="number" id="global_timeout" name="global_timeout" class="form-control"
value="${data['*']['global_timeout']}"/>
<span class="input-group-addon"> seconds</span>
</span>
</p>
<p class="form-group">
<label for="max_time_queue">Max. time in the queue</label>
<span class="input-group">
<input type="number" id="max_time_queue" name="max_time_queue" class="form-control"
value="${data['*']['max_time_queue']}"/>
<span class="input-group-addon"> seconds</span>
</span>
</p>
</div>
<div class="col-md-6">
<p class="form-group">
<label for="sec_per_mb">
Add seconds per MiB
<i class="glyphicon glyphicon-question-sign"
title="FTS3 will correct the timeout depending on the file size and this parameter"></i>
</label>
<span class="input-group">
<input type="number" id="sec_per_mb" name="sec_per_mb" class="form-control"
value="${data['*']['sec_per_mb']}"/>
<span class="input-group-addon"> seconds</span>
</span>
</p>
<div class="form-group">
<label for="show_user_dn">
Show the user's DN
<i class="glyphicon glyphicon-question-sign"
title="It is recommended to keep this to false, since distributing the users' dn publicly may be forbidden by certain regulations"></i>
</label>
<td>
<input type="number" name="global_timeout" class="form-control"/>
</td>
<td>
<input type="number" name="max_time_queue" class="form-control"/>
</td>
<td>
<input type="number" name="sec_per_mb" class="form-control"/>
</td>
<td>
<select name="show_user_dn" id="show_user_dn" class="form-control">
% if data['*']['show_user_dn']:
<option value="true" selected>Yes</option>
<option value="false">No</option>
% else:
<option value="true">Yes</option>
<option value="false" selected>No</option>
% endif
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 text-right">
<button class="btn btn-primary" type="submit">
<i class="glyphicon glyphicon-ok"></i>
Save
</button>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</form>
</div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment