mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request #688 from amalhub/master
Cherry-pick from Cloud 3.1.0
This commit is contained in:
commit
b766925fc5
@ -46,7 +46,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
||||
private static final int MAX_API_PER_TAG = 200;
|
||||
private static final String APP_TIER_TYPE = "application";
|
||||
private static final Map<String, String> tiersMap = new HashMap<>();
|
||||
private static final int MAX_ATTEMPTS = 10;
|
||||
private static final int MAX_ATTEMPTS = 20;
|
||||
|
||||
@Override
|
||||
public void removeAPIApplication(String applicationName, String username) throws APIManagerException {
|
||||
@ -76,18 +76,18 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
||||
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext()
|
||||
.getTenantDomain();
|
||||
String tiersLoadedForTenant = tiersMap.get(tenantDomain);
|
||||
|
||||
if (tiersLoadedForTenant == null) {
|
||||
int tierStatus = 0;
|
||||
boolean tierLoaded = false;
|
||||
int attempts = 0;
|
||||
do {
|
||||
try {
|
||||
storeClient.getIndividualTier()
|
||||
.tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, APP_TIER_TYPE,
|
||||
tenantDomain, CONTENT_TYPE, null, null);
|
||||
tenantDomain, CONTENT_TYPE, null, null);
|
||||
tiersMap.put(tenantDomain, "exist");
|
||||
tierStatus = 200;
|
||||
tierLoaded = true;
|
||||
} catch (FeignException e) {
|
||||
tierStatus = e.status();
|
||||
attempts++;
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
@ -95,7 +95,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
|
||||
log.warn("Interrupted the waiting for tier availability.");
|
||||
}
|
||||
}
|
||||
} while (tierStatus == 500 && attempts < MAX_ATTEMPTS);
|
||||
} while ((!tierLoaded) && attempts < MAX_ATTEMPTS);
|
||||
}
|
||||
|
||||
ApplicationList applicationList = storeClient.getApplications()
|
||||
|
||||
@ -65,8 +65,7 @@ public class DeviceTypeManagerService implements DeviceManagementService {
|
||||
this.operationMonitoringConfigs = new OperationMonitoringTaskConfig();
|
||||
this.setOperationMonitoringConfig(deviceTypeConfiguration);
|
||||
this.setInitialOperationConfig(deviceTypeConfiguration);
|
||||
if (deviceTypeConfiguration.getPolicyMonitoring() != null && deviceTypeConfiguration.getPolicyMonitoring()
|
||||
.isEnabled()) {
|
||||
if (deviceTypeConfiguration.getPolicyMonitoring() != null ) {
|
||||
this.policyMonitoringManager = new DefaultPolicyMonitoringManager();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"Logo": {
|
||||
"name": "Cloud",
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt",
|
||||
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt",
|
||||
"target": "_parent"
|
||||
},
|
||||
"Main": {
|
||||
@ -12,75 +12,21 @@
|
||||
"target": "_parent",
|
||||
"dropDown": {
|
||||
"Organization": {
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/organization.jag",
|
||||
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/organization.jag",
|
||||
"icon": "fw fw-organization",
|
||||
"dropDown": "false",
|
||||
"target": "_self"
|
||||
},
|
||||
"Members": {
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/user.jag",
|
||||
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/user.jag",
|
||||
"icon": "fa fa-users",
|
||||
"dropDown": "false",
|
||||
"target": "_self"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Account": {
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/account-summary.jag",
|
||||
"icon": "fw fw-resource",
|
||||
"isAdminOnly": true,
|
||||
"target": "_blank",
|
||||
"dropDown": {
|
||||
"Upgrade Now": {
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/payment-plans.jag?cloud-type=api_cloud",
|
||||
"icon": "fw fw-export",
|
||||
"target": "_self"
|
||||
},
|
||||
"Monetization": {
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/monetization-dashboard.jag",
|
||||
"icon": "fa fa-money fa-lg",
|
||||
"dropDown": "false",
|
||||
"target": "_self"
|
||||
},
|
||||
"Request Extension": {
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/contact-us.jag?cloud-type=api_cloud&request-extension=true",
|
||||
"icon": "fw fw-mail",
|
||||
"target": "_blank"
|
||||
},
|
||||
"Usage data": {
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/tenant-usage.jag?cloud-type=api_cloud",
|
||||
"icon": "fw fw-bar-chart",
|
||||
"target": "_self"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Configure": {
|
||||
"url": "none",
|
||||
"icon": "fw fw-settings",
|
||||
"isAdminOnly": true,
|
||||
"dropDown": {
|
||||
"Admin Dashboard": {
|
||||
"id": "admin-dashboard",
|
||||
"url": "https://<%= @apimpublisher_host %>/admin-dashboard/",
|
||||
"icon": "fw fw-user",
|
||||
"target": "_self"
|
||||
},
|
||||
"Custom URL": {
|
||||
"id": "custom-url",
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/custom_url.jag",
|
||||
"icon": "fw fw-uri",
|
||||
"target": "_self"
|
||||
},
|
||||
"API Store Access": {
|
||||
"id": "custom-url",
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/selfSignup.jag",
|
||||
"icon": "fw fw-store",
|
||||
"target": "_self"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Support": {
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/contact-us.jag",
|
||||
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/contact-us.jag",
|
||||
"icon": "fw fw-mail",
|
||||
"isAdminOnly": false,
|
||||
"target": "_self",
|
||||
@ -91,29 +37,11 @@
|
||||
"icon": "fw fw-document",
|
||||
"isAdminOnly": false,
|
||||
"dropDown": {
|
||||
"API Cloud": {
|
||||
"id": "api_cloud",
|
||||
"url": "https://docs.wso2.com/display/APICloud/WSO2+API+Cloud+Documentation",
|
||||
"icon": "fw fw-api",
|
||||
"target": "_blank"
|
||||
},
|
||||
"Integration Cloud": {
|
||||
"id": "integration_cloud",
|
||||
"url": "https://docs.wso2.com/display/IntegrationCloud/WSO2+Integration+Cloud+Documentation",
|
||||
"icon": "fw fw-application",
|
||||
"target": "_blank"
|
||||
},
|
||||
"Device Cloud": {
|
||||
"id": "device_cloud",
|
||||
"url": "https://docs.wso2.com/display/DeviceCloud/WSO2+Device+Cloud+Documentation",
|
||||
"icon": "fw fw-mobile",
|
||||
"target": "_self"
|
||||
},
|
||||
"API Cloud Walkthrough": {
|
||||
"id": "api_cloud_walkthrough",
|
||||
"url": "https://<%= @apimpublisher_host %>/publisher?interactiveTutorial=true",
|
||||
"icon": "fw fw-document",
|
||||
"target": "_self"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,19 +51,19 @@
|
||||
"icon": "fw fw-user",
|
||||
"dropDown": {
|
||||
"Profile": {
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/user-profile.jag",
|
||||
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/user-profile.jag",
|
||||
"icon": "fw fw-user",
|
||||
"dropDown": "true",
|
||||
"target": "_self"
|
||||
},
|
||||
"Change Password": {
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/change-password.jag",
|
||||
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/change-password.jag",
|
||||
"icon": "fw fw-lock",
|
||||
"dropDown": "true",
|
||||
"target": "_self"
|
||||
},
|
||||
"Logout": {
|
||||
"url": "https://<%= @apimpublisher_host %>/publisher/site/pages/logout.jag",
|
||||
"url": "https://api.cloud.wso2.com/publisher/site/pages/logout.jag",
|
||||
"icon": "fw fw-sign-out",
|
||||
"dropDown": "true",
|
||||
"target": "_self"
|
||||
@ -146,50 +74,36 @@
|
||||
"Clouds": {
|
||||
"API Cloud": {
|
||||
"id": "api_cloud",
|
||||
"url": "https://<%= @apimpublisher_host %>/publisher",
|
||||
"url": "https://api.cloud.wso2.com/publisher",
|
||||
"icon": "fw fw-api fw-3x",
|
||||
"dropDown": "true",
|
||||
"target": "_self"
|
||||
},
|
||||
"Integration Cloud": {
|
||||
"id": "integration_cloud",
|
||||
"url": "https://milestones.appfactory.wso2.com:9443/appmgt",
|
||||
"icon": "fa fa-cubes fw-3x",
|
||||
"url": "https://integration.cloud.wso2.com/appmgt",
|
||||
"icon": "fw fw-service fw-3x",
|
||||
"dropDown": "true",
|
||||
"target": "_self"
|
||||
},
|
||||
"Identity Cloud": {
|
||||
"id": "integration_cloud",
|
||||
"url": "https://identity.cloudlocal.wso2.com:9443/admin",
|
||||
"url": "https://identity.cloud.wso2.com/admin",
|
||||
"icon": "fw fw-security fw-3x",
|
||||
"dropDown": "true",
|
||||
"target": "_self"
|
||||
},
|
||||
"App Cloud": {
|
||||
"id": "app_cloud",
|
||||
"url": "https://<%= @appcloud_host %>/appmgt",
|
||||
"icon": "fw fw-application fw-3x",
|
||||
"dropDown": "true",
|
||||
"target": "_self"
|
||||
},
|
||||
"Device Cloud": {
|
||||
"id": "device_cloud",
|
||||
"url": "https://<%= @mgt_hostname %>/devicemgt",
|
||||
"icon": "fw fw-mobile fw-3x",
|
||||
"dropDown": "true",
|
||||
"target": "_self"
|
||||
}
|
||||
},
|
||||
"Actions": {
|
||||
"Organization": {
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/organization.jag",
|
||||
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/organization.jag",
|
||||
"icon": "fw fw-organization fw-3x",
|
||||
"dropDown": "true",
|
||||
"target": "_self"
|
||||
},
|
||||
"Members": {
|
||||
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/user.jag",
|
||||
"icon": "fa fa-users fw-3x",
|
||||
"url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/user.jag",
|
||||
"icon": "fa fa-users fa-3x",
|
||||
"dropDown": "true",
|
||||
"target": "_self"
|
||||
}
|
||||
|
||||
@ -40,52 +40,66 @@ var operationModule = function () {
|
||||
privateMethods.getOperationsFromFeatures = function (deviceType, operationType) {
|
||||
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/device-types/" + deviceType + "/features";
|
||||
var featuresList = serviceInvokers.XMLHttp.get(url, function (responsePayload) {
|
||||
var features = JSON.parse(responsePayload.responseText);
|
||||
var featureList = [];
|
||||
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;
|
||||
feature["contentType"] = features[i].contentType;
|
||||
feature["deviceType"] = deviceType;
|
||||
feature["params"] = [];
|
||||
var featuresEntry = utility.getDeviceTypeConfig(deviceType)["deviceType"]["features"];
|
||||
if (featuresEntry) {
|
||||
var featureEntry = featuresEntry[features[i].code];
|
||||
if (featureEntry) {
|
||||
var permissionEntry = featureEntry["permission"];
|
||||
if (permissionEntry) {
|
||||
feature["permission"] = permissionEntry
|
||||
}
|
||||
}
|
||||
}
|
||||
var metaData = features[i].metadataEntries;
|
||||
if (metaData) {
|
||||
for (var j = 0; j < metaData.length; j++) {
|
||||
feature["params"].push(metaData[j].value);
|
||||
}
|
||||
featureList.push(feature);
|
||||
}
|
||||
}
|
||||
return featureList;
|
||||
}, function (responsePayload) {
|
||||
var response = {};
|
||||
response["status"] = "error";
|
||||
return response;
|
||||
}
|
||||
var features = JSON.parse(responsePayload.responseText);
|
||||
var featureList = [];
|
||||
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;
|
||||
feature["contentType"] = features[i].contentType;
|
||||
feature["deviceType"] = deviceType;
|
||||
feature["params"] = [];
|
||||
var featuresEntry = utility.getDeviceTypeConfig(deviceType)["deviceType"]["features"];
|
||||
if (featuresEntry) {
|
||||
var featureEntry = featuresEntry[features[i].code];
|
||||
if (featureEntry) {
|
||||
var permissionEntry = featureEntry["permission"];
|
||||
if (permissionEntry) {
|
||||
feature["permission"] = permissionEntry
|
||||
}
|
||||
}
|
||||
}
|
||||
var metaData = features[i].metadataEntries;
|
||||
if (metaData) {
|
||||
for (var j = 0; j < metaData.length; j++) {
|
||||
feature["params"].push(metaData[j].value);
|
||||
}
|
||||
featureList.push(feature);
|
||||
}
|
||||
}
|
||||
return featureList;
|
||||
}, function (responsePayload) {
|
||||
var response = {};
|
||||
response["status"] = "error";
|
||||
return response;
|
||||
}
|
||||
);
|
||||
return featuresList;
|
||||
};
|
||||
|
||||
publicMethods.getControlOperations = function (deviceType) {
|
||||
var operations = privateMethods.getOperationsFromFeatures(deviceType, "operation");
|
||||
var features = utility.getDeviceTypeConfig(deviceType).deviceType.features;
|
||||
for (var op in operations) {
|
||||
var iconIdentifier = operations[op].operation;
|
||||
var icon = utility.getOperationIcon(deviceType, iconIdentifier);
|
||||
if (icon) {
|
||||
operations[op]["icon"] = icon;
|
||||
if (features && features[iconIdentifier]) {
|
||||
var icon = features[iconIdentifier].icon;
|
||||
if (icon) {
|
||||
operations[op]["iconFont"] = icon;
|
||||
} else if (iconPath) {
|
||||
var iconPath = utility.getOperationIcon(deviceType, iconIdentifier);
|
||||
operations[op]["icon"] = iconPath;
|
||||
}
|
||||
var formParams = features[iconIdentifier].formParams;
|
||||
if (formParams) {
|
||||
operations[op]["uiParams"] = formParams;
|
||||
}
|
||||
// var icon = utility.getOperationIcon(deviceType, iconIdentifier);
|
||||
// if (icon) {
|
||||
// log.error("icon found : " + icon );
|
||||
// operations[op]["icon"] = icon;
|
||||
}
|
||||
}
|
||||
return operations;
|
||||
@ -99,9 +113,9 @@ var operationModule = function () {
|
||||
var user = session.get(constants.USER_SESSION_KEY);
|
||||
var endPoint = devicemgtProps["httpsURL"] + '/' + deviceType + "/controller/" + operation;
|
||||
var header = '{"owner":"' + user.username + '","deviceId":"' + deviceId +
|
||||
'","protocol":"mqtt", "sessionId":"' + session.getId() + '", "' +
|
||||
constants.AUTHORIZATION_HEADER + '":"' + constants.BEARER_PREFIX +
|
||||
getAccessToken(deviceType, user.username, deviceId) + '"}';
|
||||
'","protocol":"mqtt", "sessionId":"' + session.getId() + '", "' +
|
||||
constants.AUTHORIZATION_HEADER + '":"' + constants.BEARER_PREFIX +
|
||||
getAccessToken(deviceType, user.username, deviceId) + '"}';
|
||||
return post(endPoint, params, JSON.parse(header), "json");
|
||||
};
|
||||
|
||||
@ -109,9 +123,9 @@ var operationModule = function () {
|
||||
var user = session.get(constants.USER_SESSION_KEY);
|
||||
var endPoint = devicemgtProps["httpsURL"] + '/' + deviceType + "/controller/" + operation;
|
||||
var header = '{"owner":"' + user.username + '","deviceId":"' + deviceId +
|
||||
'","protocol":"mqtt", "' + constants.AUTHORIZATION_HEADER + '":"' +
|
||||
constants.BEARER_PREFIX + getAccessToken(deviceType, user.username, deviceId) +
|
||||
'"}';
|
||||
'","protocol":"mqtt", "' + constants.AUTHORIZATION_HEADER + '":"' +
|
||||
constants.BEARER_PREFIX + getAccessToken(deviceType, user.username, deviceId) +
|
||||
'"}';
|
||||
var result = get(endPoint, {}, JSON.parse(header), "json");
|
||||
if (result.data) {
|
||||
var values = result.data.sensorValue.split(',');
|
||||
|
||||
@ -288,6 +288,9 @@ function loadDevices(searchType, searchParam) {
|
||||
case 'REMOVED' :
|
||||
html = '<span><i class="fw fw-delete icon-danger"></i> Removed</span>';
|
||||
break;
|
||||
case 'UNREACHABLE' :
|
||||
html = '<span><i class="fw fw-warning icon-warning"></i> Unreachable</span>';
|
||||
break;
|
||||
}
|
||||
return html;
|
||||
}
|
||||
@ -461,11 +464,11 @@ function loadDevices(searchType, searchParam) {
|
||||
attachDeviceEvents();
|
||||
|
||||
|
||||
if ($('.advance-search').length < 1) {
|
||||
$(this).closest('.dataTables_wrapper').find('div[id$=_filter] input')
|
||||
.after('<a href="' + context + '/devices/search"' +
|
||||
' class="advance-search add-padding-3x">Advance Search</a>');
|
||||
}
|
||||
// if ($('.advance-search').length < 1) {
|
||||
// $(this).closest('.dataTables_wrapper').find('div[id$=_filter] input')
|
||||
// .after('<a href="' + context + '/devices/search"' +
|
||||
// ' class="advance-search add-padding-3x">Advance Search</a>');
|
||||
// }
|
||||
|
||||
}, {
|
||||
"placeholder": "Search By Device Name",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{{#zone "content"}}
|
||||
{{#if isAuthorized}}
|
||||
<span id="logged-in-user" class="hidden" data-username="{{user.username}}" data-domain="{{user.domain}}"
|
||||
data-tenant-id="{{user.tenantId}}"></span>
|
||||
data-tenant-id="{{user.tenantId}}" data-iscloud="{{isCloud}}"></span>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
|
||||
@ -284,8 +284,8 @@
|
||||
<i class="icon fw fw-error"></i><span></span>
|
||||
</div>
|
||||
{{#unless types}}
|
||||
<h3><i class="icon fw fw-warning"></i> No compatible device types have been installed.
|
||||
Install device types to add policies.</h3>
|
||||
<h3><i class="icon fw fw-warning"></i> No compatible device types have been installed.
|
||||
Install device types to add policies.</h3>
|
||||
{{/unless}}
|
||||
<div class="row wr-tile-buttons-list">
|
||||
<div class="wr-input-control">
|
||||
|
||||
@ -50,17 +50,17 @@ function onRequest(context) {
|
||||
var policyOperationsTemplateSrc = policyWizardSrc + "/public/templates/" + deviceType + "-policy-operations.hbs";
|
||||
if (new File(policyOperationsTemplateSrc).isExists()) {
|
||||
content["template"] = "/public/cdmf.unit.device.type." + deviceType +
|
||||
".policy-wizard/templates/" + deviceType + "-policy-operations.hbs";
|
||||
".policy-wizard/templates/" + deviceType + "-policy-operations.hbs";
|
||||
}
|
||||
var policyOperationsScriptSrc = policyWizardSrc + "/public/js/" + deviceType + "-policy-operations.js";
|
||||
if (new File(policyOperationsScriptSrc).isExists()) {
|
||||
content["script"] = "/public/cdmf.unit.device.type." + deviceType +
|
||||
".policy-wizard/js/" + deviceType + "-policy-operations.js";;
|
||||
".policy-wizard/js/" + deviceType + "-policy-operations.js";;
|
||||
}
|
||||
var policyOperationsStylesSrc = policyWizardSrc + "/public/css/" + deviceType + "-policy-operations.css";
|
||||
if (new File(policyOperationsStylesSrc).isExists()) {
|
||||
content["style"] = "/public/cdmf.unit.device.type." + deviceType +
|
||||
".policy-wizard/css/" + deviceType + "-policy-operations.css";;
|
||||
".policy-wizard/css/" + deviceType + "-policy-operations.css";;
|
||||
}
|
||||
types["types"].push(content);
|
||||
}
|
||||
@ -74,6 +74,8 @@ function onRequest(context) {
|
||||
types["roles"] = roles["content"];
|
||||
}
|
||||
types["groups"] = groupModule.getGroups();
|
||||
|
||||
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
|
||||
types["isCloud"] = devicemgtProps.isCloud;
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ stepForwardFrom["policy-platform"] = function (actionButton) {
|
||||
|
||||
if (policyOperationsTemplateSrc) {
|
||||
$.template(policyOperationsTemplateCacheKey, context + policyOperationsTemplateSrc, function (template) {
|
||||
var content = template();
|
||||
var content = template({"iscloud" : $("#logged-in-user").data("iscloud")});
|
||||
$("#device-type-policy-operations").html(content).removeClass("hidden");
|
||||
$(".policy-platform").addClass("hidden");
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user