Skip to content

Commit

Permalink
Better visibility for creator of an operation.
Browse files Browse the repository at this point in the history
Fix #1933
  • Loading branch information
joernu76 committed Aug 24, 2023
1 parent 0e2073e commit 1a97f74
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 46 deletions.
24 changes: 19 additions & 5 deletions mslib/msui/mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,7 @@ def __init__(self, parent=None, data_dir=None):
self.ui.actionChangeDescription.triggered.connect(self.change_description_handler)
self.ui.actionRenameOperation.triggered.connect(self.rename_operation_handler)
self.ui.actionArchiveOperation.triggered.connect(self.archive_operation)
self.ui.actionViewDescription.triggered.connect(
lambda: QtWidgets.QMessageBox.information(
None, "Operation Description",
f"Category: {self.active_operation_category}\n"
f"{self.active_operation_description}"))
self.ui.actionViewDescription.triggered.connect(self.view_description)

self.ui.filterCategoryCb.currentIndexChanged.connect(self.operation_category_handler)
# connect slot for handling operation options combobox
Expand Down Expand Up @@ -519,6 +515,24 @@ def __init__(self, parent=None, data_dir=None):
self.data_dir = data_dir
self.create_dir()

def view_description(self):
data = {
"token": self.token,
"op_id": self.active_op_id
}
url = urljoin(self.mscolab_server_url, "/creator_of_operation")
r = requests.get(url, data=data, timeout=tuple(config_loader(dataset="MSCOLAB_timeout")))
creator_name = "unknown"
if r.text != "False":
_json = json.loads(r.text)
creator_name = _json["username"]
QtWidgets.QMessageBox.information(
None, "Operation Description",
f"<html>Creator: <b>{creator_name}</b><p>"
f"Category: <b>{self.active_operation_category}</b><p>"
"<p>"
f"{self.active_operation_description}</html>")

def open_operation_archive(self):
self.operation_archive_browser.show()

Expand Down
3 changes: 2 additions & 1 deletion mslib/msui/mscolab_admin_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ def set_label_text(self):
if r.text != "False":
_json = json.loads(r.text)
creator_name = _json["username"]
self.operationNameLabel.setText(f"Operation: {self.operation_name} by User: {creator_name}")
self.operationNameLabel.setText(f"Operation: {self.operation_name}")
self.creatorNameLabel.setText(f"Creator: {creator_name}")
self.usernameLabel.setText(f"Logged In: {self.user['username']}")

def load_import_operations(self):
Expand Down
23 changes: 11 additions & 12 deletions mslib/msui/qt5/ui_mscolab_admin_window.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'ui_mscolab_admin_window.ui'
# Form implementation generated from reading ui file 'mslib/msui/ui/ui_mscolab_admin_window.ui'
#
# Created by: PyQt5 UI code generator 5.12.3
# Created by: PyQt5 UI code generator 5.15.7
#
# WARNING! All changes made in this file will be lost!
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
Expand All @@ -25,18 +26,15 @@ def setupUi(self, MscolabAdminWindow):
self.horizontalLayout_6.setObjectName("horizontalLayout_6")
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.horizontalLayout_7 = QtWidgets.QHBoxLayout()
self.horizontalLayout_7.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint)
self.horizontalLayout_7.setContentsMargins(0, 8, -1, 8)
self.horizontalLayout_7.setSpacing(6)
self.horizontalLayout_7.setObjectName("horizontalLayout_7")
self.usernameLabel = QtWidgets.QLabel(self.centralwidget)
self.usernameLabel.setObjectName("usernameLabel")
self.horizontalLayout_7.addWidget(self.usernameLabel)
self.verticalLayout.addWidget(self.usernameLabel)
self.operationNameLabel = QtWidgets.QLabel(self.centralwidget)
self.operationNameLabel.setObjectName("operationNameLabel")
self.horizontalLayout_7.addWidget(self.operationNameLabel)
self.verticalLayout.addLayout(self.horizontalLayout_7)
self.verticalLayout.addWidget(self.operationNameLabel)
self.creatorNameLabel = QtWidgets.QLabel(self.centralwidget)
self.creatorNameLabel.setObjectName("creatorNameLabel")
self.verticalLayout.addWidget(self.creatorNameLabel)
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setObjectName("label")
self.verticalLayout.addWidget(self.label)
Expand Down Expand Up @@ -180,14 +178,15 @@ def setupUi(self, MscolabAdminWindow):
MscolabAdminWindow.addAction(self.actionCloseWindow)

self.retranslateUi(MscolabAdminWindow)
self.actionCloseWindow.triggered.connect(MscolabAdminWindow.close)
self.actionCloseWindow.triggered.connect(MscolabAdminWindow.close) # type: ignore
QtCore.QMetaObject.connectSlotsByName(MscolabAdminWindow)

def retranslateUi(self, MscolabAdminWindow):
_translate = QtCore.QCoreApplication.translate
MscolabAdminWindow.setWindowTitle(_translate("MscolabAdminWindow", "Manage Users"))
self.usernameLabel.setText(_translate("MscolabAdminWindow", "Logged In: "))
self.operationNameLabel.setText(_translate("MscolabAdminWindow", "Operation: "))
self.creatorNameLabel.setText(_translate("MscolabAdminWindow", "Creator:"))
self.label.setText(_translate("MscolabAdminWindow", "All Users Without Permission:"))
self.addUsersSearch.setPlaceholderText(_translate("MscolabAdminWindow", "Search User"))
self.selectAllAddBtn.setText(_translate("MscolabAdminWindow", "Select All"))
Expand Down
44 changes: 16 additions & 28 deletions mslib/msui/ui/ui_mscolab_admin_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,25 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7" stretch="0,0">
<property name="spacing">
<number>6</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
<widget class="QLabel" name="usernameLabel">
<property name="text">
<string>Logged In: </string>
</property>
<property name="topMargin">
<number>8</number>
</widget>
</item>
<item>
<widget class="QLabel" name="operationNameLabel">
<property name="text">
<string>Operation: </string>
</property>
<property name="bottomMargin">
<number>8</number>
</widget>
</item>
<item>
<widget class="QLabel" name="creatorNameLabel">
<property name="text">
<string>Creator:</string>
</property>
<item>
<widget class="QLabel" name="usernameLabel">
<property name="text">
<string>Logged In: </string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="operationNameLabel">
<property name="text">
<string>Operation: </string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
Expand Down

0 comments on commit 1a97f74

Please sign in to comment.