From 6dffac4191f419281e1e232b8a539d01b031cda7 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Sun, 18 Jun 2017 16:41:38 +0530 Subject: [PATCH] fixes in ui --- .../cdmf.page.devicetype.create/create.hbs | 18 ++--- .../pages/cdmf.page.devicetype.edit/edit.hbs | 10 +-- .../pages/cdmf.page.devicetype.edit/edit.js | 2 +- .../device-view.hbs | 43 ++++++----- .../device-view.js | 76 +++++++++---------- 5 files changed, 76 insertions(+), 73 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.create/create.hbs index f1741bc7bac..9227e4e3127 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.create/create.hbs @@ -109,7 +109,7 @@ -
+
@@ -156,15 +156,15 @@
+ + + + + + + - - -
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.edit/edit.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.edit/edit.hbs index 657fac23c0a..599ffcec4e1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.edit/edit.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.edit/edit.hbs @@ -171,12 +171,12 @@
- -
+ + + + -
+
{{#if type.deviceTypeMetaDefinition.initialOperationConfig}} {{#each type.deviceTypeMetaDefinition.initialOperationConfig.operations}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.edit/edit.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.edit/edit.js index 94284ac0164..ac0c4867916 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.edit/edit.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.devicetype.edit/edit.js @@ -43,7 +43,7 @@ function onRequest(context) { if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) { var typeData = parse(restAPIResponse["responseText"]); displayData.type = typeData; - + } } ); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.device-view/device-view.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.device-view/device-view.hbs index a84e3cb8467..54725160d53 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.device-view/device-view.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.device-view/device-view.hbs @@ -133,10 +133,30 @@

Retrieve operations

{{#if type.deviceTypeMetaDefinition.pushNotificationConfig}} {{#if_eq type.deviceTypeMetaDefinition.pushNotificationConfig.type "MQTT"}} - MQTT - {{mqttGateway}}
MQTT Topic : {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/# +
+
+ Topic Structure : +
    +
  • + {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/command/<feature_code>/<operation_id> +
  • +
  • + {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/config/<feature_code>/<operation_id> +
  • +
  • + {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/profile/<feature_code>/<operation_id> +
  • +
  • + {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/policy/policy_bundle +
  • +
  • + {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/policy/policy_revoke +
  • +
+
Operation Response : @@ -147,24 +167,7 @@ {"id": 1,"status": "COMPLETED", "operationResponse": "this is my response"}

- Topic Structure: -
    -
  • - {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/command/<feature_code>/<operation_id> -
  • -
  • - {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/config/<feature_code>/<operation_id> -
  • -
  • - {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/profile/<feature_code>/<operation_id> -
  • -
  • - {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/policy/policy_bundle -
  • -
  • - {{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/policy/policy_revoke -
  • -
+ {{/if_eq}} {{else}}
@@ -173,7 +176,7 @@
Retrieve next pending operation : - curl -k -X GET {{httpsGateway}}/api/device-mgt/v1.0/device/agent/next-pending/ -H 'authorization: Bearer %accessToken%' -H 'content-type: application/json' + curl -k -X GET {{httpsGateway}}/api/device-mgt/v1.0/device/agent/next-pending/{{device.type}}/{{device.deviceIdentifier}} -H 'authorization: Bearer %accessToken%' -H 'content-type: application/json'
Update operation : diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.device-view/device-view.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.device-view/device-view.js index 4bc27b0c51c..445106e6d02 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.device-view/device-view.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.default.device.type.device-view/device-view.js @@ -18,51 +18,16 @@ var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var process = require("process"); - +var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; function onRequest(context) { var log = new Log("device-view.js"); var deviceType = context.uriParams.deviceType; var deviceId = request.getParameter("id"); var attributes = []; var featureList = []; - var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] - + "/events/" + deviceType; - serviceInvokers.XMLHttp.get( - restAPIEndpoint, - function (restAPIResponse) { - if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) { - var data = parse(restAPIResponse["responseText"]); - if (data.eventAttributes.attributes.length > 0) { - for (var i = 0; i < data.eventAttributes.attributes.length; i++) { - var attribute = data.eventAttributes.attributes[i]; - if (attribute['name'] == "deviceId") { - continue; - } - attributes.push(attribute['name']); - } - } - - } - } - ); - - var featureEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] - + "/device-types/" + deviceType + "/features"; - serviceInvokers.XMLHttp.get(featureEndpoint, function (responsePayload) { - var features = JSON.parse(responsePayload.responseText); - var feature; - for (var i = 0; i < features.length; i++) { - feature = {}; - feature["operation"] = features[i].code; - feature["name"] = features[i].name; - feature["description"] = features[i].description; - featureList.push(feature); - } + var user = userModule.getCarbonUser(); + var tenantDomain = user.domain; - }, function (responsePayload) { - featureList = null; - } - ); var autoCompleteParams = [ {"name" : "deviceId", "value" : deviceId} ]; @@ -74,6 +39,34 @@ function onRequest(context) { }); var displayData = {}; + + var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + + "/device-types/config/" + deviceType; + displayData.deviceType = deviceType; + displayData.tenantDomain = tenantDomain; + serviceInvokers.XMLHttp.get( + restAPIEndpoint, + function (restAPIResponse) { + if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) { + var typeData = parse(restAPIResponse["responseText"]); + displayData.type = typeData; + if (typeData.deviceTypeMetaDefinition) { + var features = typeData.deviceTypeMetaDefinition.features; + if (features) { + var feature; + for (var i = 0; i < features.length; i++) { + feature = {}; + feature["operation"] = features[i].code; + feature["name"] = features[i].name; + feature["description"] = features[i].description; + featureList.push(feature); + } + } + } + } + } + ); + var eventRestAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/events/" + deviceType; serviceInvokers.XMLHttp.get( @@ -87,6 +80,11 @@ function onRequest(context) { var eventExample = {}; for (var i = 0; i < typeData.eventAttributes.attributes.length; i++) { var attribute = typeData.eventAttributes.attributes[i]; + if (attribute['name'] == "deviceId") { + continue; + } + attributes.push(attribute['name']); + switch (attribute.type) { case "STRING": eventExample[attribute.name] = "string"; @@ -129,6 +127,8 @@ function onRequest(context) { } ); + displayData.tenantDomain = tenantDomain; + if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; var device = deviceModule.viewDevice(deviceType, deviceId);