started working on templates and api
This commit is contained in:
@@ -18,6 +18,13 @@ h1 {
|
||||
background: orange;
|
||||
}
|
||||
|
||||
.notes{
|
||||
display: block;
|
||||
text-align: center;
|
||||
background: yellow;
|
||||
}
|
||||
|
||||
.user{
|
||||
background: lime;
|
||||
float: right;
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
@@ -6,8 +7,9 @@
|
||||
<link rel="stylesheet" href="css" />
|
||||
</head>
|
||||
<body>
|
||||
<span class="user">Logged in as <em>«data.user.name»</em></span>
|
||||
<h2>Users</h2>
|
||||
<h2>Lists</h2>
|
||||
«userinfo()»
|
||||
«messages()»
|
||||
«userlist()»
|
||||
«listlist()»
|
||||
</body>
|
||||
</html>
|
||||
@@ -1 +1,25 @@
|
||||
function loadUserList(){
|
||||
$.getJSON("/api/user/list", showUserList);
|
||||
}
|
||||
|
||||
function showUserList(data){
|
||||
for (let i in data.users){
|
||||
let user = data.users[i];
|
||||
let row = $('<tr/>');
|
||||
$('<td/>').text(user.name).appendTo(row);
|
||||
$('<td/>').text(user.email).appendTo(row);
|
||||
$('<td/>').text(user.password).appendTo(row);
|
||||
row.appendTo('#userlist');
|
||||
}
|
||||
if (data.user.name == 'Admin'){
|
||||
$('a[href=register]').show();
|
||||
} else {
|
||||
$('a[href=register]').hide();
|
||||
}
|
||||
}
|
||||
|
||||
function start(){
|
||||
console.log("application started");
|
||||
}
|
||||
|
||||
$(start); // document.on ready
|
||||
10
static/templates/listlist.st
Normal file
10
static/templates/listlist.st
Normal file
@@ -0,0 +1,10 @@
|
||||
<fieldset>
|
||||
<legend>List of mailinglists</legend>
|
||||
<table id="listlist">
|
||||
<tr>
|
||||
<th>List name</th>
|
||||
<th>List email</th>
|
||||
<th>Details</th>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
@@ -1,3 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
@@ -7,9 +8,7 @@
|
||||
</head>
|
||||
<body id="login">
|
||||
<h1>Widerhall login</h1>
|
||||
«if(data.error)»
|
||||
<span class="error">«data.error»</span>
|
||||
«endif»
|
||||
«messages()»
|
||||
<form method="POST">
|
||||
<fieldset>
|
||||
<legend>Login-Daten</legend>
|
||||
|
||||
6
static/templates/messages.st
Normal file
6
static/templates/messages.st
Normal file
@@ -0,0 +1,6 @@
|
||||
«if(data.error)»
|
||||
<span class="error">«data.error»</span>
|
||||
«endif»
|
||||
«if(data.notes)»
|
||||
<span class="notes">«data.notes»</span>
|
||||
«endif»
|
||||
36
static/templates/register.st
Normal file
36
static/templates/register.st
Normal file
@@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<script src="jquery"></script>
|
||||
<script src="js"></script>
|
||||
<link rel="stylesheet" href="css" />
|
||||
</head>
|
||||
<body id="login">
|
||||
«userinfo()»
|
||||
<h1>Widerhall user registration</h1>
|
||||
«messages()»
|
||||
<form method="POST" action="register">
|
||||
<fieldset>
|
||||
<legend>User credentials</legend>
|
||||
<label>
|
||||
<input type="text" name="name" value="«data.name»" id="name" />
|
||||
Your name
|
||||
</label>
|
||||
<label>
|
||||
<input type="text" name="email" value="«data.email»" id="email" />
|
||||
E-Mail Address
|
||||
</label>
|
||||
<label>
|
||||
<input type="password" name="pass" value="" id="password" />
|
||||
Password
|
||||
</label>
|
||||
<label>
|
||||
<input type="password" name="pass_repeat" value="" id="password_repeated" />
|
||||
Password (repeat)
|
||||
</label>
|
||||
<button type="submit">Save new user</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
7
static/templates/userinfo.st
Normal file
7
static/templates/userinfo.st
Normal file
@@ -0,0 +1,7 @@
|
||||
«if(data.user)»
|
||||
<div class="user">
|
||||
Logged in as <em>«data.user.name»</em>
|
||||
<a class="button" href="reload" />Reload templates</a>
|
||||
<a class="button" href="logout" />Logout</a>
|
||||
</div>
|
||||
«endif»
|
||||
14
static/templates/userlist.st
Normal file
14
static/templates/userlist.st
Normal file
@@ -0,0 +1,14 @@
|
||||
<fieldset>
|
||||
<legend>User list</legend>
|
||||
<table id="userlist">
|
||||
<tr>
|
||||
<th>User name</th>
|
||||
<th>Email</th>
|
||||
<th>Password</th>
|
||||
</tr>
|
||||
</table>
|
||||
<a href="register">Register new user</a>
|
||||
<script type="text/javascript">
|
||||
loadUserList();
|
||||
</script>
|
||||
</fieldset>
|
||||
Reference in New Issue
Block a user