Skip to content

Commit 94d1761

Browse files
[cuegui] Add LockState Filter to "Monitor Hosts" window in CueCommander (#1679)
- Add `LockStateSeq` message with `repeated LockState state` in `host.proto` and update HostSearchCriteria - Update `HostMonitor.py` to include the menu to filter by lock state - Update `HostSearch.java` to include lock state filtering - Add lock state handling in `_setOptions` function in `search.py` **Link the Issue(s) this Pull Request is related to.** #1678
1 parent 16c06da commit 94d1761

File tree

5 files changed

+112
-5
lines changed

5 files changed

+112
-5
lines changed

VERSION.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.7
1+
1.8

cuebot/src/main/java/com/imageworks/spcue/dao/criteria/postgres/HostSearch.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.imageworks.spcue.AllocationInterface;
2222
import com.imageworks.spcue.dao.criteria.HostSearchInterface;
2323
import com.imageworks.spcue.grpc.host.HardwareState;
24+
import com.imageworks.spcue.grpc.host.LockState;
2425
import com.imageworks.spcue.grpc.host.HostSearchCriteria;
2526

2627
public class HostSearch extends Criteria implements HostSearchInterface {
@@ -45,10 +46,16 @@ public void buildWhereClause() {
4546
addLikePhrase("host.str_name", new HashSet<>(criteria.getSubstrList()));
4647
addRegexPhrase("host.str_name", new HashSet<>(criteria.getRegexList()));
4748
addPhrase("alloc.str_name", criteria.getAllocsList());
48-
Set<String> items = new HashSet<>(criteria.getStates().getStateCount());
49-
for (HardwareState w : criteria.getStates().getStateList()) {
50-
items.add(w.toString());
49+
Set<String> hardwareStateItems = new HashSet<>(criteria.getStates().getStateCount());
50+
for (HardwareState state : criteria.getStates().getStateList()) {
51+
hardwareStateItems.add(state.toString());
5152
}
52-
addPhrase("host_stat.str_state", items);
53+
addPhrase("host_stat.str_state", hardwareStateItems);
54+
55+
Set<String> lockStateItems = new HashSet<>(criteria.getLockStates().getStateCount());
56+
for (LockState lockState : criteria.getLockStates().getStateList()) {
57+
lockStateItems.add(lockState.toString());
58+
}
59+
addPhrase("host.str_lock_state", lockStateItems);
5360
}
5461
}

cuegui/cuegui/HostMonitor.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def __init__(self, parent):
6060
self.__filterByHostNameSetup(hlayout)
6161
self.__filterAllocationSetup(hlayout)
6262
self.__filterHardwareStateSetup(hlayout)
63+
self.__filterLockStateSetup(hlayout)
6364
hlayout.addStretch()
6465
self.__refreshToggleCheckBoxSetup(hlayout)
6566
self.__refreshButtonSetup(hlayout)
@@ -265,6 +266,96 @@ def __filterHardwareStateHandle(self, action):
265266

266267
self.hostMonitorTree.updateRequest()
267268

269+
# ==============================================================================
270+
# Menu to filter by lock state
271+
# ==============================================================================
272+
def __filterLockStateSetup(self, layout):
273+
self.__filterLockStateList = sorted(opencue.api.host_pb2.LockState.keys())
274+
275+
btn = QtWidgets.QPushButton("Filter LockState")
276+
btn.setMaximumHeight(FILTER_HEIGHT)
277+
btn.setFocusPolicy(QtCore.Qt.NoFocus)
278+
btn.setContentsMargins(0, 0, 0, 0)
279+
btn.setFlat(True)
280+
281+
menu = QtWidgets.QMenu(self)
282+
btn.setMenu(menu)
283+
QtCore.QObject.connect(menu,
284+
QtCore.SIGNAL("triggered(QAction*)"),
285+
self.__filterLockStateHandle)
286+
287+
for item in ["Clear", None] + self.__filterLockStateList:
288+
if item:
289+
a = QtWidgets.QAction(menu)
290+
a.setText(str(item))
291+
if item != "Clear":
292+
a.setCheckable(True)
293+
menu.addAction(a)
294+
else:
295+
menu.addSeparator()
296+
297+
layout.addWidget(btn)
298+
self.__filterLockStateButton = btn
299+
300+
def __filterLockStateClear(self):
301+
"""Clears the currently selected lock state menu items"""
302+
btn = self.__filterLockStateButton
303+
menu = btn.menu()
304+
for action in menu.actions():
305+
action.setChecked(False)
306+
self.hostMonitorTree.hostSearch.options['lock_state'] = []
307+
308+
def __filterLockStateHandle(self, action):
309+
"""Called when an option in the filter lock state menu is triggered.
310+
Tells the HostMonitorTree widget what lock state to filter by.
311+
@param action: Defines the menu item selected
312+
@type action: QAction"""
313+
__hostSearch = self.hostMonitorTree.hostSearch
314+
if action.text() == "Clear":
315+
self.__clearLockStateFilter(__hostSearch)
316+
return
317+
318+
self.__updateLockStateFilter(__hostSearch, action)
319+
320+
self.hostMonitorTree.updateRequest()
321+
322+
def __clearLockStateFilter(self, __hostSearch):
323+
"""
324+
Clears the currently selected lock state menu items and updates the search options.
325+
@param __hostSearch: The host search criteria object to update.
326+
@type __hostSearch: HostSearchCriteria
327+
"""
328+
for item in self.__filterLockStateButton.menu().actions():
329+
if item.isChecked() and item.text() != "Clear":
330+
# Remove the lock state from the search options
331+
__hostSearch.options['lock_state'].remove(
332+
getattr(opencue.api.host_pb2, str(item.text())))
333+
# Uncheck the menu item
334+
item.setChecked(False)
335+
336+
def __updateLockStateFilter(self, __hostSearch, action):
337+
"""
338+
Updates the lock state filter based on the selected action.
339+
@param __hostSearch: The host search criteria object to update.
340+
@type __hostSearch: HostSearchCriteria
341+
@param action: The action that was triggered.
342+
@type action: QAction
343+
"""
344+
# Get the current lock states from the search options
345+
lock_states = __hostSearch.options.get('lock_state', [])
346+
# Get the lock state corresponding to the action text
347+
lock_state = getattr(opencue.api.host_pb2, str(action.text()))
348+
349+
if action.isChecked():
350+
# Add the lock state if the action is checked
351+
lock_states.append(lock_state)
352+
else:
353+
# Remove the lock state if the action is unchecked
354+
lock_states.remove(lock_state)
355+
356+
# Update the search options with the new lock states
357+
__hostSearch.options['lock_state'] = lock_states
358+
268359
# ==============================================================================
269360
# Checkbox to toggle auto-refresh
270361
# ==============================================================================
@@ -326,6 +417,7 @@ def __clearButtonHandle(self):
326417
self.hostMonitorTree.ticksWithoutUpdate = -1
327418
self.__filterAllocationClear()
328419
self.__filterHardwareStateClear()
420+
self.__filterLockStateClear()
329421
self.__filterByHostNameClear()
330422
self.hostMonitorTree.clearFilters()
331423

proto/host.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ message HardwareStateSeq {
240240
repeated HardwareState state = 1;
241241
}
242242

243+
message LockStateSeq {
244+
repeated LockState state = 1;
245+
}
246+
243247
message Host {
244248
string id = 1;
245249
string name = 2;
@@ -279,6 +283,7 @@ message HostSearchCriteria {
279283
repeated string ids = 4;
280284
repeated string allocs = 5;
281285
HardwareStateSeq states = 6;
286+
LockStateSeq lock_states = 7;
282287
}
283288

284289
message HostSeq {

pycue/opencue/search.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ def _setOptions(criteria, options):
340340
elif k == "state" and isinstance(criteria, host_pb2.HostSearchCriteria):
341341
raiseIfNotList(k, v)
342342
criteria.states.state.extend(v)
343+
elif k == "lock_state" and isinstance(criteria, host_pb2.HostSearchCriteria):
344+
raiseIfNotList(k, v)
345+
criteria.lock_states.state.extend(v)
343346
elif k == "layer":
344347
raiseIfNotList(k, v)
345348
criteria.layers.extend(v)

0 commit comments

Comments
 (0)