Merge pull request #331 from ayyoob/com

Added platform configuration and certificate configuration UI
revert-70aa11f8
Ruwan 8 years ago committed by GitHub
commit 6a580994fb

@ -16,7 +16,7 @@
* under the License.
*
*/
package org.wso2.carbon.device.mgt.jaxrs.service.api.admin;
package org.wso2.carbon.device.mgt.jaxrs.service.api;
import io.swagger.annotations.*;
import org.wso2.carbon.apimgt.annotations.api.API;
@ -30,7 +30,7 @@ import javax.ws.rs.core.Response;
@API(name = "Device Type Management", version = "1.0.0", context = "/api/device-mgt/v1.0/admin/device-types", tags = {"devicemgt_admin"})
@Path("/admin/device-types")
@Path("/device-types")
@Api(value = "Device Type Management", description = "This API corresponds to all tasks related to device " +
"type management")
@Produces(MediaType.APPLICATION_JSON)

@ -16,14 +16,14 @@
* under the License.
*
*/
package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin;
package org.wso2.carbon.device.mgt.jaxrs.service.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.jaxrs.beans.DeviceTypeList;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.DeviceTypeManagementService;
import org.wso2.carbon.device.mgt.jaxrs.service.api.DeviceTypeManagementService;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
import javax.ws.rs.GET;
@ -32,7 +32,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import java.util.List;
@Path("/admin/device-types")
@Path("/device-types")
public class DeviceTypeManagementServiceImpl implements DeviceTypeManagementService {
private static Log log = LogFactory.getLog(DeviceTypeManagementServiceImpl.class);

@ -79,7 +79,7 @@
<bean id="groupManagementAdminService" class="org.wso2.carbon.device.mgt.jaxrs.service.impl.admin.GroupManagementAdminServiceImpl"/>
<bean id="userManagementAdminService" class="org.wso2.carbon.device.mgt.jaxrs.service.impl.admin.UserManagementAdminServiceImpl"/>
<bean id="dashboardServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.service.impl.DashboardImpl"/>
<bean id="deviceTypeManagementAdminService" class="org.wso2.carbon.device.mgt.jaxrs.service.impl.admin.DeviceTypeManagementServiceImpl"/>
<bean id="deviceTypeManagementAdminService" class="org.wso2.carbon.device.mgt.jaxrs.service.impl.DeviceTypeManagementServiceImpl"/>
<bean id="jsonProvider" class="org.wso2.carbon.device.mgt.jaxrs.common.GsonMessageBodyHandler"/>
<!--<bean id="errorHandler" class="org.wso2.carbon.device.mgt.jaxrs.common.ErrorHandler"/>-->

@ -40,6 +40,32 @@ deviceModule = function () {
// var deviceCloudService = devicemgtProps["httpsURL"] + "/common/device_manager";
/**
* Only GET method is implemented for now since there are no other type of methods used this method.
* @param url - URL to call the backend without the host
* @param method - HTTP Method (GET, POST)
* @returns An object with 'status': 'success'|'error', 'content': {}
*/
privateMethods.callBackend = function (url, method) {
if (constants["HTTP_GET"] == method) {
return serviceInvokers.XMLHttp.get(url,
function (backendResponse) {
var response = {};
response.content = backendResponse.responseText;
if (backendResponse.status == 200) {
response.status = "success";
} else if (backendResponse.status == 400 || backendResponse.status == 401 ||
backendResponse.status == 404 || backendResponse.status == 500) {
response.status = "error";
}
return response;
}
);
} else {
log.error("Runtime error : This method only support HTTP GET requests.");
}
};
privateMethods.validateAndReturn = function (value) {
return (value == undefined || value == null) ? constants.UNSPECIFIED : value;
};
@ -292,16 +318,12 @@ deviceModule = function () {
};
publicMethods.getDeviceTypes = function () {
var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/types";
return serviceInvokers.XMLHttp.get(
url, function (responsePayload) {
return responsePayload;
},
function (responsePayload) {
log.error(responsePayload);
return -1;
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/device-types";
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
if (response.status == "success") {
response.content = parse(response.content);
}
);
return response;
};
//Old methods
@ -309,24 +331,24 @@ deviceModule = function () {
/*
@Updated
*/
publicMethods.getLicense = function (deviceType) {
var url;
var license;
if (deviceType == "windows") {
url = mdmProps["httpURL"] + "/mdm-windows-agent/services/device/license";
} else if (deviceType == "ios") {
url = mdmProps["httpsURL"] + "/ios-enrollment/license/";
}
// publicMethods.getLicense = function (deviceType) {
// var url;
// var license;
// if (deviceType == "windows") {
// url = mdmProps["httpURL"] + "/mdm-windows-agent/services/device/license";
// } else if (deviceType == "ios") {
// url = mdmProps["httpsURL"] + "/ios-enrollment/license/";
// }
if (url != null && url != undefined) {
serviceInvokers.XMLHttp.get(url, function (responsePayload) {
license = responsePayload.text;
}, function (responsePayload) {
return null;
});
}
return license;
};
// if (url != null && url != undefined) {
// serviceInvokers.XMLHttp.get(url, function (responsePayload) {
// license = responsePayload.text;
// }, function (responsePayload) {
// return null;
// });
// }
// return license;
// };
publicMethods.getDevices = function (userName) {
var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + userName;

@ -268,6 +268,7 @@ var userModule = function () {
/**
* Get Platforms.
* @deprecated moved this device module under getDeviceTypes.
*/
//TODO Move this piece of logic out of user.js to somewhere else appropriate.
publicMethods.getPlatforms = function () {
@ -279,7 +280,7 @@ var userModule = function () {
}
try {
utility.startTenantFlow(carbonUser);
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/admin/device-types";
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/device-types";
var response = privateMethods.callBackend(url, constants["HTTP_GET"]);
if (response.status == "success") {
response.content = parse(response.content);

@ -18,7 +18,7 @@
var WEB_APP_TITLE = "WSO2 CDM";
var WEB_APP_CONTEXT = "/devicemgt";
var ADMIN_SERVICE_CONTEXT = "/devicemgt_admin";
var ADMIN_SERVICE_CONTEXT = "/api/device-mgt/v1.0";
var USER_SESSION_KEY = "_UUF_USER";
var UNSPECIFIED = "Unspecified";
var httpURL = "httpURL";

@ -0,0 +1,101 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{unit "cdmf.unit.ui.title" pageTitle="Add Certificate"}}
{{#zone "breadcrumbs"}}
<li>
<a href="{{@app.context}}/">
<i class="icon fw fw-home"></i>
</a>
</li>
<li>
<a href="{{@app.context}}/certificates/add">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-document fw-stack-1x"></i>
</span>
Add Certificate
</a>
</li>
{{/zone}}
{{#zone "content"}}
<!-- content/body -->
<div class="row">
<div class="col-md-12">
<!-- content -->
<div id="certificate-create-form" class="container col-centered wr-content">
<div class="wr-form">
<p class="page-sub-title">Add Certificate</p>
<p>Please note that * sign represents required fields of data.</p>
<hr/>
<div class="row">
<div class="col-lg-8">
<div id="certificate-create-error-msg" class="alert alert-danger hidden" role="alert">
<i class="icon fw fw-error"></i><span></span>
</div>
<label class="wr-input-label ">
Serial Number *
</label>
<br>
<div id="serialNoInputField" class="form-group wr-input-control">
<input type="text" id="serialNo" class="form-control"/>
</div>
<label class="wr-input-label">Certificate *</label>
<div id="certificateField" class="form-group wr-input-control">
<input type="file" id="certificate" class="form-control"/>
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-lg-8">
<button id="add-certificate-btn" class="wr-btn">Add Certificate</button>
</div>
</div>
</div>
</div>
<div id="certificate-created-msg" class="container col-centered wr-content hidden">
<div class="wr-form">
<p class="page-sub-title">Certificate was added successfully.</p>
<br>
<br>Please click <b>"Add Another Certificate"</b>, if you wish to add another certificate or
click
<b>"View Certificate List"</b> to complete the process and go back to the certificate list.
<hr/>
<button class="wr-btn" onclick="window.location.href='/emm/certificates'">View Certificate List
</button>
<a href="/emm/certificates/add" class="cu-btn-inner">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Add Another Certificate
</a>
</div>
</div>
<!-- /content -->
</div>
</div>
<!-- /content/body -->
{{/zone}}
{{#zone "bottomJs"}}
{{js "/js/certificate-create.js"}}
{{/zone}}

@ -0,0 +1,45 @@
/*
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
/**
* Returns the dynamic state to be populated by add-user page.
*
* @param context Object that gets updated with the dynamic state of this page to be presented
* @returns {*} A context object that returns the dynamic state of this page to be presented
*/
function onRequest(context) {
// var log = new Log("units/user-create/create.js");
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var response = userModule.getRolesByUserStore();
if (response["status"] == "success") {
context["roles"] = response["content"];
}
context["charLimit"] = mdmProps["usernameLength"];
context["usernameJSRegEx"] = mdmProps["userValidationConfig"]["usernameJSRegEx"];
context["usernameHelpText"] = mdmProps["userValidationConfig"]["usernameHelpMsg"];
context["usernameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["usernameRegExViolationErrorMsg"];
context["firstnameJSRegEx"] = mdmProps["userValidationConfig"]["firstnameJSRegEx"];
context["firstnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["firstnameRegExViolationErrorMsg"];
context["lastnameJSRegEx"] = mdmProps["userValidationConfig"]["lastnameJSRegEx"];
context["lastnameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["lastnameRegExViolationErrorMsg"];
return context;
}

@ -0,0 +1,129 @@
/*
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
var pemContent = "";
var errorMsgWrapper = "#certificate-create-error-msg";
var errorMsg = "#certificate-create-error-msg span";
var validateInline = {};
var clearInline = {};
var base_api_url = "/api/certificate-mgt/v1.0";
var enableInlineError = function (inputField, errorMsg, errorSign) {
var fieldIdentifier = "#" + inputField;
var errorMsgIdentifier = "#" + inputField + " ." + errorMsg;
var errorSignIdentifier = "#" + inputField + " ." + errorSign;
if (inputField) {
$(fieldIdentifier).addClass(" has-error has-feedback");
}
if (errorMsg) {
$(errorMsgIdentifier).removeClass(" hidden");
}
if (errorSign) {
$(errorSignIdentifier).removeClass(" hidden");
}
};
var disableInlineError = function (inputField, errorMsg, errorSign) {
var fieldIdentifier = "#" + inputField;
var errorMsgIdentifier = "#" + inputField + " ." + errorMsg;
var errorSignIdentifier = "#" + inputField + " ." + errorSign;
if (inputField) {
$(fieldIdentifier).removeClass(" has-error has-feedback");
}
if (errorMsg) {
$(errorMsgIdentifier).addClass(" hidden");
}
if (errorSign) {
$(errorSignIdentifier).addClass(" hidden");
}
};
function readSingleFile(evt) {
var f = evt.target.files[0];
if (f) {
var r = new FileReader();
r.onload = function (e) {
var contents = e.target.result;
if (f.type == "application/x-x509-ca-cert") {
pemContent = contents;
console.log(contents);
console.log(pemContent);
pemContent = pemContent.substring(28, pemContent.length - 27);
console.log(pemContent);
$(errorMsgWrapper).addClass("hidden");
} else {
$(errorMsg).text("Certificate must be a .pem file containing a valid certificate data.");
$(errorMsgWrapper).removeClass("hidden");
}
}
r.readAsText(f);
} else {
//inline error
}
}
$(document).ready(function () {
pemContent = "";
document.getElementById('certificate').addEventListener('change', readSingleFile, false);
/**
* Following click function would execute
* when a user clicks on "Add Certificate" button.
*/
$("button#add-certificate-btn").click(function () {
var serialNoInput = $("input#serialNo");
var serialNo = serialNoInput.val();
if (!serialNo) {
$(errorMsg).text("Serial Number is a required field. It cannot be empty.");
$(errorMsgWrapper).removeClass("hidden");
} else if (!pemContent) {
$(errorMsg).text(" .pem file must contains certificate information.");
$(errorMsgWrapper).removeClass("hidden");
} else {
var addCertificateFormData = {};
addCertificateFormData.serial = serialNo;
addCertificateFormData.pem = pemContent;
var certificateList = [];
certificateList.push(addCertificateFormData);
var serviceUrl = base_api_url + "/admin/certificates";
invokerUtil.post(
serviceUrl,
certificateList,
function (data) {
// Refreshing with success message
$("#certificate-create-form").addClass("hidden");
$("#certificate-created-msg").removeClass("hidden");
}, function (data) {
if (data["status"] == 500) {
$(errorMsg).text("An unexpected error occurred at backend server. Please try again later.");
} else {
$(errorMsg).text(data);
}
$(errorMsgWrapper).removeClass("hidden");
}
);
}
});
});

@ -0,0 +1,177 @@
{{!
Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
}}
{{unit "cdmf.unit.ui.title" pageTitle="Add Certificate"}}
{{#zone "breadcrumbs"}}
<li>
<a href="{{@app.context}}/">
<i class="icon fw fw-home"></i>
</a>
</li>
<li>
<a href="{{@app.context}}/certificates/add">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-document fw-stack-1x"></i>
</span>
Add Certificate
</a>
</li>
{{/zone}}
{{#zone "content"}}
{{unit "cdmf.unit.data-tables-extended"}}
<!-- content -->
<div id="loading-content" class="col-centered">
{{#if removePermitted}}
<input type="hidden" id="can-remove" value="true"/>
{{/if}}
{{#if viewPermitted}}
<input type="hidden" id="can-view" value="true"/>
{{/if}}
<i class="fw fw-settings fw-spin fw-2x"></i>
Loading Certificates . . .
<br>
</div>
<div id="certificate-listing-status" class="raw hidden">
<ul style="list-style-type: none;">
<li class="message message-info" >
<h4>
<i class="icon fw fw-info"></i>
<a id="certificate-listing-status-msg"></a>
</h4>
</li>
</ul>
</div>
<div id="certificate-table" data-user={{adminUser}}>
<table class="table table-striped table-hover list-table display responsive nowrap data-table grid-view"
id="certificate-grid">
<thead>
<tr class="sort-row">
<th class="no-sort"></th>
<th>By Serial Number</th>
<th class="no-sort"></th>
<th class="no-sort"></th>
</tr>
<tr class="filter-row filter-box">
<th colspan="3">
<label class="wr-input-label" for="search-by-certificate">
By Serial Number
</label>
<input id="search-by-certificate" type="text" class="form-control"
placeholder="Search By Serial Number">
</th>
<th style="vertical-align:bottom;">
<button id="search-btn" class="wr-btn">
Search
</button>
</th>
</tr>
</thead>
<tbody id="ast-container">
<br class="c-both"/>
</tbody>
</table>
</div>
<br class="c-both"/>
<div id="content-filter-types" style="display: none">
<div class="sort-title">Sort By</div>
<div class="sort-options">
<a href="#">By Serial Number</a>
</div>
</div>
<div id="remove-certificate-modal-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Do you really want to remove this certificate ?</h3>
<div class="buttons">
<a href="#" id="remove-certificate-yes-link" class="btn-operations">
Remove
</a>
<a href="#" id="remove-certificate-cancel-link" class="btn-operations">
Cancel
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-certificate-success-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>Done. Certificate was successfully removed.</h3>
<div class="buttons">
<a href="#" id="remove-certificate-success-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="remove-certificate-error-content" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>An unexpected error occurred. Please try again later.</h3>
<div class="buttons">
<a href="#" id="remove-certificate-error-link" class="btn-operations">
Ok
</a>
</div>
</div>
</div>
</div>
</div>
<div id="errorCertificateView" class="hide">
<div class="content">
<div class="row">
<div class="col-lg-5 col-md-6 col-centered">
<h3>
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-error fw-stack-1x"></i>
</span>
Unauthorized action!
</h3>
</div>
</div>
</div>
</div>
{{/zone}}
{{#zone "bottomJs"}}
<script id="certificate-listing" data-current-user="{{@user.username}}"
src="{{@page.publicUri}}/templates/certificate-listing.hbs"
type="text/x-handlebars-template"></script>
{{js "/js/certificate-listing.js"}}
{{/zone}}

@ -0,0 +1,15 @@
function onRequest(context) {
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
context["permissions"] = userModule.getUIPermissions();
if (userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/certificate/Get")) {
context["removePermitted"] = true;
}
if (userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/certificate/Get")) {
context["viewPermitted"] = true;
}
context["adminUser"] = mdmProps.adminUser;
return context;
}

@ -0,0 +1,171 @@
/*
* Sorting function of certificates
* listed on Certificate Management page in WSO2 MDM Console.
*/
$(function () {
var sortableElem = '.wr-sortable';
$(sortableElem).sortable({
beforeStop: function () {
var sortedIDs = $(this).sortable('toArray');
}
});
$(sortableElem).disableSelection();
});
var modalPopup = ".wr-modalpopup";
var modalPopupContainer = modalPopup + " .modalpopup-container";
var modalPopupContent = modalPopup + " .modalpopup-content";
var body = "body";
var isInit = true;
var base_api_url = "/api/certificate-mgt/v1.0";
$(".icon .text").res_text(0.2);
/*
* set popup maximum height function.
*/
function setPopupMaxHeight() {
$(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30)));
$(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2)));
}
/*
* show popup function.
*/
function showPopup() {
$(modalPopup).show();
setPopupMaxHeight();
}
/*
* hide popup function.
*/
function hidePopup() {
$(modalPopupContent).html('');
$(modalPopup).hide();
}
/**
* Following click function would execute
* when a user clicks on "Remove" link
* on Certificate Listing page in WSO2 MDM Console.
*/
function removeCertificate(serialNumber) {
var serviceUrl = base_api_url + "/admin/certificates/" + serialNumber;
$(modalPopupContent).html($('#remove-certificate-modal-content').html());
showPopup();
$("a#remove-certificate-yes-link").click(function () {
invokerUtil.delete(
serviceUrl,
function () {
$("#" + serialNumber).remove();
var newCertificateListCount = $(".user-list > span").length;
$("#certificate-listing-status-msg").text("Total number of Certificates found : " + newCertificateListCount);
$(modalPopupContent).html($('#remove-certificate-success-content').html());
$("a#remove-certificate-success-link").click(function () {
hidePopup();
});
},
function () {
$(modalPopupContent).html($('#remove-certificate-error-content').html());
$("a#remove-certificate-error-link").click(function () {
hidePopup();
});
}
);
});
$("a#remove-certificate-cancel-link").click(function () {
hidePopup();
});
}
/**
* Following on click function would execute
* when a user type on the search field on certificate Listing page in
* WSO2 MDM Console then click on the search button.
*/
$("#search-btn").click(function () {
var searchQuery = $("#search-by-certificate").val();
$("#ast-container").empty();
loadCertificates(searchQuery);
});
/**
* Following function would execute
* when a user clicks on the list item
* initial mode and with out select mode.
*/
function InitiateViewOption() {
if ($("#can-view").val()) {
$(location).attr('href', $(this).data("url"));
} else {
$(modalPopupContent).html($('#errorCertificateView').html());
showPopup();
}
}
function loadCertificates(searchParam) {
$("#loading-content").show();
var certificateListing = $("#certificate-listing");
var certificateListingSrc = certificateListing.attr("src");
$.template("certificate-listing", certificateListingSrc, function (template) {
var serviceURL = base_api_url + "/admin/certificates";
if (searchParam != null && searchParam != undefined && searchParam.trim() != '') {
serviceURL = base_api_url + "/admin/certificates?" + searchParam;
}
var successCallback = function (data, textStatus, jqXHR) {
if (jqXHR.status == 200 && data) {
data = JSON.parse(data);
var viewModel = {};
viewModel.certificates = data.certificates;
for (var i = 0; i < viewModel.certificates.length; i++) {
viewModel.certificates[i].removePermitted = true;
viewModel.certificates[i].viewPermitted = true;
}
if (viewModel.certificates.length > 0) {
$('#ast-container').removeClass('hidden');
$('#certificate-listing-status-msg').text("");
var content = template(viewModel);
$("#ast-container").html(content);
} else {
$('#ast-container').addClass('hidden');
$('#certificate-listing-status-msg').text('No certificate is available to be displayed.');
$('#certificate-listing-status').removeClass('hidden');
}
$("#loading-content").hide();
if (isInit) {
$('#certificate-grid').datatables_extended();
isInit = false;
}
$(".icon .text").res_text(0.2);
}
};
invokerUtil.get(serviceURL,
successCallback,
function (message) {
$('#ast-container').addClass('hidden');
$('#certificate-listing-status-msg').
text('Invalid search query. Try again with a valid search query');
}
);
});
}
$(document).ready(function () {
loadCertificates();
$(".viewEnabledIcon").click(function () {
InitiateViewOption();
});
});

@ -0,0 +1,30 @@
{{#each certificates}}
<tr data-type="selectable" id="{{serialNumber}}" data-username="{{serialNumber}}">
<td class="remove-padding icon-only content-fill viewEnabledIcon" data-username="{{serialNumber}}">
<div class="thumbnail icon">
<i class="square-element text fw fw-document"></i>
</div>
</td>
<td class="fade-edge remove-padding-top" data-search="{{serialNumber}}" data-display="{{serialNumber}}"><i
class="fw-mobile"></i> {{serialNumber}}</td>
<td class="fade-edge remove-padding-top" data-search="{{subject}}" data-display="{{subject}}"><i
class="fw-policy"></i> {{subject}}</td>
<td class="text-right content-fill text-left-on-grid-view no-wrap">
{{#unequal adminUser serialNumber }}
{{#if removePermitted}}
<a href="#" data-username="{{serialNumber}}" data-userid="{{userid}}"
data-click-event="remove-form" onclick="javascript:removeCertificate('{{serialNumber}}')"
class="btn padding-reduce-on-grid-view remove-user-link">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-delete fw-stack-1x"></i>
</span>
<span class="hidden-xs hidden-on-grid-view">Remove</span>
</a>
{{/if}}
{{/unequal}}
</td>
</tr>
{{/each}}

@ -50,8 +50,10 @@ function onRequest(context) {
if (deviceCount > 0) {
page.deviceCount = deviceCount;
var utility = require("/app/modules/utility.js").utility;
var data = deviceModule.getDeviceTypes();
var typesListResponse = deviceModule.getDeviceTypes();
var deviceTypes = [];
if (typesListResponse["status"] == "success") {
var data = typesListResponse["content"];
if (data) {
for (var i = 0; i < data.length; i++) {
var config = utility.getDeviceTypeConfig(data[i].name);
@ -67,6 +69,7 @@ function onRequest(context) {
});
}
}
}
page.deviceTypes = stringify(deviceTypes);
}
}

@ -25,8 +25,9 @@ function onRequest(context) {
var viewModel = {};
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var utility = require("/app/modules/utility.js").utility;
var deviceTypes = deviceModule.getDeviceTypes();
var typesListResponse = deviceModule.getDeviceTypes();
if (typesListResponse["status"] == "success") {
var deviceTypes = typesListResponse["content"];
if (deviceTypes) {
var deviceTypesList = [], virtualDeviceTypesList = [];
for (var i = 0; i < deviceTypes.length; i++) {
@ -66,6 +67,7 @@ function onRequest(context) {
viewModel.virtualDeviceTypesList = virtualDeviceTypesList;
}
viewModel.deviceTypesList = stringify(deviceTypesList);
}
} else {
log.error("Unable to fetch device types data");
throw new Error("Unable to fetch device types!");

@ -15,6 +15,7 @@
specific language governing permissions and limitations
under the License.
}}
{{#zone "content"}}
<div class="row">
<div class="col-md-12">
<!-- content -->
@ -116,6 +117,7 @@
<!-- /content -->
</div>
</div>
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/platform-configuration.js"}}
{{/zone}}

@ -20,15 +20,26 @@ function onRequest(context) {
var utility = require("/app/modules/utility.js").utility;
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
//get all device types
var data = deviceModule.getDeviceTypes();
var deviceTypesArray = [];
var typesListResponse = deviceModule.getDeviceTypes();
if (typesListResponse["status"] == "success") {
var data = typesListResponse["content"].deviceTypes;
if (data) {
for (var i = 0; i < data.length; i++) {
var deviceTypeName = data[i].name;
var deviceTypeName = data[i];
var configUnitName = utility.getTenantedDeviceUnitName(deviceTypeName, "platform.configuration");
if (configUnitName) {
var deviceTypeConfig = utility.getDeviceTypeConfig(deviceTypeName);
deviceTypesArray.push({name: deviceTypeName, label:deviceTypeConfig.deviceType.label, unitName : configUnitName});
var deviceTypeLabel = deviceTypeName;
if (deviceTypeConfig) {
deviceTypeLabel = deviceTypeConfig.deviceType.label;
}
deviceTypesArray.push({
name: deviceTypeName,
label: deviceTypeLabel,
unitName: configUnitName
});
}
}
}
}

@ -41,7 +41,7 @@ $(document).ready(function () {
}
invokerUtil.get(
"/devicemgt_admin/configuration",
"/api/device-mgt/v1.0/configuration",
function (data) {
data = JSON.parse(data);
if (data && data.configuration) {
@ -85,13 +85,13 @@ $(document).ready(function () {
configList.push(monitorFrequency);
addConfigFormData.configuration = configList;
var addConfigAPI = "/devicemgt_admin/configuration";
invokerUtil.post(
var addConfigAPI = "/api/device-mgt/v1.0/configuration";
invokerUtil.put(
addConfigAPI,
addConfigFormData,
function (data) {
data = JSON.parse(data);
if (data.statusCode == responseCodes["SUCCESS"]) {
function (data, textStatus, jqXHR) {
data = jqXHR.status;
if (data == 200) {
$("#config-save-form").addClass("hidden");
$("#record-created-msg").removeClass("hidden");
} else if (data == 500) {
@ -118,3 +118,12 @@ $(document).ready(function () {
}
});
});
// Start of HTML embedded invoke methods
var showAdvanceOperation = function (operation, button) {
$(button).addClass('selected');
$(button).siblings().removeClass('selected');
var hiddenOperation = ".wr-hidden-operations-content > div";
$(hiddenOperation + '[data-operation="' + operation + '"]').show();
$(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide();
};

@ -25,7 +25,7 @@ function onRequest(context) {
var types = {};
types["types"] = [];
var typesListResponse = userModule.getPlatforms();
var typesListResponse = deviceModule.getDeviceTypes();
if (typesListResponse["status"] == "success") {
for (var type in typesListResponse["content"]) {
var content = {};

Loading…
Cancel
Save