Complete device event stream client side

application-manager-new
charithag 9 years ago
parent 919f9b40e9
commit fbaa9a2e2f

@ -118,9 +118,11 @@
</div>
</div>
<!-- /dashboard -->
<div id="event-stream" style="padding-top: 20px;">
<div id="event-stream-place-holder" style="padding-top: 20px;">
</div>
{{/zone}}
{{#zone "bottomJs"}}
<script src="{{self.publicURL}}/js/dashboard.js"></script>
<script id="event-stream" src="{{self.publicURL}}/templates/event-stream.hbs"
type="text/x-handlebars-template"></script>
{{/zone}}

@ -15,5 +15,31 @@ $(document).ready(function(){
updateStats("/iotserver/api/policies/count", "#policy-count");
updateStats("/iotserver/api/users/count", "#user-count");
displayEvents();
});
var displayEvents = function () {
var eventListing = $("#event-stream");
var eventListingSrc = eventListing.attr("src");
$.template("event-stream", eventListingSrc, function (template) {
var serviceURL = "/iotserver/api/event/list";
var successCallback = function (data) {
var viewModel = {};
viewModel.data = JSON.parse(data);
var content = template(viewModel);
$("#event-stream-place-holder").html(content);
formatDates();
};
invokerUtil.get(serviceURL,
successCallback, function (message) {
console.log(message);
});
});
}
function formatDates() {
$(".formatDate").each(function () {
var timeStamp = $(this).html();
$(this).html(new Date(parseInt(timeStamp)).toUTCString());
});
}

@ -1,6 +1,6 @@
<div class="col-lg-12 wr-secondary-bar" style="width: inherit;">
<label class="device-id device-select" style="font-size: 20px; margin-bottom: 0px;">
Device Data Stream
Device Events Stream
</label>
</div>
<br/>
@ -17,8 +17,8 @@
<tbody>
{{#each data}}
<tr>
<td width="20%">{{time}}</td>
<td width="20%">{{deviceIdentifier}}</td>
<td width="20%" class="formatDate">{{time}}</td>
<td width="20%">{{deviceName}}</td>
<td>{{activity}}</td>
</tr>
{{/each}}

Loading…
Cancel
Save