From 864ee109a5ef05e861c8e1ecf50ea056b71bb92c Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Fri, 7 Aug 2015 11:17:25 +0530 Subject: [PATCH 1/2] adding policy owner parameter --- .../jaggeryapps/iotserver/modules/policy.js | 13 ++++++++++--- .../units/policy-listing/policy-listing.hbs | 2 -- .../units/policy-listing/policy-listing.js | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js index c1b8e822..a9137582 100755 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/modules/policy.js @@ -38,7 +38,8 @@ policyModule = function () { name: policyName, mediaType: 'text/plain', content: policyDefinition, - description: policyDescription + description: policyDescription, + properties:{owner: carbonUser.username} }; if (carbonUser) { @@ -54,7 +55,7 @@ policyModule = function () { var mqttsenderClass = Packages.org.wso2.device.mgt.mqtt.policy.push.MqttPush; var mqttsender = new mqttsenderClass(); - var result = mqttsender.pushToMQTT("/iot/policymgt/govern", policyDefinition, "tcp://localhost:1883", "Raspberry-Policy-sender"); + var result = mqttsender.pushToMQTT("/iot/policymgt/govern/" + deviceType + "/" + carbonUser.username, policyDefinition, "tcp://localhost:1883", "Raspberry-Policy-sender"); mqttsender = null; @@ -88,6 +89,12 @@ policyModule = function () { //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. @@ -136,7 +143,7 @@ policyModule = function () { registry.remove(constants.POLICY_REGISTRY_PATH + deviceType + "/" + name); bool = true; } catch (err) { - log.error("Error while trying to remove policy :" + name); + log.error("Error while trying to remove policy :" + name, err); } } diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-listing/policy-listing.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-listing/policy-listing.hbs index 3484060b..77701f63 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-listing/policy-listing.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-listing/policy-listing.hbs @@ -3,8 +3,6 @@
-

Policies

-

{{listPolicyStatus}}

diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-listing/policy-listing.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-listing/policy-listing.js index 5da8aee7..d7f2da5c 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-listing/policy-listing.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-listing/policy-listing.js @@ -5,7 +5,7 @@ function onRequest(context) { //log.info((allPolicies)); if (!allPolicies || allPolicies.length == 0) { context.policies = []; - context.listPolicyStatus = "Oops, Sorry, No other Policies found."; + context.listPolicyStatus = ""; } else { var i, filteredPoliciesList = []; for (i = 0; i < allPolicies.length; i++) { From 29001aca933f363fd7642cd21f0ed888a59490ca Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Fri, 7 Aug 2015 11:17:42 +0530 Subject: [PATCH 2/2] minor ui changes --- .../jaggeryapps/iotserver/api/device-api.jag | 2 +- .../iotserver/units/android/android.hbs | 2 - .../units/android_sense/android_sense.hbs | 2 - .../iotserver/units/appbar/appbar.js | 2 +- .../iotserver/units/arduino/arduino.hbs | 2 - .../iotserver/units/dashboard/dashboard.hbs | 14 +- .../iotserver/units/firealarm/firealarm.hbs | 12 +- .../units/firealarm/firealarm.hbs.save | 213 ------------------ .../units/firealarm/public/js/firealarm.js | 20 +- .../units/policy-create/policy-create.hbs | 2 +- .../iotserver/units/showcase/showcase.hbs | 35 +-- .../iotserver/units/theme/public/css/main.css | 4 + 12 files changed, 39 insertions(+), 271 deletions(-) delete mode 100644 modules/distribution/src/repository/jaggeryapps/iotserver/units/firealarm/firealarm.hbs.save 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 65c0b5f6..9337c8ed 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/api/device-api.jag +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/api/device-api.jag @@ -105,7 +105,7 @@ if (uriMatcher.match("/{context}/api/device/sketch/download/{downloadId}")) { sketchGenerateLinkEndPoint = deviceManagerService + "/device/" + sketchType + "/generate_link"; var fileId = get(sketchGenerateLinkEndPoint + "?owner=" + user.username, null, "text"); - result = carbonHttpsServletTransport + constants.WEB_APP_CONTEXT + "/api/device/sketch/download/" + fileId.data; + result = "curl -k " + carbonHttpsServletTransport + constants.WEB_APP_CONTEXT + "/api/device/sketch/download/" + fileId.data + " > agent.zip"; } } diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/android/android.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/android/android.hbs index aa0018ca..5f3c15e0 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/android/android.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/android/android.hbs @@ -8,8 +8,6 @@

Connect your Android to the WSO2 device cloud.

-
-
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/android_sense/android_sense.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/android_sense/android_sense.hbs index c8d3e782..e9442e72 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/android_sense/android_sense.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/android_sense/android_sense.hbs @@ -8,8 +8,6 @@

Connect your Android Sense to the WSO2 device cloud.

-
-
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.js b/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.js index 96b64f64..c7c27bec 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.js +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/appbar/appbar.js @@ -39,7 +39,7 @@ function onRequest(context) { links.users.push(dashboardLink); links.policies.push(dashboardLink); links.profiles.push(dashboardLink); - links.store.push(dashboardLink); + //links.store.push(dashboardLink); links.store.push(storeLink); links['group-mgt'].push(dashboardLink); var groupId = request.getParameter("groupId"); diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/arduino/arduino.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/arduino/arduino.hbs index c76e6a56..92412e4e 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/arduino/arduino.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/arduino/arduino.hbs @@ -8,8 +8,6 @@

Connect your Arduino Uno device to the WSO2 Device Cloud.

- -
diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/dashboard/dashboard.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/dashboard/dashboard.hbs index 4cbb2e22..32f87c21 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/dashboard/dashboard.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/dashboard/dashboard.hbs @@ -46,13 +46,13 @@ View - - - - - - Add - + + + + + + +
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..5f81900f 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/firealarm/firealarm.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/firealarm/firealarm.hbs @@ -8,8 +8,6 @@

Connect your Fire Alarm device to the WSO2 device cloud.

- -
@@ -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/policy-create/policy-create.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-create/policy-create.hbs index 2b217e3f..84e16838 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-create/policy-create.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/policy-create/policy-create.hbs @@ -155,7 +155,7 @@
-
1
+
1

diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/showcase/showcase.hbs b/modules/distribution/src/repository/jaggeryapps/iotserver/units/showcase/showcase.hbs index 8626ace1..4f39266f 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/showcase/showcase.hbs +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/showcase/showcase.hbs @@ -2,43 +2,20 @@
- - - - - - - - - - - - - - - - - - - - - - - -
+
-
+

-
+
-
+

-
+
-
+

diff --git a/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/main.css b/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/main.css index b6f92077..47076c0c 100644 --- a/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/main.css +++ b/modules/distribution/src/repository/jaggeryapps/iotserver/units/theme/public/css/main.css @@ -630,4 +630,8 @@ input[type=checkbox] { display: inline; padding-left: 15px; text-indent: -15px; +} + +.CodeMirror pre{ + padding-left: 45px !important; } \ No newline at end of file