Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DSI Parser Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DigitalDynamicMeasurement
DSI Parser Frontend
Commits
e154d6e7
Commit
e154d6e7
authored
1 year ago
by
Benedikt
Browse files
Options
Downloads
Patches
Plain Diff
fixes
#4
parent
64c92fc1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+28
-5
28 additions, 5 deletions
main.py
with
28 additions
and
5 deletions
main.py
+
28
−
5
View file @
e154d6e7
...
@@ -41,7 +41,8 @@ If there was an error with the calculation, please fill out the table above. Fee
...
@@ -41,7 +41,8 @@ If there was an error with the calculation, please fill out the table above. Fee
*Free text comment*
"""
*Free text comment*
"""
class
dsiparserInput
():
class
dsiparserInput
():
def
__init__
(
self
,
defaultInput
=
""
):
def
__init__
(
self
,
defaultInput
=
""
,
additionalComparisonCallbacks
=
[]):
self
.
additionalComparisonCallbacks
=
additionalComparisonCallbacks
self
.
dsiInput
=
TextInput
(
value
=
defaultInput
,
title
=
"
DSI unit string:
"
,
width
=
500
)
self
.
dsiInput
=
TextInput
(
value
=
defaultInput
,
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
"
)
...
@@ -50,7 +51,12 @@ class dsiparserInput():
...
@@ -50,7 +51,12 @@ class dsiparserInput():
self
.
results
=
column
(
children
=
[])
self
.
results
=
column
(
children
=
[])
self
.
widget
=
column
(
children
=
[
self
.
inputRow
,
self
.
results
],
css_classes
=
[
"
doubleColumn
"
])
self
.
widget
=
column
(
children
=
[
self
.
inputRow
,
self
.
results
],
css_classes
=
[
"
doubleColumn
"
])
self
.
valideUnit
=
False
self
.
valideUnit
=
False
self
.
dsiTree
=
None
def
parseInpuitWithCallbacls
(
self
):
self
.
parseInput
()
for
callback
in
self
.
additionalComparisonCallbacks
:
callback
()
def
parseInput
(
self
):
def
parseInput
(
self
):
self
.
results
.
children
=
[]
self
.
results
.
children
=
[]
input
=
self
.
dsiInput
.
value
input
=
self
.
dsiInput
.
value
...
@@ -202,8 +208,8 @@ class page():
...
@@ -202,8 +208,8 @@ class page():
curdoc
().
title
=
"
DSI to Latex
"
curdoc
().
title
=
"
DSI to Latex
"
curdoc
().
add_root
(
bokehCssPTB
.
getStyleDiv
())
curdoc
().
add_root
(
bokehCssPTB
.
getStyleDiv
())
curdoc
().
theme
=
bokehCssPTB
.
getTheme
()
curdoc
().
theme
=
bokehCssPTB
.
getTheme
()
self
.
dsiInput1
=
dsiparserInput
(
defaultInput
=
"
\\
milli
\\
newton
\\
metre
"
)
self
.
dsiInput1
=
dsiparserInput
(
defaultInput
=
"
\\
milli
\\
newton
\\
metre
"
,
additionalComparisonCallbacks
=
[
self
.
clearComparison
,
self
.
tryComparison
]
)
self
.
dsiInput2
=
dsiparserInput
(
defaultInput
=
"
\\
kilo
\\
joule
"
)
self
.
dsiInput2
=
dsiparserInput
(
defaultInput
=
"
\\
kilo
\\
joule
"
,
additionalComparisonCallbacks
=
[
self
.
clearComparison
,
self
.
tryComparison
]
)
self
.
inputs
=
row
([
self
.
dsiInput1
.
widget
,
self
.
dsiInput2
.
widget
])
self
.
inputs
=
row
([
self
.
dsiInput1
.
widget
,
self
.
dsiInput2
.
widget
])
curdoc
().
add_root
(
self
.
inputs
)
curdoc
().
add_root
(
self
.
inputs
)
...
@@ -244,9 +250,16 @@ class page():
...
@@ -244,9 +250,16 @@ class page():
self
.
createIssueButton
.
js_on_event
(
"
button_click
"
,
CustomJS
(
code
=
f
"
window.open(
'
{
self
.
createIssueUrl
()
}
'
,
'
_blank
'
);
"
))
self
.
createIssueButton
.
js_on_event
(
"
button_click
"
,
CustomJS
(
code
=
f
"
window.open(
'
{
self
.
createIssueUrl
()
}
'
,
'
_blank
'
);
"
))
def
createIssueUrl
(
self
):
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
]
issueArgs
=
[
self
.
dsiInput1
.
dsiInput
.
value
,
str
(
self
.
dsiInput1
.
dsiTree
),
self
.
dsiInput2
.
dsiInput
.
value
,
str
(
self
.
dsiInput2
.
dsiTree
)]
comGenAtrssFroIssue
=
[
'
baseUnit
'
,
'
scalfactorAB
'
,
'
scalfactorBA
'
,
'
scalfactorABase
'
,
'
scalfactorBaseA
'
,
'
scalfactorBBase
'
,
'
scalfactorBaseB
'
]
for
comGenAtrss
in
comGenAtrssFroIssue
:
try
:
issueArgs
.
append
(
str
(
getattr
(
self
.
dsiCompGraphGen
,
comGenAtrss
)))
except
AttributeError
as
Ae
:
issueArgs
.
append
(
"
AttributeError:
"
+
str
(
Ae
))
#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]
#issueTemplate=open('./issue.md').read() #TODO add file inculde instead of the str....
#issueTemplate=open('./issue.md').read() #TODO add file inculde instead of the str....
filledResult
=
issueTemplate
.
format
(
*
quantitiesToAdd
)
filledResult
=
issueTemplate
.
format
(
*
issueArgs
)
filledTitle
=
f
'
Unexpected comparison result:
{
self
.
dsiInput1
.
dsiInput
.
value
}
to
{
self
.
dsiInput2
.
dsiInput
.
value
}
'
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?
'
issueUrl
=
r
'
https://gitlab1.ptb.de/digitaldynamicmeasurement/dsi-parser-frontend/-/issues/new?
'
title
=
quote
(
filledTitle
)
title
=
quote
(
filledTitle
)
...
@@ -256,4 +269,14 @@ class page():
...
@@ -256,4 +269,14 @@ class page():
return
url
return
url
def
clearComparison
(
self
):
self
.
dsiCompGraphGen
.
flush
()
self
.
compaReresult
.
text
=
""
self
.
createIssueButton
.
disabled
=
True
self
.
createIssueButton
.
button_type
=
"
primary
"
def
tryComparison
(
self
):
if
self
.
dsiInput1
.
valideUnit
and
self
.
dsiInput2
.
valideUnit
:
self
.
compare
()
thisPage
=
page
()
thisPage
=
page
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment