mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
fixes in ui
This commit is contained in:
parent
3b7d4d8966
commit
6dffac4191
@ -109,7 +109,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div class="form-group feature_field_wrapper">
|
<div class="form-group feature_field_wrapper" name="deviceFeature">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-3">
|
<div class="col-xs-3">
|
||||||
<input type="text" class="form-control" id="feature-name" placeholder="name"/>
|
<input type="text" class="form-control" id="feature-name" placeholder="name"/>
|
||||||
@ -156,15 +156,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!--Commenting enrollment operation capability-->
|
||||||
|
<!--<label class="wr-input-label" for="passcode-policy-min-length">-->
|
||||||
|
<!--Enrolment Operation-->
|
||||||
|
<!--<span class="helper" title="Triggers the operation after the enrolment, E.g alarm">-->
|
||||||
|
<!--<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>-->
|
||||||
|
<!--</span>-->
|
||||||
|
<!--</label>-->
|
||||||
|
|
||||||
<label class="wr-input-label" for="passcode-policy-min-length">
|
<div class="form-group operation_field_wrapper hidden-div">
|
||||||
Enrolment Operation
|
|
||||||
<span class="helper" title="Triggers the operation after the enrolment, E.g alarm">
|
|
||||||
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
|
|
||||||
</span>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div class="form-group operation_field_wrapper">
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="dontfloat">
|
<div class="dontfloat">
|
||||||
<div class="col-xs-3">
|
<div class="col-xs-3">
|
||||||
|
|||||||
@ -171,12 +171,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label class="wr-input-label">
|
<!--<label class="wr-input-label">-->
|
||||||
Enrolment Operation
|
<!--Enrolment Operation-->
|
||||||
</label>
|
<!--</label>-->
|
||||||
<br>
|
<!--<br>-->
|
||||||
|
|
||||||
<div class="form-group operation_field_wrapper">
|
<div class="form-group operation_field_wrapper hidden-div">
|
||||||
{{#if type.deviceTypeMetaDefinition.initialOperationConfig}}
|
{{#if type.deviceTypeMetaDefinition.initialOperationConfig}}
|
||||||
{{#each type.deviceTypeMetaDefinition.initialOperationConfig.operations}}
|
{{#each type.deviceTypeMetaDefinition.initialOperationConfig.operations}}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@ -43,7 +43,7 @@ function onRequest(context) {
|
|||||||
if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) {
|
if (restAPIResponse["status"] == 200 && restAPIResponse["responseText"]) {
|
||||||
var typeData = parse(restAPIResponse["responseText"]);
|
var typeData = parse(restAPIResponse["responseText"]);
|
||||||
displayData.type = typeData;
|
displayData.type = typeData;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@ -133,10 +133,30 @@
|
|||||||
<h3 class="uppercase">Retrieve operations</h3>
|
<h3 class="uppercase">Retrieve operations</h3>
|
||||||
{{#if type.deviceTypeMetaDefinition.pushNotificationConfig}}
|
{{#if type.deviceTypeMetaDefinition.pushNotificationConfig}}
|
||||||
{{#if_eq type.deviceTypeMetaDefinition.pushNotificationConfig.type "MQTT"}}
|
{{#if_eq type.deviceTypeMetaDefinition.pushNotificationConfig.type "MQTT"}}
|
||||||
MQTT - {{mqttGateway}}
|
|
||||||
<div class="code-segment">
|
<div class="code-segment">
|
||||||
<span>MQTT Topic :</span>
|
<span>MQTT Topic :</span>
|
||||||
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/#</code>
|
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/#</code>
|
||||||
|
<br/>
|
||||||
|
<div class="code-segment">
|
||||||
|
<span>Topic Structure :</span>
|
||||||
|
<ul class="list-unstyled">
|
||||||
|
<li class="padding-top-double">
|
||||||
|
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/command/<feature_code>/<operation_id></code>
|
||||||
|
</li>
|
||||||
|
<li class="padding-top-double">
|
||||||
|
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/config/<feature_code>/<operation_id></code>
|
||||||
|
</li>
|
||||||
|
<li class="padding-top-double">
|
||||||
|
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/profile/<feature_code>/<operation_id></code>
|
||||||
|
</li>
|
||||||
|
<li class="padding-top-double">
|
||||||
|
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/policy/policy_bundle</code>
|
||||||
|
</li>
|
||||||
|
<li class="padding-top-double">
|
||||||
|
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/policy/policy_revoke</code>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="code-segment">
|
<div class="code-segment">
|
||||||
<span>Operation Response :</span>
|
<span>Operation Response :</span>
|
||||||
@ -147,24 +167,7 @@
|
|||||||
<code>{"id": 1,"status": "COMPLETED", "operationResponse": "this is my response"}</code>
|
<code>{"id": 1,"status": "COMPLETED", "operationResponse": "this is my response"}</code>
|
||||||
</div>
|
</div>
|
||||||
<br/>
|
<br/>
|
||||||
Topic Structure:
|
|
||||||
<ul class="list-unstyled">
|
|
||||||
<li class="padding-top-double">
|
|
||||||
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/command/<feature_code>/<operation_id></code>
|
|
||||||
</li>
|
|
||||||
<li class="padding-top-double">
|
|
||||||
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/config/<feature_code>/<operation_id></code>
|
|
||||||
</li>
|
|
||||||
<li class="padding-top-double">
|
|
||||||
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/profile/<feature_code>/<operation_id></code>
|
|
||||||
</li>
|
|
||||||
<li class="padding-top-double">
|
|
||||||
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/policy/policy_bundle</code>
|
|
||||||
</li>
|
|
||||||
<li class="padding-top-double">
|
|
||||||
<code>{{tenantDomain}}/{{device.type}}/{{device.deviceIdentifier}}/operation/policy/policy_revoke</code>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
{{/if_eq}}
|
{{/if_eq}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="code-segment">
|
<div class="code-segment">
|
||||||
@ -173,7 +176,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="code-segment">
|
<div class="code-segment">
|
||||||
<span>Retrieve next pending operation :</span>
|
<span>Retrieve next pending operation :</span>
|
||||||
<code>curl -k -X GET {{httpsGateway}}/api/device-mgt/v1.0/device/agent/next-pending/ -H 'authorization: Bearer %accessToken%' -H 'content-type: application/json'</code>
|
<code>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'</code>
|
||||||
</div>
|
</div>
|
||||||
<div class="code-segment">
|
<div class="code-segment">
|
||||||
<span>Update operation :</span>
|
<span>Update operation :</span>
|
||||||
|
|||||||
@ -18,51 +18,16 @@
|
|||||||
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
|
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
|
||||||
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
|
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
|
||||||
var process = require("process");
|
var process = require("process");
|
||||||
|
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
|
||||||
function onRequest(context) {
|
function onRequest(context) {
|
||||||
var log = new Log("device-view.js");
|
var log = new Log("device-view.js");
|
||||||
var deviceType = context.uriParams.deviceType;
|
var deviceType = context.uriParams.deviceType;
|
||||||
var deviceId = request.getParameter("id");
|
var deviceId = request.getParameter("id");
|
||||||
var attributes = [];
|
var attributes = [];
|
||||||
var featureList = [];
|
var featureList = [];
|
||||||
var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"]
|
var user = userModule.getCarbonUser();
|
||||||
+ "/events/" + deviceType;
|
var tenantDomain = user.domain;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, function (responsePayload) {
|
|
||||||
featureList = null;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
var autoCompleteParams = [
|
var autoCompleteParams = [
|
||||||
{"name" : "deviceId", "value" : deviceId}
|
{"name" : "deviceId", "value" : deviceId}
|
||||||
];
|
];
|
||||||
@ -74,6 +39,34 @@ function onRequest(context) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var displayData = {};
|
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"]
|
var eventRestAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"]
|
||||||
+ "/events/" + deviceType;
|
+ "/events/" + deviceType;
|
||||||
serviceInvokers.XMLHttp.get(
|
serviceInvokers.XMLHttp.get(
|
||||||
@ -87,6 +80,11 @@ function onRequest(context) {
|
|||||||
var eventExample = {};
|
var eventExample = {};
|
||||||
for (var i = 0; i < typeData.eventAttributes.attributes.length; i++) {
|
for (var i = 0; i < typeData.eventAttributes.attributes.length; i++) {
|
||||||
var attribute = typeData.eventAttributes.attributes[i];
|
var attribute = typeData.eventAttributes.attributes[i];
|
||||||
|
if (attribute['name'] == "deviceId") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
attributes.push(attribute['name']);
|
||||||
|
|
||||||
switch (attribute.type) {
|
switch (attribute.type) {
|
||||||
case "STRING":
|
case "STRING":
|
||||||
eventExample[attribute.name] = "string";
|
eventExample[attribute.name] = "string";
|
||||||
@ -129,6 +127,8 @@ function onRequest(context) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
displayData.tenantDomain = tenantDomain;
|
||||||
|
|
||||||
if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
|
if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
|
||||||
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
|
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
|
||||||
var device = deviceModule.viewDevice(deviceType, deviceId);
|
var device = deviceModule.viewDevice(deviceType, deviceId);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user