merge-requests/1/head
thusithakalugamage 8 years ago
commit c37ad8f56d

@ -20,8 +20,8 @@ package org.wso2.carbon.device.mgt.iot.androidsense.service.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.analytics.dataservice.commons.SORT;
import org.wso2.carbon.analytics.dataservice.commons.SortByField;
import org.wso2.carbon.analytics.dataservice.commons.SortType;
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
@ -194,7 +194,7 @@ public class AndroidSenseServiceImpl implements AndroidSenseService {
List<SensorRecord> sensorDatas;
if (!sensor.equals(AndroidSenseConstants.SENSOR_WORDCOUNT)) {
List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField("time", SORT.ASC, false);
SortByField sortByField = new SortByField("time", SortType.ASC);
sortByFields.add(sortByField);
sensorDatas = APIUtil.getAllEventsForDevice(sensorTableName, query, sortByFields);
} else {

@ -17,16 +17,31 @@
*/
function onRequest(context) {
var log = new Log("stats.js");
var carbonServer = require("carbon").server;
var device = context.unit.params.device;
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var constants = require("/app/modules/constants.js");
var websocketEndpoint = devicemgtProps["httpsURL"].replace("https", "wss");
var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER);
var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss");
var jwtService = carbonServer.osgiService(
'org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService');
var jwtClient = jwtService.getJWTClient();
var encodedClientKeys = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]);
if (encodedClientKeys) {
var tokenUtil = require("/app/modules/oauth/token-handler-utils.js")["utils"];
var resp = tokenUtil.decode(encodedClientKeys).split(":");
var deviceParam = "{\"scope\":\"stats\",\"deviceIdentifiers\":[{\"id\":\"" + device.deviceIdentifier
+ "\", \"type\":\"" + device.type + "\"}]}";
var encodedScope = tokenUtil.encode(deviceParam);
var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username,"default",
{"device": encodedScope});
var token = "";
if (tokenPair) {
token = tokenPair.accessToken;
}
websocketEndpoint = websocketEndpoint + "/secured-outputui/org.wso2.iot.android.sense/1.0.0?" +
"token="+ token +"&deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type;
}
return {"device": device, "websocketEndpoint": websocketEndpoint};
}

