save locations
This commit is contained in:
73
ReallifeGamemode.DataService/wwwroot/locations.html
Normal file
73
ReallifeGamemode.DataService/wwwroot/locations.html
Normal file
@@ -0,0 +1,73 @@
|
||||
<!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>
|
||||
Reference in New Issue
Block a user