-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
255 lines (230 loc) · 10.8 KB
/
index.php
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Twitter Sentiment Analysis</title>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="css/stylesheet.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script type="application/javascript">
// configure these values globally...
window.REGISTRAR_URL = '<?php echo getenv("REGISTRAR_URL"); ?>';
window.ELASTICSEARCH_URL = '<?php echo getenv("ELASTICSEARCH_URL"); ?>';
window.AWS_ACCESS_KEY_ID = '<?php echo getenv("AWS_ACCESS_KEY_ID"); ?>';
window.AWS_ACCESS_KEY_SECRET = '<?php echo getenv("AWS_ACCESS_KEY_SECRET"); ?>';
window.AWS_EC2_REGION = '<?php echo getenv("AWS_EC2_REGION"); ?>';
window.AWS_ANALYZER_AUTO_SCALING_GROUP_NAME = '<?php echo getenv("AWS_ANALYZER_AUTO_SCALING_GROUP_NAME"); ?>';
window.AWS_PRODUCER_AUTO_SCALING_GROUP_NAME = '<?php echo getenv("AWS_PRODUCER_AUTO_SCALING_GROUP_NAME"); ?>';
window.AWS_FETCHED_TWEETS_SQS_QUEUE_NAME = '<?php echo getenv("AWS_FETCHED_TWEETS_SQS_QUEUE_NAME"); ?>';
window.AWS_ANALYZED_TWEETS_SQS_QUEUE_NAME = '<?php echo getenv("AWS_ANALYZED_TWEETS_SQS_QUEUE_NAME"); ?>';
window.REQUEST_INTERVAL = 2500;
// prepend protocol if mistakenly omitted...
if (-1 === window.REGISTRAR_URL.indexOf("http://") && -1 === window.REGISTRAR_URL.indexOf("https://")) {
window.REGISTRAR_URL = "http://" + window.REGISTRAR_URL;
}
console.log('Using registrar endpoint: "' + window.REGISTRAR_URL + '"');
console.log('Using elasticsearch endpoint: "' + window.ELASTICSEARCH_URL + '"');
console.log('Using aws access key id: "' + window.AWS_ACCESS_KEY_ID + '"');
console.log('Using aws access key secret: "' + window.AWS_ACCESS_KEY_SECRET + '"');
console.log('Using aws ec2 region: "' + window.AWS_EC2_REGION + '"');
console.log('Using aws analyzer auto scaling group name: "' + window.AWS_ANALYZER_AUTO_SCALING_GROUP_NAME + '"');
console.log('Using aws producer auto scaling group name: "' + window.AWS_PRODUCER_AUTO_SCALING_GROUP_NAME + '"');
console.log('Using aws fetched tweets SQS queue name: "' + window.AWS_FETCHED_TWEETS_SQS_QUEUE_NAME + '"');
console.log('Using aws analyzed tweets SQS queue name: "' + window.AWS_ANALYZED_TWEETS_SQS_QUEUE_NAME + '"');
console.log('Using statistic request interval: "' + window.REQUEST_INTERVAL + '"');
</script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>Twitter Sentiment Analysis</h1>
</div>
</div>
<div class="row">
<div class="col-md-8">
</div>
<div class="col-md-4">
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Current Architectural Overview</h3>
</div>
<div id="architectural-overview" class="panel-body">
</div>
</div>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Analyzer Worker Nodes Performance</h3>
</div>
<div class="panel-body">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Id</th>
<th>CPU <small>(avg/max/min)</small></th>
</tr>
</thead>
<tbody id="analyzer-workernodes-performance"></tbody>
</table>
</div>
</div>
</div>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Producer Worker Nodes Performance</h3>
</div>
<div class="panel-body">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Id</th>
<th>CPU <small>(avg/max/min)</small></th>
</tr>
</thead>
<tbody id="producer-workernodes-performance"></tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Register Term</h3>
</div>
<div class="panel-body">
<div class="input-group">
<input id="search-term" class="form-control" type="text" name="search" placeholder="Register e.g. 'kittens'">
<span class="input-group-btn">
<button id="search-btn" class="btn btn-primary" type="button">Go!</button>
<button id="stop-btn" class="btn btn-default" type="button">Stop</button>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Sentiment Value Series</h3>
</div>
<div class="panel-body">
<div id="highcharts_timeseries"></div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Aggregated Statistics</h3>
</div>
<div class="panel-body">
<b id="sentiment-avg">0.00</b> mean
<hr>
<p><span><strong id="doc-count">0</strong></span> documents</p>
<p><span><strong id="sentiment-min">0</strong></span> minimum</p>
<p><span><strong id="sentiment-max">0</strong></span> maximum</p>
<p><span><strong id="sentiment-variance">0</strong></span> variance</p>
</div>
</div>
</div>
</div>
</div>
<!-- <script src="http://code.highcharts.com/highcharts.js"></script>-->
<script src="bower_components/highcharts/highcharts.js"></script>
<script src="bower_components/aws-sdk/dist/aws-sdk.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bower_components/elasticsearch/elasticsearch.js"></script>
<script src="bower_components/moment/min/moment-with-locales.js"></script>
<script src="js/timeseries-chart.js"></script>
<script src="js/stats-chart.js"></script>
<script src="js/elasticsearch-client.js"></script>
<script src="js/aws-cloud-metrics.js"></script>
<script src="js/architecture-diagram-chart.js"></script>
<script src="js/architectural-chart.js"></script>
<script type="application/javascript">
$(document).ready(function () {
var timeSeriesChart = null;
var statsChart = null;
$('#search-btn').click(function (event) {
event.preventDefault();
var searchTerm = $("#search-term").val();
$.ajax({
beforeSend: function (xhrObj) {
xhrObj.setRequestHeader("Content-Type", "application/json");
xhrObj.setRequestHeader("Accept", "application/json");
},
type: "POST",
url: window.REGISTRAR_URL + "/terms",
dataType: "json",
data: JSON.stringify({
"identifier": searchTerm
})
}).done(function (data) {
console.log("registered term " + searchTerm);
timeSeriesChart = new TimeseriesChart(highcharts_timeseries);
timeSeriesChart.create(searchTerm);
statsChart = new StatsChart(
"#sentiment-avg",
"#doc-count",
"#sentiment-min",
"#sentiment-max",
"#sentiment-variance"
);
statsChart.create(searchTerm);
}).fail(function (data) {
console.error("Got an error while registering a search term: " + data);
});
});
$('#stop-btn').click(function (event) {
event.preventDefault();
timeSeriesChart.destroy();
statsChart.destroy();
var searchTerm = $("#search-term").val();
$.ajax({
beforeSend: function (xhrObj) {
xhrObj.setRequestHeader("Content-Type", "application/json");
xhrObj.setRequestHeader("Accept", "application/json");
},
type: "POST",
url: window.REGISTRAR_URL + "/terms/stop",
dataType: "json",
data: JSON.stringify({
"identifier": searchTerm
})
}).done(function (data) {
console.log("unregistered term");
}).fail(function (data) {
console.error("Could not unregister term");
});
});
var architecturalChart = new ArchitecturalChart("#architectural-overview", "#analyzer-workernodes-performance", "#producer-workernodes-performance");
architecturalChart.config.accessKeyId = window.AWS_ACCESS_KEY_ID;
architecturalChart.config.accessKeySecret = window.AWS_ACCESS_KEY_SECRET;
architecturalChart.config.intervalTimeout = window.REQUEST_INTERVAL;
architecturalChart.create();
});
</script>
</body>
</html>