Add data simulation as comment

application-manager-new
charithag 9 years ago
parent f4b974ea52
commit 9f99e6e4da

@ -25,12 +25,6 @@ var log = new Log("api/event-api.jag");
var constants = require("/modules/constants.js"); var constants = require("/modules/constants.js");
var dcProps = require('/config/dc-props.js').config(); var dcProps = require('/config/dc-props.js').config();
var carbon = require('carbon');
var carbonHttpsServletTransport = carbon.server.address('https');
var deviceCloudService = carbonHttpsServletTransport + "/devicecloud/group_manager";
var statsClient = new Packages.org.wso2.carbon.device.mgt.iot.common.analytics.statistics.IoTEventsStatisticsClient;
var user = session.get(constants.USER_SESSION_KEY); var user = session.get(constants.USER_SESSION_KEY);
if (!user) { if (!user) {
response.sendRedirect(dcProps.appContext + "login?#login-required"); response.sendRedirect(dcProps.appContext + "login?#login-required");
@ -38,11 +32,9 @@ if (!user) {
} }
var result; var result;
var endPoint;
var data;
var groupId;
if (uriMatcher.match("/{context}/api/event/list")) { if (uriMatcher.match("/{context}/api/event/list")) {
/* /*
var timeInterval = 30; var timeInterval = 30;
var i, rnd; var i, rnd;
@ -54,15 +46,17 @@ if (uriMatcher.match("/{context}/api/event/list")) {
var i = parseInt(startDate / 1000); var i = parseInt(startDate / 1000);
while (i < parseInt(endDate / 1000)) { while (i < parseInt(endDate / 1000)) {
rnd = rnd = Math.random() * 50; rnd = rnd = Math.random() * 50;
result.push({time: i, deviceName: 'device' + rnd, activity:'Event number ' + rnd}); result.push({time: i * 1000, deviceName: 'device' + rnd, activity:'Event number ' + rnd});
i += timeInterval; i += timeInterval;
} }
*/ */
try { try {
result = statsClient.getRecentDeviceStats(user, 10); result = statsClient.getRecentDeviceStats(user, 10);
} catch (error) { } catch (error) {
log.error(error); log.error(error);
} }
} }
// returning the result. // returning the result.

Loading…
Cancel
Save