mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'master' of https://github.com/wso2/carbon-device-mgt
This commit is contained in:
commit
1d9abd0330
@ -139,6 +139,7 @@
|
|||||||
org.wso2.carbon.context,
|
org.wso2.carbon.context,
|
||||||
org.wso2.carbon.device.mgt.common.operation.mgt,
|
org.wso2.carbon.device.mgt.common.operation.mgt,
|
||||||
org.wso2.carbon.device.mgt.common.push.notification,
|
org.wso2.carbon.device.mgt.common.push.notification,
|
||||||
|
org.wso2.carbon.device.mgt.common,
|
||||||
org.wso2.carbon.device.mgt.core.service,
|
org.wso2.carbon.device.mgt.core.service,
|
||||||
org.wso2.carbon.event.output.adapter.core,
|
org.wso2.carbon.event.output.adapter.core,
|
||||||
org.wso2.carbon.event.output.adapter.core.exception,
|
org.wso2.carbon.event.output.adapter.core.exception,
|
||||||
|
|||||||
@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
|
||||||
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||||
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||||
@ -32,6 +33,7 @@ import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterExc
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
public class MQTTNotificationStrategy implements NotificationStrategy {
|
public class MQTTNotificationStrategy implements NotificationStrategy {
|
||||||
|
|
||||||
@ -75,7 +77,15 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
|
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
|
||||||
Map<String, String> dynamicProperties = new HashMap<>();
|
Map<String, String> dynamicProperties = new HashMap<>();
|
||||||
dynamicProperties.put("topic", (String) ctx.getOperation().getProperties().get(MQTT_ADAPTER_TOPIC));
|
Properties properties = ctx.getOperation().getProperties();
|
||||||
|
if (properties != null && properties.get(MQTT_ADAPTER_TOPIC) != null) {
|
||||||
|
dynamicProperties.put("topic", (String) properties.get(MQTT_ADAPTER_TOPIC));
|
||||||
|
} else {
|
||||||
|
String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/"
|
||||||
|
+ ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + ctx.getOperation().getType();
|
||||||
|
dynamicProperties.put("topic", topic);
|
||||||
|
}
|
||||||
|
|
||||||
MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties,
|
MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties,
|
||||||
ctx.getOperation().getPayLoad());
|
ctx.getOperation().getPayLoad());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
|
|||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
||||||
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||||
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider;
|
||||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||||
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
||||||
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
|
||||||
@ -137,10 +138,16 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
|
|||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
deviceTypeIdentifier = new DeviceTypeIdentifier(deviceManagementService.getType(), tenantId);
|
deviceTypeIdentifier = new DeviceTypeIdentifier(deviceManagementService.getType(), tenantId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pushNoteConfig != null) {
|
if (pushNoteConfig != null) {
|
||||||
NotificationStrategy notificationStrategy =
|
PushNotificationProvider provider = DeviceManagementDataHolder.getInstance()
|
||||||
DeviceManagementDataHolder.getInstance().getPushNotificationProviderRepository().getProvider(
|
.getPushNotificationProviderRepository().getProvider(pushNoteConfig.getType());
|
||||||
pushNoteConfig.getType()).getNotificationStrategy(pushNoteConfig);
|
if (provider == null) {
|
||||||
|
throw new DeviceManagementException(
|
||||||
|
"No registered push notification provider found for the type: '" +
|
||||||
|
pushNoteConfig.getType() + "'.");
|
||||||
|
}
|
||||||
|
NotificationStrategy notificationStrategy = provider.getNotificationStrategy(pushNoteConfig);
|
||||||
operationManagerRepository.addOperationManager(deviceTypeIdentifier, new OperationManagerImpl(
|
operationManagerRepository.addOperationManager(deviceTypeIdentifier, new OperationManagerImpl(
|
||||||
notificationStrategy));
|
notificationStrategy));
|
||||||
} else {
|
} else {
|
||||||
@ -172,7 +179,8 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
|
|||||||
deviceTypeName = provider.getType().toLowerCase();
|
deviceTypeName = provider.getType().toLowerCase();
|
||||||
ProvisioningConfig provisioningConfig = provider.getProvisioningConfig();
|
ProvisioningConfig provisioningConfig = provider.getProvisioningConfig();
|
||||||
int tenantId = DeviceManagerUtil.getTenantId(provisioningConfig.getProviderTenantDomain());
|
int tenantId = DeviceManagerUtil.getTenantId(provisioningConfig.getProviderTenantDomain());
|
||||||
DeviceManagerUtil.registerDeviceType(deviceTypeName, tenantId, provisioningConfig.isSharedWithAllTenants());
|
DeviceManagerUtil.registerDeviceType(deviceTypeName, tenantId,
|
||||||
|
provisioningConfig.isSharedWithAllTenants());
|
||||||
registerPushNotificationStrategy(provider);
|
registerPushNotificationStrategy(provider);
|
||||||
//TODO:
|
//TODO:
|
||||||
//This is a temporory fix.
|
//This is a temporory fix.
|
||||||
@ -180,7 +188,8 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis
|
|||||||
//until fix that, use following variable to enable and disable of checking user authorization.
|
//until fix that, use following variable to enable and disable of checking user authorization.
|
||||||
|
|
||||||
DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(provider.getType(),
|
DeviceManagementDataHolder.getInstance().setRequireDeviceAuthorization(provider.getType(),
|
||||||
provider.getDeviceManager().requireDeviceAuthorization());
|
provider.getDeviceManager()
|
||||||
|
.requireDeviceAuthorization());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
/* Throwable is caught intentionally as failure of one plugin - due to invalid start up parameters,
|
/* Throwable is caught intentionally as failure of one plugin - due to invalid start up parameters,
|
||||||
etc - should not block the initialization of other device management providers */
|
etc - should not block the initialization of other device management providers */
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"appContext": "/emm/",
|
"appContext": "/devicemgt/",
|
||||||
"webAgentContext" : "/emm-web-agent/",
|
"webAgentContext" : "/emm-web-agent/",
|
||||||
"apiContext": "api",
|
"apiContext": "api",
|
||||||
"httpsURL" : "%https.ip%",
|
"httpsURL" : "%https.ip%",
|
||||||
|
|||||||
@ -66,11 +66,15 @@ var invokers = function () {
|
|||||||
* @param endpoint Backend REST API url.
|
* @param endpoint Backend REST API url.
|
||||||
* @param responseCallback a function to be called with response retrieved.
|
* @param responseCallback a function to be called with response retrieved.
|
||||||
* @param count a counter which hold the number of recursive execution
|
* @param count a counter which hold the number of recursive execution
|
||||||
|
* @param headers a list of name value pairs for additional http headers
|
||||||
*/
|
*/
|
||||||
privateMethods["execute"] = function (httpMethod, requestPayload, endpoint, responseCallback, count) {
|
privateMethods["execute"] = function (httpMethod, requestPayload, endpoint, responseCallback, count, headers) {
|
||||||
var xmlHttpRequest = new XMLHttpRequest();
|
var xmlHttpRequest = new XMLHttpRequest();
|
||||||
|
|
||||||
xmlHttpRequest.open(httpMethod, endpoint);
|
xmlHttpRequest.open(httpMethod, endpoint);
|
||||||
|
for(var i in headers){
|
||||||
|
xmlHttpRequest.setRequestHeader(headers[i].name, headers[i].value);
|
||||||
|
}
|
||||||
xmlHttpRequest.setRequestHeader(constants["CONTENT_TYPE_IDENTIFIER"], constants["APPLICATION_JSON"]);
|
xmlHttpRequest.setRequestHeader(constants["CONTENT_TYPE_IDENTIFIER"], constants["APPLICATION_JSON"]);
|
||||||
xmlHttpRequest.setRequestHeader(constants["ACCEPT_IDENTIFIER"], constants["APPLICATION_JSON"]);
|
xmlHttpRequest.setRequestHeader(constants["ACCEPT_IDENTIFIER"], constants["APPLICATION_JSON"]);
|
||||||
|
|
||||||
@ -100,7 +104,7 @@ var invokers = function () {
|
|||||||
if (xmlHttpRequest.status == 401 && (xmlHttpRequest.responseText == TOKEN_EXPIRED ||
|
if (xmlHttpRequest.status == 401 && (xmlHttpRequest.responseText == TOKEN_EXPIRED ||
|
||||||
xmlHttpRequest.responseText == TOKEN_INVALID ) && count < 5) {
|
xmlHttpRequest.responseText == TOKEN_INVALID ) && count < 5) {
|
||||||
tokenUtil.refreshTokenPair();
|
tokenUtil.refreshTokenPair();
|
||||||
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count);
|
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers);
|
||||||
} else {
|
} else {
|
||||||
return responseCallback(xmlHttpRequest);
|
return responseCallback(xmlHttpRequest);
|
||||||
}
|
}
|
||||||
@ -113,8 +117,8 @@ var invokers = function () {
|
|||||||
* @param endpoint Backend REST API url.
|
* @param endpoint Backend REST API url.
|
||||||
* @param responseCallback a function to be called with response retrieved.
|
* @param responseCallback a function to be called with response retrieved.
|
||||||
*/
|
*/
|
||||||
privateMethods["initiateXMLHTTPRequest"] = function (httpMethod, requestPayload, endpoint, responseCallback) {
|
privateMethods["initiateXMLHTTPRequest"] = function (httpMethod, requestPayload, endpoint, responseCallback, headers) {
|
||||||
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, 0);
|
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, 0, headers);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,9 +126,9 @@ var invokers = function () {
|
|||||||
* @param endpoint Backend REST API url.
|
* @param endpoint Backend REST API url.
|
||||||
* @param responseCallback a function to be called with response retrieved.
|
* @param responseCallback a function to be called with response retrieved.
|
||||||
*/
|
*/
|
||||||
publicXMLHTTPInvokers["get"] = function (endpoint, responseCallback) {
|
publicXMLHTTPInvokers["get"] = function (endpoint, responseCallback, headers) {
|
||||||
var requestPayload = null;
|
var requestPayload = null;
|
||||||
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_GET"], requestPayload, endpoint, responseCallback);
|
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_GET"], requestPayload, endpoint, responseCallback, headers);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,8 +137,8 @@ var invokers = function () {
|
|||||||
* @param requestPayload payload/data if exists which is needed to be send.
|
* @param requestPayload payload/data if exists which is needed to be send.
|
||||||
* @param responseCallback a function to be called with response retrieved.
|
* @param responseCallback a function to be called with response retrieved.
|
||||||
*/
|
*/
|
||||||
publicXMLHTTPInvokers["post"] = function (endpoint, requestPayload, responseCallback) {
|
publicXMLHTTPInvokers["post"] = function (endpoint, requestPayload, responseCallback, headers) {
|
||||||
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_POST"], requestPayload, endpoint, responseCallback);
|
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_POST"], requestPayload, endpoint, responseCallback, headers);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,8 +147,8 @@ var invokers = function () {
|
|||||||
* @param requestPayload payload/data if exists which is needed to be send.
|
* @param requestPayload payload/data if exists which is needed to be send.
|
||||||
* @param responseCallback a function to be called with response retrieved.
|
* @param responseCallback a function to be called with response retrieved.
|
||||||
*/
|
*/
|
||||||
publicXMLHTTPInvokers["put"] = function (endpoint, requestPayload, responseCallback) {
|
publicXMLHTTPInvokers["put"] = function (endpoint, requestPayload, responseCallback, headers) {
|
||||||
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_PUT"], requestPayload, endpoint, responseCallback);
|
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_PUT"], requestPayload, endpoint, responseCallback, headers);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -152,9 +156,9 @@ var invokers = function () {
|
|||||||
* @param endpoint Backend REST API url.
|
* @param endpoint Backend REST API url.
|
||||||
* @param responseCallback a function to be called with response retrieved.
|
* @param responseCallback a function to be called with response retrieved.
|
||||||
*/
|
*/
|
||||||
publicXMLHTTPInvokers["delete"] = function (endpoint, responseCallback) {
|
publicXMLHTTPInvokers["delete"] = function (endpoint, responseCallback, headers) {
|
||||||
var requestPayload = null;
|
var requestPayload = null;
|
||||||
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_DELETE"], requestPayload, endpoint, responseCallback);
|
return privateMethods.initiateXMLHTTPRequest(constants["HTTP_DELETE"], requestPayload, endpoint, responseCallback, headers);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -239,8 +243,9 @@ var invokers = function () {
|
|||||||
* @param payload payload/data which need to be send.
|
* @param payload payload/data which need to be send.
|
||||||
* @param successCallback a function to be called if the respond if successful.
|
* @param successCallback a function to be called if the respond if successful.
|
||||||
* @param errorCallback a function to be called if en error is reserved.
|
* @param errorCallback a function to be called if en error is reserved.
|
||||||
|
* @param headers a list of name value pairs for additional http headers.
|
||||||
*/
|
*/
|
||||||
privateMethods["initiateHTTPClientRequest"] = function (method, url, successCallback, errorCallback, payload) {
|
privateMethods["initiateHTTPClientRequest"] = function (method, url, successCallback, errorCallback, payload, headers) {
|
||||||
//noinspection JSUnresolvedVariable
|
//noinspection JSUnresolvedVariable
|
||||||
var HttpClient = Packages.org.apache.commons.httpclient.HttpClient;
|
var HttpClient = Packages.org.apache.commons.httpclient.HttpClient;
|
||||||
var httpMethodObject;
|
var httpMethodObject;
|
||||||
@ -269,6 +274,14 @@ var invokers = function () {
|
|||||||
//noinspection JSUnresolvedFunction
|
//noinspection JSUnresolvedFunction
|
||||||
throw new IllegalArgumentException("Invalid HTTP request method: " + method);
|
throw new IllegalArgumentException("Invalid HTTP request method: " + method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(var i in headers){
|
||||||
|
var header = new Header();
|
||||||
|
header.setName(headers[i].name);
|
||||||
|
header.setValue(headers[i].value);
|
||||||
|
httpMethodObject.addRequestHeader(header);
|
||||||
|
}
|
||||||
|
|
||||||
//noinspection JSUnresolvedVariable
|
//noinspection JSUnresolvedVariable
|
||||||
var Header = Packages.org.apache.commons.httpclient.Header;
|
var Header = Packages.org.apache.commons.httpclient.Header;
|
||||||
var header = new Header();
|
var header = new Header();
|
||||||
@ -295,15 +308,19 @@ var invokers = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//noinspection JSUnresolvedFunction
|
//noinspection JSUnresolvedFunction
|
||||||
|
if (payload != null) {
|
||||||
|
var StringRequestEntity = Packages.org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||||
var stringRequestEntity = new StringRequestEntity(stringify(payload));
|
var stringRequestEntity = new StringRequestEntity(stringify(payload));
|
||||||
//noinspection JSUnresolvedFunction
|
//noinspection JSUnresolvedFunction
|
||||||
httpMethodObject.setRequestEntity(stringRequestEntity);
|
httpMethodObject.setRequestEntity(stringRequestEntity);
|
||||||
|
}
|
||||||
var client = new HttpClient();
|
var client = new HttpClient();
|
||||||
try {
|
try {
|
||||||
//noinspection JSUnresolvedFunction
|
//noinspection JSUnresolvedFunction
|
||||||
client.executeMethod(httpMethodObject);
|
client.executeMethod(httpMethodObject);
|
||||||
//noinspection JSUnresolvedFunction
|
//noinspection JSUnresolvedFunction
|
||||||
var status = httpMethodObject.getStatusCode();
|
var status = httpMethodObject.getStatusCode();
|
||||||
|
new Log().error(status);
|
||||||
if (status == 200) {
|
if (status == 200) {
|
||||||
//noinspection JSUnresolvedFunction
|
//noinspection JSUnresolvedFunction
|
||||||
return successCallback(httpMethodObject.getResponseBody());
|
return successCallback(httpMethodObject.getResponseBody());
|
||||||
@ -315,8 +332,10 @@ var invokers = function () {
|
|||||||
return errorCallback(response);
|
return errorCallback(response);
|
||||||
} finally {
|
} finally {
|
||||||
//noinspection JSUnresolvedFunction
|
//noinspection JSUnresolvedFunction
|
||||||
|
if (method != constants["HTTP_GET"]) {
|
||||||
method.releaseConnection();
|
method.releaseConnection();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -324,11 +343,12 @@ var invokers = function () {
|
|||||||
* @param url target url.
|
* @param url target url.
|
||||||
* @param successCallback a function to be called if the respond if successful.
|
* @param successCallback a function to be called if the respond if successful.
|
||||||
* @param errorCallback a function to be called if en error is reserved.
|
* @param errorCallback a function to be called if en error is reserved.
|
||||||
|
* @param headers a list of name value pairs for additional http headers.
|
||||||
*/
|
*/
|
||||||
publicHTTPClientInvokers["get"] = function (url, successCallback, errorCallback) {
|
publicHTTPClientInvokers["get"] = function (url, successCallback, errorCallback, headers) {
|
||||||
var requestPayload = null;
|
var requestPayload = null;
|
||||||
return privateMethods.
|
return privateMethods.
|
||||||
initiateHTTPClientRequest(constants["HTTP_GET"], url, successCallback, errorCallback, requestPayload);
|
initiateHTTPClientRequest(constants["HTTP_GET"], url, successCallback, errorCallback, requestPayload, headers);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -337,10 +357,11 @@ var invokers = function () {
|
|||||||
* @param payload payload/data which need to be send.
|
* @param payload payload/data which need to be send.
|
||||||
* @param successCallback a function to be called if the respond if successful.
|
* @param successCallback a function to be called if the respond if successful.
|
||||||
* @param errorCallback a function to be called if en error is reserved.
|
* @param errorCallback a function to be called if en error is reserved.
|
||||||
|
* @param headers a list of name value pairs for additional http headers.
|
||||||
*/
|
*/
|
||||||
publicHTTPClientInvokers["post"] = function (url, payload, successCallback, errorCallback) {
|
publicHTTPClientInvokers["post"] = function (url, payload, successCallback, errorCallback, headers) {
|
||||||
return privateMethods.
|
return privateMethods.
|
||||||
initiateHTTPClientRequest(constants["HTTP_POST"], url, successCallback, errorCallback, payload);
|
initiateHTTPClientRequest(constants["HTTP_POST"], url, successCallback, errorCallback, payload, headers);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -349,10 +370,11 @@ var invokers = function () {
|
|||||||
* @param payload payload/data which need to be send.
|
* @param payload payload/data which need to be send.
|
||||||
* @param successCallback a function to be called if the respond if successful.
|
* @param successCallback a function to be called if the respond if successful.
|
||||||
* @param errorCallback a function to be called if en error is reserved.
|
* @param errorCallback a function to be called if en error is reserved.
|
||||||
|
* @param headers a list of name value pairs for additional http headers.
|
||||||
*/
|
*/
|
||||||
publicHTTPClientInvokers["put"] = function (url, payload, successCallback, errorCallback) {
|
publicHTTPClientInvokers["put"] = function (url, payload, successCallback, errorCallback, headers) {
|
||||||
return privateMethods.
|
return privateMethods.
|
||||||
initiateHTTPClientRequest(constants["HTTP_PUT"], url, successCallback, errorCallback, payload);
|
initiateHTTPClientRequest(constants["HTTP_PUT"], url, successCallback, errorCallback, payload, headers);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -360,11 +382,12 @@ var invokers = function () {
|
|||||||
* @param url target url.
|
* @param url target url.
|
||||||
* @param successCallback a function to be called if the respond if successful.
|
* @param successCallback a function to be called if the respond if successful.
|
||||||
* @param errorCallback a function to be called if en error is reserved.
|
* @param errorCallback a function to be called if en error is reserved.
|
||||||
|
* @param headers a list of name value pairs for additional http headers.
|
||||||
*/
|
*/
|
||||||
publicHTTPClientInvokers["delete"] = function (url, successCallback, errorCallback) {
|
publicHTTPClientInvokers["delete"] = function (url, successCallback, errorCallback, headers) {
|
||||||
var requestPayload = null;
|
var requestPayload = null;
|
||||||
return privateMethods.
|
return privateMethods.
|
||||||
initiateHTTPClientRequest(constants["HTTP_DELETE"], url, successCallback, errorCallback, requestPayload);
|
initiateHTTPClientRequest(constants["HTTP_DELETE"], url, successCallback, errorCallback, requestPayload, headers);
|
||||||
};
|
};
|
||||||
|
|
||||||
var publicMethods = {};
|
var publicMethods = {};
|
||||||
|
|||||||
@ -26,18 +26,18 @@
|
|||||||
{{/zone}}
|
{{/zone}}
|
||||||
|
|
||||||
{{#zone "content"}}
|
{{#zone "content"}}
|
||||||
<div class="wr-content">
|
<div class="row">
|
||||||
{{#if permissions.VIEW_DASHBOARD}}
|
{{#if permissions.VIEW_DASHBOARD}}
|
||||||
<div class="row wr-stats-board">
|
<div class="col-md-3 wr-stats-board">
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="wr-stats-board-tile">
|
<div class="wr-stats-board-tile">
|
||||||
<div class="tile-name">Devices</div>
|
<div class="tile-name">Devices</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="tile-icon"><i class="fw fw-mobile"></i></div>
|
<div class="tile-icon"><i class="fw fw-mobile"></i></div>
|
||||||
<div class="tile-stats">
|
<div class="tile-stats">
|
||||||
<span id="device-count">{{device_count}}</span>
|
<span id="device-count">{{deviceCount}}</span>
|
||||||
<span class="tile-stats-free">
|
<span class="tile-stats-free">
|
||||||
<!--suppress HtmlUnknownTarget -->
|
<!--suppress HtmlUnknownTarget -->
|
||||||
|
{{#if deviceCount}}
|
||||||
<a href="{{@app.context}}/devices">
|
<a href="{{@app.context}}/devices">
|
||||||
<span class="fw-stack">
|
<span class="fw-stack">
|
||||||
<i class="fw fw-ring fw-stack-2x"></i>
|
<i class="fw fw-ring fw-stack-2x"></i>
|
||||||
@ -45,6 +45,7 @@
|
|||||||
</span>
|
</span>
|
||||||
View
|
View
|
||||||
</a>
|
</a>
|
||||||
|
{{/if}}
|
||||||
<!--suppress HtmlUnknownTarget -->
|
<!--suppress HtmlUnknownTarget -->
|
||||||
<a href="{{@app.context}}/device/enroll">
|
<a href="{{@app.context}}/device/enroll">
|
||||||
<span class="fw-stack">
|
<span class="fw-stack">
|
||||||
@ -58,16 +59,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="col-md-3 wr-stats-board">
|
||||||
<div class="row wr-stats-board">
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="wr-stats-board-tile">
|
<div class="wr-stats-board-tile">
|
||||||
<div class="tile-name">Groups</div>
|
<div class="tile-name">Groups</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="tile-icon"><i class="fw fw-grouping"></i></div>
|
<div class="tile-icon"><i class="fw fw-grouping"></i></div>
|
||||||
<div class="tile-stats">
|
<div class="tile-stats">
|
||||||
<span id="group-count">{{group_count}}</span>
|
<span id="group-count">{{groupCount}}</span>
|
||||||
<span class="tile-stats-free">
|
<span class="tile-stats-free">
|
||||||
|
{{#if groupCount}}
|
||||||
<!--suppress HtmlUnknownTarget -->
|
<!--suppress HtmlUnknownTarget -->
|
||||||
<a href="{{@app.context}}/groups">
|
<a href="{{@app.context}}/groups">
|
||||||
<span class="fw-stack">
|
<span class="fw-stack">
|
||||||
@ -76,6 +76,7 @@
|
|||||||
</span>
|
</span>
|
||||||
View
|
View
|
||||||
</a>
|
</a>
|
||||||
|
{{/if}}
|
||||||
<!--suppress HtmlUnknownTarget -->
|
<!--suppress HtmlUnknownTarget -->
|
||||||
<a href="{{@app.context}}/group/add">
|
<a href="{{@app.context}}/group/add">
|
||||||
<span class="fw-stack">
|
<span class="fw-stack">
|
||||||
@ -89,16 +90,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="col-md-3 wr-stats-board">
|
||||||
<div class="row wr-stats-board">
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="wr-stats-board-tile">
|
<div class="wr-stats-board-tile">
|
||||||
<div class="tile-name">Users</div>
|
<div class="tile-name">Users</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="tile-icon"><i class="fw fw-user"></i></div>
|
<div class="tile-icon"><i class="fw fw-user"></i></div>
|
||||||
<div class="tile-stats">
|
<div class="tile-stats">
|
||||||
<span id="user-count">{{user_count}}</span>
|
<span id="user-count">{{userCount}}</span>
|
||||||
<span class="tile-stats-free">
|
<span class="tile-stats-free">
|
||||||
|
{{#if userCount}}
|
||||||
<!--suppress HtmlUnknownTarget -->
|
<!--suppress HtmlUnknownTarget -->
|
||||||
<a href="{{@app.context}}/users">
|
<a href="{{@app.context}}/users">
|
||||||
<span class="fw-stack">
|
<span class="fw-stack">
|
||||||
@ -107,6 +107,7 @@
|
|||||||
</span>
|
</span>
|
||||||
View
|
View
|
||||||
</a>
|
</a>
|
||||||
|
{{/if}}
|
||||||
<!--suppress HtmlUnknownTarget -->
|
<!--suppress HtmlUnknownTarget -->
|
||||||
<a href="{{@app.context}}/user/add">
|
<a href="{{@app.context}}/user/add">
|
||||||
<span class="fw-stack">
|
<span class="fw-stack">
|
||||||
@ -120,16 +121,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="col-md-3 wr-stats-board">
|
||||||
<div class="row wr-stats-board">
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="wr-stats-board-tile">
|
<div class="wr-stats-board-tile">
|
||||||
<div class="tile-name">Policies</div>
|
<div class="tile-name">Policies</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="tile-icon"><i class="fw fw-policy"></i></div>
|
<div class="tile-icon"><i class="fw fw-policy"></i></div>
|
||||||
<div class="tile-stats">
|
<div class="tile-stats">
|
||||||
<span id="policy-count">{{policy_count}}</span>
|
<span id="policy-count">{{policyCount}}</span>
|
||||||
<span class="tile-stats-free">
|
<span class="tile-stats-free">
|
||||||
|
{{#if policyCount}}
|
||||||
<!--suppress HtmlUnknownTarget -->
|
<!--suppress HtmlUnknownTarget -->
|
||||||
<a href="{{@app.context}}/policies">
|
<a href="{{@app.context}}/policies">
|
||||||
<span class="fw-stack">
|
<span class="fw-stack">
|
||||||
@ -138,6 +138,7 @@
|
|||||||
</span>
|
</span>
|
||||||
View
|
View
|
||||||
</a>
|
</a>
|
||||||
|
{{/if}}
|
||||||
<!--suppress HtmlUnknownTarget -->
|
<!--suppress HtmlUnknownTarget -->
|
||||||
<a href="{{@app.context}}/policy/add">
|
<a href="{{@app.context}}/policy/add">
|
||||||
<span class="fw-stack">
|
<span class="fw-stack">
|
||||||
@ -151,16 +152,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="col-md-3 wr-stats-board">
|
||||||
<div class="row wr-stats-board">
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="wr-stats-board-tile">
|
<div class="wr-stats-board-tile">
|
||||||
<div class="tile-name">Roles</div>
|
<div class="tile-name">Roles</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="tile-icon"><i class="fw fw-bookmark"></i></div>
|
<div class="tile-icon"><i class="fw fw-bookmark"></i></div>
|
||||||
<div class="tile-stats">
|
<div class="tile-stats">
|
||||||
<span id="role-count">{{role_count}}</span>
|
<span id="role-count">{{roleCount}}</span>
|
||||||
<span class="tile-stats-free">
|
<span class="tile-stats-free">
|
||||||
|
{{#if roleCount}}
|
||||||
<!--suppress HtmlUnknownTarget -->
|
<!--suppress HtmlUnknownTarget -->
|
||||||
<a id="device-count-view-btn" href="{{@app.context}}/roles">
|
<a id="device-count-view-btn" href="{{@app.context}}/roles">
|
||||||
<span class="fw-stack">
|
<span class="fw-stack">
|
||||||
@ -169,6 +169,7 @@
|
|||||||
</span>
|
</span>
|
||||||
View
|
View
|
||||||
</a>
|
</a>
|
||||||
|
{{/if}}
|
||||||
<!--suppress HtmlUnknownTarget -->
|
<!--suppress HtmlUnknownTarget -->
|
||||||
<a href="{{@app.context}}/roles/add-role">
|
<a href="{{@app.context}}/roles/add-role">
|
||||||
<span class="fw-stack">
|
<span class="fw-stack">
|
||||||
@ -182,28 +183,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{{else}}
|
{{else}}
|
||||||
Permission denied
|
<h1 class="page-sub-title">
|
||||||
|
Permitted None
|
||||||
|
</h1>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div id="qr-code-modal" data-enrollment-url="{{enrollmentURL}}" class="hidden">
|
|
||||||
<div class="content">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-5 col-md-6 col-centered">
|
|
||||||
<h3>
|
|
||||||
Scan QR code to start enrollment
|
|
||||||
</h3>
|
|
||||||
<h4>
|
|
||||||
Please scan the QR code using your mobile device to retrieve enrollment URL.
|
|
||||||
</h4>
|
|
||||||
<div class="panel panel-default">
|
|
||||||
<div class="panel-body col-centered ">
|
|
||||||
<div class="qr-code"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{/zone}}
|
{{/zone}}
|
||||||
@ -32,16 +32,16 @@ function onRequest() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var page = {};
|
var viewModel = {};
|
||||||
page.permissions = permissions;
|
viewModel.permissions = permissions;
|
||||||
page.enrollmentURL = devicemgtProps.enrollmentURL;
|
viewModel.enrollmentURL = devicemgtProps.enrollmentURL;
|
||||||
page.device_count = deviceModule.getDevicesCount();
|
viewModel.deviceCount = deviceModule.getDevicesCount();
|
||||||
//TODO: Enable Group Management Service API on CDMF
|
//TODO: Enable Group Management Service API on CDMF
|
||||||
//page.group_count = groupModule.getGroupCount();
|
//page.group_count = groupModule.getGroupCount();
|
||||||
page.group_count = -1;
|
viewModel.groupCount = -1;
|
||||||
page.user_count = userModule.getUsersCount();
|
viewModel.userCount = userModule.getUsersCount();
|
||||||
page.policy_count = policyModule.getPoliciesCount();
|
viewModel.policyCount = policyModule.getPoliciesCount();
|
||||||
page.role_count = userModule.getRolesCount();
|
viewModel.roleCount = userModule.getRolesCount();
|
||||||
|
|
||||||
return page;
|
return viewModel;
|
||||||
}
|
}
|
||||||
@ -24,22 +24,22 @@ function onRequest(context) {
|
|||||||
var groupName = request.getParameter("groupName");
|
var groupName = request.getParameter("groupName");
|
||||||
var groupOwner = request.getParameter("groupOwner");
|
var groupOwner = request.getParameter("groupOwner");
|
||||||
|
|
||||||
var page = {};
|
var viewModel = {};
|
||||||
var title = "Devices";
|
var title = "Devices";
|
||||||
if (groupName) {
|
if (groupName) {
|
||||||
title = groupName + " " + title;
|
title = groupName + " " + title;
|
||||||
page.groupName = groupName;
|
viewModel.groupName = groupName;
|
||||||
}
|
}
|
||||||
page.title = title;
|
viewModel.title = title;
|
||||||
var currentUser = session.get(constants.USER_SESSION_KEY);
|
var currentUser = session.get(constants.USER_SESSION_KEY);
|
||||||
if (currentUser) {
|
if (currentUser) {
|
||||||
page.permissions = {};
|
viewModel.permissions = {};
|
||||||
var uiPermissions = userModule.getUIPermissions();
|
var uiPermissions = userModule.getUIPermissions();
|
||||||
page.permissions.list = stringify(uiPermissions);
|
viewModel.permissions.list = stringify(uiPermissions);
|
||||||
if (uiPermissions.ADD_DEVICE) {
|
if (uiPermissions.ADD_DEVICE) {
|
||||||
page.permissions.enroll = true;
|
viewModel.permissions.enroll = true;
|
||||||
}
|
}
|
||||||
page.currentUser = currentUser;
|
viewModel.currentUser = currentUser;
|
||||||
var deviceCount = 0;
|
var deviceCount = 0;
|
||||||
if (groupName && groupOwner) {
|
if (groupName && groupOwner) {
|
||||||
var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"];
|
var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"];
|
||||||
@ -48,30 +48,30 @@ function onRequest(context) {
|
|||||||
deviceCount = deviceModule.getDevicesCount();
|
deviceCount = deviceModule.getDevicesCount();
|
||||||
}
|
}
|
||||||
if (deviceCount > 0) {
|
if (deviceCount > 0) {
|
||||||
page.deviceCount = deviceCount;
|
viewModel.deviceCount = deviceCount;
|
||||||
var utility = require("/app/modules/utility.js").utility;
|
var utility = require("/app/modules/utility.js").utility;
|
||||||
var typesListResponse = deviceModule.getDeviceTypes();
|
var typesListResponse = deviceModule.getDeviceTypes();
|
||||||
var deviceTypes = [];
|
var deviceTypes = [];
|
||||||
if (typesListResponse["status"] == "success") {
|
if (typesListResponse["status"] == "success") {
|
||||||
var data = typesListResponse["content"];
|
var data = typesListResponse.content.deviceTypes;
|
||||||
if (data) {
|
if (data) {
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
var config = utility.getDeviceTypeConfig(data[i].name);
|
var config = utility.getDeviceTypeConfig(data[i]);
|
||||||
if (!config) {
|
if (!config) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var deviceType = config.deviceType;
|
var deviceType = config.deviceType;
|
||||||
deviceTypes.push({
|
deviceTypes.push({
|
||||||
"type": data[i].name,
|
"type": data[i],
|
||||||
"category": deviceType.category,
|
"category": deviceType.category,
|
||||||
"label": deviceType.label,
|
"label": deviceType.label,
|
||||||
"thumb": utility.getDeviceThumb(data[i].name)
|
"thumb": utility.getDeviceThumb(data[i])
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
page.deviceTypes = stringify(deviceTypes);
|
viewModel.deviceTypes = stringify(deviceTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return page;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,12 +27,12 @@ function onRequest(context) {
|
|||||||
var utility = require("/app/modules/utility.js").utility;
|
var utility = require("/app/modules/utility.js").utility;
|
||||||
var typesListResponse = deviceModule.getDeviceTypes();
|
var typesListResponse = deviceModule.getDeviceTypes();
|
||||||
if (typesListResponse["status"] == "success") {
|
if (typesListResponse["status"] == "success") {
|
||||||
var deviceTypes = typesListResponse["content"];
|
var deviceTypes = typesListResponse.content.deviceTypes;
|
||||||
if (deviceTypes) {
|
if (deviceTypes) {
|
||||||
var deviceTypesList = [], virtualDeviceTypesList = [];
|
var deviceTypesList = [], virtualDeviceTypesList = [];
|
||||||
for (var i = 0; i < deviceTypes.length; i++) {
|
for (var i = 0; i < deviceTypes.length; i++) {
|
||||||
|
var deviceType = deviceTypes[i];
|
||||||
var deviceTypeLabel = deviceTypes[i].name;
|
var deviceTypeLabel = deviceType;
|
||||||
var configs = utility.getDeviceTypeConfig(deviceTypeLabel);
|
var configs = utility.getDeviceTypeConfig(deviceTypeLabel);
|
||||||
var deviceCategory = "device";
|
var deviceCategory = "device";
|
||||||
if (configs) {
|
if (configs) {
|
||||||
@ -47,19 +47,17 @@ function onRequest(context) {
|
|||||||
virtualDeviceTypesList.push({
|
virtualDeviceTypesList.push({
|
||||||
"hasCustTemplate": false,
|
"hasCustTemplate": false,
|
||||||
"deviceTypeLabel": deviceTypeLabel,
|
"deviceTypeLabel": deviceTypeLabel,
|
||||||
"deviceTypeName": deviceTypes[i].name,
|
"deviceTypeName": deviceType,
|
||||||
"deviceCategory": deviceCategory,
|
"deviceCategory": deviceCategory,
|
||||||
"deviceTypeId": deviceTypes[i].id,
|
"thumb": utility.getDeviceThumb(deviceType)
|
||||||
"thumb": utility.getDeviceThumb(deviceTypes[i].name)
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
deviceTypesList.push({
|
deviceTypesList.push({
|
||||||
"hasCustTemplate": false,
|
"hasCustTemplate": false,
|
||||||
"deviceTypeLabel": deviceTypeLabel,
|
"deviceTypeLabel": deviceTypeLabel,
|
||||||
"deviceTypeName": deviceTypes[i].name,
|
"deviceTypeName": deviceType,
|
||||||
"deviceCategory": deviceCategory,
|
"deviceCategory": deviceCategory,
|
||||||
"deviceTypeId": deviceTypes[i].id,
|
"thumb": utility.getDeviceThumb(deviceType)
|
||||||
"thumb": utility.getDeviceThumb(deviceTypes[i].name)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user