revert-70aa11f8
harshanl 8 years ago
commit a4b6bb85b1

@ -24,10 +24,7 @@ import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagement
import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.notification.mgt.dao.util.NotificationDAOUtil; import org.wso2.carbon.device.mgt.core.notification.mgt.dao.util.NotificationDAOUtil;
import java.sql.Connection; import java.sql.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -35,6 +32,36 @@ import java.util.List;
* This class holds the Oracle implementation of NotificationDAO which can be used to support Oracle db syntax. * This class holds the Oracle implementation of NotificationDAO which can be used to support Oracle db syntax.
*/ */
public class OracleNotificationDAOImpl extends AbstractNotificationDAOImpl { public class OracleNotificationDAOImpl extends AbstractNotificationDAOImpl {
@Override
public int addNotification(int deviceId, int tenantId, Notification notification) throws
NotificationManagementException {
Connection conn;
PreparedStatement stmt = null;
ResultSet rs;
int notificationId = -1;
try {
conn = NotificationManagementDAOFactory.getConnection();
String sql = "INSERT INTO DM_NOTIFICATION(DEVICE_ID, OPERATION_ID, STATUS, DESCRIPTION, TENANT_ID) "
+ "VALUES (?, ?, ?, ?, ?)";
stmt = conn.prepareStatement(sql, new int[] { 1 });
stmt.setInt(1, deviceId);
stmt.setInt(2, notification.getOperationId());
stmt.setString(3, notification.getStatus().toString());
stmt.setString(4, notification.getDescription());
stmt.setInt(5, tenantId);
stmt.execute();
rs = stmt.getGeneratedKeys();
if (rs.next()) {
notificationId = rs.getInt(1);
}
} catch (Exception e) {
throw new NotificationManagementException(
"Error occurred while adding the " + "Notification for device id : " + deviceId, e);
} finally {
NotificationDAOUtil.cleanupResources(stmt, null);
}
return notificationId;
}
@Override @Override
public List<Notification> getAllNotifications(PaginationRequest request, int tenantId) throws public List<Notification> getAllNotifications(PaginationRequest request, int tenantId) throws

@ -226,13 +226,14 @@ deviceModule = function () {
publicMethods.getDevices = function (userName) { publicMethods.getDevices = function (userName) {
var url = devicemgtProps["httpsURL"] + var url = devicemgtProps["httpsURL"] +
devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices/user/" + userName; devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices";
return serviceInvokers.XMLHttp.get( return serviceInvokers.XMLHttp.get(
url, function (responsePayload) { url, function (responsePayload) {
for (var i = 0; i < responsePayload.length; i++) { var devices = JSON.parse(responsePayload.responseText).devices;
responsePayload[i].thumb = utility.getDeviceThumb(responsePayload[i].type); for (var i = 0; i < devices.length; i++) {
devices[i].thumb = utility.getDeviceThumb(devices[i].type);
} }
return responsePayload; return devices;
}, },
function (responsePayload) { function (responsePayload) {
log.error(responsePayload); log.error(responsePayload);

@ -20,7 +20,10 @@
var sortUpdateBtn = "#sortUpdateBtn"; var sortUpdateBtn = "#sortUpdateBtn";
var sortedIDs; var sortedIDs;
var dataTableSelection = '.DTTT_selected'; var dataTableSelection = '.DTTT_selected';
$('#policy-grid').datatables_extended(); var settings = {
"sorting": false
};
$('#policy-grid').datatables_extended(settings);
$(".icon .text").res_text(0.2); $(".icon .text").res_text(0.2);
var saveNewPrioritiesButton = "#save-new-priorities-button"; var saveNewPrioritiesButton = "#save-new-priorities-button";
@ -90,7 +93,7 @@ function showPopup() {
function hidePopup() { function hidePopup() {
$(modalPopupContent).html(''); $(modalPopupContent).html('');
$(modalPopup).modal('hide'); $(modalPopup).modal('hide');
$('body').removeClass('modal-open').css('padding-right','0px'); $('body').removeClass('modal-open').css('padding-right', '0px');
$('.modal-backdrop').remove(); $('.modal-backdrop').remove();
} }
@ -222,7 +225,7 @@ $(document).ready(function () {
$(".policy-unpublish-link").click(function () { $(".policy-unpublish-link").click(function () {
var policyList = getSelectedPolicies(); var policyList = getSelectedPolicies();
var statusList = getSelectedPolicyStates(); var statusList = getSelectedPolicyStates();
if ( ($.inArray( 'Inactive/Updated', statusList ) > -1) || ($.inArray( 'Inactive', statusList ) > -1) ) { if (($.inArray('Inactive/Updated', statusList) > -1) || ($.inArray('Inactive', statusList) > -1)) {
$(modalPopupContent).html($("#errorPolicyUnPublishSelection").html()); $(modalPopupContent).html($("#errorPolicyUnPublishSelection").html());
showPopup(); showPopup();
} else { } else {
@ -266,7 +269,7 @@ $(document).ready(function () {
$(".policy-publish-link").click(function () { $(".policy-publish-link").click(function () {
var policyList = getSelectedPolicies(); var policyList = getSelectedPolicies();
var statusList = getSelectedPolicyStates(); var statusList = getSelectedPolicyStates();
if ( ($.inArray( 'Active/Updated', statusList ) > -1) || ($.inArray( 'Active', statusList ) > -1) ) { if (($.inArray('Active/Updated', statusList) > -1) || ($.inArray('Active', statusList) > -1)) {
$(modalPopupContent).html($("#errorPolicyPublishSelection").html()); $(modalPopupContent).html($("#errorPolicyPublishSelection").html());
showPopup(); showPopup();
} else { } else {

@ -45,9 +45,9 @@ var isInit = true;
* the font icons change the size to respective screen resolution. * the font icons change the size to respective screen resolution.
* *
*/ */
$(document).on( 'draw.dt', function () { $(document).on('draw.dt', function () {
$(".icon .text").res_text(0.2); $(".icon .text").res_text(0.2);
} ); });
/* /*
@ -72,7 +72,7 @@ function showPopup() {
function hidePopup() { function hidePopup() {
$(modalPopupContent).html(''); $(modalPopupContent).html('');
$(modalPopup).modal('hide'); $(modalPopup).modal('hide');
$('body').removeClass('modal-open').css('padding-right','0px'); $('body').removeClass('modal-open').css('padding-right', '0px');
$('.modal-backdrop').remove(); $('.modal-backdrop').remove();
} }
@ -95,7 +95,7 @@ function loadRoles() {
var objects = []; var objects = [];
$(data.roles).each(function( index ) { $(data.roles).each(function (index) {
objects.push( objects.push(
{ {
name: data.roles[index], name: data.roles[index],
@ -182,10 +182,13 @@ function loadRoles() {
var options = { var options = {
"placeholder": "Search By Role Name", "placeholder": "Search By Role Name",
"searchKey" : "filter" "searchKey": "filter"
};
var settings = {
"sorting": false
}; };
$('#role-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/roles', dataFilter, columns, fnCreatedRow, null, options); $('#role-grid').datatables_extended_serverside_paging(settings, '/api/device-mgt/v1.0/roles', dataFilter, columns, fnCreatedRow, null, options);
loadingContent.hide(); loadingContent.hide();
} }

@ -50,9 +50,9 @@ var body = "body";
* the font icons change the size to respective screen resolution. * the font icons change the size to respective screen resolution.
* *
*/ */
$(document).on( 'draw.dt', function () { $(document).on('draw.dt', function () {
$(".icon .text").res_text(0.2); $(".icon .text").res_text(0.2);
} ); });
/* /*
* set popup maximum height function. * set popup maximum height function.
@ -75,7 +75,7 @@ function showPopup() {
function hidePopup() { function hidePopup() {
$(modalPopupContent).html(''); $(modalPopupContent).html('');
$(modalPopup).modal('hide'); $(modalPopup).modal('hide');
$('body').removeClass('modal-open').css('padding-right','0px'); $('body').removeClass('modal-open').css('padding-right', '0px');
$('.modal-backdrop').remove(); $('.modal-backdrop').remove();
} }
@ -270,13 +270,14 @@ function loadUsers() {
var objects = []; var objects = [];
$(data.users).each( function (index) { $(data.users).each(function (index) {
objects.push({ objects.push({
filter: data.users[index].username, filter: data.users[index].username,
firstname: data.users[index].firstname ? data.users[index].firstname : "" , firstname: data.users[index].firstname ? data.users[index].firstname : "",
lastname: data.users[index].lastname ? data.users[index].lastname : "", lastname: data.users[index].lastname ? data.users[index].lastname : "",
emailAddress : data.users[index].emailAddress ? data.users[index].emailAddress : "", emailAddress: data.users[index].emailAddress ? data.users[index].emailAddress : "",
DT_RowId : "user-" + data.users[index].username}) DT_RowId: "user-" + data.users[index].username
})
}); });
var json = { var json = {
@ -300,7 +301,7 @@ function loadUsers() {
class: "remove-padding icon-only content-fill", class: "remove-padding icon-only content-fill",
data: null, data: null,
render: function (data, type, row, meta) { render: function (data, type, row, meta) {
return '<div class="thumbnail icon viewEnabledIcon" data-url="' + context +'/user/view?username=' + data.filter + '">' + return '<div class="thumbnail icon viewEnabledIcon" data-url="' + context + '/user/view?username=' + data.filter + '">' +
'<i class="square-element text fw fw-user" style="font-size: 74px;"></i>' + '<i class="square-element text fw fw-user" style="font-size: 74px;"></i>' +
'</div>'; '</div>';
} }
@ -338,7 +339,7 @@ function loadUsers() {
class: "text-right content-fill text-left-on-grid-view no-wrap", class: "text-right content-fill text-left-on-grid-view no-wrap",
data: null, data: null,
render: function (data, type, row, meta) { render: function (data, type, row, meta) {
var editbtn= '&nbsp;<a data-toggle="tooltip" data-placement="bottom" title="Edit User"href="' + context + '/user/edit?username=' + data.filter + '" data-username="' + data.filter + '" ' + var editbtn = '&nbsp;<a data-toggle="tooltip" data-placement="bottom" title="Edit User"href="' + context + '/user/edit?username=' + data.filter + '" data-username="' + data.filter + '" ' +
'data-click-event="edit-form" ' + 'data-click-event="edit-form" ' +
'class="btn padding-reduce-on-grid-view edit-user-link"> ' + 'class="btn padding-reduce-on-grid-view edit-user-link"> ' +
'<span class="fw-stack"> ' + '<span class="fw-stack"> ' +
@ -377,13 +378,13 @@ function loadUsers() {
'</a>'; '</a>';
var returnbtnSet = ''; var returnbtnSet = '';
if($("#can-edit").length > 0) { if ($("#can-edit").length > 0) {
returnbtnSet = returnbtnSet + editbtn; returnbtnSet = returnbtnSet + editbtn;
} }
if($("#can-reset-password").length > 0) { if ($("#can-reset-password").length > 0) {
returnbtnSet = returnbtnSet + resetPasswordbtn; returnbtnSet = returnbtnSet + resetPasswordbtn;
} }
if($("#can-remove").length > 0) { if ($("#can-remove").length > 0) {
returnbtnSet = returnbtnSet + removebtn; returnbtnSet = returnbtnSet + removebtn;
} }
@ -395,10 +396,14 @@ function loadUsers() {
var options = { var options = {
"placeholder": "Search By Username", "placeholder": "Search By Username",
"searchKey" : "filter" "searchKey": "filter"
};
var settings = {
"sorting": false
}; };
$('#user-grid').datatables_extended_serverside_paging(null, '/api/device-mgt/v1.0/users', dataFilter, columns, fnCreatedRow, null, options); $('#user-grid').datatables_extended_serverside_paging(settings, '/api/device-mgt/v1.0/users', dataFilter, columns, fnCreatedRow, null, options);
$(loadingContentView).hide(); $(loadingContentView).hide();
} }

@ -29,21 +29,22 @@
* For ex: $(this) means jQuery(this) and S.fn.x means jQuery.fn.x * For ex: $(this) means jQuery(this) and S.fn.x means jQuery.fn.x
*/ */
$.fn.datatables_extended_serverside_paging = function (settings , url, dataFilter, $.fn.datatables_extended_serverside_paging = function (settings, url, dataFilter,
columns, fnCreatedRow, fnDrawCallback, options) { columns, fnCreatedRow, fnDrawCallback, options) {
var elem = $(this); var elem = $(this);
// EMM related function // EMM related function
if (InitiateViewOption) { if (InitiateViewOption) {
$(document).on('click','.viewEnabledIcon',InitiateViewOption); $(document).on('click', '.viewEnabledIcon', InitiateViewOption);
} }
//--- End of EMM related codes
/* /*
* Work around for accessing settings params inside datatable functions * Work around for accessing settings params inside datatable functions
*/ */
if(settings != null && settings.sorting != null && settings.sorting != undefined && settings.sorting){ if (settings != null && settings.sorting != null && settings.sorting != undefined && settings.sorting) {
elem.addClass('sorting-enabled'); elem.addClass('sorting-enabled');
}else{ } else {
elem.addClass('sorting-disabled'); elem.addClass('sorting-disabled');
} }
@ -53,22 +54,22 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
//--- End of EMM related codes //--- End of EMM related codes
$(elem).DataTable( $(elem).DataTable(
$.extend({},{ $.extend({}, {
serverSide: true, serverSide: true,
processing: false, processing: false,
searching: true, searching: true,
ordering: false, ordering: false,
filter: false, filter: false,
bSortCellsTop: true, bSortCellsTop: true,
ajax : { ajax: {
url: context + "/api/data-tables/invoker", url: context + "/api/data-tables/invoker",
data : function (params) { data: function (params) {
var i; var i;
var searchParams = {}; var searchParams = {};
for (i = 0; i < params.columns.length; i++) { for (i = 0; i < params.columns.length; i++) {
searchParams[params.columns[i].data] = encodeURIComponent(params.columns[i].search.value); searchParams[params.columns[i].data] = encodeURIComponent(params.columns[i].search.value);
} }
if(options) { if (options) {
searchParams[options.searchKey] = encodeURIComponent(params.search.value); searchParams[options.searchKey] = encodeURIComponent(params.search.value);
} }
params.filter = JSON.stringify(searchParams); params.filter = JSON.stringify(searchParams);
@ -87,7 +88,7 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
columns: columns, columns: columns,
responsive: false, responsive: false,
autoWidth: false, autoWidth: false,
dom:'<"dataTablesTop"' + dom: '<"dataTablesTop"' +
'f' + 'f' +
'<"dataTables_toolbar">' + '<"dataTables_toolbar">' +
'>' + '>' +
@ -193,24 +194,42 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
/** /**
* create sorting dropdown menu for list table advance operations * create sorting dropdown menu for list table advance operations
*/ */
var table = this;
if (table.hasClass('sorting-enabled')) {
var dropdownmenu = $('<ul class="dropdown-menu arrow arrow-top-right dark sort-list add-margin-top-2x"><li class="dropdown-header">Sort by</li></ul>'); var dropdownmenu = $('<ul class="dropdown-menu arrow arrow-top-right dark sort-list add-margin-top-2x"><li class="dropdown-header">Sort by</li></ul>');
$('.sort-row th', elem).each(function () { $('.sort-row th', elem).each(function () {
if (!$(this).hasClass('no-sort')) { if (!$(this).hasClass('no-sort')) {
dropdownmenu.append('<li><a href="#' + $(this).html() + '" data-column="' + $(this).index() + '">' + $(this).html() + '</a></li>'); dropdownmenu.append('<li><a href="#' + $(this).html() + '" data-column="' + $(this).index() + '">' + $(this).html() + '</a></li>');
} }
}); });
}
/** function getAdvanceToolBar() {
* append advance operations to list table toolbar if (table.hasClass('sorting-enabled')) {
*/ return '<ul class="nav nav-pills navbar-right remove-margin" role="tablist">' +
$('.dataTable.list-table').closest('.dataTables_wrapper').find('.dataTablesTop .dataTables_toolbar').html('' +
'<ul class="nav nav-pills navbar-right remove-margin" role="tablist">' +
'<li><button data-click-event="toggle-selectable" class="btn btn-default btn-primary select-enable-btn">Select</li>' + '<li><button data-click-event="toggle-selectable" class="btn btn-default btn-primary select-enable-btn">Select</li>' +
'<li><button data-click-event="toggle-selected" id="dt-select-all" class="btn btn-default btn-primary disabled">Select All</li>' + '<li><button data-click-event="toggle-selected" id="dt-select-all" class="btn btn-default btn-primary disabled">Select All</li>' +
'<li><button data-click-event="toggle-list-view" data-view="grid" class="btn btn-default"><i class="fw fw-grid"></i></button></li>' + '<li><button data-click-event="toggle-list-view" data-view="grid" class="btn btn-default"><i class="fw fw-grid"></i></button></li>' +
'<li><button data-click-event="toggle-list-view" data-view="list" class="btn btn-default"><i class="fw fw-list"></i></button></li>' + '<li><button data-click-event="toggle-list-view" data-view="list" class="btn btn-default"><i class="fw fw-list"></i></button></li>' +
'<li><button class="btn btn-default" data-toggle="dropdown"><i class="fw fw-sort"></i></button>' + dropdownmenu[0].outerHTML + '</li>' + '<li><button class="btn btn-default" data-toggle="dropdown"><i class="fw fw-sort"></i></button>' + dropdownmenu[0].outerHTML + '</li>' +
'</ul>' '</ul>'
} else {
return '<ul class="nav nav-pills navbar-right remove-margin" role="tablist">' +
'<li><button data-click-event="toggle-selectable" class="btn btn-default btn-primary select-enable-btn">Select</li>' +
'<li><button data-click-event="toggle-selected" id="dt-select-all" class="btn btn-default btn-primary disabled">Select All</li>' +
'<li><button data-click-event="toggle-list-view" data-view="grid" class="btn btn-default"><i class="fw fw-grid"></i></button></li>' +
'<li><button data-click-event="toggle-list-view" data-view="list" class="btn btn-default"><i class="fw fw-list"></i></button></li>' +
'</ul>'
}
;
}
/**
* append advance operations to list table toolbar
*/
$('.dataTable.list-table').closest('.dataTables_wrapper').find('.dataTablesTop .dataTables_toolbar').html(
getAdvanceToolBar()
); );
/** /**
@ -248,14 +267,14 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
$(button).addClass("active").html('Cancel'); $(button).addClass("active").html('Cancel');
$(button).parent().next().children("button").removeClass("disabled"); $(button).parent().next().children("button").removeClass("disabled");
// EMM related code // EMM related code
$(document).off('click','.viewEnabledIcon'); $(document).off('click', '.viewEnabledIcon');
//--- End of EMM related codes //--- End of EMM related codes
} else if ($(button).html() == 'Cancel') { } else if ($(button).html() == 'Cancel') {
thisTable.removeClass("table-selectable"); thisTable.removeClass("table-selectable");
$(button).addClass("active").html('Select'); $(button).addClass("active").html('Select');
$(button).parent().next().children().addClass("disabled"); $(button).parent().next().children().addClass("disabled");
// EMM related function // EMM related function
$(document).on('click','.viewEnabledIcon',InitiateViewOption); $(document).on('click', '.viewEnabledIcon', InitiateViewOption);
//--- End of EMM related codes //--- End of EMM related codes
} }
}); });
@ -314,6 +333,6 @@ $.fn.datatables_extended_serverside_paging = function (settings , url, dataFilte
} }
}) })
} }
},settings) }, settings)
); );
}; };

@ -47,8 +47,11 @@ function loadNotifications() {
viewModel["appContext"] = context; viewModel["appContext"] = context;
var content = template(viewModel); var content = template(viewModel);
$("#ast-container").html(content); $("#ast-container").html(content);
$("#unread-notifications").datatables_extended(); var settings = {
$("#all-notifications").datatables_extended(); "sorting" : false
};
$("#unread-notifications").datatables_extended(settings);
$("#all-notifications").datatables_extended(settings);
} }
} }
}, },

Loading…
Cancel
Save