Skip to content
Snippets Groups Projects
Commit c1ba6f13 authored by Benedikt's avatar Benedikt
Browse files

added second unit filds and compare option

parent 03ddfdae
No related branches found
No related tags found
No related merge requests found
...@@ -13,11 +13,10 @@ ENV no_proxy="ptb.de" ...@@ -13,11 +13,10 @@ ENV no_proxy="ptb.de"
# Install any needed packages specified in requirements.txt # Install any needed packages specified in requirements.txt
RUN git clone https://dockerPull:Fu7bxBnYeyhq8Xz8seHS@gitlab1.ptb.de/digitaldynamicmeasurement/dsi-parser-frontend RUN git clone https://dockerPull:Fu7bxBnYeyhq8Xz8seHS@gitlab1.ptb.de/digitaldynamicmeasurement/dsi-parser-frontend
RUN pip install --proxy=webproxy.bs.ptb.de:8080 --no-cache-dir -r dsi-parser-frontend/requirements.txt #RUN pip install --proxy=webproxy.bs.ptb.de:8080 --no-cache-dir -r dsi-parser-frontend/requirements.txt
# RUN pip install --no-cache-dir -r dsi-parser-frontend/requirements.txt RUN pip install --no-cache-dir -r dsi-parser-frontend/requirements.txt
#COPY . .
EXPOSE 5020 EXPOSE 5020
#WORKDIR ./pydccdisplayer/src
CMD ["bokeh", "serve", "dsi-parser-frontend/", "--port", "5020", "--allow-websocket-origin", "*","--use-xheaders","--prefix","dsi-parser-frontend"] CMD ["bokeh", "serve", "dsi-parser-frontend/", "--port", "5020", "--allow-websocket-origin", "*","--use-xheaders","--prefix","dsi-parser-frontend"]
...@@ -11,30 +11,23 @@ from bokeh.models import FileInput, Div, CustomJS, Button, TabPanel, Tabs, Dropd ...@@ -11,30 +11,23 @@ from bokeh.models import FileInput, Div, CustomJS, Button, TabPanel, Tabs, Dropd
from bokeh.events import ValueSubmit from bokeh.events import ValueSubmit
VERSION = "0.1.0" VERSION = "0.1.0"
class dsiparserInput():
class page():
def __init__(self): def __init__(self):
curdoc().template_variables["VERSION"] = VERSION
curdoc().title = "DSI to Latex"
curdoc().add_root(bokehCssPTB.getStyleDiv())
curdoc().theme = bokehCssPTB.getTheme()
self.dsiInput = TextInput(value="", title="DSI unit string:", width=500) self.dsiInput = TextInput(value="", title="DSI unit string:", width=500)
self.dsiInput.on_event(ValueSubmit, self.parseInput) self.dsiInput.on_event(ValueSubmit, self.parseInput)
self.dsiSubmitButton = Button(label="Convert", button_type="primary") self.dsiSubmitButton = Button(label="Convert", button_type="primary")
self.dsiSubmitButton.on_click(self.parseInput) self.dsiSubmitButton.on_click(self.parseInput)
self.inputRow = row(children = [self.dsiInput, self.dsiSubmitButton], css_classes = ["textInputRow"]) self.inputRow = row(children = [self.dsiInput, self.dsiSubmitButton], css_classes = ["textInputRow"])
self.results = column(children = []) self.results = column(children = [])
self.widget = column(children=[self.inputRow, self.results], css_classes=["textlikeColumn"])
self.layoutColumn = column(children = [self.inputRow, self.results], css_classes = ["textlikeColumn"])
curdoc().add_root(self.layoutColumn)
def parseInput(self): def parseInput(self):
self.results.children = [] self.results.children = []
input = self.dsiInput.value input = self.dsiInput.value
p = dsiParser() p = dsiParser()
resultTree = p.parse(input) resultTree = p.parse(input)
parsingMessages = [] parsingMessages = []
if resultTree.valid: if resultTree.valid:
parsingMessages.append( parsingMessages.append(
...@@ -74,5 +67,33 @@ class page(): ...@@ -74,5 +67,33 @@ class page():
p p
], css_classes = ["latexImageRow"]) ], css_classes = ["latexImageRow"])
self.results.children = [self.resultErrors, latexOutput, imageOutput] self.results.children = [self.resultErrors, latexOutput, imageOutput]
self.dsiTree = resultTree
class page():
def __init__(self):
curdoc().template_variables["VERSION"] = VERSION
curdoc().title = "DSI to Latex"
curdoc().add_root(bokehCssPTB.getStyleDiv())
curdoc().theme = bokehCssPTB.getTheme()
self.dsiInput1 = dsiparserInput()
self.dsiInput2 = dsiparserInput()
self.inputs=row([self.dsiInput1.widget, self.dsiInput2.widget])
curdoc().add_root(self.inputs)
self.comapreButton = Button(label="Compare", button_type="primary")
self.comapreButton.on_click(self.compare)
self.compaReresult = Div(text = "", css_classes = ["msg-positive"])
self.compareRow = row(children = [self.comapreButton,self.compaReresult], css_classes = ["textInputRow"])
curdoc().add_root(self.compareRow)
def compare(self):
self.dsiInput1.parseInput()
self.dsiInput2.parseInput()
scalfactor,baseUnit=self.dsiInput1.dsiTree.isScalablyEqualTo(self.dsiInput2.dsiTree)
if scalfactor:
self.compaReresult.text = "The two units are equal up to a scaling factor of "+str(scalfactor)+" and a base unit of "+str(baseUnit)
self.compaReresult.css_classes=["msg-positive"]
else:
self.compaReresult.text = "The two units are not equal"
self.compaReresult.css_classes = ["msg-negative"]
thisPage = page() thisPage = page()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment