-
Notifications
You must be signed in to change notification settings - Fork 3
/
preferences.html
92 lines (79 loc) · 2.57 KB
/
preferences.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Preferences</title>
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
<style type="text/css">
#overlay {
position: absolute;
display: block;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
z-index: 999;
text-align: center;
vertical-align: middle;
padding-top: 60px;
}
#loading-text {
font-size: 18px;
z-index: 1000;
color: #fff;
}
.alert h1 {
font-size: 16px;
}
.alert p {
font-size: 14px;
}
</style>
</head>
<body>
<div class="container" style="margin-top: 20px;">
<div class="alert alert-info" role="alert">
<h1>Welcome to the Hakuna Menubar App</h1>
<p>Please sign in using your company name and <a href="#" id="apiLink" target="_blank">API key</a>.</p>
</div>
<div>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="your-company-name" id="company-name">
<span class="input-group-append">
<span class="input-group-text">.hakuna.ch</span>
</div>
<div class="input-group" style="margin-top: 10px;">
<input type="text" class="form-control" placeholder="Your API key" style="width: 270px; float: left; margin-right: 10px;" id="api-key">
<button type="button" id="login-button" class="btn btn-default btn-primary" style="float: left;">Sign in</button>
</div>
</div>
</div>
<div id="overlay" style="display: none;">
<span id="loading-text">Loading...</span>
</div>
<script type="text/javascript">
const { ipcRenderer, shell } = require('electron')
document.getElementById('apiLink').addEventListener('click', (evt) => {
evt.preventDefault()
shell.openExternal(`https://${document.getElementById('company-name').value}.hakuna.ch/token`)
})
document.getElementById('login-button').addEventListener('click', (evt) => {
var companyName = document.getElementById('company-name').value
var apiKey = document.getElementById('api-key').value
if (!companyName || !apiKey) return
document.getElementById('overlay').style.display = 'block'
ipcRenderer.send('login', { companyName, apiKey })
})
ipcRenderer.on('login-reply', (evt, successful) => {
if (successful) {
document.getElementById('loading-text').innerText = 'Successfully logged in!'
return
}
alert('An error occured while logging in. Did you supply the right API key?')
document.getElementById('overlay').style.display = 'none'
})
</script>
</body>
</html>