Skip to content

Commit

Permalink
Add dropdown menu for server templates (#210)
Browse files Browse the repository at this point in the history
* Add dropdown menu for server templates

* ruff

---------

Co-authored-by: Staiger, Christine <christine.staiger@wur.nl>
  • Loading branch information
chStaiger and Staiger, Christine committed Jun 26, 2024
1 parent 49aea96 commit ffbfca5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
27 changes: 27 additions & 0 deletions ibridgesgui/popup_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import irods
from ibridges import IrodsPath
from ibridges.util import find_environment_provider, get_environment_providers
from PyQt6 import QtCore
from PyQt6.QtWidgets import QDialog, QFileDialog
from PyQt6.uic import loadUi
Expand Down Expand Up @@ -140,8 +141,10 @@ def __init__(self, logger, env_path):
self.env_path = env_path
self.setWindowTitle("Create, edit and inspect iRODS environment")
self._init_env_box()
self._init_template_box()

self.envbox.activated.connect(self.load_env)
self.template_box.activated.connect(self.load_template)
self.new_button.clicked.connect(self.create_env)
self.check_button.clicked.connect(self.check_env)
self.save_button.clicked.connect(self.save_env)
Expand All @@ -155,6 +158,30 @@ def _init_env_box(self):
self.envbox.addItems(env_jsons)
self.envbox.setCurrentIndex(0)

def _init_template_box(self):
self.template_box.clear()
providers = get_environment_providers()

if len(providers) == 0:
self.template_box.hide()
return

templates = [key+": "+descr for p in providers
for key, descr in p.descriptions.items()]
if len(templates) > 0:
self.template_box.addItems(templates)
self.template_box.setCurrentIndex(0)

def load_template(self):
"""Load environment template into text field."""
self.error_label.clear()
template = self.template_box.currentText()
key = template.split(": ")[0]
env_json = find_environment_provider(get_environment_providers(), key).\
environment_json(key, "USERNAME").split("\n")
populate_textfield(self.env_field, env_json)
self.error_label.setText("Please fill in your user name.")

def load_env(self):
"""Load json into text field."""
self.error_label.clear()
Expand Down
11 changes: 8 additions & 3 deletions ibridgesgui/ui_files/configCheck.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Form implementation generated from reading ui file 'ibridgesgui/ui_files/configCheck.ui'
#
# Created by: PyQt6 UI code generator 6.6.1
# Created by: PyQt6 UI code generator 6.4.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.


from PyQt6 import QtCore, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets


class Ui_configCheck(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(1034, 429)
Dialog.resize(1034, 373)
Dialog.setStyleSheet("QWidget\n"
"{\n"
" background-color: rgb(211,211,211);\n"
Expand Down Expand Up @@ -56,6 +56,10 @@ def setupUi(self, Dialog):
self.envbox = QtWidgets.QComboBox(parent=Dialog)
self.envbox.setObjectName("envbox")
self.horizontalLayout.addWidget(self.envbox)
self.template_box = QtWidgets.QComboBox(parent=Dialog)
self.template_box.setObjectName("template_box")
self.template_box.addItem("")
self.horizontalLayout.addWidget(self.template_box)
self.new_button = QtWidgets.QPushButton(parent=Dialog)
self.new_button.setObjectName("new_button")
self.horizontalLayout.addWidget(self.new_button)
Expand Down Expand Up @@ -101,6 +105,7 @@ def setupUi(self, Dialog):
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.template_box.setItemText(0, _translate("Dialog", "Server Templates"))
self.new_button.setText(_translate("Dialog", "New Config"))
self.check_button.setText(_translate("Dialog", "Check"))
self.save_button.setText(_translate("Dialog", "Save"))
Expand Down
11 changes: 10 additions & 1 deletion ibridgesgui/ui_files/configCheck.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1034</width>
<height>429</height>
<height>373</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -57,6 +57,15 @@ QTabWidget#info_tabs
<item>
<widget class="QComboBox" name="envbox"/>
</item>
<item>
<widget class="QComboBox" name="template_box">
<item>
<property name="text">
<string>Server Templates</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QPushButton" name="new_button">
<property name="text">
Expand Down

0 comments on commit ffbfca5

Please sign in to comment.