diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..b5c87da2 Binary files /dev/null and b/.DS_Store differ diff --git a/modules/.DS_Store b/modules/.DS_Store new file mode 100644 index 00000000..65deaca4 Binary files /dev/null and b/modules/.DS_Store differ diff --git a/modules/distribution/.DS_Store b/modules/distribution/.DS_Store new file mode 100644 index 00000000..e919e235 Binary files /dev/null and b/modules/distribution/.DS_Store differ diff --git a/modules/distribution/pom.xml b/modules/distribution/pom.xml index ea5f04ec..9c8a451c 100644 --- a/modules/distribution/pom.xml +++ b/modules/distribution/pom.xml @@ -411,6 +411,8 @@ + + @@ -431,6 +433,10 @@ + + + + + + + + + //global object to pass request stat among fuse framework files. var fuseState = { @@ -14,14 +14,14 @@ var fuseState = { currentUnit: null }; -var requestId = function makeId() { - var text = ""; - var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - for (var i = 0; i < 5; i++) - text += possible.charAt(Math.floor(Math.random() * possible.length)); + + + + + - return text; -}(); + + var fuseDebug = false; //var fuseDebug = true; diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse.js b/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse.js index 7380f57c..134f441c 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse.js @@ -93,10 +93,10 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors, layout = model.layout; mainUnit = model.name; } else { - log.warn( - '[' + requestId + '] multiple layouts ' + mainUnit + ':' + - layout + ' vs ' + model.name + ':' + model.layout - ); + //log.warn( + // '[' + requestId + '] multiple layouts ' + mainUnit + ':' + + // layout + ' vs ' + model.name + ':' + model.layout + //); } } }; @@ -152,8 +152,8 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors, initLookUp(definitions); var model = definitions[lookUpTable[unit]]; if (!model) { - log.warn('[' + requestId + '] unit "' + unit + '" does not exits'); - throw '[' + requestId + '] unit "' + unit + '" does not exits'; + //log.warn('[' + requestId + '] unit "' + unit + '" does not exits'); + //throw '[' + requestId + '] unit "' + unit + '" does not exits'; } return model; }; @@ -219,7 +219,7 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors, var path = definitionFile.getPath(); if (log.isDebugEnabled()) { - log.debug('[' + requestId + '] reading file "' + path + '"'); + //log.debug('[' + requestId + '] reading file "' + path + '"'); } unitModel.definition = require(path); @@ -351,10 +351,10 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors, while (len--) { if (toDelete[units[len]]) { if (log.isDebugEnabled()) { - log.debug( - '[' + requestId + '] unit "' + units[len] + - '" is overridden by "' + toDelete[units[len]] + '"' - ); + //log.debug( + // '[' + requestId + '] unit "' + units[len] + + // '" is overridden by "' + toDelete[units[len]] + '"' + //); } units.splice(len, 1); } @@ -412,10 +412,10 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors, var selfFile = new File(getUnitPath(unitName) + slashPath + selfFileName); if (selfFile.isExists()) { if (log.isDebugEnabled()) { - log.debug( - '[' + requestId + '] for unit "' + unitName + '" file resolved : "' - + slashPath + selfFileName + '" -> "' + selfFile.getPath() + '"' - ); + //log.debug( + // '[' + requestId + '] for unit "' + unitName + '" file resolved : "' + // + slashPath + selfFileName + '" -> "' + selfFile.getPath() + '"' + //); } return selfFile; @@ -434,19 +434,19 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors, var file = new File(getUnitPath(ancestorName) + slashPath + fileName); if (file.isExists()) { if (log.isDebugEnabled()) { - log.debug( - '[' + requestId + '] for unit "' + unitName + '" file resolved : "' - + slashPath + selfFileName + '" -> "' + file.getPath() + '"' - ); + //log.debug( + // '[' + requestId + '] for unit "' + unitName + '" file resolved : "' + // + slashPath + selfFileName + '" -> "' + file.getPath() + '"' + //); } return file; } } if (log.isDebugEnabled()) { - log.debug( - '[' + requestId + '] for unit "' + unitName + '" (non-excising) file resolved : "' - + slashPath + selfFileName + '" -> "' + selfFile.getPath() + '"' - ); + //log.debug( + // '[' + requestId + '] for unit "' + unitName + '" (non-excising) file resolved : "' + // + slashPath + selfFileName + '" -> "' + selfFile.getPath() + '"' + //); } return selfFile; }; diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/lib/handlebars-helpers.js b/modules/distribution/src/repository/jaggeryapps/iotserver/lib/handlebars-helpers.js index 8c915700..f303d0e0 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/lib/handlebars-helpers.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/lib/handlebars-helpers.js @@ -29,8 +29,8 @@ var getScope = function (unit,configs) { //a warning as the unit author may have forgotten to return a data object if(cbResult===undefined){ cbResult = {}; //Give an empty data object - log.warn('[' + requestId + '] unit "' + unit + '" has a onRequest method which does not return a value.This may lead to the ' - +'unit not been rendered correctly.'); + //log.warn('[' + requestId + '] unit "' + unit + '" has a onRequest method which does not return a value.This may lead to the ' + // +'unit not been rendered correctly.'); } viewModel = cbResult; } @@ -72,7 +72,7 @@ Handlebars.registerHelper('defineZone', function (zoneName, zoneContent) { var unit = unitsToRender[i]; if (Handlebars.innerZonesFromUnit == null || Handlebars.innerZonesFromUnit.unitName == unit.unitName) { var template = fuse.getFile(unit.originUnitName || unit.unitName, '', '.hbs'); - log.debug('[' + requestId + '] for zone "' + zone + '" including template :"' + template.getPath() + '"'); + //log.debug('[' + requestId + '] for zone "' + zone + '" including template :"' + template.getPath() + '"'); result += Handlebars.compileFile(template)(getScope(unit.unitName, zoneContent.data.root)); } } @@ -157,7 +157,7 @@ Handlebars.registerHelper('unit', function (unitName,options) { //TODO warn when unspecified decencies are included. fuseState.currentZone.push('main'); var template = fuse.getFile(baseUnit, '', '.hbs'); - log.debug('[' + requestId + '] including "' + baseUnit + '"'+" with configs "+stringify(templateConfigs)); + //log.debug('[' + requestId + '] including "' + baseUnit + '"'+" with configs "+stringify(templateConfigs)); var result = new Handlebars.SafeString(Handlebars.compileFile(template)(getScope(baseUnit,templateConfigs))); fuseState.currentZone.pop(); return result; @@ -176,7 +176,7 @@ Handlebars.compileFile = function (file) { } f.open('r'); - log.debug('[' + requestId + '] reading file "' + f.getPath() + '"'); + //log.debug('[' + requestId + '] reading file "' + f.getPath() + '"'); var content = f.readAll().trim(); f.close(); var compiled = Handlebars.compile(content); diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/lib/less-rhino-1.7.5.js b/modules/distribution/src/repository/jaggeryapps/iotserver/lib/less-rhino-1.7.5.js index 4a191ca4..b9d609e9 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/lib/less-rhino-1.7.5.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/lib/less-rhino-1.7.5.js @@ -14,7 +14,7 @@ function readFile(name) { var pathInfo = fuse.toRelativePath(name); f = fuse.getFile(pathInfo.unit, pathInfo.path); } - log.debug('[' + requestId + '] opening less file : "' + f.getPath() + '"'); + //log.debug('[' + requestId + '] opening less file : "' + f.getPath() + '"'); f.open('r'); return f.readAll(); } diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/constants.js b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/constants.js index d0cc6283..0e68d24b 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/constants.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/constants.js @@ -21,6 +21,7 @@ var WEB_APP_CONTEXT = "/iotserver"; var USER_SESSION_KEY = "USER"; var UNSPECIFIED = "Unspecified"; var DEVICES_UNIT_PATH="/units/"; +var POLICY_REGISTRY_PATH="/_system/governance/policy_declarations/"; var DEVICE_IDENTIFIER = "deviceIdentifier"; var DEVICE_NAME = "name"; diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/device.js b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/device.js index 845c2ea2..ae25e845 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/device.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/device.js @@ -232,7 +232,7 @@ deviceModule = function () { deviceManagementService.addOperation(operationInstance, deviceList); }; - privateMethods.getDevice = function (type, deviceId) { + publicMethods.getDevice = function (type, deviceId) { var deviceIdentifier = new DeviceIdentifier(); deviceIdentifier.setType(type); deviceIdentifier.setId(deviceId); @@ -240,7 +240,7 @@ deviceModule = function () { }; publicMethods.viewDevice = function (type, deviceId) { - var device = privateMethods.getDevice(type, deviceId); + var device = publicMethods.getDevice(type, deviceId); if (device) { var propertiesList = DeviceManagerUtil.convertDevicePropertiesToMap(device.getProperties()); var entries = propertiesList.entrySet(); diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/event.js b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/event.js new file mode 100644 index 00000000..75594e97 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/event.js @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2015, 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. + */ + +var eventModule; +eventModule = function () { + var log = new Log("modules/event.js"); + + var constants = require("/modules/constants.js"); + var utility = require("/modules/utility.js").utility; + + var publicMethods = {}; + var privateMethods = {}; + + var statsClient = new Packages.org.wso2.carbon.device.mgt.iot.common.analytics.statistics.IoTEventsStatisticsClient; + + publicMethods.getEventsData = function (username, recordLimit) { + var fetchedData = null; + + try { + fetchedData = statsClient.getRecentDeviceStats(username, recordLimit); + } catch (error) { + log.error(error); + } + + var eventsData = []; + + // -- start of dummy data + + var timeInterval = 30; + var i, rnd; + var currentDay = new Date(); + var startDate = currentDay.getTime() - (60 * 60 * 24 * 5); + var endDate = currentDay.getTime(); + + var i = parseInt(startDate / 1000); + while (i < parseInt(endDate / 1000)) { + rnd = rnd = Math.random() * 50; + eventsData.push({time: i*1000, deviceName: 'device' + rnd, activity:'Event number ' + rnd}); + i += timeInterval; + } + + // -- end of dummy data + + // for (var i = 0; i < fetchedData.size(); i++) { + // eventsData.push({ + // time: fetchedData.get(i).getTime(), + // deviceName: fetchedData.get(i).getDeviceName(), + // activity: fetchedData.get(i).getDeviceActivity() + // }); + // }; + + return eventsData; + }; + + + return publicMethods; +}(); + + diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js old mode 100644 new mode 100755 index c7501239..a9137582 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js @@ -26,59 +26,128 @@ policyModule = function () { var publicMethods = {}; var privateMethods = {}; - publicMethods.addPolicy = function (name, deviceType, policyDefinition) { + publicMethods.addPolicy = function (policyName, deviceType, policyDefinition, policyDescription) { + if (policyName && deviceType) { + var carbonModule = require("carbon"); + var carbonServer = application.get("carbonServer"); + var options = {system: true}; + var carbonUser = session.get(constants.USER_SESSION_KEY); + + var resource = { + name: policyName, + mediaType: 'text/plain', + content: policyDefinition, + description: policyDescription, + properties:{owner: carbonUser.username} + }; + + if (carbonUser) { + options.tenantId = carbonUser.tenantId; + var registry = new carbonModule.registry.Registry(carbonServer, options); + log.info("########### Policy name : " + policyName); + log.info("########### Policy type : " + deviceType); + log.info("########### Policy Declaration : " + policyDefinition); + log.info("########### Policy policyDescription: " + policyDescription); + registry.put(constants.POLICY_REGISTRY_PATH + deviceType + "/" + policyName, resource); + } + + var mqttsenderClass = Packages.org.wso2.device.mgt.mqtt.policy.push.MqttPush; + var mqttsender = new mqttsenderClass(); + + var result = mqttsender.pushToMQTT("/iot/policymgt/govern/" + deviceType + "/" + carbonUser.username, policyDefinition, "tcp://localhost:1883", "Raspberry-Policy-sender"); + + mqttsender = null; + + return true; + + } else { + return false; + } }; publicMethods.getPolicies = function () { - - //TODO-This method returns includes dummy policy data + var carbonModule = require("carbon"); + var carbonServer = application.get("carbonServer"); + var options = {system: true}; + var carbonUser = session.get(constants.USER_SESSION_KEY); var policies = []; - var policyObj = { - "id":1, // Identifier of the policy. - "priorityId":1, // Priority of the policies. This will be used only for simple evaluation. - "profile":{}, // Profile - "policyName":"Turn off light", // Name of the policy. - "generic":true, // If true, this should be applied to all related device. - "roles":{}, // Roles which this policy should be applied. - "ownershipType":{}, // Ownership type (COPE, BYOD, CPE) - "devices":{}, // Individual devices this policy should be applied - "users":{}, // Individual users this policy should be applied - "Compliance":{}, - "policyCriterias":{}, - "startTime":283468236, // Start time to apply the policy. - "endTime":283468236, // After this time policy will not be applied - "startDate":"", // Start date to apply the policy - "endDate":"", // After this date policy will not be applied. - "tenantId":-1234, - "profileId":1 - }; - policies.push(policyObj); + if (carbonUser) { + options.tenantId = carbonUser.tenantId; + var registry = new carbonModule.registry.Registry(carbonServer, options); + var allPolicies = registry.get(constants.POLICY_REGISTRY_PATH); - policyObj = { - "id":2, // Identifier of the policy. - "priorityId":1, // Priority of the policies. This will be used only for simple evaluation. - "profile":{}, // Profile - "policyName":"Turn on Buzzer", // Name of the policy. - "generic":false, // If true, this should be applied to all related device. - "roles":{}, // Roles which this policy should be applied. - "ownershipType":{}, // Ownership type (COPE, BYOD, CPE) - "devices":{}, // Individual devices this policy should be applied - "users":{}, // Individual users this policy should be applied - "Compliance":{}, - "policyCriterias":{}, - "startTime":283468236, // Start time to apply the policy. - "endTime":283468236, // After this time policy will not be applied - "startDate":"", // Start date to apply the policy - "endDate":"", // After this date policy will not be applied. - "tenantId":-1234, - "profileId":2 - }; + if (allPolicies) { + + //loop through all device types + for (var i = 0; i < allPolicies.content.length; i++) { + var deviceType = allPolicies.content[i].replace(constants.POLICY_REGISTRY_PATH, ""); + var deviceTypePolicies = registry.get(allPolicies.content[i]); + + //loop through policies + for (var j = 0; j < deviceTypePolicies.content.length; j++) { + var deviceTypePolicy = registry.get(deviceTypePolicies.content[j]); + + if(stringify(registry.properties(deviceTypePolicies.content[j]).owner) != '["'+carbonUser.username+'"]'){ + //not owned by current user, skip it + continue; + } + + var policyObj = { + "id": deviceTypePolicy.uuid, // Identifier of the policy. + //"priorityId": 1, // Priority of the policies. This will be used only for simple evaluation. + //"profile": {}, // Profile + "policyName": deviceTypePolicy.name, // Name of the policy. + "updated": deviceTypePolicy.updated.time, + "deviceType": deviceType + //"generic": true, // If true, this should be applied to all related device. + //"roles": {}, // Roles which this policy should be applied. + //"ownershipType": {}, // Ownership type (COPE, BYOD, CPE) + //"devices": {}, // Individual devices this policy should be applied + //"users": {}, // Individual users this policy should be applied + //"Compliance": {}, + //"policyCriterias": {}, + //"startTime": 283468236, // Start time to apply the policy. + //"endTime": 283468236, // After this time policy will not be applied + //"startDate": "", // Start date to apply the policy + //"endDate": "", // After this date policy will not be applied. + //"tenantId": -1234, + //"profileId": 1 + }; + + policies.push(policyObj); + }//end of policy loop + }//end of device type policy loop + } + } - policies.push(policyObj); return policies; + + }; + + publicMethods.removePolicy = function (name, deviceType) { + var carbonModule = require("carbon"); + var carbonServer = application.get("carbonServer"); + var options = {system: true}; + var carbonUser = session.get(constants.USER_SESSION_KEY); + var bool = false; + + if (carbonUser) { + options.tenantId = carbonUser.tenantId; + var registry = new carbonModule.registry.Registry(carbonServer, options); + log.info("########### Policy name : " + name); + log.info("########### Policy type : " + deviceType); + try { + registry.remove(constants.POLICY_REGISTRY_PATH + deviceType + "/" + name); + bool = true; + } catch (err) { + log.error("Error while trying to remove policy :" + name, err); + } + } + + return bool; }; return publicMethods; diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/devices/analytics.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/analytics.hbs similarity index 57% rename from modules/distribution/src/repository/jaggeryapps/iotserver/pages/devices/analytics.hbs rename to modules/distribution/src/repository/jaggeryapps/iotserver/pages/analytics.hbs index 5f42efc4..31264fd6 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/devices/analytics.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/analytics.hbs @@ -1,9 +1,9 @@ {{authorized}} {{layout "fluid"}} {{#zone "title"}} - WSO2 DC | FireAlarm + WSO2 DC | Analytics {{/zone}} {{#zone "body"}} - {{unit "appbar" link="analytics" title="Device Analytics"}} + {{unit "appbar" link="analytics" title="Analytics"}} {{unit "analytics"}} {{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/dashboard.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/dashboard.hbs index d11adeca..3a282d01 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/dashboard.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/dashboard.hbs @@ -4,6 +4,6 @@ WSO2 DC | Device Cloud {{/zone}} {{#zone "body"}} - {{unit "appbar"}} + {{unit "appbar" title="Dashboard"}} {{unit "dashboard"}} {{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/events/index.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/events/index.hbs new file mode 100644 index 00000000..30fa1e8a --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/events/index.hbs @@ -0,0 +1,9 @@ +{{authorized}} +{{layout "fluid"}} +{{#zone "title"}} + Events +{{/zone}} +{{#zone "body"}} + {{unit "appbar" link="events" title="My Events"}} + {{unit "events"}} +{{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/groups/index.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/groups.hbs similarity index 100% rename from modules/distribution/src/repository/jaggeryapps/iotserver/pages/groups/index.hbs rename to modules/distribution/src/repository/jaggeryapps/iotserver/pages/groups.hbs diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/policies/index.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/policies/index.hbs index cb210ed1..a2c83823 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/pages/policies/index.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/pages/policies/index.hbs @@ -5,7 +5,7 @@ {{/zone}} {{#zone "body"}} {{unit "appbar" link="policies" title="My Policies"}} - {{unit "extended-search-box"}} + {{unit "extended-search-box" item="Policie"}}
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/analiytics-graphs.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/analiytics-graphs.hbs index bfbfcf19..c802e1e9 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/analiytics-graphs.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/analiytics-graphs.hbs @@ -1,6 +1,7 @@ {{#zone "topCss"}} - + + {{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/analiytics-graphs.json b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/analiytics-graphs.json index b199b1be..56db749f 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/analiytics-graphs.json +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/analiytics-graphs.json @@ -1,3 +1,3 @@ { - "predicate": "urlMatch('/devices/analytics')" + "predicate": "urlMatch('/analytics')" } \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/detail.css b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/detail.css new file mode 100644 index 00000000..501719f4 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/detail.css @@ -0,0 +1,105 @@ +.rickshaw_graph .detail { + pointer-events: none; + position: absolute; + top: 0; + z-index: 2; + background: rgba(0, 0, 0, 0.1); + bottom: 0; + width: 1px; + transition: opacity 0.25s linear; + -moz-transition: opacity 0.25s linear; + -o-transition: opacity 0.25s linear; + -webkit-transition: opacity 0.25s linear; +} +.rickshaw_graph .detail.inactive { + opacity: 0; +} +.rickshaw_graph .detail .item.active { + opacity: 1; +} +.rickshaw_graph .detail .x_label { + font-family: Arial, sans-serif; + border-radius: 3px; + padding: 6px; + opacity: 0.5; + border: 1px solid #e0e0e0; + font-size: 12px; + position: absolute; + background: white; + white-space: nowrap; +} +.rickshaw_graph .detail .x_label.left { + left: 0; +} +.rickshaw_graph .detail .x_label.right { + right: 0; +} +.rickshaw_graph .detail .item { + position: absolute; + z-index: 2; + border-radius: 3px; + padding: 0.25em; + font-size: 12px; + font-family: Arial, sans-serif; + opacity: 0; + background: rgba(0, 0, 0, 0.4); + color: white; + border: 1px solid rgba(0, 0, 0, 0.4); + margin-left: 1em; + margin-right: 1em; + margin-top: -1em; + white-space: nowrap; +} +.rickshaw_graph .detail .item.left { + left: 0; +} +.rickshaw_graph .detail .item.right { + right: 0; +} +.rickshaw_graph .detail .item.active { + opacity: 1; + background: rgba(0, 0, 0, 0.8); +} +.rickshaw_graph .detail .item:after { + position: absolute; + display: block; + width: 0; + height: 0; + + content: ""; + + border: 5px solid transparent; +} +.rickshaw_graph .detail .item.left:after { + top: 1em; + left: -5px; + margin-top: -5px; + border-right-color: rgba(0, 0, 0, 0.8); + border-left-width: 0; +} +.rickshaw_graph .detail .item.right:after { + top: 1em; + right: -5px; + margin-top: -5px; + border-left-color: rgba(0, 0, 0, 0.8); + border-right-width: 0; +} +.rickshaw_graph .detail .dot { + width: 4px; + height: 4px; + margin-left: -3px; + margin-top: -3.5px; + border-radius: 5px; + position: absolute; + box-shadow: 0 0 2px rgba(0, 0, 0, 0.6); + box-sizing: content-box; + -moz-box-sizing: content-box; + background: white; + border-width: 2px; + border-style: solid; + display: none; + background-clip: padding-box; +} +.rickshaw_graph .detail .dot.active { + display: block; +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/graph.css b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/graph.css index ba03ec5c..48defd85 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/graph.css +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/graph.css @@ -4,7 +4,7 @@ position: relative; } .rickshaw_graph svg { - display: block; + display: block; overflow: hidden; } @@ -25,7 +25,7 @@ opacity: 0.5; white-space: nowrap; margin-left: 3px; - bottom: 1px; + bottom: -20px; } /* annotations */ @@ -151,7 +151,7 @@ .rickshaw_graph .y_ticks.glow text { fill: black; color: black; - text-shadow: + text-shadow: -1px 1px 0 rgba(255, 255, 255, 0.1), 1px -1px 0 rgba(255, 255, 255, 0.1), 1px 1px 0 rgba(255, 255, 255, 0.1), @@ -165,7 +165,7 @@ .rickshaw_graph .y_ticks.inverse text { fill: white; color: white; - text-shadow: + text-shadow: -1px 1px 0 rgba(0, 0, 0, 0.8), 1px -1px 0 rgba(0, 0, 0, 0.8), 1px 1px 0 rgba(0, 0, 0, 0.8), @@ -187,11 +187,11 @@ } .custom_slider { - left: 40px; + left: 40px; } .custom_x_axis { position: relative; left: 40px; - height: 40px; + height: 30px; } \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/legend.css b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/legend.css new file mode 100644 index 00000000..283e26f2 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/legend.css @@ -0,0 +1,87 @@ +.rickshaw_legend { + font-family: Arial; + font-size: 12px; + color: white; + background: #404040; + display: inline-block; + padding: 12px 5px; + border-radius: 2px; + position: relative; + float: right; +} +.rickshaw_legend:hover { + z-index: 10; +} +.rickshaw_legend .swatch { + width: 10px; + height: 10px; + border: 1px solid rgba(0, 0, 0, 0.2); +} +.rickshaw_legend .line { + clear: both; + line-height: 140%; + padding-right: 15px; +} +.rickshaw_legend .line .swatch { + display: inline-block; + margin-right: 3px; + border-radius: 2px; +} +.rickshaw_legend .label { + margin: 0; + white-space: nowrap; + display: inline; + font-size: inherit; + background-color: transparent; + color: inherit; + font-weight: normal; + line-height: normal; + padding: 0px; + text-shadow: none; +} +.rickshaw_legend .action:hover { + opacity: 0.6; +} +.rickshaw_legend .action { + margin-right: 0.2em; + font-size: 10px; + opacity: 0.2; + cursor: pointer; + font-size: 14px; +} +.rickshaw_legend .line.disabled { + opacity: 0.4; +} +.rickshaw_legend ul { + list-style-type: none; + margin: 0; + padding: 0; + margin: 2px; + cursor: pointer; +} +.rickshaw_legend li { + padding: 0 0 0 2px; + min-width: 80px; + white-space: nowrap; +} +.rickshaw_legend li:hover { + background: rgba(255, 255, 255, 0.08); + border-radius: 3px; +} +.rickshaw_legend li:active { + background: rgba(255, 255, 255, 0.2); + border-radius: 3px; +} +.legend { + display: inline-block; + position: relative; + left: 8px; +} +.legend_container { + float: right; + padding-right: 10px; + width: 0; + z-index: 1; + position: relative; + opacity: 0.7; +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/lines.css b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/lines.css index 2e724fac..b96fceb8 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/lines.css +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/lines.css @@ -1,3 +1,6 @@ +div, span, p, td { + font-family: Arial, sans-serif; +} #chart { display: inline-block; } @@ -15,4 +18,4 @@ #chart_container { float: left; position: relative; -} +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/nv.d3.css b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/nv.d3.css deleted file mode 100644 index 5da2cc92..00000000 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analiytics-graphs/public/css/nv.d3.css +++ /dev/null @@ -1,641 +0,0 @@ -/* nvd3 version 1.8.1 (https://github.com/novus/nvd3) 2015-06-17 */ -.nvd3 .nv-axis { - pointer-events:none; - opacity: 1; -} - -.nvd3 .nv-axis path { - fill: none; - stroke: #000; - stroke-opacity: .75; - shape-rendering: crispEdges; -} - -.nvd3 .nv-axis path.domain { - stroke-opacity: .75; -} - -.nvd3 .nv-axis.nv-x path.domain { - stroke-opacity: 0; -} - -.nvd3 .nv-axis line { - fill: none; - stroke: #e5e5e5; - shape-rendering: crispEdges; -} - -.nvd3 .nv-axis .zero line, - /*this selector may not be necessary*/ .nvd3 .nv-axis line.zero { - stroke-opacity: .75; -} - -.nvd3 .nv-axis .nv-axisMaxMin text { - font-weight: bold; -} - -.nvd3 .x .nv-axis .nv-axisMaxMin text, -.nvd3 .x2 .nv-axis .nv-axisMaxMin text, -.nvd3 .x3 .nv-axis .nv-axisMaxMin text { - text-anchor: middle -} - -.nvd3 .nv-axis.nv-disabled { - opacity: 0; -} - -.nvd3 .nv-bars rect { - fill-opacity: .75; - - transition: fill-opacity 250ms linear; - -moz-transition: fill-opacity 250ms linear; - -webkit-transition: fill-opacity 250ms linear; -} - -.nvd3 .nv-bars rect.hover { - fill-opacity: 1; -} - -.nvd3 .nv-bars .hover rect { - fill: lightblue; -} - -.nvd3 .nv-bars text { - fill: rgba(0,0,0,0); -} - -.nvd3 .nv-bars .hover text { - fill: rgba(0,0,0,1); -} - -.nvd3 .nv-multibar .nv-groups rect, -.nvd3 .nv-multibarHorizontal .nv-groups rect, -.nvd3 .nv-discretebar .nv-groups rect { - stroke-opacity: 0; - - transition: fill-opacity 250ms linear; - -moz-transition: fill-opacity 250ms linear; - -webkit-transition: fill-opacity 250ms linear; -} - -.nvd3 .nv-multibar .nv-groups rect:hover, -.nvd3 .nv-multibarHorizontal .nv-groups rect:hover, -.nvd3 .nv-candlestickBar .nv-ticks rect:hover, -.nvd3 .nv-discretebar .nv-groups rect:hover { - fill-opacity: 1; -} - -.nvd3 .nv-discretebar .nv-groups text, -.nvd3 .nv-multibarHorizontal .nv-groups text { - font-weight: bold; - fill: rgba(0,0,0,1); - stroke: rgba(0,0,0,0); -} - -/* boxplot CSS */ -.nvd3 .nv-boxplot circle { - fill-opacity: 0.5; -} - -.nvd3 .nv-boxplot circle:hover { - fill-opacity: 1; -} - -.nvd3 .nv-boxplot rect:hover { - fill-opacity: 1; -} - -.nvd3 line.nv-boxplot-median { - stroke: black; -} - -.nv-boxplot-tick:hover { - stroke-width: 2.5px; -} -/* bullet */ -.nvd3.nv-bullet { font: 10px sans-serif; } -.nvd3.nv-bullet .nv-measure { fill-opacity: .8; } -.nvd3.nv-bullet .nv-measure:hover { fill-opacity: 1; } -.nvd3.nv-bullet .nv-marker { stroke: #000; stroke-width: 2px; } -.nvd3.nv-bullet .nv-markerTriangle { stroke: #000; fill: #fff; stroke-width: 1.5px; } -.nvd3.nv-bullet .nv-tick line { stroke: #666; stroke-width: .5px; } -.nvd3.nv-bullet .nv-range.nv-s0 { fill: #eee; } -.nvd3.nv-bullet .nv-range.nv-s1 { fill: #ddd; } -.nvd3.nv-bullet .nv-range.nv-s2 { fill: #ccc; } -.nvd3.nv-bullet .nv-title { font-size: 14px; font-weight: bold; } -.nvd3.nv-bullet .nv-subtitle { fill: #999; } - - -.nvd3.nv-bullet .nv-range { - fill: #bababa; - fill-opacity: .4; -} -.nvd3.nv-bullet .nv-range:hover { - fill-opacity: .7; -} - -.nvd3.nv-candlestickBar .nv-ticks .nv-tick { - stroke-width: 1px; -} - -.nvd3.nv-candlestickBar .nv-ticks .nv-tick.hover { - stroke-width: 2px; -} - -.nvd3.nv-candlestickBar .nv-ticks .nv-tick.positive rect { - stroke: #2ca02c; - fill: #2ca02c; -} - -.nvd3.nv-candlestickBar .nv-ticks .nv-tick.negative rect { - stroke: #d62728; - fill: #d62728; -} - -.with-transitions .nv-candlestickBar .nv-ticks .nv-tick { - transition: stroke-width 250ms linear, stroke-opacity 250ms linear; - -moz-transition: stroke-width 250ms linear, stroke-opacity 250ms linear; - -webkit-transition: stroke-width 250ms linear, stroke-opacity 250ms linear; - -} - -.nvd3.nv-candlestickBar .nv-ticks line { - stroke: #333; -} - - -.nvd3 .nv-legend .nv-disabled rect { - /*fill-opacity: 0;*/ -} - -.nvd3 .nv-check-box .nv-box { - fill-opacity:0; - stroke-width:2; -} - -.nvd3 .nv-check-box .nv-check { - fill-opacity:0; - stroke-width:4; -} - -.nvd3 .nv-series.nv-disabled .nv-check-box .nv-check { - fill-opacity:0; - stroke-opacity:0; -} - -.nvd3 .nv-controlsWrap .nv-legend .nv-check-box .nv-check { - opacity: 0; -} - -/* line plus bar */ -.nvd3.nv-linePlusBar .nv-bar rect { - fill-opacity: .75; -} - -.nvd3.nv-linePlusBar .nv-bar rect:hover { - fill-opacity: 1; -} -.nvd3 .nv-groups path.nv-line { - fill: none; -} - -.nvd3 .nv-groups path.nv-area { - stroke: none; -} - -.nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point { - fill-opacity: 0; - stroke-opacity: 0; -} - -.nvd3.nv-scatter.nv-single-point .nv-groups .nv-point { - fill-opacity: .5 !important; - stroke-opacity: .5 !important; -} - - -.with-transitions .nvd3 .nv-groups .nv-point { - transition: stroke-width 250ms linear, stroke-opacity 250ms linear; - -moz-transition: stroke-width 250ms linear, stroke-opacity 250ms linear; - -webkit-transition: stroke-width 250ms linear, stroke-opacity 250ms linear; - -} - -.nvd3.nv-scatter .nv-groups .nv-point.hover, -.nvd3 .nv-groups .nv-point.hover { - stroke-width: 7px; - fill-opacity: .95 !important; - stroke-opacity: .95 !important; -} - - -.nvd3 .nv-point-paths path { - stroke: #aaa; - stroke-opacity: 0; - fill: #eee; - fill-opacity: 0; -} - - - -.nvd3 .nv-indexLine { - cursor: ew-resize; -} - -/******************** - * SVG CSS - */ - -/******************** - Default CSS for an svg element nvd3 used -*/ -svg.nvd3-svg { - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -ms-user-select: none; - -moz-user-select: none; - user-select: none; - display: block; - width:100%; - height:100%; -} - -/******************** - Box shadow and border radius styling -*/ -.nvtooltip.with-3d-shadow, .with-3d-shadow .nvtooltip { - -moz-box-shadow: 0 5px 10px rgba(0,0,0,.2); - -webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2); - box-shadow: 0 5px 10px rgba(0,0,0,.2); - - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - border-radius: 5px; -} - - -.nvd3 text { - font: normal 12px Arial; -} - -.nvd3 .title { - font: bold 14px Arial; -} - -.nvd3 .nv-background { - fill: white; - fill-opacity: 0; -} - -.nvd3.nv-noData { - font-size: 18px; - font-weight: bold; -} - - -/********** -* Brush -*/ - -.nv-brush .extent { - fill-opacity: .125; - shape-rendering: crispEdges; -} - -.nv-brush .resize path { - fill: #eee; - stroke: #666; -} - - -/********** -* Legend -*/ - -.nvd3 .nv-legend .nv-series { - cursor: pointer; -} - -.nvd3 .nv-legend .nv-disabled circle { - fill-opacity: 0; -} - -/* focus */ -.nvd3 .nv-brush .extent { - fill-opacity: 0 !important; -} - -.nvd3 .nv-brushBackground rect { - stroke: #000; - stroke-width: .4; - fill: #fff; - fill-opacity: .7; -} - - -.nvd3.nv-ohlcBar .nv-ticks .nv-tick { - stroke-width: 1px; -} - -.nvd3.nv-ohlcBar .nv-ticks .nv-tick.hover { - stroke-width: 2px; -} - -.nvd3.nv-ohlcBar .nv-ticks .nv-tick.positive { - stroke: #2ca02c; -} - -.nvd3.nv-ohlcBar .nv-ticks .nv-tick.negative { - stroke: #d62728; -} - - -.nvd3 .background path { - fill: none; - stroke: #EEE; - stroke-opacity: .4; - shape-rendering: crispEdges; -} - -.nvd3 .foreground path { - fill: none; - stroke-opacity: .7; -} - -.nvd3 .nv-parallelCoordinates-brush .extent -{ - fill: #fff; - fill-opacity: .6; - stroke: gray; - shape-rendering: crispEdges; -} - -.nvd3 .nv-parallelCoordinates .hover { - fill-opacity: 1; - stroke-width: 3px; -} - - -.nvd3 .missingValuesline line { - fill: none; - stroke: black; - stroke-width: 1; - stroke-opacity: 1; - stroke-dasharray: 5, 5; -} -.nvd3.nv-pie path { - stroke-opacity: 0; - transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear; - -moz-transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear; - -webkit-transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear; - -} - -.nvd3.nv-pie .nv-pie-title { - font-size: 24px; - fill: rgba(19, 196, 249, 0.59); -} - -.nvd3.nv-pie .nv-slice text { - stroke: #000; - stroke-width: 0; -} - -.nvd3.nv-pie path { - stroke: #fff; - stroke-width: 1px; - stroke-opacity: 1; -} - -.nvd3.nv-pie .hover path { - fill-opacity: .7; -} -.nvd3.nv-pie .nv-label { - pointer-events: none; -} -.nvd3.nv-pie .nv-label rect { - fill-opacity: 0; - stroke-opacity: 0; -} - -/* scatter */ -.nvd3 .nv-groups .nv-point.hover { - stroke-width: 20px; - stroke-opacity: .5; -} - -.nvd3 .nv-scatter .nv-point.hover { - fill-opacity: 1; -} -.nv-noninteractive { - pointer-events: none; -} - -.nv-distx, .nv-disty { - pointer-events: none; -} - -/* sparkline */ -.nvd3.nv-sparkline path { - fill: none; -} - -.nvd3.nv-sparklineplus g.nv-hoverValue { - pointer-events: none; -} - -.nvd3.nv-sparklineplus .nv-hoverValue line { - stroke: #333; - stroke-width: 1.5px; -} - -.nvd3.nv-sparklineplus, -.nvd3.nv-sparklineplus g { - pointer-events: all; -} - -.nvd3 .nv-hoverArea { - fill-opacity: 0; - stroke-opacity: 0; -} - -.nvd3.nv-sparklineplus .nv-xValue, -.nvd3.nv-sparklineplus .nv-yValue { - stroke-width: 0; - font-size: .9em; - font-weight: normal; -} - -.nvd3.nv-sparklineplus .nv-yValue { - stroke: #f66; -} - -.nvd3.nv-sparklineplus .nv-maxValue { - stroke: #2ca02c; - fill: #2ca02c; -} - -.nvd3.nv-sparklineplus .nv-minValue { - stroke: #d62728; - fill: #d62728; -} - -.nvd3.nv-sparklineplus .nv-currentValue { - font-weight: bold; - font-size: 1.1em; -} -/* stacked area */ -.nvd3.nv-stackedarea path.nv-area { - fill-opacity: .7; - stroke-opacity: 0; - transition: fill-opacity 250ms linear, stroke-opacity 250ms linear; - -moz-transition: fill-opacity 250ms linear, stroke-opacity 250ms linear; - -webkit-transition: fill-opacity 250ms linear, stroke-opacity 250ms linear; -} - -.nvd3.nv-stackedarea path.nv-area.hover { - fill-opacity: .9; -} - - -.nvd3.nv-stackedarea .nv-groups .nv-point { - stroke-opacity: 0; - fill-opacity: 0; -} - - -.nvtooltip { - position: absolute; - background-color: rgba(255,255,255,1.0); - color: rgba(0,0,0,1.0); - padding: 1px; - border: 1px solid rgba(0,0,0,.2); - z-index: 10000; - display: block; - - font-family: Arial; - font-size: 13px; - text-align: left; - pointer-events: none; - - white-space: nowrap; - - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -.nvtooltip { - background: rgba(255,255,255, 0.8); - border: 1px solid rgba(0,0,0,0.5); - border-radius: 4px; -} - -/*Give tooltips that old fade in transition by - putting a "with-transitions" class on the container div. -*/ -.nvtooltip.with-transitions, .with-transitions .nvtooltip { - transition: opacity 50ms linear; - -moz-transition: opacity 50ms linear; - -webkit-transition: opacity 50ms linear; - - transition-delay: 200ms; - -moz-transition-delay: 200ms; - -webkit-transition-delay: 200ms; -} - -.nvtooltip.x-nvtooltip, -.nvtooltip.y-nvtooltip { - padding: 8px; -} - -.nvtooltip h3 { - margin: 0; - padding: 4px 14px; - line-height: 18px; - font-weight: normal; - background-color: rgba(247,247,247,0.75); - color: rgba(0,0,0,1.0); - text-align: center; - - border-bottom: 1px solid #ebebeb; - - -webkit-border-radius: 5px 5px 0 0; - -moz-border-radius: 5px 5px 0 0; - border-radius: 5px 5px 0 0; -} - -.nvtooltip p { - margin: 0; - padding: 5px 14px; - text-align: center; -} - -.nvtooltip span { - display: inline-block; - margin: 2px 0; -} - -.nvtooltip table { - margin: 6px; - border-spacing:0; -} - - -.nvtooltip table td { - padding: 2px 9px 2px 0; - vertical-align: middle; -} - -.nvtooltip table td.key { - font-weight:normal; -} -.nvtooltip table td.value { - text-align: right; - font-weight: bold; -} - -.nvtooltip table tr.highlight td { - padding: 1px 9px 1px 0; - border-bottom-style: solid; - border-bottom-width: 1px; - border-top-style: solid; - border-top-width: 1px; -} - -.nvtooltip table td.legend-color-guide div { - width: 8px; - height: 8px; - vertical-align: middle; -} - -.nvtooltip table td.legend-color-guide div { - width: 12px; - height: 12px; - border: 1px solid #999; -} - -.nvtooltip .footer { - padding: 3px; - text-align: center; -} - -.nvtooltip-pending-removal { - pointer-events: none; - display: none; -} - - -/**** -Interactive Layer -*/ -.nvd3 .nv-interactiveGuideLine { - pointer-events:none; -} -.nvd3 line.nv-guideline { - stroke: #ccc; -} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/analytics.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/analytics.hbs index 27abf139..9805074f 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/analytics.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/analytics/analytics.hbs @@ -1,13 +1,14 @@ {{#zone "main"}} +
-

Device Statistics

+

{{title}}


-
+
@@ -15,14 +16,14 @@ - - -
-
@@ -20,11 +18,11 @@

- + Arduino Uno

- + Arduino Ethernet / WiFi Shield

View + + + + + + Add +
+ +
+
+
Groups
+
+
+ +
+
+
+ {{#if permissions.ADD_USER}}
@@ -39,7 +75,36 @@ View - + + + + + + + + +
+
+
+
+ {{/if}} + +
+ - {{/if}} +
-
Policies
+
Events
@@ -86,4 +144,6 @@ {{/zone}} {{#zone "bottomJs"}} + {{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/dashboard/public/js/dashboard.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/dashboard/public/js/dashboard.js index eaae317d..fcc37aaf 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/dashboard/public/js/dashboard.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/dashboard/public/js/dashboard.js @@ -1,20 +1,17 @@ var updateStats = function (serviceURL, id) { invokerUtil.get( serviceURL, - function (data) { - $(id).html(data); + function (result) { + $(id).html(JSON.parse(result)); }, function (message) { console.log(message); } ); }; -$(document).ready(function(){ - //updateStats("/mdm-admin/devices/count", "#device-count"); - //updateStats("/mdm-admin/policies/count", "#policy-count"); - //updateStats("/mdm-admin/users/count/" + "carbon.super", "#user-count"); - //TODO: get this value from devicecloud webservice - $("#device-count").html("0"); - $("#policy-count").html("0"); - $("#user-count").html("0"); +$(document).ready(function () { + updateStats("/iotserver/api/devices/count", "#device-count"); + updateStats("/iotserver/api/group/all/count", "#group-count"); + updateStats("/iotserver/api/policies/count", "#policy-count"); + updateStats("/iotserver/api/users/count", "#user-count"); }); \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/device-detail.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/device-detail.hbs index bf566146..e14547ff 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/device-detail.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/device-detail.hbs @@ -1,22 +1,22 @@ {{#zone "main"}}
-
-
- {{unit "operation-bar" deviceType=device.type}} + {{unit "operation-bar" deviceType=device.type}}
@@ -25,11 +25,13 @@
- +
Owner: {{device.owner}}
-
Date of Enrollment:
{{device.enrollment}}
+
Date of Enrollment:
{{device.dateOfEnrolment}}
@@ -45,114 +47,142 @@
- {{#if device.viewModel.BatteryLevel}} + {{#if device.viewModel.BatteryLevel}}
BATTERY
-
-
{{device.viewModel.BatteryLevel}}%
+
+
+
{{device.viewModel.BatteryLevel}} + % +
- {{/if}} + {{/if}} - {{#if device.viewModel.DeviceCapacity}} + {{#if device.viewModel.DeviceCapacity}}
STORAGE
-
-
{{device.viewModel.DeviceCapacityPercentage}}%{{device.viewModel.DeviceCapacityUsed}} GB Free
+
+
+
{{device.viewModel.DeviceCapacityPercentage}} + %{{device.viewModel.DeviceCapacityUsed}} + GB Free
- {{/if}} - {{#if device.viewModel.internal_memory.FreeCapacity}} + {{/if}} + {{#if device.viewModel.internal_memory.FreeCapacity}}
LOCAL STORAGE
-
-
{{device.viewModel.internal_memory.DeviceCapacityPercentage}}%{{device.viewModel.internal_memory.FreeCapacity}} GB Free
+
+
+
{{device.viewModel.internal_memory.DeviceCapacityPercentage}} + %{{device.viewModel.internal_memory.FreeCapacity}} + GB Free
- {{/if}} - {{#if device.viewModel.external_memory.FreeCapacity}} + {{/if}} + {{#if device.viewModel.external_memory.FreeCapacity}}
EXTERNAL STORAGE
-
-
{{device.viewModel.external_memory.DeviceCapacityPercentage}}%{{device.viewModel.external_memory.FreeCapacity}} GB Free
+
+
+
{{device.viewModel.external_memory.DeviceCapacityPercentage}} + %{{device.viewModel.external_memory.FreeCapacity}} + GB Free
- {{/if}} + {{/if}}
-
+
+ + +
+ +
+
+ IP Address: 0.0.0.0 +
+
+
+ +
- - - - - - - - - - - - - - - - - - - - - -
-
+
Not available yet
@@ -162,27 +192,26 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + -
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/public/js/device-detail.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/public/js/device-detail.js index c453c889..a86523fd 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/public/js/device-detail.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-detail/public/js/device-detail.js @@ -16,54 +16,13 @@ * under the License. */ -function formatDates(){ - $(".formatDate").each(function(){ +function formatDates() { + $(".formatDate").each(function () { var timeStamp = $(this).html(); $(this).html(new Date(parseInt(timeStamp)).toUTCString()); }); } -(function () { - var deviceId = $(".device-id"); - var deviceIdentifier = deviceId.data("deviceid"); - var deviceType = deviceId.data("type"); - var payload = [deviceIdentifier]; - if (deviceType == "ios") { - var serviceUrl = "/ios/operation/deviceinfo"; - } else if (deviceType == "android") { - var serviceUrl = "/mdm-android-agent/operation/device-info"; - } - invokerUtil.post(serviceUrl, payload, - function(message){ - console.log(message); - }, function (message) { - console.log(message); - }); - $(document).ready(function(){ - loadOperationBar(deviceType); - loadMap(); - formatDates(); - }); - function loadMap(){ - var map; - function initialize() { - var mapOptions = { - zoom: 18 - }; - var lat = 6.9098591; - var long = 79.8523753; - map = new google.maps.Map(document.getElementById('device-location'), - mapOptions); - - var pos = new google.maps.LatLng(lat, - long); - var marker = new google.maps.Marker({ - position: pos, - map: map - }); - - map.setCenter(pos); - } - google.maps.event.addDomListener(window, 'load', initialize); - } -}()); +$(document).ready(function () { + formatDates(); +}); \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.hbs index e2633391..52a4c2c5 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.hbs @@ -1,8 +1,8 @@ {{#zone "main"}} - - + + -
+
@@ -52,6 +52,16 @@
+
+ +
+
+

You don't have any associated devices here.

+
+
+ +
+
@@ -77,12 +87,6 @@

Device was successfully removed.

- -
@@ -118,12 +122,6 @@

Device was successfully updated.

- -
@@ -138,13 +136,13 @@
Loading...
@@ -156,12 +154,6 @@

Device was successfully associated with group.

- -
@@ -172,12 +164,6 @@

Device was successfully removed from group.

- -
@@ -246,8 +232,238 @@
+ +
+
+
+
+

Select user to manage group sharing

+
Loading...
+ +
+
+
+
+ +
+
+
+
+

Select sharing roles

+
+
Loading...
+ +
+
+
+
+ +
+
+
+
+

Group sharing updated successfully.

+
+
+
+
+ +
+
+
+
+

Do you really want to remove this group from your Group List?

+ + +
+
+
+
+ +
+
+
+
+

Group was successfully removed.

+
+
+
+
+ +
+
+
+
+

Please enter name and description for new group

+
+ +
+ +
+
+ +
+ +
+ +
+
+
+
+ +
+
+
+
+

Group successfully added.

+
+
+
+
+ +
+
+
+
+

Please enter new name and description for the group

+
+ +
+ +
+
+ +
+ +
+ +
+
+
+
+ +
+
+
+
+

Group was successfully updated.

+
+
+
+
+ +
+
+
+
+

Exception at backend. Try Later.

+ + +
+
+
+
+ +
+
+
+
+

Action not permitted.

+ + +
+
+
+
+ +
+
+
+
+

Group does not exist.

+ + +
+
+
+
+ +
+
+
+
+

Group does not exist.

+ + +
+
+
+
+ {{/zone}} {{#zone "bottomJs"}} + diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.js index 3db7b52b..d4cdaca9 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/device-listing.js @@ -1,6 +1,7 @@ var log = new Log("modules/device-listing.js"); function onRequest(context){ + var constants = require("/modules/constants.js"); var userModule = require("/modules/user.js").userModule; var permissions = []; if(userModule.isAuthorized("/permission/device-mgt/admin/devices/list")){ @@ -19,6 +20,6 @@ function onRequest(context){ }else{ context.groupId = 0; } - + context.user = session.get(constants.USER_SESSION_KEY).username; return context; } \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/js/device-listing.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/js/device-listing.js index acc0984c..91fda3dd 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/js/device-listing.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/js/device-listing.js @@ -16,12 +16,17 @@ * under the License. */ +var groupId, username; + (function () { var cache = {}; var permissionSet = {}; var validateAndReturn = function (value) { return (value == undefined || value == null) ? "Unspecified" : value; }; + Handlebars.registerHelper("groupMap", function (group) { + group.id = validateAndReturn(group.id); + }); Handlebars.registerHelper("deviceMap", function (device) { device.owner = validateAndReturn(device.owner); device.ownership = validateAndReturn(device.ownership); @@ -33,6 +38,13 @@ }, {}); } }); + Handlebars.registerHelper("if_owner", function (owner, opts) { + if (owner == username) { + return opts.fn(this); + } else { + opts.inverse(this); + } + }); //This method is used to setup permission for device listing $.setPermission = function (permission) { @@ -47,13 +59,12 @@ /* * Setting-up global variables. */ -var deviceCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']"; -var assetContainer = "#ast-container"; +var deviceCheckbox = "#ast-container-parent .ctrl-wr-asset .itm-select input[type='checkbox']"; +var assetContainerParent = "#ast-container-parent"; /* * DOM ready functions. */ -var groupId; $(document).ready(function () { /* Adding selected class for selected devices */ $(deviceCheckbox).each(function () { @@ -61,6 +72,7 @@ $(document).ready(function () { }); var i; + username = $("#permission").data("user"); var permissionList = $("#permission").data("permission"); for (i = 0; i < permissionList.length; i++) { $.setPermission(permissionList[i]); @@ -76,6 +88,7 @@ $(document).ready(function () { groupId = $("#request-group-id").data("groupid"); loadDevices(); + attachGroupAdding(); }); /* @@ -113,9 +126,9 @@ function changeDeviceView(view, selection) { }); $(selection).addClass("selected"); if (view == "list") { - $(assetContainer).addClass("list-view"); + $(".ast-container .devices-set").addClass("list-view"); } else { - $(assetContainer).removeClass("list-view"); + $(".ast-container .devices-set").removeClass("list-view"); } } @@ -131,63 +144,61 @@ function addDeviceSelectedClass(checkbox) { $(checkbox).closest(".ctrl-wr-asset").removeClass("selected device-select"); } } -function loadDevices(searchType, searchParam) { - var deviceListing = $("#device-listing"); - var deviceListingSrc = deviceListing.attr("src"); - var imageResource = deviceListing.data("image-resource"); - $.template("device-listing", deviceListingSrc, function (template) { + +function loadDevices() { + var groupListing = $("#group-listing"); + var groupListingSrc = groupListing.attr("src"); + $.template("group-listing", groupListingSrc, function (template) { var serviceURL; - if ($.hasPermission("LIST_DEVICES")) { - if (groupId && groupId != "0") { - serviceURL = "/iotserver/api/group/id/" + groupId + "/device/all"; - } else { - serviceURL = "/iotserver/api/devices/all"; - } - } else if ($.hasPermission("LIST_OWN_DEVICES")) { - //Get authenticated users devices - if (groupId && groupId != "0") { - serviceURL = "/iotserver/api/group/id/" + groupId + "/device/all"; - } else { - serviceURL = "/iotserver/api/devices/all"; - } + if (groupId && groupId != "0") { + serviceURL = "/iotserver/api/group/id/" + groupId + "/device/all"; } else { - $("#ast-container").html("Permission denied"); - return; - } - if (searchParam) { - if (searchType == "users") { - serviceURL = serviceURL + "?user=" + searchParam; - } else if (searchType == "user-roles") { - serviceURL = serviceURL + "?role=" + searchParam; - } else { - serviceURL = serviceURL + "?type=" + searchParam; - } + serviceURL = "/iotserver/api/devices/all"; } var successCallback = function (data) { data = JSON.parse(data); var viewModel = {}; + var groups; if (groupId && groupId != "0") { - data.data = data; - } - viewModel.devices = data.data; - viewModel.imageLocation = imageResource; - if (!data.data || data.data.length <= 0) { - if (groupId && groupId != "0") { - $("#ast-container").html($("#no-grouped-devices-div-content").html()); - } else { - $("#ast-container").html($("#no-devices-div-content").html()); - } + groups = data; } else { + groups = data.data; + } + if (groups.length == 1 && groups[0].id == 0 && groups[0].devices.length == 0) { + $("#ast-container-parent").html($("#no-devices-div-content").html()); + } else { + viewModel.groups = groups; var content = template(viewModel); - $("#ast-container").html(content); - /* - * On device checkbox select add parent selected style class - */ - $(deviceCheckbox).click(function () { - addDeviceSelectedClass(this); + $("#ast-container-parent").html(content); + var deviceListing = $("#device-listing"); + var deviceListingSrc = deviceListing.attr("src"); + var imageResource = deviceListing.data("image-resource"); + $.template("device-listing", deviceListingSrc, function (template) { + for (var g in groups) { + if (groups[g].devices && groups[g].devices.length > 0) { + viewModel = {}; + viewModel.devices = groups[g].devices; + viewModel.imageLocation = imageResource; + content = template(viewModel); + } else { + if (groupId && groupId != "0") { + content = $("#no-grouped-devices-div-content").html(); + } else { + content = $("#no-devices-in-group-div-content").html(); + } + } + $("#ast-container-" + groups[g].id).html(content); + } + /* + * On device checkbox select add parent selected style class + */ + $(deviceCheckbox).click(function () { + addDeviceSelectedClass(this); + }); + attachGroupEvents(); + attachDeviceEvents(); + formatDates(); }); - attachEvents(); - //formatDates(); } }; invokerUtil.get(serviceURL, @@ -252,7 +263,7 @@ function hidePopup() { /** * Following functions should be triggered after AJAX request is made. */ -function attachEvents() { +function attachDeviceEvents() { /** * Following click function would execute * when a user clicks on "Remove" link @@ -274,9 +285,9 @@ function attachEvents() { if (status == 200) { $(modalPopupContent).html($('#remove-device-200-content').html()); $('div[data-deviceid="' + deviceId + '"]').remove(); - $("a#remove-device-200-link").click(function () { + setTimeout(function () { hidePopup(); - }); + }, 2000); } else if (status == 400) { $(modalPopupContent).html($('#remove-device-400-content').html()); $("a#remove-device-400-link").click(function () { @@ -335,9 +346,9 @@ function attachEvents() { if (status == 200) { $(modalPopupContent).html($('#edit-device-200-content').html()); $("div[data-deviceid='" + deviceId + "'] .ast-name").html(newDeviceName); - $("a#edit-device-200-link").click(function () { + setTimeout(function () { hidePopup(); - }); + }, 2000); } else if (status == 400) { $(modalPopupContent).html($('#device-400-content').html()); $("a#device-400-link").click(function () { @@ -374,81 +385,376 @@ function attachEvents() { * when a user clicks on "Group" link * on Device Management page in WSO2 MDM Console. */ - $("a.group-device-link").click(function () { - var deviceId = $(this).data("deviceid"); - var deviceType = $(this).data("devicetype"); - var endPoint = "/iotserver/api/group/all"; + if ($("a.group-device-link").length > 0) { + $("a.group-device-link").click(function () { + var deviceId = $(this).data("deviceid"); + var deviceType = $(this).data("devicetype"); + var endPoint = "/iotserver/api/group/all"; - $(modalPopupContent).html($('#group-device-modal-content').html()); - $('#user-groups').html("Loading..."); - $("a#group-device-yes-link").hide(); + $(modalPopupContent).html($('#group-device-modal-content').html()); + $('#user-groups').html("Loading..."); + $("a#group-device-yes-link").hide(); + showPopup(); + + invokerUtil.get(endPoint, + function (data, txtStatus, jqxhr) { + var groups = JSON.parse(data); + var status = jqxhr.status; + if (status == 200) { + if (groups.length <= 0) { + $('#user-groups').html("There is no any groups available"); + return; + } + var str = '
'; + $('#user-groups').html(str); + $("a#group-device-yes-link").show(); + $("a#group-device-yes-link").click(function () { + var selectedGroupId = $('#assign-group-selector').val(); + endPoint = "/iotserver/api/group/id/" + selectedGroupId + "/assign"; + var device = {"deviceId": deviceId, "deviceType": deviceType}; + invokerUtil.post( + endPoint, + device, + function (data, txtStatus, jqxhr) { + var status = jqxhr.status; + if (status == 200) { + $(modalPopupContent).html($('#group-associate-device-200-content').html()); + loadDevices(); + setTimeout(function () { + hidePopup(); + }, 2000); + } else if (status == 400) { + $(modalPopupContent).html($('#device-400-content').html()); + $("a#device-400-link").click(function () { + hidePopup(); + }); + } else if (status == 403) { + $(modalPopupContent).html($('#device-403-content').html()); + $("a#device-403-link").click(function () { + hidePopup(); + }); + } else if (status == 409) { + $(modalPopupContent).html($('#device-409-content').html()); + $("a#device-409-link").click(function () { + hidePopup(); + }); + } + }, + function () { + $(modalPopupContent).html($('#device-unexpected-error-content').html()); + $("a#device-unexpected-error-link").click(function () { + hidePopup(); + }); + }); + }); + } + }, + function () { + $(modalPopupContent).html($('#device-unexpected-error-content').html()); + $("a#device-unexpected-error-link").click(function () { + hidePopup(); + }); + }); + + $("a#group-device-cancel-link").click(function () { + hidePopup(); + }); + }); + + } +} + +var errorHandler = function () { + $(modalPopupContent).html($('#add-group-unexpected-error-content').html()); + $("a#group-unexpected-error-link").click(function () { + hidePopup(); + }); +}; + +function attachGroupAdding() { + /** + * Following click function would execute + * when a user clicks on "Remove" link + * on Group Management page in WSO2 IoT Server Console. + */ + $("a.add-group-link").click(function () { + var addGroupApi = "/iotserver/api/group/add"; + $(modalPopupContent).html($('#add-group-modal-content').html()); showPopup(); - invokerUtil.get(endPoint, + $("a#add-group-yes-link").click(function () { + var newGroupName = $('#add-group-name').val(); + var newGroupDescription = $('#add-group-description').val(); + var group = {"name": newGroupName, "description": newGroupDescription}; + invokerUtil.post( + addGroupApi, + group, + function (data, txtStatus, jqxhr) { + var status = jqxhr.status; + if (status == 200) { + if (data != "false") { + $(modalPopupContent).html($('#add-group-200-content').html()); + loadDevices(); + setTimeout(function () { + hidePopup(); + }, 2000); + } else { + $(modalPopupContent).html($('#group-400-content').html()); + $("a#group-400-link").click(function () { + hidePopup(); + }); + } + } else if (status == 400) { + $(modalPopupContent).html($('#group-400-content').html()); + $("a#group-400-link").click(function () { + hidePopup(); + }); + } else if (status == 403) { + $(modalPopupContent).html($('#agroup-403-content').html()); + $("a#group-403-link").click(function () { + hidePopup(); + }); + } else if (status == 409) { + $(modalPopupContent).html($('#group-409-content').html()); + $("a#group-409-link").click(function () { + hidePopup(); + }); + } + }, errorHandler + ); + }); + + $("a#add-group-cancel-link").click(function () { + hidePopup(); + }); + + }); +} + +/** + * Following functions should be triggered after AJAX request is made. + */ +function attachGroupEvents() { + + /** + * Following click function would execute + * when a user clicks on "Share" link + * on Group Management page in WSO2 IoT Server Console. + */ + $("a.share-group-link").click(function () { + var groupId = $(this).data("groupid"); + $(modalPopupContent).html($('#share-group-w1-modal-content').html()); + $('#user-names').html('Loading...'); + showPopup(); + $("a#share-group-next-link").hide(); + invokerUtil.get("/iotserver/api/users", function (data, txtStatus, jqxhr) { - var groups = JSON.parse(data); + var users = JSON.parse(data); var status = jqxhr.status; if (status == 200) { - if (groups.length <= 0) { - $('#user-groups').html("There is no any groups available"); - return; - } - var str = '
'; + var hasUsers = false; + for (var user in users) { + if (users[user].username != username) { + str += ''; + hasUsers = true; + } } str += ''; - $('#user-groups').html(str); - $("a#group-device-yes-link").show(); - $("a#group-device-yes-link").click(function () { - var selectedGroupId = $('#assign-group-selector').val(); - endPoint = "/iotserver/api/group/id/" + selectedGroupId + "/assign"; - var device = {"deviceId": deviceId, "deviceType": deviceType}; - invokerUtil.post( - endPoint, - device, + if (!hasUsers) { + str = "There is no any other users registered"; + $('#user-names').html(str); + return; + } + $('#user-names').html(str); + $("a#share-group-next-link").show(); + $("a#share-group-next-link").click(function () { + var selectedUser = $('#share-user-selector').val(); + $(modalPopupContent).html($('#share-group-w2-modal-content').html()); + $('#user-roles').html('Loading...'); + $("a#share-group-yes-link").hide(); + invokerUtil.get("/iotserver/api/group/id/" + groupId + "/" + selectedUser + "/rolemapping", function (data, txtStatus, jqxhr) { + var roleMap = JSON.parse(data); var status = jqxhr.status; if (status == 200) { - $(modalPopupContent).html($('#group-associate-device-200-content').html()); - $("a#group-associate-device-200-link").click(function () { - hidePopup(); - }); - } else if (status == 400) { - $(modalPopupContent).html($('#device-400-content').html()); - $("a#device-400-link").click(function () { - hidePopup(); - }); - } else if (status == 403) { - $(modalPopupContent).html($('#device-403-content').html()); - $("a#device-403-link").click(function () { - hidePopup(); - }); - } else if (status == 409) { - $(modalPopupContent).html($('#device-409-content').html()); - $("a#device-409-link").click(function () { - hidePopup(); + var str = ''; + var isChecked = ''; + var hasRoles = false; + for (var role in roleMap) { + if (roleMap[role].assigned == true) { + isChecked = 'checked'; + } + str += '    '; + hasRoles = true; + } + if (!hasRoles) { + str = "There is no any roles for this group"; + return; + } + $('#user-roles').html(str); + $("a#share-group-yes-link").show(); + $("a#share-group-yes-link").click(function () { + var updatedRoleMap = []; + for (var role in roleMap) { + if ($('#user-role-' + roleMap[role].role).is(':checked') != roleMap[role].assigned) { + roleMap[role].assigned = $('#user-role-' + roleMap[role].role).is(':checked'); + updatedRoleMap.push(roleMap[role]); + } + } + invokerUtil.post("/iotserver/api/group/id/" + groupId + "/" + selectedUser + "/roleupdate", + updatedRoleMap, + function (data, txtStatus, jqxhr) { + var status = jqxhr.status; + if (status == 200) { + $(modalPopupContent).html($('#share-group-200-content').html()); + loadDevices(); + setTimeout(function () { + hidePopup(); + }, 2000); + } else { + displayErrors(status); + } + }, errorHandler); }); + } else { + displayErrors(status); } - }, - function () { - $(modalPopupContent).html($('#device-unexpected-error-content').html()); - $("a#device-unexpected-error-link").click(function () { - hidePopup(); - }); - }); + }, errorHandler); + $("a#share-group-w2-cancel-link").click(function () { + hidePopup(); + }); + }); + } else { + displayErrors(status); + } + }, errorHandler); + + $("a#share-group-w1-cancel-link").click(function () { + hidePopup(); + }); + + }); + + /** + * Following click function would execute + * when a user clicks on "Remove" link + * on Group Management page in WSO2 IoT Server Console. + */ + $("a.remove-group-link").click(function () { + var groupId = $(this).data("groupid"); + var removeGroupApi = "/iotserver/api/group/id/" + groupId + "/remove"; + + $(modalPopupContent).html($('#remove-group-modal-content').html()); + showPopup(); + + $("a#remove-group-yes-link").click(function () { + invokerUtil.delete( + removeGroupApi, + function (data, txtStatus, jqxhr) { + var status = jqxhr.status; + if (status == 200) { + $(modalPopupContent).html($('#remove-group-200-content').html()); + loadDevices(); + setTimeout(function () { + hidePopup(); + }, 2000); + } else { + displayErrors(status); + } + }, + function () { + $(modalPopupContent).html($('#group-unexpected-error-content').html()); + $("a#group-unexpected-error-link").click(function () { + hidePopup(); }); } - }, - function () { - $(modalPopupContent).html($('#device-unexpected-error-content').html()); - $("a#device-unexpected-error-link").click(function () { - hidePopup(); - }); - }); + ); + }); - $("a#group-device-cancel-link").click(function () { + $("a#remove-group-cancel-link").click(function () { + hidePopup(); + }); + + }); + + /** + * Following click function would execute + * when a user clicks on "Edit" link + * on Device Management page in WSO2 MDM Console. + */ + $("a.edit-group-link").click(function () { + var groupId = $(this).data("groupid"); + var groupName = $(this).data("groupname"); + var groupDescription = $(this).data("groupdescription"); + var editGroupApi = "/iotserver/api/group/id/" + groupId + "/update"; + + $(modalPopupContent).html($('#edit-group-modal-content').html()); + $('#edit-group-name').val(groupName); + $('#edit-group-description').val(groupDescription); + showPopup(); + + $("a#edit-group-yes-link").click(function () { + var newGroupName = $('#edit-group-name').val(); + var newGroupDescription = $('#edit-group-description').val(); + var group = {"name": newGroupName, "description": newGroupDescription}; + invokerUtil.post( + editGroupApi, + group, + function (data, txtStatus, jqxhr) { + var status = jqxhr.status; + if (status == 200) { + if (data != "false") { + $(modalPopupContent).html($('#edit-group-200-content').html()); + loadDevices(); + setTimeout(function () { + hidePopup(); + }, 2000); + } else { + $(modalPopupContent).html($('#group-409-content').html()); + $("a#group-409-link").click(function () { + hidePopup(); + }); + } + } else { + displayErrors(status); + } + }, + function () { + $(modalPopupContent).html($('#group-unexpected-error-content').html()); + $("a#group-unexpected-error-link").click(function () { + hidePopup(); + }); + } + ); + }); + + $("a#edit-group-cancel-link").click(function () { hidePopup(); }); }); } + +function displayErrors(status) { + if (status == 400) { + $(modalPopupContent).html($('#group-400-content').html()); + $("a#group-400-link").click(function () { + hidePopup(); + }); + } else if (status == 403) { + $(modalPopupContent).html($('#group-403-content').html()); + $("a#group-403-link").click(function () { + hidePopup(); + }); + } else if (status == 409) { + $(modalPopupContent).html($('#group-409-content').html()); + $("a#group-409-link").click(function () { + hidePopup(); + }); + } +} diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/templates/device-listing.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/templates/device-listing.hbs index f1fe2032..3fc02326 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/templates/device-listing.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/templates/device-listing.hbs @@ -8,16 +8,16 @@
- +

{{name}}

Device Type: {{type}} - Date of Enrollment: {{dateOfEnrolment}} + Enrolled On: {{enrolmentInfo.dateOfEnrolment}}
- {{owner}} + Owner: {{enrolmentInfo.owner}} {{status}}
@@ -28,13 +28,22 @@ View - + - + - Group + Stats + {{#if_owner enrolmentInfo.owner }} + + + + + + Group + + {{/if_owner}} diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/templates/group-listing.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/templates/group-listing.hbs new file mode 100644 index 00000000..8b173486 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/device-listing/public/templates/group-listing.hbs @@ -0,0 +1,54 @@ +{{#each groups}} + {{groupMap this}} + +
+
+
+
+{{/each}} + diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/digital_display/digital_display.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/digital_display/digital_display.hbs index 1b8d3d58..983fb891 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/digital_display/digital_display.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/digital_display/digital_display.hbs @@ -8,8 +8,6 @@

Connect your Digital Display device to the WSO2 device cloud.

-
-
@@ -20,11 +18,11 @@

- + Raspberry Pi

- + HDMI Supported Digital Display

+
+
+
+

Device Events Stream

+
+

Events Analyzer

+
+
+
+
+
+
+{{/zone}} +{{#zone "bottomJs"}} + + +{{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/events/events.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/events/events.js new file mode 100644 index 00000000..a28530c1 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/events/events.js @@ -0,0 +1,6 @@ +function onRequest(context){ + var userModule = require("/modules/user.js").userModule; + var permissions = userModule.getUIPermissions(); + context.permissions = permissions; + return context; +} diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/events/events.json b/modules/distribution/src/repository/jaggeryapps/iotserver/units/events/events.json new file mode 100644 index 00000000..0e0dcd23 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/events/events.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/events/public/js/events.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/events/public/js/events.js new file mode 100644 index 00000000..f23c7c0b --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/events/public/js/events.js @@ -0,0 +1,29 @@ +$(document).ready(function () { + 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()); + }); +} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/events/public/templates/event-stream.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/events/public/templates/event-stream.hbs new file mode 100644 index 00000000..a80c4042 --- /dev/null +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/events/public/templates/event-stream.hbs @@ -0,0 +1,20 @@ +
+ + + + + + + + + + {{#each data}} + + + + + + {{/each}} + +
TimeDeviceActivity
{{time}}{{deviceName}}{{activity}}
+
\ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/firealarm/firealarm.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/firealarm/firealarm.hbs index a3d2e33b..55add972 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/firealarm/firealarm.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/firealarm/firealarm.hbs @@ -8,11 +8,9 @@

Connect your Fire Alarm device to the WSO2 device cloud.

-
-
-
+

Ingredients


@@ -20,25 +18,25 @@
- + Raspberry Pi (Internet Enabled)       - + DHT11 Temperature Sensor

- + LED                                                     - + Buzzer(3v)

- Download + Download -
- -
-
-

Prepare


-

Get your device ready

-
- 01 Set up your RaspberryPi device as shown in the schematic below and get the FireAlarm setup. -
-
- 02 Connect a monitor to your RaspberryPi via the HDMI cable to get a UI view of the device. -
-
- 03 Get the RaspberryPi to connect to the internet (via Ethernet or Wifi) and note its IP_ADDRESS -
-
-
-

Schematic Diagram


-

Click on the image to zoom

-
- - - -
-
-
-
-
-

Connect (Quickstart)

-
-

Internet of Things Foundation Quickstart connection

-
- 01 Click on the "Create DEB" button above to get the download link for the FireAlarm setup files
-
-
-
- (The following commands can be issued by directly typing into the terminal of the device or by an "ssh" login from a remote PC) -
-
- 02 Download the FireAlarm setup files using the following command: "wget <url_link_received_from_the_above_step>"
-                 This will download a zip file named "FireAlarmAgent.zip" -
-
- 03 Run the following commands to successfuly install the package and get the service running:
- - -
- - -
- 04 Use the Sketch program to open the samples code samples/quickstart/quickstart.ino
-
-
- 05 View the lower part of the Sketch pad window to check that the COM connection is shown as active
-
-
-
-
- -
-
-
-
-

Please download the file from following link.

-
-
- - - - -    - -     Copy Link     - -    - -
-
-
-
-
- - - -
-
-
-
-

Exception at backend. Try Later.

- -
-
-
-
- -
-
-
-
-

Action not permitted.

- -
-
-
-
- -
-
-
-
-

Device Sketch does not exist.

- -
-
-
-
- -
-
-
-
-

Unexpected error.

- -
-
-
-
- -{{/zone}} -{{#zone "topCss"}} - - -{{/zone}} -{{#zone "bottomJs"}} - -{{/zone}} diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/firealarm/public/js/firealarm.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/firealarm/public/js/firealarm.js index 1c88318a..42f877d2 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/firealarm/public/js/firealarm.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/firealarm/public/js/firealarm.js @@ -73,12 +73,20 @@ function attachEvents() { payload, function (data, textStatus, jqxhr) { if(jqxhr.status == 200) { - $(modalPopupContent).html($('#download-device-modal-content-links').html()); - $("#download-device-url").val(data); - $("#download-device-url").focus(function () { - $(this).select(); - }); - showPopup(); + if(data == "403"){ + $(modalPopupContent).html($('#device-403-content').html()); + $("#device-403-link").click(function () { + window.location = "/iotserver/login"; + }); + showPopup(); + }else { + $(modalPopupContent).html($('#download-device-modal-content-links').html()); + $("#download-device-url").val(data); + $("#download-device-url").focus(function () { + $(this).select(); + }); + showPopup(); + } }else{ $(modalPopupContent).html($('#device-403-content').html()); $("#device-403-link").click(function () { diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/footer/footer.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/footer/footer.hbs index ab43f387..678ed6e3 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/footer/footer.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/footer/footer.hbs @@ -1,7 +1,7 @@ {{#zone "footer"}}

- WSO2 IOT Device Manager v.1.0.0 | © Inc. All Rights Reserved. + WSO2 IoT Device Manager v.1.0.0 | © Inc. All Rights Reserved.

{{/zone}} \ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs index 272963e1..3b8dd302 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-detail/group-detail.hbs @@ -60,7 +60,7 @@ href="#collapseFour" aria-expanded="false" aria-controls="collapseFour"> - + Group Statistics @@ -69,7 +69,7 @@ @@ -83,7 +83,7 @@ href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"> - + Group Devices diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs index e4fe30c4..92c46f88 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/group-listing.hbs @@ -38,13 +38,13 @@

Select user to manage group sharing

Loading...
@@ -59,13 +59,13 @@
Loading...
@@ -77,12 +77,6 @@

Group sharing updated successfully.

- -
@@ -113,12 +107,6 @@

Group was successfully removed.

- -
@@ -160,12 +148,6 @@

Group successfully added.

- -
@@ -207,12 +189,6 @@

Group was successfully updated.

- -
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/js/group-listing.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/js/group-listing.js index c84285b5..24be4bce 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/js/group-listing.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/js/group-listing.js @@ -64,7 +64,14 @@ $(document).ready(function () { return $("#content-filter-types").html(); } }); - changeGroupView('grid', this); + + loadGroups(); + changeGroupView('grid', $('a.ctrl-filter-grid')); + + var path = window.location.pathname; + if (path == '/iotserver/groups/add-group'){ + addNewGroup(); + } }); /* @@ -168,9 +175,6 @@ function loadGroups(searchType, searchParam) { }); }); } -$(document).ready(function () { - loadGroups(); -}); function formatDates() { $(".formatDate").each(function () { @@ -236,58 +240,60 @@ function attachGroupAdding() { * when a user clicks on "Remove" link * on Group Management page in WSO2 IoT Server Console. */ - $("a.add-group-link").click(function () { - var addGroupApi = "/iotserver/api/group/add"; - $(modalPopupContent).html($('#add-group-modal-content').html()); - showPopup(); + $("a.add-group-link").click(addNewGroup); +} - $("a#add-group-yes-link").click(function () { - var newGroupName = $('#add-group-name').val(); - var newGroupDescription = $('#add-group-description').val(); - var group = {"name": newGroupName, "description": newGroupDescription}; - invokerUtil.post( - addGroupApi, - group, - function (data, txtStatus, jqxhr) { - var status = jqxhr.status; - if (status == 200) { - if (data != "false") { - $(modalPopupContent).html($('#add-group-200-content').html()); - $("a#add-group-200-link").click(function () { - hidePopup(); - location.reload(); - }); - } else { - $(modalPopupContent).html($('#group-400-content').html()); - $("a#group-400-link").click(function () { - hidePopup(); - }); - } - } else if (status == 400) { +var addNewGroup = function () { + var addGroupApi = "/iotserver/api/group/add"; + $(modalPopupContent).html($('#add-group-modal-content').html()); + showPopup(); + + $("a#add-group-yes-link").click(function () { + var newGroupName = $('#add-group-name').val(); + var newGroupDescription = $('#add-group-description').val(); + var group = {"name": newGroupName, "description": newGroupDescription}; + invokerUtil.post( + addGroupApi, + group, + function (data, txtStatus, jqxhr) { + var status = jqxhr.status; + if (status == 200) { + if (data != "false") { + $(modalPopupContent).html($('#add-group-200-content').html()); + loadGroups(); + setTimeout(function () { + hidePopup(); + }, 2000); + } else { $(modalPopupContent).html($('#group-400-content').html()); $("a#group-400-link").click(function () { hidePopup(); }); - } else if (status == 403) { - $(modalPopupContent).html($('#agroup-403-content').html()); - $("a#group-403-link").click(function () { - hidePopup(); - }); - } else if (status == 409) { - $(modalPopupContent).html($('#group-409-content').html()); - $("a#group-409-link").click(function () { - hidePopup(); - }); } - }, errorHandler - ); - }); - - $("a#add-group-cancel-link").click(function () { - hidePopup(); - }); - + } else if (status == 400) { + $(modalPopupContent).html($('#group-400-content').html()); + $("a#group-400-link").click(function () { + hidePopup(); + }); + } else if (status == 403) { + $(modalPopupContent).html($('#agroup-403-content').html()); + $("a#group-403-link").click(function () { + hidePopup(); + }); + } else if (status == 409) { + $(modalPopupContent).html($('#group-409-content').html()); + $("a#group-409-link").click(function () { + hidePopup(); + }); + } + }, errorHandler + ); }); + + $("a#add-group-cancel-link").click(function () { + hidePopup(); + }); + } /** @@ -299,8 +305,9 @@ function attachEvents() { * when a user clicks on "Share" link * on Group Management page in WSO2 IoT Server Console. */ - $("a.view-group-link").click(function () { - $("#group_data").closest('form').submit(); + $(".view-group-link").click(function () { + var groupId = $(this).data("groupid"); + $("#group-data-form-" + groupId).closest('form').submit(); }); /** @@ -366,7 +373,7 @@ function attachEvents() { $("a#share-group-yes-link").click(function () { var updatedRoleMap = []; for (var role in roleMap) { - if ($('#user-role-' + roleMap[role].role).is(':checked') != roleMap[role].assigned){ + if ($('#user-role-' + roleMap[role].role).is(':checked') != roleMap[role].assigned) { roleMap[role].assigned = $('#user-role-' + roleMap[role].role).is(':checked'); updatedRoleMap.push(roleMap[role]); } @@ -377,10 +384,11 @@ function attachEvents() { var status = jqxhr.status; if (status == 200) { $(modalPopupContent).html($('#share-group-200-content').html()); - $("a#share-group-200-link").click(function () { + loadGroups(); + setTimeout(function () { hidePopup(); - }); - }else { + }, 2000); + } else { displayErrors(status); } }, errorHandler); @@ -422,19 +430,11 @@ function attachEvents() { function (data, txtStatus, jqxhr) { var status = jqxhr.status; if (status == 200) { - if (data != "false") { - $(modalPopupContent).html($('#remove-group-200-content').html()); - $('div[data-group="' + groupId + '"]').remove(); - $("a#remove-group-200-link").click(function () { - hidePopup(); - location.reload(); - }); - } else { - $(modalPopupContent).html($('#group-409-content').html()); - $("a#group-409-link").click(function () { - hidePopup(); - }); - } + $(modalPopupContent).html($('#remove-group-200-content').html()); + loadGroups(); + setTimeout(function () { + hidePopup(); + }, 2000); } else { displayErrors(status); } @@ -483,9 +483,9 @@ function attachEvents() { if (data != "false") { $(modalPopupContent).html($('#edit-group-200-content').html()); $("div[data-groupid='" + groupId + "'] .ast-name").html(newGroupName); - $("a#edit-group-200-link").click(function () { + setTimeout(function () { hidePopup(); - }); + }, 2000); } else { $(modalPopupContent).html($('#group-409-content').html()); $("a#group-409-link").click(function () { diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/templates/group-listing.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/templates/group-listing.hbs index 844645b9..f145e844 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/templates/group-listing.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/group-listing/public/templates/group-listing.hbs @@ -1,6 +1,6 @@ {{#each groups}} {{groupMap this}} -
+ @@ -9,7 +9,7 @@
-
+
-
+
-
+
- Shared with: {{users}} -
- +
+ View + + + + + + Devices + + + + + + + Stats +