Merge branch 'release-2.0.x' of https://github.com/wso2/carbon-device-mgt into release-2.0.x

revert-70aa11f8
inoshperera 8 years ago
commit 346fd28814

@ -144,6 +144,7 @@
org.wso2.carbon.event.output.adapter.core,
org.wso2.carbon.event.output.adapter.core.exception,
org.osgi.framework,
org.wso2.carbon.device.mgt.core.operation.mgt,
org.wso2.carbon.core
</Import-Package>
</instructions>

@ -22,17 +22,21 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.policy.mgt.Profile;
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.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException;
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
import org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.internal.MQTTDataHolder;
import org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.internal.util.MQTTAdapterConstants;
import org.wso2.carbon.event.output.adapter.core.MessageType;
import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration;
import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException;
import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@ -57,7 +61,7 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_USERNAME,
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_USERNAME));
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_PASSWORD,
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_PASSWORD));
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_PASSWORD));
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_CLEAR_SESSION,
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_CLEAR_SESSION));
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_SCOPES,
@ -79,23 +83,48 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
@Override
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
Map<String, String> dynamicProperties = new HashMap<>();
Operation operation = ctx.getOperation();
Properties properties = operation.getProperties();
if (properties != null && properties.get(MQTT_ADAPTER_TOPIC) != null) {
Map<String, String> dynamicProperties = new HashMap<>();
dynamicProperties.put("topic", (String) properties.get(MQTT_ADAPTER_TOPIC));
MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties,
operation.getPayLoad());
} else {
String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/"
+ ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + operation.getType()
.toString().toLowerCase() + "/" + operation.getCode();
dynamicProperties.put("topic", topic);
if (operation.getPayLoad() == null) {
operation.setPayLoad("");
if (PolicyOperation.POLICY_OPERATION_CODE.equals(operation.getCode())) {
PolicyOperation policyOperation = (PolicyOperation) operation;
List<ProfileOperation> profileOperations = policyOperation.getProfileOperations();
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true);
String deviceType = ctx.getDeviceId().getType();
String deviceId = ctx.getDeviceId().getId();
for (ProfileOperation profileOperation : profileOperations) {
Map<String, String> dynamicProperties = new HashMap<>();
String topic = tenantDomain + "/"
+ deviceType + "/" + deviceId + "/" + profileOperation.getType()
.toString().toLowerCase() + "/" + profileOperation.getCode().toLowerCase();
dynamicProperties.put("topic", topic);
MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties,
profileOperation.getPayLoad());
}
} else {
Map<String, String> dynamicProperties = new HashMap<>();
String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/"
+ ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + operation.getType()
.toString().toLowerCase() + "/" + operation.getCode();
dynamicProperties.put("topic", topic);
if (operation.getPayLoad() == null) {
operation.setPayLoad("");
}
MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties,
operation.getPayLoad());
}
}
MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties,
operation.getPayLoad());
}
@Override
@ -109,3 +138,4 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
}
}

