Skip to content

Commit

Permalink
Add OS filter to HostMonitor in CueGUI
Browse files Browse the repository at this point in the history
- A new dropdown menu for filtering by OS.
- Logic to handle the selection and clearing of OS filters.
- Integration of the OS filter with the clear button to reset filters.
  • Loading branch information
ramonfigueiredo committed Oct 16, 2024
1 parent 2400979 commit 983a993
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions cuegui/cuegui/HostMonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def __init__(self, parent):
self.__filterByHostNameSetup(hlayout)
self.__filterAllocationSetup(hlayout)
self.__filterHardwareStateSetup(hlayout)
self.__filterOSSetup(hlayout)
hlayout.addStretch()
self.__refreshToggleCheckBoxSetup(hlayout)
self.__refreshButtonSetup(hlayout)
Expand Down Expand Up @@ -262,6 +263,69 @@ def __filterHardwareStateHandle(self, action):

self.hostMonitorTree.updateRequest()

# ==============================================================================
# Menu to filter by OS
# ==============================================================================
def __filterOSSetup(self, layout):
self.__filterOSList = ["rhel7", "rhel9", "Windows"]

btn = QtWidgets.QPushButton("Filter OS")
btn.setMaximumHeight(FILTER_HEIGHT)
btn.setFocusPolicy(QtCore.Qt.NoFocus)
btn.setContentsMargins(0, 0, 0, 0)
btn.setFlat(True)

menu = QtWidgets.QMenu(self)
btn.setMenu(menu)
QtCore.QObject.connect(menu,
QtCore.SIGNAL("triggered(QAction*)"),
self.__filterOSHandle)

for item in ["Clear", None] + self.__filterOSList:
if item:
a = QtWidgets.QAction(menu)
a.setText(str(item))
if item != "Clear":
a.setCheckable(True)
menu.addAction(a)
else:
menu.addSeparator()

layout.addWidget(btn)
self.__filterOSButton = btn

def __filterOSClear(self):
"""Clears the currently selected OS filter"""
btn = self.__filterOSButton
menu = btn.menu()
for action in menu.actions():
action.setChecked(False)
self.hostMonitorTree.hostSearch.options['os'] = []

def __filterOSHandle(self, action):
"""Called when an option in the filter OS menu is triggered.
Tells the HostMonitorTree widget what OS to filter by.
@param action: Defines the menu item selected
@type action: QAction"""
__hostSearch = self.hostMonitorTree.hostSearch
if action.text() == "Clear":
for item in self.__filterOSButton.menu().actions():
if item.isChecked():
if item.text() != "Clear":
__hostSearch.options['os'].remove(str(item.text()))
item.setChecked(False)
else:
os_list = __hostSearch.options.get('os', [])
if action.isChecked():
os_list.append(str(action.text()))
elif os_list is not None:
os_list.remove(str(action.text()))
else:
os_list = []
__hostSearch.options['os'] = os_list

self.hostMonitorTree.updateRequest()

# ==============================================================================
# Checkbox to toggle auto-refresh
# ==============================================================================
Expand Down Expand Up @@ -321,6 +385,7 @@ def __clearButtonHandle(self):
self.hostMonitorTree.ticksWithoutUpdate = -1
self.__filterAllocationClear()
self.__filterHardwareStateClear()
self.__filterOSClear()
self.__filterByHostNameClear()
self.hostMonitorTree.clearFilters()

Expand Down

0 comments on commit 983a993

Please sign in to comment.