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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JastAdd
motion-grammar-example
Commits
691b1951
Commit
691b1951
authored
3 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
improved js
parent
bde06308
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#14114
failed
3 years ago
Stage: build
Stage: test
Stage: ragdoc
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
dashboard/src/App.js
+30
-48
30 additions, 48 deletions
dashboard/src/App.js
with
30 additions
and
48 deletions
dashboard/src/App.js
+
30
−
48
View file @
691b1951
...
@@ -12,12 +12,23 @@ class App extends React.Component {
...
@@ -12,12 +12,23 @@ class App extends React.Component {
asts
:
[],
asts
:
[],
contexts
:
{}
contexts
:
{}
};
};
}
componentDidMount
()
{
fetch
(
'
http://localhost:7070/asts/
'
)
.
then
(
res
=>
res
.
json
())
.
then
((
asts
)
=>
{
this
.
setState
({
asts
:
asts
.
reverse
(),
contexts
:
{}
})
})
.
catch
(
console
.
log
)
const
ws
=
new
WebSocket
(
"
ws://localhost:7070/ast-events
"
);
const
ws
=
new
WebSocket
(
"
ws://localhost:7070/ast-events
"
);
ws
.
onopen
=
(
event
)
=>
{
ws
.
onopen
=
(
event
)
=>
{
ws
.
send
(
"
Web client connected!
"
);
ws
.
send
(
"
Hi
"
);
};
};
ws
.
onmessage
=
(
event
)
=>
{
ws
.
onmessage
=
(
event
)
=>
{
...
@@ -30,57 +41,30 @@ class App extends React.Component {
...
@@ -30,57 +41,30 @@ class App extends React.Component {
asts
:
[
event
.
data
,
...
asts
],
asts
:
[
event
.
data
,
...
asts
],
contexts
:
contexts
contexts
:
contexts
});
});
console
.
log
(
event
.
data
)
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
err
);
console
.
log
(
err
);
}
}
ws
.
send
(
"
Got Something, thx
"
);
};
};
}
}
componentDidMount
()
{
fetch
(
'
http://localhost:7070/asts/
'
)
.
then
(
res
=>
res
.
json
())
.
then
((
asts
)
=>
{
this
.
setState
({
asts
:
asts
.
reverse
(),
contexts
:
{}
})
})
.
catch
(
console
.
log
)
}
render
()
{
render
()
{
const
astlist
=
this
.
state
.
asts
.
map
(
v
=>
{
const
image
=
v
.
diagram
;
return
(
<
li
key
=
{
v
.
timestamp
}
>
<
p
>
{
v
.
parseRule
}
<
/p
>
<
p
><
img
src
=
{
`data:image/svg+xml;utf8,
${
encodeURIComponent
(
image
)}
`
}
alt
=
'
{v.parseRule}
'
/><
/p
>
<
/li
>
)
})
const
astTimeline
=
this
.
state
.
asts
.
map
(
v
=>
{
const
astTimeline
=
this
.
state
.
asts
.
map
(
v
=>
{
const
image
=
v
.
diagram
;
const
timestamp
=
new
Date
(
v
.
timestamp
);
return
(
return
(
<
VerticalTimelineElement
<
VerticalTimelineElement
className
=
"
ast-timeline-event
"
className
=
"
ast-timeline-event
"
contentStyle
=
{{
background
:
'
rgb(33, 150, 243)
'
,
color
:
'
#fff
'
}}
contentStyle
=
{{
background
:
'
rgb(33, 150, 243)
'
,
color
:
'
#fff
'
}}
contentArrowStyle
=
{{
borderRight
:
'
7px solid rgb(33, 150, 243)
'
}}
contentArrowStyle
=
{{
borderRight
:
'
7px solid rgb(33, 150, 243)
'
}}
date
=
{
timestamp
.
toLocaleTimeString
(
'
en-us
'
,
{
hour12
:
false
})}
date
=
{
new
Date
(
v
.
timestamp
)
.
toLocaleTimeString
(
'
en-us
'
,
{
hour12
:
false
})}
iconStyle
=
{{
background
:
'
rgb(33, 150, 243)
'
,
color
:
'
#fff
'
}}
iconStyle
=
{{
background
:
'
rgb(33, 150, 243)
'
,
color
:
'
#fff
'
,
rotate
:
'
180deg
'
}}
icon
=
{
<
GiFamilyTree
className
=
'
ASTIcon
'
/>
}
icon
=
{
<
GiFamilyTree
/>
}
key
=
{
v
.
timestamp
}
key
=
{
v
.
timestamp
}
position
=
{
'
right
'
}
position
=
{
'
right
'
}
>
>
<
h3
className
=
"
vertical-timeline-element-title
"
>
{
v
.
parseRule
}()
<
/h3
>
<
h3
className
=
"
vertical-timeline-element-title
"
>
{
v
.
parseRule
}()
<
/h3
>
<
p
>
<
p
>
<
img
className
=
"
AstInTimeline
"
src
=
{
`data:image/svg+xml;utf8,
${
encodeURIComponent
(
image
)}
`
}
alt
=
'
{v.parseRule}
'
/>
<
img
className
=
"
AstInTimeline
"
src
=
{
`data:image/svg+xml;utf8,
${
encodeURIComponent
(
v
.
diagram
)}
`
}
alt
=
{
v
.
parseRule
}
/
>
<
/p
>
<
/p
>
<
/VerticalTimelineElement
>
<
/VerticalTimelineElement
>
...
@@ -95,12 +79,10 @@ class App extends React.Component {
...
@@ -95,12 +79,10 @@ class App extends React.Component {
<
ControlPanel
/>
<
ControlPanel
/>
<
/header
>
<
/header
>
<
main
>
<
main
>
<
div
className
=
"
curent-state
"
>
<
CurrentState
<
img
className
=
"
CurrentAst
"
src
=
{
`data:image/svg+xml;utf8,
${
encodeURIComponent
(
lastImage
.
diagram
)}
`
}
alt
=
'
lastImage.parseRule
'
/>
diagram
=
{
lastImage
.
diagram
}
<
/div
>
label
=
{
lastImage
.
parseRule
}
{
/* <div className="ast-history">
/
>
<ol>{astlist}</ol>
</div> */
}
<
VerticalTimeline
<
VerticalTimeline
className
=
'
MG-Timeline
'
>
className
=
'
MG-Timeline
'
>
{
astTimeline
}
{
astTimeline
}
...
@@ -111,19 +93,19 @@ class App extends React.Component {
...
@@ -111,19 +93,19 @@ class App extends React.Component {
}
}
}
}
class
ControlPanel
extends
React
.
Component
{
function
CurrentState
(
props
)
{
constructor
(
props
)
{
return
(
super
(
props
);
<
div
className
=
"
curent-state
"
>
};
<
img
className
=
"
CurrentAst
"
src
=
{
`data:image/svg+xml;utf8,
${
encodeURIComponent
(
props
.
diagram
)}
`
}
alt
=
{
props
.
label
}
/
>
<
/div
>
sayHello
=
()
=>
{
)
alert
(
'
You clicked me!
'
);
}
}
class
ControlPanel
extends
React
.
Component
{
render
()
{
render
()
{
return
(
return
(
<
div
className
=
'
ControlPanel
'
>
<
div
className
=
'
ControlPanel
'
>
<
button
onClick
=
{
this
.
sayHello
}
>
connect
<
/button
>
<
button
onClick
=
{
()
=>
{
alert
(
'
You clicked me!
'
);
}
}
>
connect
<
/button
>
<
/div
>
<
/div
>
);
);
}
}
...
...
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