@ -72,7 +72,7 @@ import javax.ws.rs.core.Response;
"Further, this is strictly restricted to admin users only ")
public interface UserManagementAdminService {
@PUT
@POST
@Path("/{username}/credentials")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,

@ -89,7 +89,7 @@
<filter-class>org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter</filter-class>
<init-param>
<param-name>patterns</param-name>
<param-value>"text/html*","application/json*","text/plain*"</param-value>
<param-value>text/html" ,application/json" ,text/plain</param-value>
</init-param>
<init-param>
<param-name>filterAction</param-name>

@ -24,6 +24,7 @@ var uriMatcher = new URIMatcher(String(uri));
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
var utility = require("/app/modules/utility.js")["utility"];
function appendQueryParam (url, queryParam , value) {
if (url.indexOf("?") > 0) {
@ -60,7 +61,7 @@ if (uriMatcher.match("/{context}/api/data-tables/invoker")) {
// response callback
function (backendResponse) {
response["status"] = backendResponse["status"];
response["content"] = backendResponse["responseText"];
response["content"] = utility.encodeJson(backendResponse["responseText"]);
}
);
}

@ -117,15 +117,44 @@ var invokers = function () {
log.debug("Response status : " + xmlHttpRequest.status);
log.debug("Response payload if any : " + xmlHttpRequest.responseText);
if (xmlHttpRequest.status == 401 && (xmlHttpRequest.responseText == TOKEN_EXPIRED ||
xmlHttpRequest.responseText == TOKEN_INVALID ) && count < 5) {
tokenUtil.refreshTokenPair();
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers);
} else {
if (xmlHttpRequest.status == 401) {
if ((xmlHttpRequest.responseText == TOKEN_EXPIRED ||
xmlHttpRequest.responseText == TOKEN_INVALID ) && count < 5) {
tokenUtil.refreshTokenPair();
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers);
} else if (privateMethods.isInvalidCredential(xmlHttpRequest.responseText)) {
tokenUtil.refreshTokenPair();
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers);
}
} else {
return responseCallback(xmlHttpRequest);
}
}
};
/**
* This method verify whether the access token is expired using response payload.
* This is required when using API gateway.
* @param responsePayload response payload.
* return true if it is invalid otherwise false.
*/
privateMethods["isInvalidCredential"] =
function (responsePayload) {
if (responsePayload) {
try {
payload = parse(responsePayload);
if (payload["fault"]["code"] == 900901) {
log.debug("Access token is invalid: " + payload["fault"]["code"]);
log.debug(payload["fault"]["description"]);
return true;
}
} catch (err) {
// do nothing
}
}
return false;
};
/**
* This method add Oauth authentication header to outgoing XML-HTTP Requests if Oauth authentication is enabled.
* @param httpMethod HTTP request type.

@ -153,5 +153,24 @@ utility = function () {
return scopesList;
};
/**
* Escapes special characters such as <,>,',",...etc
* This will prevent XSS attacks upon JSON.
* @param text
* @returns {*}
*/
publicMethods.encodeJson = function (text) {
return text
.replace(/\\u003c/g, "&lt;")
.replace(/</g, "&lt;")
.replace(/\\u003e/g, "&gt;")
.replace(/>/g, "&gt;")
.replace(/\\u0027/g, "&#39;")
.replace(/'/g, "&#39;")
.replace(/\\"/g, "&quot;")
.replace(/\\u0022/g, "&quot;")
};
return publicMethods;
}();

@ -375,15 +375,15 @@ function loadDevices(searchType, searchParam) {
var fnCreatedRow = function (row, data, dataIndex) {
$(row).attr('data-type', 'selectable');
$(row).attr('data-deviceid', data.deviceIdentifier);
$(row).attr('data-devicetype', data.deviceType);
$(row).attr('data-url', context + '/device/' + data.deviceType + '?id=' + data.deviceIdentifier);
var model = getPropertyValue(data.properties, 'DEVICE_MODEL');
var vendor = getPropertyValue(data.properties, 'VENDOR');
var owner = data.user;
var status = data.status;
var ownership = data.ownership;
var deviceType = data.deviceType;
$(row).attr('data-deviceid', htmlspecialchars(data.deviceIdentifier));
$(row).attr('data-devicetype', htmlspecialchars(data.deviceType));
$(row).attr('data-url', context + '/device/' + htmlspecialchars(data.deviceType) + '?id=' + htmlspecialchars(data.deviceIdentifier));
var model = htmlspecialchars(getPropertyValue(data.properties, 'DEVICE_MODEL'));
var vendor = htmlspecialchars(getPropertyValue(data.properties, 'VENDOR'));
var owner = htmlspecialchars(data.user);
var status = htmlspecialchars(data.status);
var ownership = htmlspecialchars(data.ownership);
var deviceType = htmlspecialchars(data.deviceType);
var category = getDeviceTypeCategory(deviceType);
$.each($('td', row), function (colIndex) {
switch (colIndex) {
@ -417,6 +417,10 @@ function loadDevices(searchType, searchParam) {
});
};
function htmlspecialchars(text){
return jQuery('<div/>').text(text).html();
}
var dataFilter = function (data) {
data = JSON.parse(data);
var objects = [];

@ -112,6 +112,10 @@ function toTitleCase(str) {
});
}
function htmlspecialchars(text){
return jQuery('<div/>').text(text).html();
}
function loadGroups() {
var groupListing = $("#group-listing");
var currentUser = groupListing.data("currentUser");
@ -134,10 +138,10 @@ function loadGroups() {
var objects = [];
$(data.deviceGroups).each(function (index) {
objects.push({
groupId: data.deviceGroups[index].id,
name: data.deviceGroups[index].name,
description: data.deviceGroups[index].description,
owner: data.deviceGroups[index].owner
groupId: htmlspecialchars(data.deviceGroups[index].id),
name: htmlspecialchars(data.deviceGroups[index].name),
description: htmlspecialchars(data.deviceGroups[index].description),
owner: htmlspecialchars(data.deviceGroups[index].owner)
})
});
var json = {

@ -86,6 +86,10 @@ function InitiateViewOption() {
// $(location).attr('href', $(this).data("url"));
}
function htmlspecialchars(text){
return jQuery('<div/>').text(text).html();
}
function loadRoles() {
var loadingContent = $("#loading-content");
loadingContent.show();
@ -98,8 +102,8 @@ function loadRoles() {
$(data.roles).each(function (index) {
objects.push(
{
name: data.roles[index],
DT_RowId: "role-" + data.roles[index]
name: htmlspecialchars(data.roles[index]),
DT_RowId: "role-" + htmlspecialchars(data.roles[index])
}
)
});

@ -258,6 +258,10 @@ function InitiateViewOption() {
}
}
function htmlspecialchars(text){
return jQuery('<div/>').text(text).html();
}
function loadUsers() {
var loadingContentView = "#loading-content";
$(loadingContentView).show();
@ -269,11 +273,11 @@ function loadUsers() {
$(data.users).each(function (index) {
objects.push({
filter: data.users[index].username,
firstname: data.users[index].firstname ? data.users[index].firstname : "",
lastname: data.users[index].lastname ? data.users[index].lastname : "",
emailAddress: data.users[index].emailAddress ? data.users[index].emailAddress : "",
DT_RowId: "user-" + data.users[index].username
filter: htmlspecialchars(data.users[index].username),
firstname: htmlspecialchars(data.users[index].firstname) ? htmlspecialchars(data.users[index].firstname) : "",
lastname: htmlspecialchars(data.users[index].lastname) ? htmlspecialchars(data.users[index].lastname) : "",
emailAddress: htmlspecialchars(data.users[index].emailAddress) ? htmlspecialchars(data.users[index].emailAddress) : "",
DT_RowId: "user-" + htmlspecialchars(data.users[index].username)
})
});

@ -273,6 +273,7 @@ $.fn.datatables_extended_serverside_paging = function (settings, url, dataFilter
thisTable.removeClass("table-selectable");
$(button).addClass("active").html('Select');
$(button).parent().next().children().addClass("disabled");
$('.DTTT_selected.selected').removeClass(rowSelectedClass);
// EMM related function
$(document).on('click', '.viewEnabledIcon', InitiateViewOption);
//--- End of EMM related codes

@ -41,22 +41,22 @@ $(document).ready(function () {
/* for device list sorting drop down */
$(".ctrl-filter-type-switcher").popover({
html : true,
content : function () {
return $("#content-filter-types").html();
}
});
html: true,
content: function () {
return $("#content-filter-types").html();
}
});
$(".ast-container").on("click", ".claim-btn", function(e){
$(".ast-container").on("click", ".claim-btn", function (e) {
e.stopPropagation();
var deviceId = $(this).data("deviceid");
var deviceListing = $("#device-listing");
var currentUser = deviceListing.data("current-user");
var serviceURL = "/temp-controller-agent/enrollment/claim?username=" + currentUser;
var deviceIdentifier = {id: deviceId, type: "TemperatureController"};
invokerUtil.put(serviceURL, deviceIdentifier, function(message){
invokerUtil.put(serviceURL, deviceIdentifier, function (message) {
console.log(message);
}, function(message){
}, function (message) {
console.log(message);
});
});
@ -68,15 +68,15 @@ $(document).ready(function () {
* @param button: Select All Device button
*/
function selectAllDevices(button) {
if(!$(button).data('select')){
$(deviceCheckbox).each(function(index){
if (!$(button).data('select')) {
$(deviceCheckbox).each(function (index) {
$(this).prop('checked', true);
addDeviceSelectedClass(this);
});
$(button).data('select', true);
$(button).html('Deselect All Devices');
}else{
$(deviceCheckbox).each(function(index){
} else {
$(deviceCheckbox).each(function (index) {
$(this).prop('checked', false);
addDeviceSelectedClass(this);
});
@ -92,7 +92,7 @@ function selectAllDevices(button) {
* @param selection: Selection button
*/
function changeDeviceView(view, selection) {
$(".view-toggle").each(function() {
$(".view-toggle").each(function () {
$(this).removeClass("selected");
});
$(selection).addClass("selected");
@ -117,27 +117,33 @@ function addDeviceSelectedClass(checkbox) {
}
function toTitleCase(str) {
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
return str.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
var deviceTypeCount, compiledDeviceTypesCount = 0;
function loadDevices(searchType, searchParam){
function htmlspecialchars(text) {
return jQuery('<div/>').text(text).html();
}
function loadDevices(searchType, searchParam) {
var deviceListing = $("#device-listing");
var deviceListingSrc = deviceListing.attr("src");
var currentUser = deviceListing.data("currentUser");
$('#ast-container').html("");
deviceTypeCount = deviceTypesList.length;
if(deviceTypesList.length > 0){
if (deviceTypesList.length > 0) {
for (var i = 0; i < deviceTypesList.length; i++) {
var viewModel = {};
viewModel.thumb = deviceTypesList[i].thumb;
viewModel.appContext = clientJsAppContext;
viewModel.deviceTypeName = deviceTypesList[i].deviceTypeName;
viewModel.deviceTypeId = deviceTypesList[i].deviceTypeId;
viewModel.deviceCategory = deviceTypesList[i].deviceCategory;
viewModel.deviceTypeLabel = deviceTypesList[i].deviceTypeLabel;
viewModel.deviceTypeName = htmlspecialchars(deviceTypesList[i].deviceTypeName);
viewModel.deviceTypeId = htmlspecialchars(deviceTypesList[i].deviceTypeId);
viewModel.deviceCategory = htmlspecialchars(deviceTypesList[i].deviceCategory);
viewModel.deviceTypeLabel = htmlspecialchars(deviceTypesList[i].deviceTypeLabel);
compileTemplate(viewModel, deviceListingSrc);
}
} else {
@ -155,12 +161,12 @@ function loadDevices(searchType, searchParam){
}
function compileTemplate(viewModel, templateSrc){
function compileTemplate(viewModel, templateSrc) {
$.template("device-listing", templateSrc, function (template) {
$("#ast-container").html($("#ast-container").html() + template(viewModel));
compiledDeviceTypesCount++;
if(deviceTypeCount == compiledDeviceTypesCount){
$('#device-type-grid').datatables_extended({"bFilter": false, "order": [[ 1, "asc" ]]});
if (deviceTypeCount == compiledDeviceTypesCount) {
$('#device-type-grid').datatables_extended({"bFilter": false, "order": [[1, "asc"]]});
}
});
}
@ -171,17 +177,16 @@ function compileTemplate(viewModel, templateSrc){
var deviceCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']";
var assetContainer = "#ast-container";
function openCollapsedNav(){
function openCollapsedNav() {
$('.wr-hidden-nav-toggle-btn').addClass('active');
$('#hiddenNav').slideToggle('slideDown', function(){
if($(this).css('display') == 'none'){
$('#hiddenNav').slideToggle('slideDown', function () {
if ($(this).css('display') == 'none') {
$('.wr-hidden-nav-toggle-btn').removeClass('active');
}
});
}
/*
* DOM ready functions.
*/
@ -196,22 +201,22 @@ $(document).ready(function () {
/* for device list sorting drop down */
$(".ctrl-filter-type-switcher").popover({
html : true,
content : function () {
return $("#content-filter-types").html();
}
});
html: true,
content: function () {
return $("#content-filter-types").html();
}
});
$(".ast-container").on("click", ".claim-btn", function(e){
$(".ast-container").on("click", ".claim-btn", function (e) {
e.stopPropagation();
var deviceId = $(this).data("deviceid");
var deviceListing = $("#device-listing");
var currentUser = deviceListing.data("current-user");
var serviceURL = "/temp-controller-agent/enrollment/claim?username=" + currentUser;
var deviceIdentifier = {id: deviceId, type: "TemperatureController"};
invokerUtil.put(serviceURL, deviceIdentifier, function(message){
invokerUtil.put(serviceURL, deviceIdentifier, function (message) {
console.log(message);
}, function(message){
}, function (message) {
console.log(message);
});
});
@ -222,20 +227,20 @@ $(document).ready(function () {
$("[data-toggle=popover]").popover();
$(".ctrl-filter-type-switcher").popover({
html : true,
content: function() {
return $('#content-filter-types').html();
}
});
html: true,
content: function () {
return $('#content-filter-types').html();
}
});
$('#nav').affix({
offset: {
top: $('header').height()
}
});
offset: {
top: $('header').height()
}
});
$(document).on("click", "tr.clickable-row", function(){
window.document.location = $(this).data('href');
$(document).on("click", "tr.clickable-row", function () {
window.document.location = $(this).data('href');
})
});

@ -67,11 +67,4 @@
});
}
</script>
<script type="text/javascript">
function toggleEnrollment(){
$(".modal-content").html($("#qr-code-modal").html());
generateQRCode(".modal-content .qr-code");
showQRCodePopup();
}
</script>
{{/zone}}

@ -20,15 +20,15 @@
var modalDialog = (function () {
var publicMethoads = {};
publicMethoads.header = function (headerText) {
$("#modal-title-text").html(headerText);
$("#basic-modal-view #modal-title-text").html(headerText);
};
publicMethoads.content = function (contentText) {
$("#modal-content-text").html(contentText);
$("#basic-modal-view #modal-content-text").html(contentText);
};
publicMethoads.footer = function (footerContent) {
$("#modal-footer-content").html(footerContent);
$("#basic-modal-view #modal-footer-content").html(footerContent);
};
publicMethoads.footerButtons = function (buttonList) {
@ -37,7 +37,7 @@ var modalDialog = (function () {
footerContent = footerContent + '<div class="buttons"><a href="#" id="' + btn.id +
'" class="btn-operations">' + btn.text + '</a></div>';
}
$("#modal-footer-content").html(footerContent);
$("#basic-modal-view #modal-footer-content").html(footerContent);
};
publicMethoads.show = function () {
@ -62,11 +62,21 @@ var modalDialog = (function () {
publicMethoads.hide = function () {
$("#basic-modal-view").addClass('hidden');
$("#basic-modal-view").modal('hide');
$("#modal-title-text").html("");
$("#modal-content-text").html("");
$("#modal-footer-content").html("");
$('body').removeClass('modal-open').css('padding-right', '0px');
$('.modal-backdrop').remove();
};
$("#basic-modal-view").on('hidden.bs.modal', function () {
$('#basic-modal-view .modal-dialog').html('<div class="modal-content"><div class="modal-header">' +
'<h3 class="pull-left modal-title"><span class="fw-stack error-msg-icon hidden">' +
'<i class="fw fw-circle-outline fw-stack-2x"></i><i class="fw fw-error fw-stack-1x"></i></span>' +
'<span class="fw-stack warning-msg-icon hidden"><i class="fw fw-circle-outline fw-stack-2x"></i>' +
'<i class="fw fw-warning fw-stack-1x"></i></span><span id="modal-title-text"></span></h3>' +
'<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i>' +
'</button></div><div class="modal-body add-margin-top-2x add-margin-bottom-2x">' +
'<div id="modal-content-text"></div></div>' +
'<div class="modal-footer" id="modal-footer-content"></div></div>');
$('body').removeClass('modal-open').css('padding-right', '0px');
});
return publicMethoads;
}(modalDialog));

@ -80,9 +80,9 @@
<!--<a href="{{@app.context}}notification-listing" title="Failures of operations on the device side will be listed here">-->
<a data-toggle="sidebar" data-target="#right-sidebar" data-container=".page-content"
aria-expanded="false" rel="notifications-sidebar">
<span class="icon fw-stack">
<i class="fw fw-notification fw-stack-1x"></i>
</span>
<span class="icon fw-stack">
<i class="fw fw-notification fw-stack-1x"></i>
</span>
<span class="hidden-xs">Notifications</span>
<span class="badge notifications" id="notification-bubble"></span>
</a>
@ -90,9 +90,8 @@
</ul>
{{/zone}}
{{#zone "sidePanes"}}
<div class="sidebar-wrapper" id="right-sidebar" is-authorized="{{isAuthorizedForNotifications}}"
data-side="right" data-width="320" data-sidebar-fixed="true" data-fixed-offset="50" data-spy="affix"
data-offset-top="80">
<div class="sidebar-wrapper sidebar-wrapper-animation-fix" id="right-sidebar" is-authorized="{{isAuthorizedForNotifications}}"
data-side="right" data-width="320" data-sidebar-fixed="true" data-top="90" data-fixed-offset="90" data-offset-top="50" data-spy="affix">
<ul class="sidebar-messages">
</ul>
<div class="text-center"><a href="{{@app.context}}/notification-listing" class="btn btn-primary">Show All Notifications</a></div>

@ -32,6 +32,7 @@ function onRequest(context) {
var constants = require("/app/modules/constants.js");
var uiPermissions = userModule.getUIPermissions();
context["permissions"] = uiPermissions;
context["userMgtEnabled"] = (uiPermissions["LIST_USERS"] || uiPermissions["LIST_ROLES"]);
var links = {
"user-mgt": [],

@ -128,15 +128,16 @@ function loadNewNotifications() {
}
/**
* Toggle function for
* notification listing sidebar.
* Sidebar function
* @return {Null}
*/
$.sidebar_toggle = function (action, target, container) {
$.sidebar_toggle = function(action, target, container) {
var elem = '[data-toggle=sidebar]',
button,
containerOffsetLeft,
containerOffsetRight,
container,
conrainerOffsetLeft,
conrainerOffsetRight,
target,
targetOffsetLeft,
targetOffsetRight,
targetWidth,
@ -145,104 +146,177 @@ $.sidebar_toggle = function (action, target, container) {
pushType,
buttonParent;
/**
* Dynamically adjust the height of sidebar to fill parent
*/
function sidebarHeightAdjust(){
$('.sidebar-wrapper').each(function(){
var elemOffsetBottom = $(this).data('offset-bottom'),
scrollBottom = ($(document).height() - $(window).height()),
offesetBottom = 0,
getBottomOffset = elemOffsetBottom - (scrollBottom - ($(window).scrollTop()-elemOffsetBottom) - elemOffsetBottom);
if(getBottomOffset > 0){
offesetBottom = getBottomOffset;
}
$(this).height(($(window).height() - ($(this).offset().top - $(window).scrollTop())) - offesetBottom);
if((typeof $.fn.nanoScroller == 'function') && ($('.nano-content', this).length > 0)){
$(".nano-content").parent()[0].nanoscroller.reset();
}
});
};
var sidebar_window = {
update: function (target, container, button) {
containerOffsetLeft = $(container).data('offset-left') ? $(container).data('offset-left') : 0;
containerOffsetRight = $(container).data('offset-right') ? $(container).data('offset-right') : 0;
targetOffsetLeft = $(target).data('offset-left') ? $(target).data('offset-left') : 0;
targetOffsetRight = $(target).data('offset-right') ? $(target).data('offset-right') : 0;
targetWidth = $(target).data('width');
targetSide = $(target).data("side");
pushType = $(container).parent().is('body') == true ? 'padding' : 'margin';
if (button !== undefined) {
update: function(target, container, button){
conrainerOffsetLeft = $(container).data('offset-left') ? $(container).data('offset-left') : 0,
conrainerOffsetRight = $(container).data('offset-right') ? $(container).data('offset-right') : 0,
targetTop = $(target).data('top') ? $(target).data('top') : 0,
targetOffsetLeft = $(target).data('offset-left') ? $(target).data('offset-left') : 0,
targetOffsetRight = $(target).data('offset-right') ? $(target).data('offset-right') : 0,
targetWidth = $(target).data('width'),
targetSide = $(target).data("side"),
pushType = $(container).parent().is('body') == true ? 'padding' : 'padding'; //TODO: Remove if works everywhere
$(container).addClass('sidebar-target');
if(button !== undefined){
relationship = button.attr('rel') ? button.attr('rel') : '';
buttonParent = $(button).parent();
}
},
show: function () {
if ($(target).data('sidebar-fixed') == true) {
$(target).css('top', targetTop);
sidebarHeightAdjust();
},
show: function(){
if($(target).data('sidebar-fixed') == true) {
$(target).css('top',$(target).data('fixed-offset') + 'px');
$(target).height($(window).height() - $(target).data('fixed-offset'));
}
$(target).off('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend');
$(target).trigger('show.sidebar');
if (targetWidth !== undefined) {
if(targetWidth !== undefined) {
$(target).css('width', targetWidth);
}
$(target).addClass('toggled');
if (button !== undefined) {
if (relationship !== '') {
if(button !== undefined){
if(relationship !== ''){
// Removing active class from all relative buttons
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').removeClass("active");
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').attr('aria-expanded', 'false');
$(elem+'[rel='+relationship+']:not([data-handle=close])').removeClass("active");
$(elem+'[rel='+relationship+']:not([data-handle=close])').attr('aria-expanded', 'false');
}
// Adding active class to button
if (button.attr('data-handle') !== 'close') {
if(button.attr('data-handle') !== 'close'){
button.addClass("active");
button.attr('aria-expanded', 'true');
}
if (buttonParent.is('li')) {
if (relationship !== '') {
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().removeClass("active");
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().
attr('aria-expanded', 'false');
if(buttonParent.is('li')) {
if(relationship !== ''){
$(elem+'[rel='+relationship+']:not([data-handle=close])').parent().removeClass("active");
$(elem+'[rel='+relationship+']:not([data-handle=close])').parent().attr('aria-expanded', 'false');
}
buttonParent.addClass("active");
buttonParent.attr('aria-expanded', 'true');
}
}
// Sidebar open function
if (targetSide == 'left') {
if ((button !== undefined) && (button.attr('data-container-divide'))) {
$(container).css(pushType + '-' + targetSide, targetWidth + targetOffsetLeft);
if (targetSide == 'left'){
if ($(target).attr('data-container-divide')){
$(container).css(pushType+'-'+targetSide, targetWidth + targetOffsetLeft);
$(target).css(targetSide, targetOffsetLeft);
}
$(target).css(targetSide, targetOffsetLeft);
} else if (targetSide == 'right') {
if ((button !== undefined) && (button.attr('data-container-divide'))) {
$(container).css(pushType + '-' + targetSide, targetWidth + targetOffsetRight);
else if ($(target).attr('data-container-push')){
$(container).css(targetSide, Math.abs(targetWidth + targetOffsetLeft));
$(target).css(targetSide, -Math.abs(targetWidth + targetOffsetLeft));
}
else {
$(target).css(targetSide, Math.abs(targetOffsetLeft));
}
}
else if (targetSide == 'right'){
if ($(target).attr('data-container-divide')){
$(container).css(pushType+'-'+targetSide, targetWidth + targetOffsetRight);
$(target).css(targetSide, targetOffsetRight);
}
else if ($(target).attr('data-container-push')){
$(container).css(targetSide, Math.abs(targetWidth + targetOffsetRight));
$(target).css(targetSide, -Math.abs(targetWidth + targetOffsetRight));
}
else {
$(target).css(targetSide, Math.abs(targetOffsetRight));
}
$(target).css(targetSide, targetOffsetRight);
}
$(target).trigger('shown.sidebar');
},
hide: function () {
hide: function(){
$(target).trigger('hide.sidebar');
$(target).removeClass('toggled');
if (button !== undefined) {
if (relationship !== '') {
if(button !== undefined){
if(relationship !== ''){
// Removing active class from all relative buttons
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').removeClass("active");
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').attr('aria-expanded', 'false');
$(elem+'[rel='+relationship+']:not([data-handle=close])').removeClass("active");
$(elem+'[rel='+relationship+']:not([data-handle=close])').attr('aria-expanded', 'false');
}
// Removing active class from button
if (button.attr('data-handle') !== 'close') {
if(button.attr('data-handle') !== 'close'){
button.removeClass("active");
button.attr('aria-expanded', 'false');
}
if ($(button).parent().is('li')) {
if (relationship !== '') {
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().removeClass("active");
$(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().
attr('aria-expanded', 'false');
if($(button).parent().is('li')){
if(relationship !== ''){
$(elem+'[rel='+relationship+']:not([data-handle=close])').parent().removeClass("active");
$(elem+'[rel='+relationship+']:not([data-handle=close])').parent().attr('aria-expanded', 'false');
}
}
}
// Sidebar close function
if (targetSide == 'left') {
if ((button !== undefined) && (button.attr('data-container-divide'))) {
$(container).css(pushType + '-' + targetSide, targetOffsetLeft);
if (targetSide == 'left'){
if($(target).attr('data-container-divide')){
$(container).css(pushType+'-'+targetSide, targetOffsetLeft);
$(target).css(targetSide, -Math.abs(targetWidth + targetOffsetRight));
}
$(target).css(targetSide, -Math.abs(targetWidth + targetOffsetLeft));
} else if (targetSide == 'right') {
if ((button !== undefined) && (button.attr('data-container-divide'))) {
$(container).css(pushType + '-' + targetSide, targetOffsetRight);
else if($(target).attr('data-container-push')){
$(container).css(targetSide, targetOffsetLeft);
$(target).css(targetSide, -Math.abs(targetWidth + targetOffsetLeft));
}
else {
$(target).css(targetSide, -Math.abs(targetWidth + targetOffsetLeft));
}
$(target).css(targetSide, -Math.abs(targetWidth + targetOffsetRight));
}
else if (targetSide == 'right'){
if($(target).attr('data-container-divide')){
$(container).css(pushType+'-'+targetSide, targetOffsetRight);
$(target).css(targetSide, -Math.abs(targetWidth + targetOffsetRight));
}
else if($(target).attr('data-container-push')){
$(container).css(targetSide, targetOffsetRight);
$(target).css(targetSide, -Math.abs(targetWidth + targetOffsetRight));
}
else {
$(target).css(targetSide, -Math.abs(targetWidth + targetOffsetRight));
}
}
$(target).trigger('hidden.sidebar');
$(target).on('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(e) {
$(container).removeClass('sidebar-target');
});
}
};
if (action === 'show') {
sidebar_window.update(target, container);
sidebar_window.show();
@ -251,27 +325,52 @@ $.sidebar_toggle = function (action, target, container) {
sidebar_window.update(target, container);
sidebar_window.hide();
}
// binding click function
var body = 'body';
$(body).off('click', elem);
$(body).on('click', elem, function (e) {
$('body').off('click', elem);
$('body').on('click', elem, function(e) {
e.preventDefault();
button = $(this);
container = button.data('container');
target = button.data('target');
container = $(target).data('container');
sidebar_window.update(target, container, button);
/**
* Sidebar function on data container divide
* @return {Null}
*/
if (button.attr('aria-expanded') == 'false') {
if(button.attr('aria-expanded') == 'false'){
sidebar_window.show();
} else if (button.attr('aria-expanded') == 'true') {
}
else if (button.attr('aria-expanded') == 'true') {
sidebar_window.hide();
}
});
$(window)
.load(sidebarHeightAdjust)
.resize(sidebarHeightAdjust)
.scroll(sidebarHeightAdjust);
};
var sideWrapper = $('.sidebar-wrapper');
$(document).on('affix.bs.affix','.sidebar-wrapper',function(){
sideWrapper.css('top',$('.navbar-wrapper').height());
sideWrapper.data('top',$('.navbar-wrapper').height());
sideWrapper.data('fixed-offset', $('.navbar-wrapper').height());
});
$(document).on('affix-top.bs.affix','.sidebar-wrapper',function(){
sideWrapper.css('top',$('.navbar-wrapper').height() + $('.header').height());
sideWrapper.data('top',$('.navbar-wrapper').height() + $('.header').height());
sideWrapper.data('fixed-offset', $('.navbar-wrapper').height() + $('.header').height());
});
$.fn.collapse_nav_sub = function () {
var navSelector = 'ul.nav';
@ -324,7 +423,6 @@ $.fn.collapse_nav_sub = function () {
$(document).ready(function () {
loadNotificationsPanel();
$.sidebar_toggle();
$("#right-sidebar").on("click", ".new-notification", function () {
var notificationId = $(this).data("id");

@ -804,7 +804,7 @@ header .dropdown[aria-expanded=true], header .dropdown:hover {
.navbar .container-fluid > .navbar-header .icon,
.navbar .container > .navbar-collapse .icon,
.navbar .container > .navbar-header .icon {
margin-bottom: 4px;
margin-bottom: 0px !important;
}
.navbar-nav {
@ -1108,6 +1108,14 @@ header .dropdown[aria-expanded=true], header .dropdown:hover {
right: 0;
}
.sidebar-wrapper-animation-fix{
-webkit-transition: left 0.5s ease, right 0.5s ease !important;
-moz-transition: left 0.5s ease, right 0.5s ease !important;
-ms-transition: left 0.5s ease, right 0.5s ease !important;
-o-transition: left 0.5s ease, right 0.5s ease !important;
transition: left 0.5s ease, right 0.5s ease !important;
}
ul.sidebar-messages {
padding: 0;
margin: 0;
@ -6393,6 +6401,7 @@ ul.tiles .icon {
background: #f4f4f4;
border:1px solid #ddd;
margin-bottom:10px;
padding: 15px;
}
.media .list-group-item a, .media .list-group-item a{
background:#f4f4f4;
@ -6536,6 +6545,9 @@ select > option:hover {
padding-right: 5px;
}
.btn-operations:hover, .btn-operations:focus, .btn-operations:active {
color : #C7C7C7;
}
/**
*

Loading…
Cancel
Save