kopia lustrzana https://github.com/OpenDroneMap/WebODM
Added verify configuration button
rodzic
620af7fc53
commit
7578e01a0f
|
@ -10,7 +10,74 @@ On this screen, you can provide the registry url and credentials to access Drone
|
|||
<h4>Settings</h4>
|
||||
{% csrf_token %}
|
||||
{% include "app/plugins/templates/form.html" %}
|
||||
<button type="submit" class="btn btn-primary"><i class="fa fa-save fa-fw"></i> Save Configuration</i></button>
|
||||
<button id="btnVerify" type="button" class="btn btn-success" disabled><i class="fas fa-user-check"></i> Verify Configuration</i></button>
|
||||
<button type="submit" class="btn btn-primary"><i class="fa fa-save fa-fw"></i> Save Configuration</i></button>
|
||||
</form>
|
||||
<div id="alert-result" style="display: none; margin-top: 20px" class="alert" role="alert"></div>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var running = false;
|
||||
var timeout = null;
|
||||
|
||||
$("input[name=registry_url],input[name=username],input[name=password]").on('keyup', function() {
|
||||
|
||||
var alert = $("#alert-result").hide();
|
||||
if (timeout != null) clearTimeout(timeout);
|
||||
|
||||
$("#btnVerify").prop('disabled',
|
||||
$("input[name=registry_url]").val().length == 0 ||
|
||||
$("input[name=username]").val().length == 0 ||
|
||||
$("input[name=password]").val().length == 0);
|
||||
});
|
||||
|
||||
$("#btnVerify").click(function() {
|
||||
if (running) return;
|
||||
running = true;
|
||||
if (timeout != null) clearTimeout(timeout);
|
||||
|
||||
var alert = $("#alert-result");
|
||||
|
||||
alert.attr('class', 'alert alert-info');
|
||||
alert.text("Testing configuration...");
|
||||
alert.show();
|
||||
|
||||
$.ajax({
|
||||
url: "/api/plugins/dronedb/checkcredentials",
|
||||
type: "POST",
|
||||
data: {
|
||||
"csrfmiddlewaretoken": $("input[name=csrfmiddlewaretoken]").val(),
|
||||
"hubUrl": $("input[name=registry_url]").val(),
|
||||
"userName": $("input[name=username]").val(),
|
||||
"password": $("input[name=password]").val()
|
||||
},
|
||||
success: function(data) {
|
||||
|
||||
if (data.success) {
|
||||
alert.attr('class', 'alert alert-success');
|
||||
alert.text("Configuration verified successfully!");
|
||||
} else {
|
||||
alert.attr('class', 'alert alert-danger');
|
||||
alert.text("Configuration verification failed!");
|
||||
}
|
||||
|
||||
var timeoutID = setTimeout(function() { alert.hide(); }, 5000);
|
||||
|
||||
},
|
||||
error: function(data) {
|
||||
alert.attr('class', 'alert alert-danger');
|
||||
alert.text("Configuration failed!");
|
||||
},
|
||||
complete: function() {
|
||||
running = false;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
|
Ładowanie…
Reference in New Issue