@ -35,27 +35,6 @@ function setPopupMaxHeight() {
function showPopup() {
$(modalPopup).modal('show');
setPopupMaxHeight();
$('#downloadForm').validate({
rules: {
deviceName: {
minlength: 4,
required: true
}
},
highlight: function (element) {
$(element).closest('.control-group').removeClass('success').addClass('error');
},
success: function (element) {
$(element).closest('.control-group').removeClass('error').addClass('success');
$('label[for=deviceName]').remove();
}
});
var deviceType = "";
$('.deviceType').each(function () {
if (this.value != "") {
deviceType = this.value;
}
});
}
/*
@ -81,22 +60,13 @@ function attachEvents() {
* when a user clicks on "Download" link
* on Device Management page in WSO2 DC Console.
*/
$("a.download-link").click(function () {
$(modalPopupContent).html($('#download-device-modal-content').html());
showPopup();
var deviceName;
$("a#download-device-download-link").click(function () {
$('.new-device-name').each(function () {
if (this.value != "") {
deviceName = this.value;
}
});
$('label[for=deviceName]').remove();
});
$("a#download-device-cancel-link").click(function () {
hidePopup();
$(".download-link").click(function(){
toggleEnrollment();
});
});
function toggleEnrollment(){
$(modalPopupContent).html($("#qr-code-modal").html());
generateQRCode(modalPopupContent + " .qr-code");
showPopup();
}
}

@ -60,21 +60,6 @@
<i class="fw fw-mobile fw-inverse fw-lg"></i> Enroll Device</a>
<br/><br/>
<div id="download-device-modal-content-links" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-md-7 col-centered center-container">
<h3>Please download the file from following link(Press CTRL+C).</h3>
<br/>
<div>
<input id="download-device-url" style="color:#3f3f3f;padding:5px"
type="text" value="" placeholder="Type here" size="60">
</div>
</div>
</div>
</div>
</div>
<div id="device-400-content" class="hide">
<div class="modal-content">
<div class="row">
@ -242,25 +227,75 @@
</div>
<div id="qr-code-modal" data-enrollment-url="{{hostName}}{{@unit.publicUri}}/asset/androidsense.apk" class="hidden">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Scan QR code to start enrollment</h3>
<p>Please scan the QR code using your mobile device to retrieve enrollment URL.</p>
<div class="modal-header">
<h4 class="pull-left modal-title">
<span class="fw-stack">
<i class="fw fw-mobile fw-stack-2x"></i>
<span class="fw-stack fw-move-right fw-move-bottom">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-circle fw-stack-2x fw-stroke text-info"></i>
<i class="fw fw-add fw-stack-1x fw-inverse"></i>
</span>
</span>
&nbsp;&nbsp;Add your new mobile device to {{@app.conf.appName}}
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
</div>
<hr>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<div class="panel-body col-centered text-center">
<h5>
Please scan the following QR code using your new <b>Android</b>, <b>iPhone</b> or <b>Windows</b> mobile device.
</h5>
<br>
<div class="panel panel-default">
<div class="panel-body col-centered">
<div class="panel-body">
<div class="qr-code"></div>
</div>
</div>
<form id="downloadForm" method="GET"
action="{{hostName}}{{@unit.publicUri}}/asset/androidsense.apk">
<div class="buttons" style="padding-bottom: 0px">
<input class="btn btn-operations" type="submit" value="Download Now">
</div>
</form>
<br>
<h5>
Not having a QR code scanner in your device?
<br><br>
Try following link
<br><br>
<b>{{hostName}}{{@unit.publicUri}}/asset/androidsense.apk</b>
<br><br>
on your device's Internet browser instead.
</h5>
</div>
</div>
<div class="modal-footer">
<div class="buttons">
<a href="javascript:hidePopup()" class="btn-operations btn-default">Ok</a>
</div>
</div>
</div>
<!--<div class="content">-->
<!--<div class="row">-->
<!--<div class="col-lg-5 col-md-6 col-centered">-->
<!--<h3>Scan QR code to start enrollment</h3>-->
<!--<p>Please scan the QR code using your mobile device to retrieve enrollment URL.</p>-->
<!--<div class="panel panel-default">-->
<!--<div class="panel-body col-centered">-->
<!--<div class="qr-code"></div>-->
<!--<br>-->
<!--<h5>-->
<!--Not having a QR code scanner in your device?-->
<!--<br><br>-->
<!--Try following link-->
<!--<br><br>-->
<!--<b>{{hostName}}/{{@unit.publicUri}}/asset/androidsense.apk</b>-->
<!--<br><br>-->
<!--on your device's Internet browser instead.-->
<!--</h5>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<div id="device-agent-downloading-content" class="hide">
<div class="modal-content">
<div class="row">

@ -19,6 +19,6 @@
function onRequest(context){
var viewModel = {};
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
viewModel.hostName = devicemgtProps["httpsWebURL"];
viewModel.hostName = devicemgtProps["generalConfig"]["host"];
return viewModel;
}

@ -21,8 +21,8 @@ package org.wso2.carbon.device.mgt.iot.arduino.service.impl;
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.analytics.dataservice.commons.SORT;
import org.wso2.carbon.analytics.dataservice.commons.SortByField;
import org.wso2.carbon.analytics.dataservice.commons.SortType;
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
@ -159,7 +159,7 @@ public class ArduinoServiceImpl implements ArduinoService {
String sensorTableName = ArduinoConstants.TEMPERATURE_EVENT_TABLE;
try {
List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField("time", SORT.ASC, false);
SortByField sortByField = new SortByField("time", SortType.ASC);
sortByFields.add(sortByField);
List<SensorRecord> sensorRecords = APIUtil.getAllEventsForDevice(sensorTableName, query, sortByFields);
return Response.status(Response.Status.OK.getStatusCode()).entity(sensorRecords).build();

@ -18,16 +18,30 @@
function onRequest(context) {
var log = new Log("stats.js");
var carbonServer = require("carbon").server;
var device = context.unit.params.device;
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var constants = require("/app/modules/constants.js");
var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss");
var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER);
var jwtService = carbonServer.osgiService(
'org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService');
var jwtClient = jwtService.getJWTClient();
var encodedClientKeys = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]);
if (encodedClientKeys) {
var tokenUtil = require("/app/modules/oauth/token-handler-utils.js")["utils"];
var resp = tokenUtil.decode(encodedClientKeys).split(":");
var deviceParam = "{\"scope\":\"stats\",\"deviceIdentifiers\":[{\"id\":\"" + device.deviceIdentifier
+ "\", \"type\":\"" + device.type + "\"}]}";
var encodedScope = tokenUtil.encode(deviceParam);
var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username,"default",
{"device": encodedScope});
var token = "";
if (tokenPair) {
token = tokenPair.accessToken;
}
websocketEndpoint = websocketEndpoint + "/secured-outputui/org.wso2.iot.devices.temperature/1.0.0?" +
"token="+ token +"&deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type;
}
return {"device": device, "websocketEndpoint": websocketEndpoint};
}

