Various bug fixes

This commit is contained in:
Landon Wark
2024-03-07 14:26:29 -06:00
parent b466cb61d2
commit d0418ebc9e
7 changed files with 80 additions and 37 deletions

View File

@@ -44,9 +44,11 @@ class GelBox(QDialog):
pg.setConfigOptions(antialias=True)
# creating image view object
self.imv = pg.ImageView()
img = np.array(Image.open(self.img_path).rotate(-90).transpose(Image.FLIP_LEFT_RIGHT))
self.imv.setImage(img, scale=None)#, xvals=np.linspace(1., 3., data.shape[0]))
# Create image.
# For some reason, ImageView wants to flip the image, so we have to rotate and flip the array first.
# Using the Image.rotate function results in cropped image.
img = np.flip(np.rot90(np.array(Image.open(self.img_path)),1),0)
self.imv.setImage(img)
layout = QGridLayout()
layout.addWidget(QLabel("DNA Core Submission Number"),0,1)
self.core_number = QLineEdit()

View File

@@ -37,21 +37,21 @@ class SubmissionDetails(QDialog):
# create scrollable interior
interior = QScrollArea()
interior.setParent(self)
self.base_dict = sub.to_dict(full_data=True)
logger.debug(f"Submission details data:\n{pformat({k:v for k,v in self.base_dict.items() if k != 'samples'})}")
# don't want id
del self.base_dict['id']
logger.debug(f"Creating barcode.")
if not check_if_app():
self.base_dict['barcode'] = base64.b64encode(sub.make_plate_barcode(width=120, height=30)).decode('utf-8')
logger.debug(f"Making platemap...")
self.base_dict['platemap'] = sub.make_plate_map()
self.base_dict, self.template = sub.get_details_template(base_dict=self.base_dict)
self.html = self.template.render(sub=self.base_dict)
# self.base_dict = sub.to_dict(full_data=True)
# logger.debug(f"Submission details data:\n{pformat({k:v for k,v in self.base_dict.items() if k != 'samples'})}")
# # don't want id
# del self.base_dict['id']
# logger.debug(f"Creating barcode.")
# if not check_if_app():
# self.base_dict['barcode'] = base64.b64encode(sub.make_plate_barcode(width=120, height=30)).decode('utf-8')
# logger.debug(f"Making platemap...")
# self.base_dict['platemap'] = sub.make_plate_map()
# self.base_dict, self.template = sub.get_details_template(base_dict=self.base_dict)
# self.html = self.template.render(sub=self.base_dict)
self.webview = QWebEngineView(parent=self)
self.webview.setMinimumSize(900, 500)
self.webview.setMaximumSize(900, 500)
self.webview.setHtml(self.html)
# self.webview.setHtml(self.html)
self.layout = QVBoxLayout()
interior.resize(900, 500)
interior.setWidget(self.webview)
@@ -64,18 +64,46 @@ class SubmissionDetails(QDialog):
# setup channel
self.channel = QWebChannel()
self.channel.registerObject('backend', self)
self.submission_details(submission=sub)
self.webview.page().setWebChannel(self.channel)
@pyqtSlot(str)
def sample_details(self, sample):
# print(f"{string} is in row {row}, column {column}")
# self.webview.setHtml(f"<html><body><br><br>{sample}</body></html>")
def sample_details(self, sample:str):
"""
Changes details view to summary of Sample
Args:
sample (str): Submitter Id of the sample.
"""
sample = BasicSample.query(submitter_id=sample)
base_dict = sample.to_sub_dict(full_data=True)
base_dict, template = sample.get_details_template(base_dict=base_dict)
html = template.render(sample=base_dict)
self.webview.setHtml(html)
# sample.show_details(obj=self)
@pyqtSlot(str)
def submission_details(self, submission:str|BasicSubmission):
"""
Sets details view to summary of Submission.
Args:
submission (str | BasicSubmission): Submission of interest.
"""
logger.debug(f"Details for: {submission}")
if isinstance(submission, str):
submission = BasicSubmission.query(rsl_number=submission)
self.base_dict = submission.to_dict(full_data=True)
logger.debug(f"Submission details data:\n{pformat({k:v for k,v in self.base_dict.items() if k != 'samples'})}")
# don't want id
del self.base_dict['id']
logger.debug(f"Creating barcode.")
if not check_if_app():
self.base_dict['barcode'] = base64.b64encode(submission.make_plate_barcode(width=120, height=30)).decode('utf-8')
logger.debug(f"Making platemap...")
self.base_dict['platemap'] = submission.make_plate_map()
self.base_dict, self.template = submission.get_details_template(base_dict=self.base_dict)
self.html = self.template.render(sub=self.base_dict)
self.webview.setHtml(self.html)
def export(self):
"""

View File

@@ -395,7 +395,7 @@ class SubmissionFormWidget(QWidget):
def __init__(self, parent: QWidget, **kwargs) -> None:
super().__init__(parent)
self.ignore = ['filepath', 'samples', 'reagents', 'csv', 'ctx', 'comment', 'equipment']
self.ignore = ['filepath', 'samples', 'reagents', 'csv', 'ctx', 'comment', 'equipment', 'source_plates']
self.recover = ['filepath', 'samples', 'csv', 'comment', 'equipment']
layout = QVBoxLayout()
for k, v in kwargs.items():