From 6b2b3df6e955d16faf7195e5c6886768bdef6a05 Mon Sep 17 00:00:00 2001 From: Benedikt Seeger <benedikt.seeger@ptb.de> Date: Wed, 24 Jan 2024 11:59:06 +0100 Subject: [PATCH] added Issue Creation function --- issue.md | 20 +++++++++++--------- main.py | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/issue.md b/issue.md index f9e0ba7..d3fdd59 100644 --- a/issue.md +++ b/issue.md @@ -1,19 +1,21 @@ There was an issue with the following unit conversion: -- Left unit: {} -- Right unit: {} +| Which unit | User entered input | Parsed input | +| ---------- | ------------------ | ------------ | +| Left unit | {} | {} | +| Right unit | {} | {} | ### Result/Expectation: | Calculation | Result | Expectation | Did match | |-------------|--------|-------------|-----------| -| Base unit | {} | | [] | -| factor * left = right | {} | | [] | -| factor * right = left | {} | | [] | -| factor * left = base | {} | | [] | -| factor * base = left | {} | | [] | -| factor * right = base | {} | | [] | -| factor * base = right | {} | | [] | +| Base unit | {} | | [ ] | +| factor * left = right | {} | | [ ] | +| factor * right = left | {} | | [ ] | +| factor * left = base | {} | | [ ] | +| factor * base = left | {} | | [ ] | +| factor * right = base | {} | | [ ] | +| factor * base = right | {} | | [ ] | If there was an error with the calculation, please fill out the table above. Feel free to also add additional info here: diff --git a/main.py b/main.py index 6b72452..4e8d658 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,7 @@ import warnings import itertools import math import bokehCssPTB +from urllib.parse import quote from dsiParser import dsiParser from bokeh.plotting import curdoc,figure from bokeh.layouts import column, row @@ -190,6 +191,10 @@ class page(): curdoc().add_root(self.compareRow) self.dsiCompGraphGen=dsiCompGraphGen(self.dsiInput1,self.dsiInput2) curdoc().add_root(self.dsiCompGraphGen.widget) + self.createIssueButton = Button(label="Report conversion error", disabled=True) + # self.createIssueButton.on_click(self.createIssueUrl) + curdoc().add_root(self.dsiCompGraphGen.widget) + curdoc().add_root(self.createIssueButton) def compare(self): self.dsiInput1.parseInput() @@ -211,4 +216,21 @@ class page(): self.compaReresult.text = "The two units are not equal" self.compaReresult.css_classes = ["msg-negative"] self.dsiCompGraphGen.flush() + self.createIssueButton.disabled=False + self.createIssueButton.button_type="danger" + self.createIssueButton.js_on_event("button_click",CustomJS(code=f"window.open('{self.createIssueUrl()}', '_blank');")) + + def createIssueUrl(self): + quantitiesToAdd=[self.dsiInput1.dsiInput.value,str(self.dsiInput1.dsiTree),self.dsiInput2.dsiInput.value,str(self.dsiInput2.dsiTree),str(self.dsiCompGraphGen.baseUnit),self.dsiCompGraphGen.scalfactorAB,self.dsiCompGraphGen.scalfactorBA,self.dsiCompGraphGen.scalfactorABase,self.dsiCompGraphGen.scalfactorBaseA,self.dsiCompGraphGen.scalfactorBBase,self.dsiCompGraphGen.scalfactorBaseB] + templateStr=open('./issue.md').read() + filledResult=templateStr.format(*quantitiesToAdd) + filledTitle = f'Unexpected comparison result: {self.dsiInput1.dsiInput.value} to {self.dsiInput2.dsiInput.value}' + issueUrl = r'https://gitlab1.ptb.de/digitaldynamicmeasurement/dsi-parser-frontend/-/issues/new?' + title = quote(filledTitle) + body = quote(filledResult) + + url = issueUrl + 'issue[title]=' + title + '&issue[description]=' + body + + return url + thisPage = page() -- GitLab