Complete device event stream client side

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

@ -118,9 +118,11 @@
</div> </div>
</div> </div>
<!-- /dashboard --> <!-- /dashboard -->
<div id="event-stream" style="padding-top: 20px;"> <div id="event-stream-place-holder" style="padding-top: 20px;">
</div> </div>
{{/zone}} {{/zone}}
{{#zone "bottomJs"}} {{#zone "bottomJs"}}
<script src="{{self.publicURL}}/js/dashboard.js"></script> <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}} {{/zone}}

@ -9,11 +9,37 @@ var updateStats = function (serviceURL, id) {
); );
}; };
$(document).ready(function(){ $(document).ready(function () {
updateStats("/iotserver/api/devices/count", "#device-count"); updateStats("/iotserver/api/devices/count", "#device-count");
updateStats("/iotserver/api/group/all/count", "#group-count"); updateStats("/iotserver/api/group/all/count", "#group-count");
updateStats("/iotserver/api/policies/count", "#policy-count"); updateStats("/iotserver/api/policies/count", "#policy-count");
updateStats("/iotserver/api/users/count", "#user-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;"> <div class="col-lg-12 wr-secondary-bar" style="width: inherit;">
<label class="device-id device-select" style="font-size: 20px; margin-bottom: 0px;"> <label class="device-id device-select" style="font-size: 20px; margin-bottom: 0px;">
Device Data Stream Device Events Stream
</label> </label>
</div> </div>
<br/> <br/>
@ -17,8 +17,8 @@
<tbody> <tbody>
{{#each data}} {{#each data}}
<tr> <tr>
<td width="20%">{{time}}</td> <td width="20%" class="formatDate">{{time}}</td>
<td width="20%">{{deviceIdentifier}}</td> <td width="20%">{{deviceName}}</td>
<td>{{activity}}</td> <td>{{activity}}</td>
</tr> </tr>
{{/each}} {{/each}}

Loading…
Cancel
Save