@ -21,8 +21,8 @@ package org.wso2.carbon.device.mgt.iot.raspberrypi.service.impl;
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.analytics.dataservice.commons.SORT;
import org.wso2.carbon.analytics.dataservice.commons.SortByField;
import org.wso2.carbon.analytics.dataservice.commons.SortType;
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
@ -121,7 +121,7 @@ public class RaspberryPiServiceImpl implements RaspberryPiService {
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
}
List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField("time", SORT.ASC, false);
SortByField sortByField = new SortByField("time", SortType.ASC);
sortByFields.add(sortByField);
List<SensorRecord> sensorRecords = APIUtil.getAllEventsForDevice(sensorTableName, query, sortByFields);
return Response.status(Response.Status.OK.getStatusCode()).entity(sensorRecords).build();

@ -18,16 +18,30 @@
function onRequest(context) {
var log = new Log("stats.js");
var carbonServer = require("carbon").server;
var device = context.unit.params.device;
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var constants = require("/app/modules/constants.js");
var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss");
var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER);
var jwtService = carbonServer.osgiService(
'org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService');
var jwtClient = jwtService.getJWTClient();
var encodedClientKeys = session.get(constants["ENCODED_TENANT_BASED_CLIENT_APP_CREDENTIALS"]);
if (encodedClientKeys) {
var tokenUtil = require("/app/modules/oauth/token-handler-utils.js")["utils"];
var resp = tokenUtil.decode(encodedClientKeys).split(":");
var deviceParam = "{\"scope\":\"stats\",\"deviceIdentifiers\":[{\"id\":\"" + device.deviceIdentifier
+ "\", \"type\":\"" + device.type + "\"}]}";
var encodedScope = tokenUtil.encode(deviceParam);
var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username,"default",
{"device": encodedScope});
var token = "";
if (tokenPair) {
token = tokenPair.accessToken;
}
websocketEndpoint = websocketEndpoint + "/secured-outputui/org.wso2.iot.devices.temperature/1.0.0?" +
"token="+ token +"&deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type;
}
return {"device": device, "websocketEndpoint": websocketEndpoint};
}

@ -22,8 +22,8 @@ import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.analytics.dataservice.commons.SORT;
import org.wso2.carbon.analytics.dataservice.commons.SortByField;
import org.wso2.carbon.analytics.dataservice.commons.SortType;
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
@ -215,7 +215,7 @@ public class VirtualFireAlarmServiceImpl implements VirtualFireAlarmService {
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
}
List<SortByField> sortByFields = new ArrayList<>();
SortByField sortByField = new SortByField("time", SORT.ASC, false);
SortByField sortByField = new SortByField("time", SortType.ASC);
sortByFields.add(sortByField);
List<SensorRecord> sensorRecords = APIUtil.getAllEventsForDevice(sensorTableName, query, sortByFields);
return Response.status(Response.Status.OK.getStatusCode()).entity(sensorRecords).build();

@ -59,10 +59,26 @@
</a>
<a href="#" class="download-link btn-operations">
<i class="fw fw-download"></i>Download Agent</a>
<div id="download-device-modal-content" class="hide">
<div class="modal-content">
<div class="row">
<div class="col-md-7 center-container">
<div class="modal-header">
<h4 class="pull-left modal-title">
<span class="fw-stack">
<i class="fw fw-raspberry fw-stack-2x"></i>
<span class="fw-stack fw-move-right fw-move-bottom">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-circle fw-stack-2x fw-stroke text-info"></i>
<i class="fw fw-add fw-stack-1x fw-inverse"></i>
</span>
</span>
&nbsp;&nbsp;Add your new firealarm device to {{@app.conf.appName}}
</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i>
</button>
</div>
<hr>
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
<div class="panel-body col-centered text-center">
<h3>Name your device and download the agent from following link.</h3>
<br />
<form id="downloadForm" method="GET"
@ -90,12 +106,14 @@
<label for="advanced_agent">Advanced Agent</label>
</div>
</div>
<div class="buttons" style="padding-bottom: 0px">
<a class="btn btn-operations" onclick="downloadAgent()">Download Now</a>
</div>
</form>
</div>
</div>
<div class="modal-footer">
<div class="buttons" style="padding-bottom: 0px">
<a class="btn btn-operations" onclick="downloadAgent()">Download Now</a>
<a href="javascript:hidePopup()" class="btn-operations btn-default">Cancel</a>
</div>
</div>
</div>
<div id="device-agent-downloading-content" class="hide">

@ -79,7 +79,7 @@
</properties>
</adviceFile>
<bundles>
<bundleDef>org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.appmgt.mdm.osgiconnector:2.2.2-SNAPSHOT</bundleDef>
<bundleDef>org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.appmgt.mdm.osgiconnector:${carbon.devicemgt.plugins.version}</bundleDef>
<bundleDef>com.googlecode.plist:dd-plist:${googlecode.plist.version}</bundleDef>
</bundles>
<importFeatures>

