Merge pull request #3389 from rbb-data/feature/remove-jquery
Remove jQuery from web-based installer
This commit is contained in:
@@ -218,9 +218,9 @@ def main():
|
|||||||
PAGE = """
|
PAGE = """
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
<title>Dokku Setup</title>
|
<title>Dokku Setup</title>
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
||||||
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
|
|
||||||
<style>
|
<style>
|
||||||
.bd-callout {
|
.bd-callout {
|
||||||
padding: 1.25rem;
|
padding: 1.25rem;
|
||||||
@@ -306,44 +306,59 @@ PAGE = """
|
|||||||
|
|
||||||
<div id="error-output"></div>
|
<div id="error-output"></div>
|
||||||
<script>
|
<script>
|
||||||
|
var $ = document.querySelector.bind(document)
|
||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
if ($.trim($("#key").val()) == "") {
|
if ($("#key").value.trim() == "") {
|
||||||
alert("Your admin public key cannot be blank.")
|
alert("Your admin public key cannot be blank.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ($.trim($("#hostname").val()) == "") {
|
if ($("#hostname").value.trim() == "") {
|
||||||
alert("Your hostname cannot be blank.")
|
alert("Your hostname cannot be blank.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data = $("#form").serialize()
|
var data = new FormData($("#form"))
|
||||||
$("input,textarea,button").prop("disabled", true);
|
|
||||||
$.post('/setup', data)
|
var inputs = [].slice.call(document.querySelectorAll("input, textarea, button"))
|
||||||
.done(function() {
|
inputs.forEach(function (input) {
|
||||||
$(".result").addClass('text-success');
|
input.disabled = true
|
||||||
$(".result").html("Success! Redirecting in 3 seconds. ..")
|
})
|
||||||
|
|
||||||
|
var result = $(".result")
|
||||||
|
fetch("/setup", {method: "POST", body: data})
|
||||||
|
.then(function(response) {
|
||||||
|
if (response.ok) {
|
||||||
|
return response.json()
|
||||||
|
} else {
|
||||||
|
throw new Error('Server returned error')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(function(response) {
|
||||||
|
result.classList.add("text-success");
|
||||||
|
result.textContent = "Success! Redirecting in 3 seconds. .."
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
window.location.href = "http://dokku.viewdocs.io/dokku~{VERSION}/deployment/application-deployment/";
|
window.location.href = "http://dokku.viewdocs.io/dokku~{VERSION}/deployment/application-deployment/";
|
||||||
}, 3000);
|
}, 3000);
|
||||||
})
|
})
|
||||||
.fail(function(data) {
|
.catch(function (error) {
|
||||||
$(".result").addClass('text-danger');
|
result.classList.add("text-danger");
|
||||||
$(".result").html("Something went wrong...")
|
result.textContent = "Could not send the request"
|
||||||
$("#error-output").html(data.responseText)
|
})
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
if ($("#vhost").is(":checked") && $("#hostname").val().match(/^(\d{1,3}\.){3}\d{1,3}$/)) {
|
if ($("#vhost").matches(":checked") && $("#hostname").value.match(/^(\d{1,3}\.){3}\d{1,3}$/)) {
|
||||||
alert("In order to use virtualhost naming, the hostname must not be an IP but a valid domain name.")
|
alert("In order to use virtualhost naming, the hostname must not be an IP but a valid domain name.")
|
||||||
$("#vhost").prop('checked', false);
|
$("#vhost").checked = false;
|
||||||
}
|
}
|
||||||
if ($("#vhost").is(':checked')) {
|
if ($("#vhost").matches(':checked')) {
|
||||||
$("#example").html("http://<app-name>."+$("#hostname").val())
|
$("#example").textContent = "http://<app-name>."+$("#hostname").value
|
||||||
} else {
|
} else {
|
||||||
$("#example").html("http://"+$("#hostname").val()+":<app-port>")
|
$("#example").textContent = "http://"+$("#hostname").value+":<app-port>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$("#vhost").change(update);
|
$("#vhost").addEventListener("input", update);
|
||||||
$("#hostname").change(update);
|
$("#hostname").addEventListener("input", update);
|
||||||
update();
|
update();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user