-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
220 lines (216 loc) · 7.11 KB
/
index.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>News Subscription</title>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
type="text/css"
href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css"
/>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
height: 900px;
}
header {
background: url("https://images.pexels.com/photos/1198817/pexels-photo-1198817.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
text-align: center;
width: 100%;
height: auto;
background-size: cover;
background-attachment: fixed;
position: relative;
overflow: hidden;
border-radius: 0 0 85% 85% / 30%;
}
header .overlay {
width: 100%;
height: 100%;
padding: 50px;
color: #fff;
text-shadow: 1px 1px 1px #333;
background-image: linear-gradient(135deg, #9f05ff69 10%, #fd5e086b 85%);
}
h1 {
font-family: "Dancing Script", cursive;
font-size: 80px;
margin-bottom: 30px;
}
h3,
p {
font-family: "Open Sans", sans-serif;
margin-bottom: 30px;
}
</style>
</head>
<body>
<header>
<div class="overlay">
<h1>News Subscription</h1>
<h3>Bloomberg Markets</h3>
<p>
To start subscription to Bloomberg news feed, fill up the form and
click <b>Start</b><br />
Remember to select the relevant key words <br />
Latest relevant news are streamed to Slack
</p>
</div>
</header>
<div class="container-xl">
<form class="mt-3">
<div class="mb-3">
<label for="slackInput" class="form-label">Slack Channel</label>
<input
type="text"
class="form-control"
id="slackInput"
placeholder="e.g. C03405AQ91D"
value="C03405AQ91D"
/>
</div>
<div class="mb-3">
<label for="searchTermsInput" class="form-label">Search terms</label>
<textarea
class="form-control"
id="SearchTermsInput"
placeholder="Keywords / Phrases to query news articles for, separated by commas, e.g. energy, ukraine crisis, inflation, rates, bonds, feds, metals, gold"
rows="3"
></textarea>
</div>
</form>
<div class="card mt-3">
<div class="card-header">Infomation</div>
<div class="card-body">
<h5 class="card-title">Latest Keywords Searched</h5>
<hr />
<p class="card-text" id="keywords-para">
{{ if .SearchTerms }} {{ range $index, $element := .SearchTerms }}
{{ if $index }}, {{ end }}<span
class="badge bg-light text-dark rounded-pill"
>{{ $element }}</span
>{{ end }}{{ else }} *** No previous searches found *** {{ end }}
</p>
</div>
</div>
<div class="btn-group mt-4" role="group" aria-label="Start subscriptions">
<button
type="button"
onclick="start()"
class="btn btn-primary"
data-bs-toggle="tooltip"
data-bs-placement="top"
id="startButton"
title="Start news subscription"
{{
if
.Started
}}
disabled
{{
end
}}
>
Start
</button>
<button
type="button"
class="btn btn-danger"
onclick="stop()"
data-bs-toggle="tooltip"
data-bs-placement="top"
id="stopButton"
title="Stop news subscription"
{{
if
not
.Started
}}
disabled
{{
end
}}
>
Stop
</button>
</div>
</div>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"
></script>
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"
></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"
integrity="sha512-VEd+nq25CkR676O+pLBnDW09R7VQX9Mdiij052gVCp5yVH3jGtH70Ho/UUv4mJDsEdTvqRCFZg0NKGiojGnUCw=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script>
var tooltipTriggerList = [].slice.call(
document.querySelectorAll('[data-bs-toggle="tooltip"]')
);
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
var hostport = {{ .SchemeHostPort }}
function start() {
const keywords = document.getElementById("SearchTermsInput").value
const slackInput = document.getElementById("slackInput").value
if (keywords == '') {
toastr.error("Search Terms cannot be empty")
return
}
fetch(`${hostport}/start`, {
method: "POST",
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({keywords: keywords.replaceAll("\"", ""), slackChannelID: slackInput})
}).then(res => {
console.log(`%c Started news subscription`, "color: green");
if (res.status === 200) {
document.getElementById("startButton").setAttribute("disabled", true)
$('.tooltip.show').tooltip('hide')
document.getElementById("stopButton").removeAttribute("disabled")
document.getElementById("keywords-para").innerHTML = keywords.split(",").map(x => `<span class="badge bg-light text-dark rounded-pill">${x.trim()}</span>`).join()
toastr.info("Successfully started news subscriptions")
} else {
toastr.error("Something unexpected occurred")
}
})
}
function stop() {
console.log(`%c Stopped news subscription`, "color: red");
fetch(`${hostport}/stop`, {
method: "POST"
}).then(res => {
if (res.status === 200) {
document.getElementById("stopButton").setAttribute("disabled", true)
$('.tooltip.show').tooltip('hide')
document.getElementById("startButton").removeAttribute("disabled")
toastr.info("Successfully stopped news subscriptions")
} else {
toastr.error("Something unexpected occurred")
}
})
}
</script>
</body>
</html>