added dashboard
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -4,13 +4,15 @@
|
||||
<title>Light OIDC</title>
|
||||
<script src="scripts/common.js"></script>
|
||||
<script src="scripts/user.js"></script>
|
||||
<script src="scripts/index.js"></script>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body>
|
||||
<nav></nav>
|
||||
<div id="content">
|
||||
<h1>Welcome!</h1>
|
||||
<h1 id="welcome">Welcome, {}!</h1>
|
||||
<h3 id="client_hint" style="display: none">These are your authorized clients:</h3>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -44,4 +44,4 @@ function remove(clientId){
|
||||
}
|
||||
}
|
||||
|
||||
fetch(client_controller+"/list",{method:'POST',credentials:'include'}).then(handleClients);
|
||||
fetch(client_controller+"/list").then(handleClients);
|
||||
@@ -0,0 +1,27 @@
|
||||
function handleDash(response){
|
||||
if (response.status == UNAUTHORIZED) {
|
||||
redirect('login.html?return_to='+encodeURI(window.location.href))
|
||||
return;
|
||||
}
|
||||
var clients = response.json().then(data => {
|
||||
var name = data.name;
|
||||
var welcome = get('welcome');
|
||||
welcome.innerHTML = welcome.innerHTML.replace('{}',name);
|
||||
|
||||
var clients = data.authorized;
|
||||
var content = document.getElementById('content');
|
||||
var any = false;
|
||||
for (let id in clients){
|
||||
var client = clients[id];
|
||||
if (client.landing_page){
|
||||
var div = document.createElement("div");
|
||||
div.innerHTML = `<button onclick="window.location.href='${client.landing_page}';">${client.name}</button>`;
|
||||
content.append(div);
|
||||
any = true;
|
||||
}
|
||||
}
|
||||
if (any) show('client_hint');
|
||||
});
|
||||
}
|
||||
|
||||
fetch(client_controller+"/dash").then(handleDash)
|
||||
Reference in New Issue
Block a user