diff --git a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.hbs b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.hbs
index 9907fa26..76a4038a 100644
--- a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.hbs
+++ b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.hbs
@@ -1,8 +1,47 @@
-
+{{!
+ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-
+ WSO2 Inc. licenses this file to you under the Apache License,
+ Version 2.0 (the "License"); you may not use this file except
+ in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+}}
+
+
+
+
Temperature
+
+
+
+
+
+
+
+
+
+
+
Coffee Level
+
+
+
+
+
+
+
+
+
+
{{#zone "bottomJs"}}
{{js "js/connectedcup.js"}}
diff --git a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.js b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.js
index c70c6d0c..d651ba0b 100644
--- a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.js
+++ b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/analytics-view.js
@@ -17,30 +17,26 @@
*/
function onRequest(context) {
- var devicemgtProps = require('/app/conf/devicemgt-props.js').config();
-
var devices = context.unit.params.devices;
var deviceType = context.uriParams.deviceType;
- var deviceId = request.getParameter('deviceId');
+ var deviceId = request.getParameter("deviceId");
if (devices) {
return {
- 'devices': stringify(devices),
- 'backendApiUri': devicemgtProps['httpsURL'] + '/connectedcup/stats/',
- 'dashboardserverURL': devicemgtProps['dashboardserverURL']
+ "devices": stringify(devices),
+ "backendApiUri": "/connectedcup/stats/"
};
- } else if (deviceType && deviceId) {
- var deviceModule = require('/app/modules/device.js').deviceModule;
+ } else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
+ var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId);
- if (device && device.status != 'error') {
+ if (device && device.status != "error") {
return {
- 'device': device.content,
- 'backendApiUri': devicemgtProps['httpsURL'] + '/connectedcup/stats/' + deviceId,
- 'dashboardserverURL': devicemgtProps['dashboardserverURL']
+ "device": device.content,
+ "backendApiUri": "/connectedcup/stats/" + deviceId
};
} else {
- response.sendError(404, 'Device Id ' + deviceId + ' of type ' + deviceType + ' cannot be found!');
+ response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");
exit();
}
}
-}
+}
\ No newline at end of file
diff --git a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/public/js/connectedcup.js b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/public/js/connectedcup.js
index ebd48673..02e4a6d3 100644
--- a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/public/js/connectedcup.js
+++ b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.analytics-view/public/js/connectedcup.js
@@ -224,7 +224,8 @@ function drawGraph_connectedcup(from, to) {
if (devices) {
getData();
} else {
- var backendApiUrl = $('#connectedcup-div-chart').data('backend-api-url') + '/sensors/temperature' + '?from=' + from + '&to=' + to;
+ var backendApiUrl = $('#connectedcup-div-chart').data('backend-api-url') + '/sensors/temperature'
+ + '?from=' + from + '&to=' + to;
var successCallback = function (data) {
if (data) {
drawTemperatureLineGraph(JSON.parse(data));
@@ -249,8 +250,7 @@ function drawGraph_connectedcup(from, to) {
return;
}
var backendApiUrl = $('#connectedcup-div-chart').data('backend-api-url') + devices[deviceIndex].deviceIdentifier
- + '/sensors/temperature'
- + '?from=' + from + '&to=' + to;
+ + '/sensors/temperature?from=' + from + '&to=' + to;
var successCallback = function (data) {
if (data) {
drawTemperatureLineGraph(JSON.parse(data));
@@ -264,7 +264,7 @@ function drawGraph_connectedcup(from, to) {
getData();
});
var coffeeLevelApiUrl = $('#connectedcup-div-chart').data('backend-api-url') + devices[deviceIndex].deviceIdentifier
- + '/sensors/coffeelevel' + '?from=' + from + '&to=' + to;
+ + '/sensors/coffeelevel?from=' + from + '&to=' + to;
var successCallbackCoffeeLevel = function (data) {
if (data) {
diff --git a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.hbs b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.hbs
index 304e8ba9..89403d3e 100644
--- a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.hbs
+++ b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.hbs
@@ -24,49 +24,43 @@
{{/zone}}
-{{#zone "device-detail-properties"}}
-
diff --git a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.js b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.js
index b4fa71bc..63ebf3d2 100644
--- a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.js
+++ b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.device-view/device-view.js
@@ -18,26 +18,23 @@
function onRequest(context) {
- var log = new Log('detail.js');
var deviceType = context.uriParams.deviceType;
var deviceId = request.getParameter('id');
- var devicemgtProps = require('/app/conf/devicemgt-props.js').config();
-
if (deviceType && deviceId) {
- var deviceModule = require('/app/modules/device.js').deviceModule;
- var device = deviceModule.viewDevice(deviceType, deviceId);
+ var deviceModule = require("/app/modules/business-controllers/device.js").deviceModule;
+ var deviceData = deviceModule.viewDevice(deviceType, deviceId);
- if (device && device.status != 'error') {
+ if (deviceData && deviceData.status != 'error') {
+ var device = deviceData.content;
var constants = require('/app/modules/constants.js');
- var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER);
- var token = '';
+ var tokenPair = JSON.parse(session.get(constants.TOKEN_PAIR));
if (tokenPair) {
- token = tokenPair.accessToken;
+ device.accessToken = tokenPair.accessToken;
}
- device.accessToken = token;
+ var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
device.ip = devicemgtProps['httpsWebURL'];
- return {'device': device.content};
+ return {'device': deviceData.content};
}
}
}
diff --git a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/analytics-view.hbs b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/analytics-view.hbs
index 656ad5fc..0a7848a4 100644
--- a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/analytics-view.hbs
+++ b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/analytics-view.hbs
@@ -1,8 +1,25 @@
+{{!
+ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+
+ WSO2 Inc. licenses this file to you under the Apache License,
+ Version 2.0 (the "License"); you may not use this file except
+ in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+}}
{{unit "cdmf.unit.lib.rickshaw-graph"}}
-
Temperature
+
Temperature
diff --git a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/analytics-view.js b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/analytics-view.js
index 51e51b99..e54cef4e 100644
--- a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/analytics-view.js
+++ b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/analytics-view.js
@@ -17,16 +17,28 @@
*/
function onRequest(context) {
+ var log = new Log("stats.js");
+ var carbonServer = require("carbon").server;
var device = context.unit.params.device;
- var devicemgtProps = require('/app/conf/devicemgt-props.js').config();
- var constants = require('/app/modules/constants.js');
- var websocketEndpoint = devicemgtProps['wssURL'].replace('https', 'wss');
- var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER);
- var token = '';
- if (tokenPair) {
- token = tokenPair.accessToken;
+ 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 jwtService = carbonServer.osgiService(
+ 'org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService');
+ var jwtClient = jwtService.getJWTClient();
+ var encodedClientKeys = session.get(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"]);
+ var token = "";
+ if (encodedClientKeys) {
+ var tokenUtil = require("/app/modules/oauth/token-handler-utils.js")["utils"];
+ var resp = tokenUtil.decode(encodedClientKeys).split(":");
+ var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username,"default", {});
+ if (tokenPair) {
+ token = tokenPair.accessToken;
+ }
+ websocketEndpoint = websocketEndpoint + "/secured-websocket/org.wso2.iot.devices.temperature/1.0.0?"
+ + "deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type;
+ var websocketToken= {'name':'websocket-token','value': token, 'path':'/', "maxAge":18000};
+ response.addCookie(websocketToken);
}
- websocketEndpoint = websocketEndpoint + '/secured-outputui/org.wso2.iot.connectedcup/1.0.0?' +
- 'token=' + token + '&deviceId=' + device.deviceIdentifier;
- return {'device': device, 'websocketEndpoint': websocketEndpoint};
-}
+ return {"device": device, "websocketEndpoint": websocketEndpoint};
+}
\ No newline at end of file
diff --git a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/device-stats.js b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/device-stats.js
index 1eaca7d9..2805d0c4 100644
--- a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/device-stats.js
+++ b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.realtime.analytics-view/public/js/device-stats.js
@@ -18,41 +18,30 @@
var ws;
var graph;
-var temperatureData = [];
-var coffeeData = [];
-var temperature = 0;
-var coffeelevel = 0;
-var lastTime = 0;
-var palette = new Rickshaw.Color.Palette({scheme: 'classic9'});
+var chartData = [];
+var palette = new Rickshaw.Color.Palette({scheme: "classic9"});
$(window).load(function () {
var tNow = new Date().getTime() / 1000;
for (var i = 0; i < 30; i++) {
- temperatureData.push({
- x: tNow - (30 - i) * 15,
- y: parseFloat(0)
- });
- coffeeData.push({
- x: tNow - (30 - i) * 15,
- y: parseFloat(0)
- });
+ chartData.push({
+ x: tNow - (30 - i) * 15,
+ y: parseFloat(0)
+ });
}
graph = new Rickshaw.Graph({
- element: document.getElementById('chart'),
- width: $('#div-chart').width() - 50,
+ element: document.getElementById("chart"),
+ width: $("#div-chart").width() - 50,
height: 300,
- renderer: 'line',
+ renderer: "line",
+ interpolation: "linear",
padding: {top: 0.2, left: 0.0, right: 0.0, bottom: 0.2},
xScale: d3.time.scale(),
series: [{
'color': palette.color(),
- 'data': coffeeData,
- 'name': 'Coffee Level'
- }, {
- 'color': palette.color(),
- 'data': temperatureData,
- 'name': 'Temperature'
+ 'data': chartData,
+ 'name': "Temperature"
}]
});
@@ -77,11 +66,11 @@ $(window).load(function () {
formatter: function (series, x, y) {
var date = '' + moment(x * 1000).format('Do MMM YYYY h:mm:ss a') + '';
var swatch = '';
- return swatch + series.name + ': ' + parseInt(y) + ' ' + date;
+ return swatch + series.name + ": " + parseInt(y) + ' ' + date;
}
});
- var websocketUrl = $('#div-chart').data('websocketurl');
+ var websocketUrl = $("#div-chart").data("websocketurl");
connect(websocketUrl)
});
@@ -101,25 +90,12 @@ function connect(target) {
if (ws) {
ws.onmessage = function (event) {
var dataPoint = JSON.parse(event.data);
- if (lastTime < parseInt(dataPoint[4]) / 1000) {
- lastTime = parseInt(dataPoint[4]) / 1000;
- if (dataPoint[3] == 'temperature') {
- temperature = parseFloat(dataPoint[5]);
- } else if (dataPoint[3] == 'coffeelevel') {
- coffeelevel = parseFloat(dataPoint[6]);
- }
- temperatureData.push({
- x: lastTime,
- y: temperature
- });
- temperatureData.shift();
- coffeeData.push({
- x: lastTime,
- y: coffeelevel
- });
- coffeeData.shift();
- graph.update();
- }
+ chartData.push({
+ x: parseInt(dataPoint[4]) / 1000,
+ y: parseFloat(dataPoint[5])
+ });
+ chartData.shift();
+ graph.update();
};
}
}
diff --git a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/css/styles.css b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/css/styles.css
new file mode 100644
index 00000000..4783af75
--- /dev/null
+++ b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/css/styles.css
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+.circle {
+ background: none repeat scroll 0 0 #191919;
+ border-radius: 50px;
+ height: 50px;
+ padding: 10px;
+ width: 50px;
+ color: #fff;
+}
+
+.padding-top-double {
+ padding-top: 20px;
+}
+
+.padding-double {
+ padding: 20px;
+}
+
+.grey {
+ color: #333;
+}
+
+hr {
+ display: block;
+ height: 1px;
+ border: 0;
+ border-top: 1px solid #7f7f7f;
+ margin: 1em 0;
+ padding: 0;
+ opacity: 0.2;
+}
+
+.light-grey {
+ color: #7c7c7c;
+}
+
+.uppercase {
+ text-transform: uppercase;
+}
+
+.grey-bg {
+ background-color: #f6f4f4;
+}
+
+.doc-link{
+ background: none;
+ color: #000;
+ padding: 10px 0px;
+}
+.doc-link a {
+ color: #006eff;
+}
diff --git a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/js/download.js b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/js/download.js
index 1508597b..edafe562 100644
--- a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/js/download.js
+++ b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/public/js/download.js
@@ -16,13 +16,13 @@
* under the License.
*/
-var modalPopup = '.wr-modalpopup';
-var modalPopupContainer = modalPopup + ' .modalpopup-container';
-var modalPopupContent = modalPopup + ' .modalpopup-content';
-var body = 'body';
+var modalPopup = ".modal";
+var modalPopupContainer = modalPopup + " .modal-content";
+var modalPopupContent = modalPopup + " .modal-content";
+var body = "body";
/*
- * set popup maximum height function.
+ * Set popup maximum height function.
*/
function setPopupMaxHeight() {
$(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30)));
@@ -33,36 +33,14 @@ function setPopupMaxHeight() {
* show popup function.
*/
function showPopup() {
- $(modalPopup).show();
+ $(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 = '';
+ var deviceType = "";
$('.deviceType').each(function () {
if (this.value != '') {
deviceType = this.value;
}
});
- if (deviceType == 'digitaldisplay') {
- $('.sketchType').remove();
- $('input[name="sketchType"][value="digitaldisplay"]').prop('checked', true);
- $('label[for="digitaldisplay"]').text('Simple Agent');
- } else {
- $('.sketchTypes').remove();
- }
}
/*
@@ -72,7 +50,7 @@ function hidePopup() {
$('label[for=deviceName]').remove();
$('.control-group').removeClass('success').removeClass('error');
$(modalPopupContent).html('');
- $(modalPopup).hide();
+ $(modalPopup).modal('hide');
}
/*
@@ -88,46 +66,9 @@ function attachEvents() {
* when a user clicks on "Download" link
* on Device Management page in WSO2 DC Console.
*/
- $('a.download-link').click(function () {
- var sketchType = $(this).data('sketchtype');
- var deviceType = $(this).data('devicetype');
- var downloadDeviceAPI = '/devicemgt/api/devices/sketch/generate_link';
- var payload = {'sketchType': sketchType, 'deviceType': deviceType};
+ $("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();
- if (deviceName && deviceName.length >= 4) {
- payload.deviceName = deviceName;
- invokerUtil.post(
- downloadDeviceAPI,
- payload,
- function (data, textStatus, jqxhr) {
- doAction(data);
- },
- function (data) {
- doAction(data);
- }
- );
- } else if (deviceName) {
- $('.controls').append('');
- $('.control-group').removeClass('success').addClass('error');
- } else {
- $('.controls').append('');
- $('.control-group').removeClass('success').addClass('error');
- }
- });
-
- $('a#download-device-cancel-link').click(function () {
- hidePopup();
- });
-
});
}
@@ -141,33 +82,40 @@ function downloadAgent() {
values[this.name] = $(this).val();
});
- var payload = {};
- payload.name = $inputs[0].value;
- payload.owner = $inputs[1].value;
-
- var connectedCupRegisterURL = '/connectedcup/device/register?name=' + encodeURI(payload.name);
-
- invokerUtil.post(
- connectedCupRegisterURL,
- payload,
- function (data, textStatus, jqxhr) {
- hidePopup();
- },
- function (data) {
- hidePopup();
- }
- );
-
- var deviceName;
+ var deviceName = $inputs[0].value;
$('.new-device-name').each(function () {
if (this.value != '') {
deviceName = this.value;
}
});
- if (deviceName && deviceName.length >= 4) {
- setTimeout(function () {
- hidePopup();
- }, 1000);
+ var deviceNameFormat = /^[^~?!#$:;%^*`+={}\[\]\\()|<>,'"]{1,30}$/;
+ if (deviceName && deviceName.length < 4) {
+ $("#invalid-username-error-msg span").text("Device name should be more than 3 letters!");
+ $("#invalid-username-error-msg").removeClass("hidden");
+ } else if (deviceName && deviceNameFormat.test(deviceName)) {
+ var payload = {};
+ payload.name = $inputs[0].value;
+ payload.owner = $inputs[1].value;
+ var connectedCupRegisterURL = '/connectedcup/device/register?name=' + encodeURI(payload.name);
+ invokerUtil.post(
+ connectedCupRegisterURL,
+ payload,
+ function (data, textStatus, jqxhr) {
+ $(modalPopupContent).html($('#device-created-content').html());
+ $('#device-created-link').click(function () {
+ hidePopup();
+ });
+ setTimeout(function () {
+ hidePopup();
+ }, 1000);
+ },
+ function (data) {
+ doAction(data)
+ }
+ );
+ } else {
+ $("#invalid-username-error-msg span").text("Invalid device name");
+ $("#invalid-username-error-msg").removeClass("hidden");
}
}
@@ -202,4 +150,4 @@ function doAction(data) {
hidePopup();
});
}
-}
+}
\ No newline at end of file
diff --git a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/type-view.hbs b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/type-view.hbs
index 6025acd6..8082fe39 100644
--- a/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/type-view.hbs
+++ b/modules/distribution/src/resources/samples/connectedcup/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.connectedcup.type-view/type-view.hbs
@@ -1,16 +1,28 @@
-
+{{!
+ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+
+ WSO2 Inc. licenses this file to you under the Apache License,
+ Version 2.0 (the "License"); you may not use this file except
+ in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+}}
+
Connected Cup
-
+
-
-
Click
- [ here ] for latest instructions and troubleshooting.
-
-
+
What it Does
Connected cup is a virtual simulation of a smart coffee cup from the IOT Hardware
@@ -18,35 +30,36 @@
around with the temperature and Coffee level. And the information will be relayed back to
the IoTServer and summarized.
-
The device supports communication via HTTPS only.
-
What You Need
-
STEP 01 Go ahead and
- [Crete an Instance] of the Device.
+
+ STEP 01
+ Go ahead and [Download] the Device.
-
STEP 02 Give a name to your
- Connected Cup instance.
+
+ STEP 02
+ Proceed to [Prepare] section.
-
STEP 03 Read
- [Try Out] section
- to further experiment with the device.
+
+ STEP 03
+ Read [Try Out] section to further experiment with the device.