From 4b396cf3211ccb061deb76e3a8965bd9d125a3b9 Mon Sep 17 00:00:00 2001 From: kamidu Date: Tue, 31 Jan 2017 13:41:49 +0530 Subject: [PATCH 1/4] enable location without das --- .../devicemgt/app/conf/config.json | 1 + .../app/modules/batch-provider-api.js | 7 + .../modules/business-controllers/device.js | 30 +-- .../pages/cdmf.page.user.create/create.hbs | 7 - .../user-menu.hbs | 209 ++++++++++++++++++ .../user-menu.js | 30 +++ .../user-menu.json | 3 + .../public/js/user-menu.js | 0 .../user-menu.hbs | 123 +++++++++++ .../user-menu.js | 30 +++ .../user-menu.json | 3 + .../user-menu.hbs | 111 +--------- .../user-menu.js | 10 +- .../app/units/uuf.unit.header/header.hbs | 3 + 14 files changed, 432 insertions(+), 135 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.js create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.json rename components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/{cdmf.unit.ui.header.user-menu => cdmf.unit.ui.header.default.user-menu}/public/js/user-menu.js (100%) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.hbs create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.js create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.json diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index a43bb34bce..3bb62bf46c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -1,5 +1,6 @@ { "appContext": "/devicemgt/", + "isCloud": true, "httpsURL" : "https://%iot.gateway.host%:%iot.gateway.https.port%", "httpURL" : "http://%iot.gateway.host%:%iot.gateway.http.port", "wssURL" : "https://%iot.analytics.host%:%iot.analytics.https.port%", diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/batch-provider-api.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/batch-provider-api.js index 78d026bf1a..b747ae3153 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/batch-provider-api.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/batch-provider-api.js @@ -125,6 +125,13 @@ batchProviders = function () { result = connector.getRecordsByRange(loggedInUser, tablename, from, to, 0, limit, null).getMessage(); } + + // error handling ---- + var resultString = result.toString(); + if (resultString.contains("Failed to get records from table")) { + return null; + } + result = JSON.parse(result); var data = []; for (var i = 0; i < result.length; i++) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js index 56939377cf..68fa4630d7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js @@ -71,7 +71,7 @@ deviceModule = function () { var userName = carbonUser.username + "@" + carbonUser.domain; var locationDataSet = []; - switch(deviceType) { + switch (deviceType) { case 'android': locationDataSet = batchProvider.getData(userName, deviceId, deviceType); break; @@ -80,24 +80,24 @@ deviceModule = function () { break; } - - var locationData = []; var locationTimeData = []; - for (var i = 0 ; i < locationDataSet.length; i++) { - var gpsReading = {}; - var gpsReadingTimes = {}; - gpsReading.lat = locationDataSet[i].latitude; - gpsReading.lng = locationDataSet[i].longitude; - if (deviceType == "android") { - gpsReadingTimes.time = locationDataSet[i].timeStamp; - } else { - gpsReadingTimes.time = locationDataSet[i].meta_timestamp; + if (locationDataSet != null) { + + for (var i = 0; i < locationDataSet.length; i++) { + var gpsReading = {}; + var gpsReadingTimes = {}; + gpsReading.lat = locationDataSet[i].latitude; + gpsReading.lng = locationDataSet[i].longitude; + if (deviceType == "android") { + gpsReadingTimes.time = locationDataSet[i].timeStamp; + } else { + gpsReadingTimes.time = locationDataSet[i].meta_timestamp; + } + locationData.push(gpsReading); + locationTimeData.push(gpsReadingTimes); } - locationData.push(gpsReading); - locationTimeData.push(gpsReadingTimes); } - var utility = require('/app/modules/utility.js')["utility"]; try { utility.startTenantFlow(carbonUser); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs index 6c152b07ee..e69c9d4184 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.hbs @@ -127,14 +127,7 @@

User was added successfully.

An invitation mail will be sent to this user to initiate device enrollment. - Below QR code can also be used to enroll a device.

-
- -
-
-
-

Please click "Add Another User", if you wish to add another user or click "View User List" to complete the process and go back to the user list. diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs new file mode 100644 index 0000000000..af4e2b767f --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs @@ -0,0 +1,209 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. licenses this file to you under the Apache License, + Version 2.0 (the "License"); you may not use this file except + in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +}} + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.js new file mode 100644 index 0000000000..03d61cad53 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.js @@ -0,0 +1,30 @@ +/* + * 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. + */ + +function onRequest(context) { + var constants = require("/app/modules/constants.js"); + var user = context.user; + var isSuperTenant = false; + if (user.tenantId == -1234){ + isSuperTenant = true; + } + var viewModal = {}; + viewModal.isSuperTenant = isSuperTenant; + viewModal.USER_SESSION_KEY = session.get(constants["USER_SESSION_KEY"]); + return viewModal; +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.json new file mode 100644 index 0000000000..e4e47235ef --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0", +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/public/js/user-menu.js similarity index 100% rename from components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/public/js/user-menu.js rename to components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/public/js/user-menu.js diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.hbs new file mode 100644 index 0000000000..8bc7d0b35b --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.hbs @@ -0,0 +1,123 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. licenses this file to you under the Apache License, + Version 2.0 (the "License"); you may not use this file except + in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +}} + + + +{{#zone "bottomJs"}} + {{js "/js/user-menu.js"}} +{{/zone}} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.js new file mode 100644 index 0000000000..03d61cad53 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.js @@ -0,0 +1,30 @@ +/* + * 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. + */ + +function onRequest(context) { + var constants = require("/app/modules/constants.js"); + var user = context.user; + var isSuperTenant = false; + if (user.tenantId == -1234){ + isSuperTenant = true; + } + var viewModal = {}; + viewModal.isSuperTenant = isSuperTenant; + viewModal.USER_SESSION_KEY = session.get(constants["USER_SESSION_KEY"]); + return viewModal; +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.json new file mode 100644 index 0000000000..e4e47235ef --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.default.user-menu/user-menu.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0", +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs index 95d7264473..bd55f2a00d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.hbs @@ -15,110 +15,11 @@ specific language governing permissions and limitations under the License. }} -{{#zone "userMenu"}} - -{{/zone}} - -{{#zone "bottomJs"}} - {{js "/js/user-menu.js"}} +{{#zone "userMenu"}} + {{#if isCloud}} + {{unit "cdmf.unit.ui.header.cloud.user-menu"}} + {{else}} + {{unit "cdmf.unit.ui.header.default.user-menu"}} + {{/if}} {{/zone}} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.js index 03d61cad53..e63ad073c3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.user-menu/user-menu.js @@ -17,14 +17,8 @@ */ function onRequest(context) { - var constants = require("/app/modules/constants.js"); - var user = context.user; - var isSuperTenant = false; - if (user.tenantId == -1234){ - isSuperTenant = true; - } + var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; var viewModal = {}; - viewModal.isSuperTenant = isSuperTenant; - viewModal.USER_SESSION_KEY = session.get(constants["USER_SESSION_KEY"]); + viewModal.isCloud = mdmProps["isCloud"]; return viewModal; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header/header.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header/header.hbs index fe6c030d27..af3e248189 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header/header.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/app/units/uuf.unit.header/header.hbs @@ -21,6 +21,9 @@
{{defineZone "brand"}}
+
+ {{defineZone "cloudMenu"}} +
{{defineZone "userMenu"}}
From 43b0d1f1ce2eb3697f02119a792d37414b9b233b Mon Sep 17 00:00:00 2001 From: kamidu Date: Thu, 2 Feb 2017 13:07:41 +0530 Subject: [PATCH 2/4] Enable appstore and app publisher --- .../user-menu.hbs | 66 +++++++++++-------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs index af4e2b767f..28f1e68b7c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs @@ -18,13 +18,14 @@ -
  • @@ -84,20 +84,16 @@ +
  • -
  • - + @@ -138,36 +134,51 @@ App Cloud
  • +
  • - - App Cloud + Device Cloud
  • - + API Cloud Walkthrough
  • + + +
  • + + App Publisher + +
  • + +
  • + + App Store + +
  • + +
  • - - + + {{else}} + {{@user.username}}@{{@user.domain}} + {{/if}} + \ No newline at end of file From 41fd4026192065361aa0120d3432ddafa96ed5d1 Mon Sep 17 00:00:00 2001 From: kamidu Date: Thu, 2 Feb 2017 13:13:39 +0530 Subject: [PATCH 3/4] DIABLE CLOUD UI IN THE MASTER --- .../main/resources/jaggeryapps/devicemgt/app/conf/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 3bb62bf46c..1dab6437de 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -1,6 +1,6 @@ { "appContext": "/devicemgt/", - "isCloud": true, + "isCloud": false, "httpsURL" : "https://%iot.gateway.host%:%iot.gateway.https.port%", "httpURL" : "http://%iot.gateway.host%:%iot.gateway.http.port", "wssURL" : "https://%iot.analytics.host%:%iot.analytics.https.port%", From 6af09cdd3129a9b87e7a845687291ece2846f5bd Mon Sep 17 00:00:00 2001 From: kamidu Date: Fri, 3 Feb 2017 12:44:01 +0530 Subject: [PATCH 4/4] Remove the defaut black color for icons --- .../app/units/cdmf.unit.ui.theme/public/css/custom-desktop.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-desktop.css b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-desktop.css index 6321372ccd..a7114108ee 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-desktop.css +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-desktop.css @@ -6517,7 +6517,7 @@ select > option:hover { } .header .fw:before { - color: #000; + } /* Adding style for required fields */