73 lines
2.1 KiB
HTML
73 lines
2.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>Orte</title>
|
|
<style>
|
|
body {
|
|
font-family: sans-serif;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<label for="username">Username</label>
|
|
<input type="text" id="username" />
|
|
|
|
<label for="password">Passwort</label>
|
|
<input type="password" id="password" />
|
|
|
|
<input type="button" value="Anmelden" id="login-btn" />
|
|
|
|
<span id="login-status"></span>
|
|
|
|
<br />
|
|
<input type="button" value="Gespeicherte Orte laden" id="fetch-locations-btn" />
|
|
<br />
|
|
|
|
<ul id="location-list"></ul>
|
|
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function () {
|
|
|
|
var token = null;
|
|
var list = $("#location-list");
|
|
|
|
$("#login-btn").click(function () {
|
|
var username = $("#username").val();
|
|
var password = $("#password").val();
|
|
|
|
$.ajax({
|
|
url: 'DataService/Auth/Login',
|
|
type: 'post',
|
|
contentType: 'application/json',
|
|
data: JSON.stringify({
|
|
username: username,
|
|
password: password
|
|
})
|
|
}).done(function (result) {
|
|
token = result.token;
|
|
$("#login-status").text("Erfolgreich angemeldet");
|
|
}).fail(function () {
|
|
$("#login-status").text("Login fehlgeschlagen");
|
|
});
|
|
});
|
|
|
|
$("#fetch-locations-btn").click(function () {
|
|
list.empty();
|
|
$.ajax({
|
|
url: 'DataService/Location/GetLocations',
|
|
type: 'get',
|
|
headers: {
|
|
Authorization: 'Bearer ' + token
|
|
}
|
|
}).done(function (result) {
|
|
result.forEach(function (item) {
|
|
list.append(`<li>${item}</li>`);
|
|
});
|
|
});
|
|
});
|
|
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |