-
Notifications
You must be signed in to change notification settings - Fork 4
/
siam-rules-1-code.html
58 lines (52 loc) · 1.96 KB
/
siam-rules-1-code.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<html>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4"
crossorigin="anonymous"></script>
<script src="https://s3.amazonaws.com/stitch-sdks/js/library/v2/stable/stitch.min.js"></script>
<script>
const client = new stitch.StitchClient('stitchdocs-jdtdl');
const db = client.service('mongodb', 'mongodb-atlas').db('HR');
if (client.authedId()) {
client.logout().then(handleLogin)
} else {
handleLogin()
}
function handleLogin() {
client.login('dafu@bufudlur.et', 'sekritpwd')
.then(displayEmployees)
.catch(err => console.error(err))
}
function displayEmployees() {
db.collection('employees_secured').find({}).sort({ "name.last": 1 }).execute()
.then(employees => {
html = employees.map(employee => `
<tr>
<td>${employee.name.last}, ${employee.name.first}</td>
<td>${employee.email}</td>
<td>${employee.role} - ${employee.level}</td>
<td>${employee.salary}</td>
</tr>
`).join('');
document.getElementById('employees').innerHTML = html;
})
.catch(error => console.log(error));
}
</script>
<body>
<table class='table'>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Title</th>
<th>Salary</th>
</tr>
</thead>
<tbody id='employees'></tbody>
</table>
</body>
</html>