@ -1,6 +1,7 @@
-- -----------------------------------------------------
-- Table `AD_DEVICE`
-- -----------------------------------------------------
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AD_DEVICE]') AND TYPE IN (N'U'))
CREATE TABLE AD_DEVICE (
DEVICE_ID VARCHAR(45) NOT NULL,
GCM_TOKEN VARCHAR(1000) NULL DEFAULT NULL,
@ -21,6 +22,7 @@ CREATE TABLE AD_DEVICE (
-- -----------------------------------------------------
-- Table `AD_FEATURE`
-- -----------------------------------------------------
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AD_FEATURE]') AND TYPE IN (N'U'))
CREATE TABLE AD_FEATURE (
ID INT NOT NULL IDENTITY,
CODE VARCHAR(45) NOT NULL,

@ -1,6 +1,7 @@
-- -----------------------------------------------------
-- Table `AD_DEVICE`
-- -----------------------------------------------------
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AD_DEVICE]') AND TYPE IN (N'U'))
CREATE TABLE AD_DEVICE (
DEVICE_ID VARCHAR(45) NOT NULL,
GCM_TOKEN VARCHAR(1000) NULL DEFAULT NULL,
@ -21,6 +22,7 @@ CREATE TABLE AD_DEVICE (
-- -----------------------------------------------------
-- Table `AD_FEATURE`
-- -----------------------------------------------------
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AD_FEATURE]') AND TYPE IN (N'U'))
CREATE TABLE AD_FEATURE (
ID INT NOT NULL IDENTITY,
CODE VARCHAR(45) NOT NULL,

@ -1,6 +1,7 @@
-- -----------------------------------------------------
-- Table `IOS_FEATURE`
-- -----------------------------------------------------
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[IOS_FEATURE]') AND TYPE IN (N'U'))
CREATE TABLE IOS_FEATURE (
ID INT NOT NULL IDENTITY,
CODE VARCHAR(45) NOT NULL,
@ -12,6 +13,7 @@ CREATE TABLE IOS_FEATURE (
-- -----------------------------------------------------
-- Table `IOS_DEVICE`
-- -----------------------------------------------------
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[IOS_DEVICE]') AND TYPE IN (N'U'))
CREATE TABLE IOS_DEVICE (
MOBILE_DEVICE_ID VARCHAR(45) NOT NULL,
APNS_PUSH_TOKEN VARCHAR(100) NULL DEFAULT NULL,

@ -1,6 +1,7 @@
-- -----------------------------------------------------
-- Table `WINDOWS_FEATURE`
-- -----------------------------------------------------
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[WIN_FEATURE]') AND TYPE IN (N'U'))
CREATE TABLE WIN_FEATURE (
ID INT NOT NULL IDENTITY,
CODE VARCHAR(45) NOT NULL,
@ -12,6 +13,7 @@ CREATE TABLE WIN_FEATURE (
-- -----------------------------------------------------
-- Table `WINDOWS_DEVICE`
-- -----------------------------------------------------
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[WIN_DEVICE]') AND TYPE IN (N'U'))
CREATE TABLE WIN_DEVICE (
DEVICE_ID VARCHAR(45) NOT NULL,
CHANNEL_URI VARCHAR(100) NULL DEFAULT NULL,

@ -1,6 +1,7 @@
-- -----------------------------------------------------
-- Table `WINDOWS_FEATURE`
-- -----------------------------------------------------
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[WIN_FEATURE]') AND TYPE IN (N'U'))
CREATE TABLE WIN_FEATURE (
ID INT NOT NULL IDENTITY,
CODE VARCHAR(45) NOT NULL,
@ -12,6 +13,7 @@ CREATE TABLE WIN_FEATURE (
-- -----------------------------------------------------
-- Table `WINDOWS_DEVICE`
-- -----------------------------------------------------
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[WIN_DEVICE]') AND TYPE IN (N'U'))
CREATE TABLE WIN_DEVICE (
DEVICE_ID VARCHAR(45) NOT NULL,
CHANNEL_URI VARCHAR(100) NULL DEFAULT NULL,

@ -1250,8 +1250,8 @@
<!-- Carbon Analytics -->
<carbon.analytics.common.version>5.1.3</carbon.analytics.common.version>
<carbon.analytics.common.version.range>[5.1.3,6.0.0)</carbon.analytics.common.version.range>
<carbon.analytics.version>1.0.6-ALPHA</carbon.analytics.version>
<carbon.analytics.version.range>[1.0.5,2.0.0]</carbon.analytics.version.range>
<carbon.analytics.version>1.2.8</carbon.analytics.version>
<carbon.analytics.version.range>[1.2.8,2.0.0]</carbon.analytics.version.range>
<!-- Third Party Dependencies-->
<spongycastle.version>1.51.0.0</spongycastle.version>

Loading…
Cancel
Save