Skip to content

Commit

Permalink
select2 for Systems
Browse files Browse the repository at this point in the history
  • Loading branch information
slominskir committed Nov 14, 2024
1 parent 4832eea commit 8d55c5e
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private FilterPredicates getFilters(
Boolean filterable,
String alarmName,
String actionName,
String componentName,
String[] systemNameArray,
boolean alwaysIncludeUnregistered,
boolean alwaysIncludeUnfilterable,
Map<String, Join> joins) {
Expand Down Expand Up @@ -367,8 +367,8 @@ private FilterPredicates getFilters(
filters.add(cb.like(cb.lower(actionJoin.get("name")), actionName.toLowerCase()));
}

if (componentName != null && !componentName.isEmpty()) {
filters.add(cb.like(cb.lower(systemJoin.get("name")), componentName.toLowerCase()));
if (systemNameArray != null && systemNameArray.length > 0) {
filters.add(systemJoin.get("name").in((List.of(systemNameArray))));
}

if (teamId != null) {
Expand Down Expand Up @@ -403,7 +403,7 @@ public List<Notification> filterList(
Boolean filterable,
String alarmName,
String actionName,
String componentName,
String[] systemNameArray,
boolean alwaysIncludeUnregistered,
boolean alwaysIncludeUnfilterable,
int offset,
Expand Down Expand Up @@ -431,7 +431,7 @@ public List<Notification> filterList(
filterable,
alarmName,
actionName,
componentName,
systemNameArray,
alwaysIncludeUnregistered,
alwaysIncludeUnfilterable,
joins);
Expand Down Expand Up @@ -473,7 +473,7 @@ public long countList(
Boolean filterable,
String alarmName,
String actionName,
String componentName,
String[] systemNameArray,
boolean alwaysIncludeUnregistered,
boolean alwaysIncludeUnfilterable) {
CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
Expand All @@ -498,7 +498,7 @@ public long countList(
filterable,
alarmName,
actionName,
componentName,
systemNameArray,
alwaysIncludeUnregistered,
alwaysIncludeUnfilterable,
joins);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class Notifications extends HttpServlet {
@EJB PriorityFacade priorityFacade;
@EJB ActionFacade actionFacade;
@EJB LocationFacade locationFacade;
@EJB SystemFacade systemFacade;

/**
* Handles the HTTP <code>GET</code> method.
Expand All @@ -59,7 +60,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
BigInteger[] locationIdArray = ParamConverter.convertBigIntegerArray(request, "locationId");
String actionName = request.getParameter("actionName");
BigInteger priorityId = ParamConverter.convertBigInteger(request, "priorityId");
String systemName = request.getParameter("systemName");
String[] systemNameArray = request.getParameterValues("systemName");
BigInteger teamId = ParamConverter.convertBigInteger(request, "teamId");
Boolean registered = ParamConverter.convertYNBoolean(request, "registered");
Boolean filterable = ParamConverter.convertYNBoolean(request, "filterable");
Expand All @@ -83,7 +84,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
filterable,
alarmName,
actionName,
systemName,
systemNameArray,
alwaysIncludeUnregistered,
alwaysIncludeUnfilterable,
offset,
Expand All @@ -94,6 +95,8 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
List<Priority> priorityList =
priorityFacade.findAll(new AbstractFacade.OrderDirective("priorityId"));
List<Action> actionList = actionFacade.findAll(new AbstractFacade.OrderDirective("name"));
List<SystemEntity> systemList =
systemFacade.findAll(new AbstractFacade.OrderDirective("name"));
Location locationRoot = locationFacade.findBranch(Location.TREE_ROOT);
List<String> typeList = new ArrayList<>();

Expand Down Expand Up @@ -142,7 +145,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
filterable,
alarmName,
actionName,
systemName,
systemNameArray,
alwaysIncludeUnregistered,
alwaysIncludeUnfilterable);

Expand All @@ -165,12 +168,13 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
filterable,
alarmName,
actionName,
systemName,
systemNameArray,
alwaysIncludeUnregistered,
alwaysIncludeUnfilterable);

request.setAttribute("notificationList", notificationList);
request.setAttribute("actionList", actionList);
request.setAttribute("systemList", systemList);
request.setAttribute("selectionMessage", selectionMessage);
request.setAttribute("teamList", teamList);
request.setAttribute("stateList", stateList);
Expand Down Expand Up @@ -251,7 +255,7 @@ public static String createSelectionMessage(
Boolean filterable,
String alarmName,
String actionName,
String systemName,
String[] systemNameArray,
boolean alwaysIncludeUnregistered,
boolean alwaysIncludeUnfilterable) {
DecimalFormat formatter = new DecimalFormat("###,###");
Expand Down Expand Up @@ -337,8 +341,15 @@ public static String createSelectionMessage(
filters.add("Action Name \"" + actionName + "\"");
}

if (systemName != null && !systemName.isBlank()) {
filters.add("System Name \"" + systemName + "\"");
if (systemNameArray != null && systemNameArray.length > 0) {
String sublist = "\"" + systemNameArray[0] + "\"";

for (int i = 1; i < systemNameArray.length; i++) {
String name = systemNameArray[i];
sublist = sublist + ", \"" + name + "\"";
}

filters.add("System Name " + sublist);
}

if (!filters.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
filterable,
alarmName,
actionName,
systemName,
systemName == null ? null : new String[] {systemName},
alwaysIncludeUnregistered,
alwaysIncludeUnfilterable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
filterable,
alarmName,
actionName,
systemName,
systemName == null ? null : new String[] {systemName},
alwaysIncludeUnregistered,
alwaysIncludeUnfilterable);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
filterable,
alarmName,
actionName,
systemName,
systemName == null ? null : new String[] {systemName},
alwaysIncludeUnregistered,
alwaysIncludeUnfilterable);

Expand Down
12 changes: 7 additions & 5 deletions src/main/webapp/WEB-INF/views/notifications.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,15 @@
</li>
<li>
<div class="li-key">
<label for="system-name">System Name</label>
<label for="system-select">System</label>
</div>
<div class="li-value">
<input id="system-name"
name="systemName" value="${fn:escapeXml(param.systemName)}"
placeholder="system name"/>
<div>(use % as wildcard)</div>
<select id="system-select" name="systemName" multiple="multiple">
<c:forEach items="${systemList}" var="system">
<option value="${system.name}"${s:inArray(paramValues.systemName, system.name) ? ' selected="selected"' : ''}>
<c:out value="${system.name}"/></option>
</c:forEach>
</select>
</div>
</li>
</ul>
Expand Down
6 changes: 5 additions & 1 deletion src/main/webapp/resources/js/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ $(document).on("click", ".default-clear-panel", function () {
$("#filterable-select").val('');
$("#alarm-name").val('');
$("#action-name").val('');
$("#system-name").val('');
$("#system-select").val(null).trigger('change');
$("#always-include-unregistered").prop( "checked", false );
$("#always-include-unfilterable").prop( "checked", false );
return false;
Expand Down Expand Up @@ -334,6 +334,10 @@ $(function () {
width: 390
});

$("#system-select").select2({
width: 390
});

/*Custom time picker*/
var myControl = {
create: function (tp_inst, obj, unit, val, min, max, step) {
Expand Down

0 comments on commit 8d55c5e

Please sign in to comment.