diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/device-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/device-api.jag index 75cc8b77..5bd5fb95 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/device-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/device-api.jag @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - var uri = request.getRequestURI(); var uriMatcher = new URIMatcher(String(uri)); diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag index 7a16d385..1bf40351 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/user-api.jag @@ -42,7 +42,6 @@ if (uriMatcher.match("/{context}/api/user/login/")) { if (log.isDebugEnabled()) { log.debug("User Logged In : " + user); } - var hasDevcies = (deviceManagementService.getDevicesOfUser(username).size() >= 1); if(hasDevcies){ @@ -79,7 +78,7 @@ if (uriMatcher.match("/{context}/api/user/login/")) { } else { userRoles = String(addUserFormData.userRoles).split(","); } - + userRoles="deviceRole, deviceUser"; try { result = userModule.registerUser(username, firstname, lastname, emailAddress, password, userRoles); diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse-router.js b/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse-router.js index 7aab77d7..e9e2b793 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse-router.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse-router.js @@ -82,7 +82,9 @@ var route; }; var renderStatic = function (unit, path) { - log.debug('[' + requestId + '] for unit "' + unit + '" a request received for a static file "' + path + '"'); + if (log.isDebugEnabled()) { + log.debug('[' + requestId + '] for unit "' + unit + '" a request received for a static file "' + path + '"'); + } var staticFile = fuse.getFile(unit, 'public' + path); if (staticFile.isExists() && !staticFile.isDirectory()) { response.addHeader('Content-type', getMime(path)); @@ -145,20 +147,24 @@ var route; var layout = fuseState.layout; if (layout !== null) { - log.debug( - '[' + requestId + '] request for "' + path + '" will be rendered using layout "' + - layout + '" (defined in "' + mainUnit + '") and zones ' + - stringify(zones) - ); + if (log.isDebugEnabled()) { + log.debug( + '[' + requestId + '] request for "' + path + '" will be rendered using layout "' + + layout + '" (defined in "' + mainUnit + '") and zones ' + + stringify(zones) + ); + } var output = handlebars.Handlebars.compileFile(fuse.getLayoutPath(layout))({}); response.addHeader('Content-type', 'text/html'); print(output); return true; } else { - log.debug( - '[' + requestId + '] request for "' + path + '" will can\'t be rendered, since no layout is defined' + - 'in any of the units ' + stringify(zones)); + if (log.isDebugEnabled()) { + log.debug( + '[' + requestId + '] request for "' + path + '" will can\'t be rendered, since no layout is defined' + + 'in any of the units ' + stringify(zones)); + } return false; } }; @@ -174,7 +180,9 @@ var route; */ function renderLess(unit, path) { //TODO: fix - incorrect less files makes it respond the old less even if it is nocahce. - log.debug('[' + requestId + '] for unit "' + unit + '" a request received for a less file "' + path + '"'); + if (log.isDebugEnabled()) { + log.debug('[' + requestId + '] for unit "' + unit + '" a request received for a less file "' + path + '"'); + } var cacheKey = '/tmp/cached_' + unit + path.replace(/[^\w\.-]/g, '_'); fuseState.currentUnit = unit; var cachedCss = new File(cacheKey); @@ -188,7 +196,9 @@ var route; if (lessFile.isExists()) { var x = require('less-rhino-1.7.5.js'); x.compile([lessFile.getPath(), cacheKey]); - log.debug('[' + requestId + '] for unit "' + unit + '" request for "' + path + '" is cached as "' + cacheKey + '"'); + if (log.isDebugEnabled()) { + log.debug('[' + requestId + '] for unit "' + unit + '" request for "' + path + '" is cached as "' + cacheKey + '"'); + } } } diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse.jag b/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse.jag index 6676b328..c7731e91 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse.jag @@ -11,8 +11,7 @@ var fuseState = { zones: {}, appName: '', currentZone: [], //TODO: rename to zone Stack - currentUnit: null, - viewModelCache:{} + currentUnit: null }; var requestId = function makeId() { diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse.js b/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse.js index 3dd87fc2..7380f57c 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/lib/fuse.js @@ -218,7 +218,9 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors, } var path = definitionFile.getPath(); - log.debug('[' + requestId + '] reading file "' + path + '"'); + if (log.isDebugEnabled()) { + log.debug('[' + requestId + '] reading file "' + path + '"'); + } unitModel.definition = require(path); // add the information derived by parsing hbs file to the same model @@ -348,10 +350,12 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors, } while (len--) { if (toDelete[units[len]]) { - log.debug( - '[' + requestId + '] unit "' + units[len] + - '" is overridden by "' + toDelete[units[len]] + '"' - ); + if (log.isDebugEnabled()) { + log.debug( + '[' + requestId + '] unit "' + units[len] + + '" is overridden by "' + toDelete[units[len]] + '"' + ); + } units.splice(len, 1); } } @@ -407,10 +411,12 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors, var selfFile = new File(getUnitPath(unitName) + slashPath + selfFileName); if (selfFile.isExists()) { - log.debug( - '[' + requestId + '] for unit "' + unitName + '" file resolved : "' - + slashPath + selfFileName + '" -> "' + selfFile.getPath() + '"' - ); + if (log.isDebugEnabled()) { + log.debug( + '[' + requestId + '] for unit "' + unitName + '" file resolved : "' + + slashPath + selfFileName + '" -> "' + selfFile.getPath() + '"' + ); + } return selfFile; } @@ -427,17 +433,21 @@ var getHbsFile, getFile, toRelativePath, cleanupAncestors, } var file = new File(getUnitPath(ancestorName) + slashPath + fileName); if (file.isExists()) { - log.debug( - '[' + requestId + '] for unit "' + unitName + '" file resolved : "' - + slashPath + selfFileName + '" -> "' + file.getPath() + '"' - ); + if (log.isDebugEnabled()) { + log.debug( + '[' + requestId + '] for unit "' + unitName + '" file resolved : "' + + slashPath + selfFileName + '" -> "' + file.getPath() + '"' + ); + } return file; } } - log.debug( - '[' + requestId + '] for unit "' + unitName + '" (non-excising) file resolved : "' - + slashPath + selfFileName + '" -> "' + selfFile.getPath() + '"' - ); + if (log.isDebugEnabled()) { + 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 35e4b56c..8c915700 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/lib/handlebars-helpers.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/lib/handlebars-helpers.js @@ -11,35 +11,29 @@ var getScope = function (unit,configs) { var viewModel = {}; var cbResult; if (jsFile.isExists()) { - if(fuseState.viewModelCache[jsFile.getPath()]){ - cbResult = fuseState.viewModelCache[jsFile.getPath()]; - }else{ - script = require(jsFile.getPath()); - //Eagerly make the viewModel the template configs - viewModel = templateConfigs; - //Check if the unit author has specified an onRequest - //callback - if(script.hasOwnProperty('onRequest')){ - script.app = { - url: '/' + fuseState.appName, - publicURL: '/' + fuseState.appName + '/public/' + unit, - "class": unit + '-unit' - }; - onRequestCb = script.onRequest; - cbResult = onRequestCb(templateConfigs); - log.debug("passing configs to unit "+unit+" configs: "+stringify(templateConfigs)); - fuseState.viewModelCache[jsFile.getPath()] = cbResult; + script = require(jsFile.getPath()); + //Eagerly make the viewModel the template configs + viewModel = templateConfigs; + //Check if the unit author has specified an onRequest + //callback + if(script.hasOwnProperty('onRequest')){ + script.app = { + url: '/' + fuseState.appName, + publicURL: '/' + fuseState.appName + '/public/' + unit, + "class": unit + '-unit' + }; + onRequestCb = script.onRequest; + cbResult = onRequestCb(templateConfigs); + log.debug("passing configs to unit "+unit+" configs: "+stringify(templateConfigs)); + //If the execution does not yield an object we will print + //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.'); } + viewModel = cbResult; } - - //If the execution does not yield an object we will print - //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.'); - } - viewModel = cbResult; } else{ //If there is no script then the view should get the configurations diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/device.js b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/device.js index dd10270c..935d4071 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/device.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/device.js @@ -266,8 +266,6 @@ deviceModule = function () { properties[constants.DEVICE_VENDOR] = constants.VENDOR_APPLE; } deviceObject[constants.DEVICE_PROPERTIES] = properties; - log.info("-------------------------"); - log.info(device.getEnrolmentInfo().getDateOfEnrolment()); deviceObject[constants.DEVICE_ENROLLMENT] = device.getEnrolmentInfo().getDateOfEnrolment(); return deviceObject; } diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js index 7117b6fe..75683235 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/utility.js @@ -20,7 +20,6 @@ var utility; utility = function () { var JavaClass = Packages.java.lang.Class; var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext; - var userManagement = Packages.org.wso2.carbon.device.mgt.iot.common.UserManagement(); var getOsgiService = function (className) { return PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(JavaClass.forName(className)); @@ -33,7 +32,7 @@ utility = function () { }; publicMethods.getUserManagementService = function () { - return userManagement; + return getOsgiService('org.wso2.carbon.device.mgt.user.core.UserManager'); }; publicMethods.getPolicyManagementService = function () { 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 18462e9d..c453c889 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 @@ -24,7 +24,46 @@ function formatDates(){ } (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); + } }()); diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-create/public/js/policy-create.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-create/public/js/policy-create.js index 90792be7..fb9d4e0b 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-create/public/js/policy-create.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-create/public/js/policy-create.js @@ -87,6 +87,7 @@ function savePolicy(){ } $(document).ready(function(){ + alert("hiiiii"); initStepper(".wizard-stepper"); $( "input[type='radio'].user-select-radio" ).change(function() { $('.user-select').hide(); diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-create/public/templates/hidden-operations-android.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-create/public/templates/hidden-operations-android.hbs deleted file mode 100644 index c8eb81e2..00000000 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-create/public/templates/hidden-operations-android.hbs +++ /dev/null @@ -1,251 +0,0 @@ -
-
- - - - - Security - - - - - - Restrictions - - - - - - Applications - - - - - - Wi-fi - -
-
- - -
-
- -
-
- -
- -
-
-
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- -
- -
- -
- -
- - -
-
-
- - - -
-
- -
- - -
- -
- - - -
- -
- -
-
-
- - -
-
- -
- - -
- -
-
- -
- - -
- -
- -
-
-
- -
- - -
- -
- - -
- -
- -
-
-
- -
- - -
- -
- -
-
-
- - - -
-
- -
-
- -
- -
-
-
- -
-
\ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-create/public/templates/hidden-operations-ios.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-create/public/templates/hidden-operations-ios.hbs deleted file mode 100644 index 4cb006ef..00000000 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-create/public/templates/hidden-operations-ios.hbs +++ /dev/null @@ -1,366 +0,0 @@ -
-
- - - - - Wi-fi - - - - - - Applications - - - - - - Restrictions - - - - - - Mail - - - - - - Air Play - -
-
- - -
-
- -
- -
- -
- -
- -
- - -
- -
-
- - -
-
- - -
- Install -
- -
-
- -
- -
- -
- -
- -
- - -
- -
-
- - -
-
- - -
- Install -
-
-
- -
- -
- -
- Uninstall -
-
-
- - - -
- - -
- -
- -
- - -
- -
- - -
- - - -
- -
- - - -
- -
- - - -
- -
- - - -
- -
- Configure -
- - - -
- - -
- -
- - - -
-
- -
-
- Path Prefix -
-
-
- - - -
- -
- - - -
- -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- - - -
-
- -
-
- : -
-
-
- - - -
- -
- - - -
- -
- - - -
- -
- -
- - -
-
- - - -
-
- -
-
- -
-
- -
-
- -
-
- -
- Configure -
- - -
- -
- -
- -
- -
AirPlay password -
- -
- Configure -
- -
-
\ No newline at end of file diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-detail/public/js/policy-detail.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-detail/public/js/policy-detail.js index 18462e9d..c453c889 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-detail/public/js/policy-detail.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-detail/public/js/policy-detail.js @@ -24,7 +24,46 @@ function formatDates(){ } (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); + } }()); diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/theme.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/theme.hbs index 33343d53..88fb1409 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/theme.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/theme.hbs @@ -34,20 +34,20 @@ \ No newline at end of file