Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

active_op_id needs to be shared #2326

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions mslib/msui/multiple_flightpath_dockwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ class MultipleFlightpathControlWidget(QtWidgets.QWidget, ui.Ui_MultipleViewWidge
signal_parent_closes = QtCore.pyqtSignal()

def __init__(self, parent=None, view=None, listFlightTracks=None,
listOperationsMSC=None, category=None, activeFlightTrack=None, mscolab_server_url=None, token=None):
listOperationsMSC=None, category=None, activeFlightTrack=None, active_op_id=None,
mscolab_server_url=None, token=None):
super().__init__(parent)
# ToDO: Remove all patches, on closing dockwidget.
self.ui = parent
Expand All @@ -124,6 +125,7 @@ def __init__(self, parent=None, view=None, listFlightTracks=None,
self.flight_path = None # flightpath object
self.dict_flighttrack = {} # Dictionary of flighttrack data: patch,color,wp_model
self.active_flight_track = activeFlightTrack
self.active_op_id = active_op_id
self.msc_category = category # object of active category
self.listOperationsMSC = listOperationsMSC
self.listFlightTracks = listFlightTracks
Expand Down Expand Up @@ -196,8 +198,11 @@ def login(self, url, token):
self.connect_mscolab_server()

def connect_mscolab_server(self):
if self.active_op_id is not None:
self.deactivate_all_flighttracks()
self.operations = MultipleFlightpathOperations(self, self.mscolab_server_url, self.token,
self.list_operation_track,
self.active_op_id,
self.listOperationsMSC, self.view)
self.obb.append(self.operations)

Expand Down Expand Up @@ -510,10 +515,10 @@ class MultipleFlightpathOperations:
on the TopView canvas.
"""

def __init__(self, parent, mscolab_server_url, token, list_operation_track, listOperationsMSC, view):
def __init__(self, parent, mscolab_server_url, token, list_operation_track, active_op_id, listOperationsMSC, view):
# Variables related to Mscolab Operations
self.parent = parent
self.active_op_id = None
self.active_op_id = active_op_id
self.mscolab_server_url = mscolab_server_url
self.token = token
self.view = view
Expand Down
6 changes: 5 additions & 1 deletion mslib/msui/topview.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ def __init__(self, parent=None, mainwindow=None, model=None, _id=None,
# Dock windows [WMS, Satellite, Trajectories, Remote Sensing, KML Overlay, Multiple Flightpath]:
self.docks = [None, None, None, None, None, None]

# Corresponding widget objects
self.widgets = [None, None, None, None, None, None]

matrss marked this conversation as resolved.
Show resolved Hide resolved
# Initialise the GUI elements (map view, items of combo boxes etc.).
self.setup_top_view()

Expand All @@ -221,7 +224,7 @@ def __init__(self, parent=None, mainwindow=None, model=None, _id=None,
self.active_flighttrack = active_flighttrack

# Stores active mscolab operation id
self.active_op_id = None
self.active_op_id = mainwindow.mscolab.active_op_id
Copy link
Collaborator

@matrss matrss Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which situation should the topview's active_op_id be something different than the mainwindow.mscolab.active_op_id? I.e. why does the topview need a copy of this attribute, instead of always using the one from the mainwindow?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

topview won't need it. The current implementation of the multiple_flighpath_dockingwidget has no access to the mainwindow, e.g.
https://github.com/Open-MSS/MSS/blob/develop/mslib/msui/multiple_flightpath_dockwidget.py#L507
There were more vars introduced which are already known in the mainwindow https://github.com/Open-MSS/MSS/blob/develop/mslib/msui/topview.py#L204

Currently I do prefer first a kind of logic test coverage before we refactor the inner. It is somehow improving the Proof-Of-Concept before we can do the cleanup.

One of the bigger refactoring steps is to remove all the dups and focus on a better understandable API.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't the topview just hold a reference to the mainwindow then? Holding another reference to all of the mainwindow's signals is also something that feels wrong to me, and could be eliminated if the mainwindow was just accessible through the topview.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be a better solution and has to be done in a refactoring. @Jatin2020-24 did you have a reason not to do it that way?

This PR is related to fix a bug in the order for opening the dockingwidget when a mscolab operation was selected. We need a few more tests to figure that any combination for the docking widget works.

I guess there is at least one more bug which needs to be test covered and fixed.

When this part is refactored we also have to refactor tests.


# Mscolab Server Url and token
self.mscolab_server_url = mscolab_server_url
Expand Down Expand Up @@ -356,6 +359,7 @@ def openTool(self, index):
listOperationsMSC=self.mainwindow_listOperationsMSC,
category=self.mainwindow_filterCategoryCb,
activeFlightTrack=self.active_flighttrack,
active_op_id=self.active_op_id,
mscolab_server_url=self.mscolab_server_url,
token=self.token)

Expand Down
4 changes: 4 additions & 0 deletions mslib/msui/viewwindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def __init__(self, parent=None, model=None, _id=None):
# in proper size in derived classes!
self.docks = []

self.widgets = []

# # emit _id if not none
# logging.debug(_id)
# self._id = _id
Expand Down Expand Up @@ -140,6 +142,8 @@ def createDockWidget(self, index, title, widget):
# setWidget transfers the widget's ownership to Qt -- no setParent()
# call is necessary:
self.docks[index].setWidget(widget)
# store data of widget
self.widgets[index] = widget
matrss marked this conversation as resolved.
Show resolved Hide resolved
self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.docks[index])

# Check if another dock widget occupies the dock area. If yes,
Expand Down
71 changes: 71 additions & 0 deletions tests/_test_msui/test_mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,77 @@ def assert_logout_text():
qtbot.wait_until(assert_label_text)
# ToDo verify all operations disabled again without a visual check

def test_marked_bold_only_in_multiple_flight_path_operations_for_active_operation(self, qtbot):
"""
checks that when we use operations only the operations is bold marked not the flighttrack too
"""
# more operations for the user
for op_name in ["second", "third"]:
assert add_operation(op_name, "description")
assert add_user_to_operation(path=op_name, emailid=self.userdata[0])

self._connect_to_mscolab(qtbot)
modify_config_file({"MSS_auth": {self.url: self.userdata[0]}})
self._login(qtbot, emailid=self.userdata[0], password=self.userdata[2])

# test after activating operation
self._activate_operation_at_index(0)
self.window.actionTopView.trigger()

def assert_active_views():
# check 1 view opened
assert len(self.window.get_active_views()) == 1
qtbot.wait_until(assert_active_views)

topview_0 = self.window.listViews.item(0)
assert topview_0.window.tv_window_exists is True
# open multiple flightpath first window
topview_0.window.cbTools.currentIndexChanged.emit(6)

def assert_dock_loaded():
assert topview_0.window.docks[5] is not None
qtbot.wait_until(assert_dock_loaded)
assert topview_0.window.active_op_id is not None

list_flighttrack = topview_0.window.widgets[5].list_flighttrack
list_operation_track = topview_0.window.widgets[5].list_operation_track

for i in range(list_operation_track.count()):
listItem = list_operation_track.item(i)
if self.window.mscolab.active_op_id == listItem.op_id:
assert listItem.font().bold() is True
for i in range(list_flighttrack.count()):
listItem = list_flighttrack.item(i)
assert listItem.font().bold() is False

def test_correct_active_op_id_in_topview(self, qtbot):
"""
checks that active_op_id is set
"""
# more operations for the user
for op_name in ["second", "third"]:
assert add_operation(op_name, "description")
assert add_user_to_operation(path=op_name, emailid=self.userdata[0])

self._connect_to_mscolab(qtbot)
modify_config_file({"MSS_auth": {self.url: self.userdata[0]}})
self._login(qtbot, emailid=self.userdata[0], password=self.userdata[2])

assert self.window.mscolab.active_op_id is None
# test after activating operation
self._activate_operation_at_index(0)
assert self.window.mscolab.active_op_id is not None
selected_op_id = self.window.mscolab.active_op_id
self.window.actionTopView.trigger()

def assert_active_views():
# check 1 view opened
assert len(self.window.get_active_views()) == 1
qtbot.wait_until(assert_active_views)
topview_0 = self.window.listViews.item(0)
assert topview_0.window.active_op_id is not None
assert topview_0.window.active_op_id == selected_op_id

def test_multiple_flightpath_switching_to_flighttrack_and_logout(self, qtbot):
"""
checks that we can switch in topviews with the multiple flightpath dockingwidget
Expand Down
Loading