Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
motion-grammar-example
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
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
JastAdd
motion-grammar-example
Commits
90924087
Commit
90924087
authored
2 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
update dashboard to single image only
parent
17850c96
No related branches found
No related tags found
1 merge request
!1
festival updatesfestival updatesfestival updatesfestival updatesfestival
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dashboard/src/App.css
+3
-0
3 additions, 0 deletions
dashboard/src/App.css
dashboard/src/App.js
+42
-46
42 additions, 46 deletions
dashboard/src/App.js
dashboard/src/mgSlice.js
+15
-15
15 additions, 15 deletions
dashboard/src/mgSlice.js
with
60 additions
and
61 deletions
dashboard/src/App.css
+
3
−
0
View file @
90924087
...
@@ -26,7 +26,10 @@
...
@@ -26,7 +26,10 @@
}
}
.CurrentAst
{
.CurrentAst
{
height
:
50vh
;
width
:
100vw
;
width
:
100vw
;
object-fit
:
cover
;
object-position
:
right
;
}
}
.AstInTimeline
{
.AstInTimeline
{
...
...
This diff is collapsed.
Click to expand it.
dashboard/src/App.js
+
42
−
46
View file @
90924087
import
'
./App.css
'
;
import
'
./App.css
'
;
import
React
,
{
useEffect
,
useRef
}
from
'
react
'
;
import
React
,
{
useEffect
,
useRef
}
from
'
react
'
;
import
'
./index.css
'
;
import
'
./index.css
'
;
import
{
VerticalTimeline
,
VerticalTimelineElement
}
from
'
react-vertical-timeline-component
'
;
import
'
react-vertical-timeline-component/style.min.css
'
;
import
'
react-vertical-timeline-component/style.min.css
'
;
import
{
GiFamilyTree
}
from
"
react-icons/gi
"
;
import
{
useSelector
,
useDispatch
}
from
'
react-redux
'
import
{
useSelector
,
useDispatch
}
from
'
react-redux
'
import
{
add
Ast
,
set
AstLis
t
}
from
'
./mgSlice
'
import
{
set
Ast
,
set
Contex
t
}
from
'
./mgSlice
'
function
App
()
{
function
App
()
{
const
ws
=
useRef
(
null
);
const
ws
=
useRef
(
null
);
const
dispatch
=
useDispatch
();
const
dispatch
=
useDispatch
();
const
asts
=
useSelector
(
state
=>
state
.
mg
.
asts
);
const
ast
=
useSelector
(
state
=>
state
.
mg
.
ast
);
const
context
=
useSelector
(
state
=>
state
.
mg
.
context
);
useEffect
(()
=>
{
useEffect
(()
=>
{
ws
.
current
=
new
WebSocket
(
"
ws://localhost:7070/ast-events
"
);
ws
.
current
=
new
WebSocket
(
"
ws://localhost:7070/ast-events
"
);
...
@@ -20,8 +19,10 @@ function App() {
...
@@ -20,8 +19,10 @@ function App() {
ws
.
current
.
onmessage
=
(
event
)
=>
{
ws
.
current
.
onmessage
=
(
event
)
=>
{
const
json
=
JSON
.
parse
(
event
.
data
);
const
json
=
JSON
.
parse
(
event
.
data
);
try
{
try
{
if
((
json
.
event
=
"
data
"
))
{
if
(
json
.
type
===
"
ast
"
)
{
dispatch
(
addAst
(
json
));
dispatch
(
setAst
(
json
));
}
else
if
(
json
.
type
===
"
context
"
)
{
dispatch
(
setContext
(
json
));
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
);
console
.
log
(
err
);
...
@@ -36,51 +37,47 @@ function App() {
...
@@ -36,51 +37,47 @@ function App() {
},
[
dispatch
]);
},
[
dispatch
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
asts
.
length
===
0
)
{
if
(
ast
.
diagram
==
null
)
{
fetch
(
'
http://localhost:7070/asts/
'
)
console
.
log
(
"
setting ast from WS 1
"
);
fetch
(
'
http://localhost:7070/ast/
'
)
.
then
(
res
=>
res
.
json
())
.
then
(
res
=>
res
.
json
())
.
then
((
asts
)
=>
{
.
then
((
ast
)
=>
{
dispatch
(
setAstList
(
asts
))
console
.
log
(
"
setting ast from WS
"
);
console
.
log
(
ast
);
dispatch
(
setAst
(
ast
))
})
})
.
catch
(
console
.
log
)
.
catch
(
console
.
log
)
}
}
},
[
dispatch
,
asts
.
length
])
if
(
context
.
diagram
==
null
)
{
console
.
log
(
"
setting ctx from WS
"
);
fetch
(
'
http://localhost:7070/context/
'
)
.
then
(
res
=>
res
.
json
())
.
then
((
context
)
=>
{
dispatch
(
setContext
(
context
))
})
.
catch
(
console
.
log
)
}
else
{
console
.
log
(
context
)
}
},
[
dispatch
,
ast
,
context
])
return
(
return
(
<
div
className
=
"
App
"
>
<
div
className
=
"
App
"
>
<
header
className
=
"
App-header
"
>
<
header
className
=
"
App-header
"
>
<
ControlPanel
/>
<
ControlPanel
ws
=
{
ws
}
/
>
<
/header
>
<
/header
>
<
main
>
<
main
>
<
CurrentState
<
CurrentState
diagram
=
{
asts
[
0
]
?
asts
[
0
].
diagram
:
''
}
diagram
=
{
context
?
context
.
diagram
:
''
}
label
=
{
asts
[
0
]
?
asts
[
0
].
parseRule
:
''
}
label
=
''
/>
<
CurrentState
diagram
=
{
ast
?
ast
.
diagram
:
''
}
label
=
{
ast
?
ast
.
parseRule
:
''
}
/
>
/
>
<
VerticalTimeline
className
=
'
MG-Timeline
'
>
{
asts
.
map
(
v
=>
{
console
.
log
(
v
.
parseRule
)
return
(
<
VerticalTimelineElement
className
=
"
ast-timeline-event
"
contentStyle
=
{{
background
:
'
rgb(33, 150, 243)
'
,
color
:
'
#fff
'
}}
contentArrowStyle
=
{{
borderRight
:
'
7px solid rgb(33, 150, 243)
'
}}
date
=
{
new
Date
(
v
.
timestamp
).
toLocaleTimeString
(
'
en-us
'
,
{
hour12
:
false
})}
iconStyle
=
{{
background
:
'
rgb(33, 150, 243)
'
,
color
:
'
#fff
'
,
rotate
:
'
180deg
'
}}
icon
=
{
<
GiFamilyTree
/>
}
key
=
{
v
.
timestamp
}
position
=
{
'
right
'
}
>
<
h3
className
=
"
vertical-timeline-element-title
"
>
{
v
.
parseRule
}()
<
/h3
>
<
p
>
<
img
className
=
"
AstInTimeline
"
src
=
{
`data:image/svg+xml;utf8,
${
encodeURIComponent
(
v
.
diagram
)}
`
}
alt
=
{
v
.
parseRule
}
/
>
<
/p
>
<
/VerticalTimelineElement
>
)
})}
<
/VerticalTimeline
>
<
/main
>
<
/main
>
<
/div
>
<
/div
>
);
);
...
@@ -94,14 +91,13 @@ function CurrentState(props) {
...
@@ -94,14 +91,13 @@ function CurrentState(props) {
)
)
}
}
class
ControlPanel
extends
React
.
Component
{
function
ControlPanel
(
props
)
{
render
()
{
return
(
return
(
<
div
className
=
'
ControlPanel
'
>
<
div
className
=
'
ControlPanel
'
>
<
button
onClick
=
{()
=>
{
props
.
ws
.
current
.
send
(
"
parse
"
)
}}
>
start
parsing
<
/button
>
<
button
onClick
=
{()
=>
{
alert
(
'
You clicked me!
'
);
}}
>
connect
<
/button
>
<
button
onClick
=
{()
=>
{
props
.
ws
.
current
.
send
(
"
reset
"
)
}}
>
reset
selections
<
/button
>
<
/div
>
<
/div
>
);
)
}
}
}
export
default
App
;
export
default
App
;
This diff is collapsed.
Click to expand it.
dashboard/src/mgSlice.js
+
15
−
15
View file @
90924087
import
{
createSlice
}
from
'
@reduxjs/toolkit
'
import
{
createSlice
}
from
'
@reduxjs/toolkit
'
export
const
mgSlice
=
createSlice
({
export
const
mgSlice
=
createSlice
({
name
:
'
mg
'
,
name
:
'
mg
'
,
initialState
:
{
initialState
:
{
asts
:
[],
ast
:
{},
contexts
:
{},
context
:
{},
},
reducers
:
{
addAst
:
(
state
,
action
)
=>
{
state
.
asts
=
[
action
.
payload
,
...
state
.
asts
];
console
.
log
(
"
added ast, size is
"
+
state
.
asts
.
length
);
},
},
setAstList
:
(
state
,
action
)
=>
{
reducers
:
{
state
.
asts
=
action
.
payload
.
reverse
();
setAst
:
(
state
,
action
)
=>
{
console
.
log
(
"
set AST list, size is
"
+
state
.
asts
.
length
);
state
.
ast
=
action
.
payload
;
console
.
log
(
"
set AST
"
);
},
setContext
:
(
state
,
action
)
=>
{
state
.
context
=
action
.
payload
;
console
.
log
(
"
set context
"
);
}
}
}
}
})
})
export
const
{
add
Ast
,
set
AstList
}
=
mgSlice
.
actions
export
const
{
set
Ast
,
set
Context
}
=
mgSlice
.
actions
export
default
mgSlice
.
reducer
export
default
mgSlice
.
reducer
\ No newline at end of file
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