mirror of
https://github.com/ansible/awx.git
synced 2026-05-23 08:37:48 -02:30
Improves FSM design and adds tools to diff design and implementation.
* Resolves conflicts between designs and implementation * Adding fsm_diff to network_ui/tools * Add extract.js for FSM toolchain to network_ui
This commit is contained in:
1
awx/network_ui/static/network_ui/.gitignore
vendored
1
awx/network_ui/static/network_ui/.gitignore
vendored
@@ -1,7 +1,6 @@
|
|||||||
/bundle.js
|
/bundle.js
|
||||||
/node_modules
|
/node_modules
|
||||||
/style.css
|
/style.css
|
||||||
/extract.js
|
|
||||||
/css
|
/css
|
||||||
/js
|
/js
|
||||||
/src-instrumented
|
/src-instrumented
|
||||||
|
|||||||
@@ -34,3 +34,40 @@ simple-server: lint main lessc
|
|||||||
|
|
||||||
deploy: main
|
deploy: main
|
||||||
rsync -av src/ ../../../../awx/ui/client/src/network_ui/
|
rsync -av src/ ../../../../awx/ui/client/src/network_ui/
|
||||||
|
|
||||||
|
|
||||||
|
extract:
|
||||||
|
mkdir -p extracted
|
||||||
|
./extract.js ./src/button.js > extracted/button.yml
|
||||||
|
./extract.js ./src/buttons.js > extracted/buttons.yml
|
||||||
|
./extract.js ./src/device.detail.fsm.js > extracted/device_detail.yml
|
||||||
|
./extract.js ./src/group.js > extracted/group.yml
|
||||||
|
./extract.js ./src/hotkeys.fsm.js > extracted/hotkeys.yml
|
||||||
|
./extract.js ./src/link.js > extracted/link.yml
|
||||||
|
./extract.js ./src/mode.fsm.js > extracted/mode.yml
|
||||||
|
./extract.js ./src/move.js > extracted/move.yml
|
||||||
|
./extract.js ./src/null.fsm.js > extracted/null.yml
|
||||||
|
./extract.js ./src/rack.fsm.js > extracted/rack.yml
|
||||||
|
./extract.js ./src/site.fsm.js > extracted/site.yml
|
||||||
|
./extract.js ./src/stream.fsm.js > extracted/stream.yml
|
||||||
|
./extract.js ./src/toolbox.fsm.js > extracted/toolbox.yml
|
||||||
|
./extract.js ./src/view.js > extracted/view.yml
|
||||||
|
./extract.js ./src/time.js > extracted/time.yml
|
||||||
|
|
||||||
|
|
||||||
|
diff:
|
||||||
|
fsm_diff designs/button.yml extracted/button.yml
|
||||||
|
fsm_diff designs/buttons.yml extracted/buttons.yml
|
||||||
|
fsm_diff designs/device_detail.yml extracted/device_detail.yml
|
||||||
|
fsm_diff designs/group.yml extracted/group.yml
|
||||||
|
fsm_diff designs/hotkeys.yml extracted/hotkeys.yml
|
||||||
|
fsm_diff designs/link.yml extracted/link.yml
|
||||||
|
fsm_diff designs/mode.yml extracted/mode.yml
|
||||||
|
fsm_diff designs/move.yml extracted/move.yml
|
||||||
|
fsm_diff designs/null.yml extracted/null.yml
|
||||||
|
fsm_diff designs/rack.yml extracted/rack.yml
|
||||||
|
fsm_diff designs/site.yml extracted/site.yml
|
||||||
|
fsm_diff designs/stream.yml extracted/stream.yml
|
||||||
|
fsm_diff designs/time.yml extracted/time.yml
|
||||||
|
fsm_diff designs/toolbox.yml extracted/toolbox.yml
|
||||||
|
fsm_diff designs/view.yml extracted/view.yml
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ states:
|
|||||||
y: 491
|
y: 491
|
||||||
transitions:
|
transitions:
|
||||||
- from_state: Start
|
- from_state: Start
|
||||||
label: ''
|
label: start
|
||||||
to_state: Ready
|
to_state: Ready
|
||||||
- from_state: Ready
|
- from_state: Ready
|
||||||
label: onMouseDown
|
label: onMouseDown
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
finite_state_machine_id: 102
|
finite_state_machine_id: 6
|
||||||
name: fsm
|
name: fsm
|
||||||
states:
|
states:
|
||||||
|
- id: 11
|
||||||
|
label: Disable
|
||||||
|
x: 497
|
||||||
|
y: 84
|
||||||
- id: 1
|
- id: 1
|
||||||
label: Resize
|
label: Resize
|
||||||
x: 571
|
x: 571
|
||||||
@@ -25,14 +29,6 @@ states:
|
|||||||
label: Move
|
label: Move
|
||||||
x: 1297
|
x: 1297
|
||||||
y: 786
|
y: 786
|
||||||
- id: 7
|
|
||||||
label: Ready
|
|
||||||
x: 740
|
|
||||||
y: 324
|
|
||||||
- id: 8
|
|
||||||
label: EditLabel
|
|
||||||
x: 1056
|
|
||||||
y: 148
|
|
||||||
- id: 9
|
- id: 9
|
||||||
label: Selected2
|
label: Selected2
|
||||||
x: 1179
|
x: 1179
|
||||||
@@ -41,58 +37,75 @@ states:
|
|||||||
label: Placing
|
label: Placing
|
||||||
x: 410
|
x: 410
|
||||||
y: 295
|
y: 295
|
||||||
|
- id: 7
|
||||||
|
label: Ready
|
||||||
|
x: 733
|
||||||
|
y: 304
|
||||||
|
- id: 8
|
||||||
|
label: EditLabel
|
||||||
|
x: 1130
|
||||||
|
y: 112
|
||||||
transitions:
|
transitions:
|
||||||
- from_state: Ready
|
|
||||||
label: onMouseDown
|
|
||||||
to_state: Selected1
|
|
||||||
- from_state: EditLabel
|
|
||||||
label: onMouseDown
|
|
||||||
to_state: Ready
|
|
||||||
- from_state: Selected2
|
|
||||||
label: onMouseDown
|
|
||||||
to_state: Ready
|
|
||||||
- from_state: Selected2
|
|
||||||
label: onMouseDown
|
|
||||||
to_state: Selected3
|
|
||||||
- from_state: Selected1
|
|
||||||
label: onMouseUp
|
|
||||||
to_state: Selected2
|
|
||||||
- from_state: Move
|
|
||||||
label: onMouseUp
|
|
||||||
to_state: Selected2
|
|
||||||
- from_state: Selected1
|
|
||||||
label: onMouseMove
|
|
||||||
to_state: Move
|
|
||||||
- from_state: Start
|
|
||||||
label: start
|
|
||||||
to_state: Ready
|
|
||||||
- from_state: Ready
|
|
||||||
label: onMouseDown
|
|
||||||
to_state: CornerSelected
|
|
||||||
- from_state: Selected3
|
|
||||||
label: onMouseMove
|
|
||||||
to_state: Move
|
|
||||||
- from_state: Selected3
|
|
||||||
label: onMouseUp
|
|
||||||
to_state: EditLabel
|
|
||||||
- from_state: Ready
|
|
||||||
label: onNewGroup
|
|
||||||
to_state: Placing
|
|
||||||
- from_state: Placing
|
|
||||||
label: onMouseDown
|
|
||||||
to_state: CornerSelected
|
|
||||||
- from_state: CornerSelected
|
- from_state: CornerSelected
|
||||||
label: onMouseMove
|
label: onMouseMove
|
||||||
to_state: Resize
|
to_state: Resize
|
||||||
- from_state: Resize
|
- from_state: Placing
|
||||||
label: onMouseUp
|
label: onMouseDown
|
||||||
to_state: Selected1
|
to_state: CornerSelected
|
||||||
- from_state: Selected2
|
- from_state: Ready
|
||||||
label: onNewGroup
|
label: onMouseDown
|
||||||
to_state: Ready
|
to_state: CornerSelected
|
||||||
- from_state: CornerSelected
|
|
||||||
label: onMouseUp
|
|
||||||
to_state: Selected1
|
|
||||||
- from_state: Move
|
- from_state: Move
|
||||||
label: onMouseDown
|
label: onMouseDown
|
||||||
to_state: Selected1
|
to_state: Selected1
|
||||||
|
- from_state: CornerSelected
|
||||||
|
label: onMouseUp
|
||||||
|
to_state: Selected1
|
||||||
|
- from_state: Resize
|
||||||
|
label: onMouseUp
|
||||||
|
to_state: Selected1
|
||||||
|
- from_state: Ready
|
||||||
|
label: onMouseDown
|
||||||
|
to_state: Selected1
|
||||||
|
- from_state: Selected2
|
||||||
|
label: onMouseDown
|
||||||
|
to_state: Selected3
|
||||||
|
- from_state: Selected3
|
||||||
|
label: onMouseMove
|
||||||
|
to_state: Move
|
||||||
|
- from_state: Selected1
|
||||||
|
label: onMouseMove
|
||||||
|
to_state: Move
|
||||||
|
- from_state: EditLabel
|
||||||
|
label: onKeyDown
|
||||||
|
to_state: Selected2
|
||||||
|
- from_state: Ready
|
||||||
|
label: onPasteGroup
|
||||||
|
to_state: Selected2
|
||||||
|
- from_state: Move
|
||||||
|
label: onMouseUp
|
||||||
|
to_state: Selected2
|
||||||
|
- from_state: Selected1
|
||||||
|
label: onMouseUp
|
||||||
|
to_state: Selected2
|
||||||
|
- from_state: Ready
|
||||||
|
label: onNewGroup
|
||||||
|
to_state: Placing
|
||||||
|
- from_state: Selected2
|
||||||
|
label: onKeyDown
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: Selected2
|
||||||
|
label: onNewGroup
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: Start
|
||||||
|
label: start
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: Selected2
|
||||||
|
label: onMouseDown
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: EditLabel
|
||||||
|
label: onMouseDown
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: Selected3
|
||||||
|
label: onMouseUp
|
||||||
|
to_state: EditLabel
|
||||||
|
|||||||
@@ -1,32 +1,27 @@
|
|||||||
app: link
|
finite_state_machine_id: 10
|
||||||
panX: -15
|
name: src/link
|
||||||
panY: 0
|
|
||||||
scaleXY: 1
|
|
||||||
states:
|
states:
|
||||||
- label: Ready
|
- id: 5
|
||||||
size: 100
|
label: Selecting
|
||||||
x: 540
|
x: -429
|
||||||
y: 307
|
y: 63
|
||||||
- label: Start
|
- id: 2
|
||||||
size: 100
|
label: Start
|
||||||
x: 533
|
x: 15
|
||||||
y: 96
|
y: -221
|
||||||
- label: Selecting
|
- id: 4
|
||||||
size: 100
|
label: Connecting
|
||||||
x: 780
|
x: -429
|
||||||
y: 299
|
y: 466
|
||||||
- label: Connecting
|
- id: 3
|
||||||
size: 100
|
label: Connected
|
||||||
x: 782
|
x: 47
|
||||||
y: 541
|
y: 453
|
||||||
- label: Connected
|
- id: 1
|
||||||
size: 100
|
label: Ready
|
||||||
x: 546
|
x: 26
|
||||||
y: 543
|
y: 61
|
||||||
transitions:
|
transitions:
|
||||||
- from_state: Start
|
|
||||||
label: start
|
|
||||||
to_state: Ready
|
|
||||||
- from_state: Ready
|
- from_state: Ready
|
||||||
label: onNewLink
|
label: onNewLink
|
||||||
to_state: Selecting
|
to_state: Selecting
|
||||||
@@ -36,6 +31,12 @@ transitions:
|
|||||||
- from_state: Connecting
|
- from_state: Connecting
|
||||||
label: onMouseUp
|
label: onMouseUp
|
||||||
to_state: Connected
|
to_state: Connected
|
||||||
- from_state: Connected
|
- from_state: Connecting
|
||||||
label: free
|
label: onMouseUp
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: Connected
|
||||||
|
label: start
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: Start
|
||||||
|
label: start
|
||||||
to_state: Ready
|
to_state: Ready
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
finite_state_machine_id: 106
|
finite_state_machine_id: 13
|
||||||
name: move
|
name: move
|
||||||
states:
|
states:
|
||||||
|
- id: 9
|
||||||
|
label: Disable
|
||||||
|
x: 743
|
||||||
|
y: 108
|
||||||
- id: 1
|
- id: 1
|
||||||
label: Start
|
label: Start
|
||||||
x: 533
|
x: 533
|
||||||
@@ -34,54 +38,57 @@ states:
|
|||||||
x: 92
|
x: 92
|
||||||
y: 82
|
y: 82
|
||||||
transitions:
|
transitions:
|
||||||
|
- from_state: Selected2
|
||||||
|
label: onKeyDown
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: Selected2
|
||||||
|
label: onNewDevice
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: EditLabel
|
||||||
|
label: onMouseDown
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: Selected2
|
||||||
|
label: onMouseDown
|
||||||
|
to_state: Ready
|
||||||
- from_state: Start
|
- from_state: Start
|
||||||
label: start
|
label: start
|
||||||
to_state: Ready
|
to_state: Ready
|
||||||
- from_state: Ready
|
- from_state: Move
|
||||||
label: onMouseDown
|
label: onMouseDown
|
||||||
to_state: Selected1
|
to_state: Selected1
|
||||||
- from_state: Selected1
|
- from_state: Placing
|
||||||
label: onMouseUp
|
|
||||||
to_state: Selected2
|
|
||||||
- from_state: Selected1
|
|
||||||
label: onMouseMove
|
|
||||||
to_state: Move
|
|
||||||
- from_state: Selected2
|
|
||||||
label: onMouseDown
|
label: onMouseDown
|
||||||
to_state: Ready
|
to_state: Selected1
|
||||||
- from_state: Move
|
- from_state: Move
|
||||||
label: onMouseUp
|
label: onMouseUp
|
||||||
to_state: Selected1
|
to_state: Selected1
|
||||||
|
- from_state: Ready
|
||||||
|
label: onMouseDown
|
||||||
|
to_state: Selected1
|
||||||
|
- from_state: Ready
|
||||||
|
label: onPasteDevice
|
||||||
|
to_state: Selected2
|
||||||
- from_state: EditLabel
|
- from_state: EditLabel
|
||||||
label: onKeyDown
|
label: onKeyDown
|
||||||
to_state: Selected2
|
to_state: Selected2
|
||||||
- from_state: EditLabel
|
- from_state: Selected1
|
||||||
label: onMouseDown
|
label: onMouseUp
|
||||||
to_state: Ready
|
to_state: Selected2
|
||||||
- from_state: Selected2
|
- from_state: Placing
|
||||||
label: onMouseDown
|
label: onMouseMove
|
||||||
to_state: Selected3
|
to_state: Move
|
||||||
- from_state: Selected3
|
- from_state: Selected3
|
||||||
label: onMouseMove
|
label: onMouseMove
|
||||||
to_state: Move
|
to_state: Move
|
||||||
|
- from_state: Selected1
|
||||||
|
label: onMouseMove
|
||||||
|
to_state: Move
|
||||||
- from_state: Selected3
|
- from_state: Selected3
|
||||||
label: onMouseUp
|
label: onMouseUp
|
||||||
to_state: EditLabel
|
to_state: EditLabel
|
||||||
- from_state: Placing
|
- from_state: Selected2
|
||||||
label: onMouseMove
|
label: onMouseDown
|
||||||
to_state: Move
|
to_state: Selected3
|
||||||
- from_state: Ready
|
- from_state: Ready
|
||||||
label: onNewDevice
|
label: onNewDevice
|
||||||
to_state: Placing
|
to_state: Placing
|
||||||
- from_state: Placing
|
|
||||||
label: onMouseDown
|
|
||||||
to_state: Selected1
|
|
||||||
- from_state: Move
|
|
||||||
label: onMouseDown
|
|
||||||
to_state: Selected1
|
|
||||||
- from_state: Selected2
|
|
||||||
label: onNewDevice
|
|
||||||
to_state: Ready
|
|
||||||
- from_state: Selected2
|
|
||||||
label: onKeyDown
|
|
||||||
to_state: Ready
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
finite_state_machine_id: 89
|
finite_state_machine_id: 11
|
||||||
name: src/time
|
name: src/time
|
||||||
states:
|
states:
|
||||||
- id: 3
|
- id: 1
|
||||||
label: Present
|
label: Present
|
||||||
x: 256
|
x: 256
|
||||||
y: 123
|
y: 123
|
||||||
@@ -9,14 +9,11 @@ states:
|
|||||||
label: Start
|
label: Start
|
||||||
x: 245
|
x: 245
|
||||||
y: -161
|
y: -161
|
||||||
- id: 1
|
- id: 3
|
||||||
label: Past
|
label: Past
|
||||||
x: -115
|
x: -115
|
||||||
y: 129
|
y: 129
|
||||||
transitions:
|
transitions:
|
||||||
- from_state: Past
|
|
||||||
label: onMessage
|
|
||||||
to_state: Present
|
|
||||||
- from_state: Past
|
- from_state: Past
|
||||||
label: onRedo
|
label: onRedo
|
||||||
to_state: Present
|
to_state: Present
|
||||||
@@ -29,9 +26,6 @@ transitions:
|
|||||||
- from_state: Start
|
- from_state: Start
|
||||||
label: start
|
label: start
|
||||||
to_state: Present
|
to_state: Present
|
||||||
- from_state: Present
|
|
||||||
label: onMessage
|
|
||||||
to_state: Past
|
|
||||||
- from_state: Present
|
- from_state: Present
|
||||||
label: onUndo
|
label: onUndo
|
||||||
to_state: Past
|
to_state: Past
|
||||||
|
|||||||
@@ -1,49 +1,62 @@
|
|||||||
finite_state_machine_id: 120
|
finite_state_machine_id: 14
|
||||||
name: toolbox
|
name: toolbox
|
||||||
states:
|
states:
|
||||||
- id: 6
|
|
||||||
label: Dropping
|
|
||||||
x: 1197
|
|
||||||
y: 427
|
|
||||||
- id: 4
|
|
||||||
label: Selected
|
|
||||||
x: 889
|
|
||||||
y: 713
|
|
||||||
- id: 2
|
- id: 2
|
||||||
|
label: Selected
|
||||||
|
x: 1180
|
||||||
|
y: 959
|
||||||
|
- id: 6
|
||||||
|
label: Move
|
||||||
|
x: 1409
|
||||||
|
y: 741
|
||||||
|
- id: 3
|
||||||
label: Ready
|
label: Ready
|
||||||
x: 892
|
x: 892
|
||||||
y: 429
|
y: 429
|
||||||
- id: 3
|
- id: 4
|
||||||
label: Scrolling
|
label: Scrolling
|
||||||
x: 567
|
x: 567
|
||||||
y: 431
|
y: 431
|
||||||
- id: 1
|
- id: 5
|
||||||
label: Start
|
label: Start
|
||||||
x: 892
|
x: 892
|
||||||
y: 216
|
y: 216
|
||||||
- id: 5
|
- id: 7
|
||||||
label: Move
|
label: Selecting
|
||||||
x: 1197
|
x: 888
|
||||||
y: 708
|
y: 710
|
||||||
|
- id: 1
|
||||||
|
label: Dropping
|
||||||
|
x: 1358
|
||||||
|
y: 431
|
||||||
transitions:
|
transitions:
|
||||||
- from_state: Start
|
- from_state: Selecting
|
||||||
label: start
|
|
||||||
to_state: Ready
|
|
||||||
- from_state: Move
|
|
||||||
label: onMouseUp
|
|
||||||
to_state: Dropping
|
|
||||||
- from_state: Dropping
|
|
||||||
label: start
|
|
||||||
to_state: Ready
|
|
||||||
- from_state: Ready
|
|
||||||
label: onMouseDown
|
label: onMouseDown
|
||||||
to_state: Selected
|
to_state: Selected
|
||||||
- from_state: Ready
|
|
||||||
label: onMouseWheel
|
|
||||||
to_state: Scrolling
|
|
||||||
- from_state: Scrolling
|
|
||||||
label: start
|
|
||||||
to_state: Ready
|
|
||||||
- from_state: Selected
|
- from_state: Selected
|
||||||
label: onMouseMove
|
label: onMouseMove
|
||||||
to_state: Move
|
to_state: Move
|
||||||
|
- from_state: Selecting
|
||||||
|
label: onMouseDown
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: Selected
|
||||||
|
label: onMouseUp
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: Dropping
|
||||||
|
label: start
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: Start
|
||||||
|
label: start
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: Scrolling
|
||||||
|
label: onMouseWheel
|
||||||
|
to_state: Ready
|
||||||
|
- from_state: Ready
|
||||||
|
label: onMouseWheel
|
||||||
|
to_state: Scrolling
|
||||||
|
- from_state: Ready
|
||||||
|
label: onMouseDown
|
||||||
|
to_state: Selecting
|
||||||
|
- from_state: Move
|
||||||
|
label: onMouseUp
|
||||||
|
to_state: Dropping
|
||||||
|
|||||||
@@ -1,38 +1,36 @@
|
|||||||
app: view
|
finite_state_machine_id: 15
|
||||||
panX: 1
|
name: view
|
||||||
panY: -67
|
|
||||||
scaleXY: 1
|
|
||||||
states:
|
states:
|
||||||
- label: Start
|
- id: 1
|
||||||
size: 100
|
label: Start
|
||||||
x: 498
|
x: 498
|
||||||
y: 175
|
y: 175
|
||||||
- label: Ready
|
- id: 2
|
||||||
size: 100
|
label: Ready
|
||||||
x: 506
|
x: 506
|
||||||
y: 395
|
y: 395
|
||||||
- label: Scale
|
- id: 3
|
||||||
size: 100
|
label: Scale
|
||||||
x: 310
|
x: 310
|
||||||
y: 626
|
y: 626
|
||||||
- label: Pan
|
- id: 4
|
||||||
size: 100
|
label: Pan
|
||||||
x: 741
|
x: 741
|
||||||
y: 631
|
y: 631
|
||||||
- label: Pressed
|
- id: 5
|
||||||
size: 100
|
label: Pressed
|
||||||
x: 739
|
x: 739
|
||||||
y: 392
|
y: 392
|
||||||
transitions:
|
transitions:
|
||||||
|
- from_state: Scale
|
||||||
|
label: onMouseWheel
|
||||||
|
to_state: Ready
|
||||||
- from_state: Start
|
- from_state: Start
|
||||||
label: start
|
label: start
|
||||||
to_state: Ready
|
to_state: Ready
|
||||||
- from_state: Ready
|
- from_state: Ready
|
||||||
label: onMouseWheel
|
label: onMouseWheel
|
||||||
to_state: Scale
|
to_state: Scale
|
||||||
- from_state: Scale
|
|
||||||
label: onTimeout
|
|
||||||
to_state: Ready
|
|
||||||
- from_state: Ready
|
- from_state: Ready
|
||||||
label: onMouseDown
|
label: onMouseDown
|
||||||
to_state: Pressed
|
to_state: Pressed
|
||||||
|
|||||||
47
awx/network_ui/static/network_ui/extract.js
Executable file
47
awx/network_ui/static/network_ui/extract.js
Executable file
@@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var YAML = require('yamljs');
|
||||||
|
|
||||||
|
function Iterator(o){
|
||||||
|
var k=Object.keys(o);
|
||||||
|
return {
|
||||||
|
next:function(){
|
||||||
|
return k.shift();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var myArgs = process.argv.slice(2);
|
||||||
|
var implementation = require(myArgs[0]);
|
||||||
|
var states = [];
|
||||||
|
var transitions = [];
|
||||||
|
var data = {states: states,
|
||||||
|
transitions: transitions};
|
||||||
|
|
||||||
|
var state_iter = Iterator(implementation);
|
||||||
|
var transition_iter = null;
|
||||||
|
var next_state = state_iter.next();
|
||||||
|
var next_transition = null;
|
||||||
|
var state = null;
|
||||||
|
var transition = null;
|
||||||
|
var i = 0;
|
||||||
|
while(next_state !== undefined) {
|
||||||
|
state = implementation[next_state];
|
||||||
|
transition_iter = Iterator(state.constructor.prototype)
|
||||||
|
next_transition = transition_iter.next();
|
||||||
|
while (next_transition !== undefined) {
|
||||||
|
transition = state.constructor.prototype[next_transition];
|
||||||
|
if (transition.transitions !== undefined) {
|
||||||
|
for (i = 0; i < transition.transitions.length; i++) {
|
||||||
|
transitions.push({from_state: next_state,
|
||||||
|
to_state:transition.transitions[i],
|
||||||
|
label:next_transition});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next_transition = transition_iter.next();
|
||||||
|
}
|
||||||
|
states.push({label: state.name});
|
||||||
|
next_state = state_iter.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
console.log(YAML.stringify(data));
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
<html ng-app="networkUI">
|
<html ng-app="networkUI">
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="css/style.css" />
|
<link rel="stylesheet" href="css/style.css" />
|
||||||
<script src="js/bundle.js"></script>
|
|
||||||
<script src="js/vendor.bundle.js"></script>
|
<script src="js/vendor.bundle.js"></script>
|
||||||
|
<script src="js/bundle.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body style="margin: 0px">
|
<body style="margin: 0px">
|
||||||
<awx-network-ui></awx-network-ui>
|
<awx-network-ui></awx-network-ui>
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ _Ready.prototype.onNewLink = function (controller, msg_type, message) {
|
|||||||
controller.changeState(Selecting);
|
controller.changeState(Selecting);
|
||||||
controller.next_controller.handle_message(msg_type, message);
|
controller.next_controller.handle_message(msg_type, message);
|
||||||
};
|
};
|
||||||
|
_Ready.prototype.onNewLink.transitions = ['Selecting'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -60,6 +61,7 @@ _Start.prototype.start = function (controller) {
|
|||||||
controller.changeState(Ready);
|
controller.changeState(Ready);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
_Start.prototype.start.transitions = ['Ready'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -68,6 +70,7 @@ _Connected.prototype.start = function (controller) {
|
|||||||
controller.scope.clear_selections();
|
controller.scope.clear_selections();
|
||||||
controller.changeState(Ready);
|
controller.changeState(Ready);
|
||||||
};
|
};
|
||||||
|
_Connected.prototype.start.transitions = ['Ready'];
|
||||||
|
|
||||||
|
|
||||||
_Connecting.prototype.onMouseDown = function () {
|
_Connecting.prototype.onMouseDown = function () {
|
||||||
@@ -121,6 +124,7 @@ _Connecting.prototype.onMouseUp = function (controller) {
|
|||||||
controller.changeState(Ready);
|
controller.changeState(Ready);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
_Connecting.prototype.onMouseUp.transitions = ['Ready', 'Connected'];
|
||||||
|
|
||||||
|
|
||||||
_Selecting.prototype.onMouseDown = function () {
|
_Selecting.prototype.onMouseDown = function () {
|
||||||
@@ -135,4 +139,5 @@ _Selecting.prototype.onMouseUp = function (controller) {
|
|||||||
controller.changeState(Connecting);
|
controller.changeState(Connecting);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
_Selecting.prototype.onMouseUp.transitions = ['Connecting'];
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ _Selected.prototype.onMouseUp = function (controller) {
|
|||||||
toolbox.selected_item = null;
|
toolbox.selected_item = null;
|
||||||
controller.changeState(Ready);
|
controller.changeState(Ready);
|
||||||
};
|
};
|
||||||
_Selected.prototype.onMouseUp.transitions = ['Move'];
|
_Selected.prototype.onMouseUp.transitions = ['Ready'];
|
||||||
|
|
||||||
|
|
||||||
_Selecting.prototype.onMouseDown = function (controller) {
|
_Selecting.prototype.onMouseDown = function (controller) {
|
||||||
@@ -133,7 +133,7 @@ _Selecting.prototype.onMouseDown = function (controller) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
_Selecting.prototype.onMouseDown.transitions = ['Selected'];
|
_Selecting.prototype.onMouseDown.transitions = ['Selected', 'Ready'];
|
||||||
|
|
||||||
_Ready.prototype.onMouseDown = function (controller, msg_type, $event) {
|
_Ready.prototype.onMouseDown = function (controller, msg_type, $event) {
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ _Scrolling.prototype.onMouseWheel = function (controller, msg_type, $event) {
|
|||||||
controller.changeState(Ready);
|
controller.changeState(Ready);
|
||||||
|
|
||||||
};
|
};
|
||||||
_Scrolling.prototype.start.transitions = ['Ready'];
|
_Scrolling.prototype.onMouseWheel.transitions = ['Ready'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ _Ready.prototype.onMouseDown = function (controller) {
|
|||||||
controller.changeState(Pressed);
|
controller.changeState(Pressed);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
_Ready.prototype.onMouseDown.transitions = ['Pressed'];
|
||||||
|
|
||||||
_Ready.prototype.onTouchStart = function (controller, msg_type, event) {
|
_Ready.prototype.onTouchStart = function (controller, msg_type, event) {
|
||||||
|
|
||||||
@@ -79,12 +80,14 @@ _Ready.prototype.onTouchStart = function (controller, msg_type, event) {
|
|||||||
controller.changeState(Pressed);
|
controller.changeState(Pressed);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
_Ready.prototype.onTouchStart.transitions = ['Pressed'];
|
||||||
|
|
||||||
_Ready.prototype.onMouseWheel = function (controller, msg_type, $event) {
|
_Ready.prototype.onMouseWheel = function (controller, msg_type, $event) {
|
||||||
|
|
||||||
controller.changeState(Scale);
|
controller.changeState(Scale);
|
||||||
controller.handle_message(msg_type, $event);
|
controller.handle_message(msg_type, $event);
|
||||||
};
|
};
|
||||||
|
_Ready.prototype.onMouseWheel.transitions = ['Scale'];
|
||||||
|
|
||||||
|
|
||||||
_Start.prototype.start = function (controller) {
|
_Start.prototype.start = function (controller) {
|
||||||
@@ -92,6 +95,7 @@ _Start.prototype.start = function (controller) {
|
|||||||
controller.changeState(Ready);
|
controller.changeState(Ready);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
_Start.prototype.start.transitions = ['Ready'];
|
||||||
|
|
||||||
_Scale.prototype.onMouseWheel = function (controller, msg_type, message) {
|
_Scale.prototype.onMouseWheel = function (controller, msg_type, message) {
|
||||||
var delta = message[1];
|
var delta = message[1];
|
||||||
|
|||||||
6
awx/network_ui/static/network_ui/tools/fsm_diff/__init__.py
Executable file
6
awx/network_ui/static/network_ui/tools/fsm_diff/__init__.py
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
__author__ = 'Ben Thomasson'
|
||||||
|
__email__ = 'benthomasson@gmail.com'
|
||||||
|
__version__ = '0.1.0'
|
||||||
79
awx/network_ui/static/network_ui/tools/fsm_diff/cli.py
Normal file
79
awx/network_ui/static/network_ui/tools/fsm_diff/cli.py
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
"""
|
||||||
|
Usage:
|
||||||
|
fsm_diff [options] <a> <b> [<output>]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Show this page
|
||||||
|
--debug Show debug logging
|
||||||
|
--verbose Show verbose logging
|
||||||
|
"""
|
||||||
|
from docopt import docopt
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
logger = logging.getLogger('cli')
|
||||||
|
|
||||||
|
|
||||||
|
def fsm_diff(a, b, silent=True):
|
||||||
|
|
||||||
|
a_states = {x['label'] for x in a['states']}
|
||||||
|
b_states = {x['label'] for x in b['states']}
|
||||||
|
|
||||||
|
missing_in_a = b_states - a_states
|
||||||
|
missing_in_b = a_states - b_states
|
||||||
|
|
||||||
|
|
||||||
|
if (missing_in_b) and not silent:
|
||||||
|
print "Extra states in a:\n ", "\n ".join(list(missing_in_b))
|
||||||
|
|
||||||
|
if (missing_in_a) and not silent:
|
||||||
|
print "Extra states in b:\n ", "\n ".join(list(missing_in_a))
|
||||||
|
|
||||||
|
new_states = missing_in_b.union(missing_in_a)
|
||||||
|
|
||||||
|
a_transitions = {tuple(sorted(x.items())) for x in a['transitions']}
|
||||||
|
b_transitions = {tuple(sorted(x.items())) for x in b['transitions']}
|
||||||
|
|
||||||
|
missing_in_a = b_transitions - a_transitions
|
||||||
|
missing_in_b = a_transitions - b_transitions
|
||||||
|
|
||||||
|
|
||||||
|
if (missing_in_b) and not silent:
|
||||||
|
print "Extra transitions in a:\n ", "\n ".join(map(str, missing_in_b))
|
||||||
|
|
||||||
|
if (missing_in_a) and not silent:
|
||||||
|
print "Extra transitions in b:\n ", "\n ".join(map(str, missing_in_a))
|
||||||
|
|
||||||
|
new_transitions = missing_in_b.union(missing_in_a)
|
||||||
|
|
||||||
|
data = dict(states=[dict(label=x) for x in list(new_states)],
|
||||||
|
transitions=[dict(x) for x in list(new_transitions)])
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def main(args=None):
|
||||||
|
if args is None:
|
||||||
|
args = sys.argv[1:]
|
||||||
|
parsed_args = docopt(__doc__, args)
|
||||||
|
if parsed_args['--debug']:
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
elif parsed_args['--verbose']:
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
else:
|
||||||
|
logging.basicConfig(level=logging.WARNING)
|
||||||
|
|
||||||
|
with open(parsed_args['<a>']) as f:
|
||||||
|
a = yaml.load(f.read())
|
||||||
|
|
||||||
|
with open(parsed_args['<b>']) as f:
|
||||||
|
b = yaml.load(f.read())
|
||||||
|
|
||||||
|
data = fsm_diff(a, b, silent=False)
|
||||||
|
|
||||||
|
if parsed_args['<output>']:
|
||||||
|
with open(parsed_args['<output>'], 'w') as f:
|
||||||
|
f.write(yaml.dump(data, default_flow_style=False))
|
||||||
|
|
||||||
|
return 0
|
||||||
69
awx/network_ui/static/network_ui/tools/fsm_generate_diffs.py
Executable file
69
awx/network_ui/static/network_ui/tools/fsm_generate_diffs.py
Executable file
@@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
"""
|
||||||
|
Usage:
|
||||||
|
fsm_generate_diffs [options] <design> <implementation>
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Show this page
|
||||||
|
--debug Show debug logging
|
||||||
|
--verbose Show verbose logging
|
||||||
|
--append Append the newly generated code to the implementation.
|
||||||
|
"""
|
||||||
|
from docopt import docopt
|
||||||
|
import logging
|
||||||
|
import sys
|
||||||
|
import fsm_diff.cli
|
||||||
|
import transform_fsm
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
from jinja2 import FileSystemLoader, Environment
|
||||||
|
|
||||||
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
|
logger = logging.getLogger('fsm_generate_diffs')
|
||||||
|
|
||||||
|
|
||||||
|
def main(args=None):
|
||||||
|
if args is None:
|
||||||
|
args = sys.argv[1:]
|
||||||
|
parsed_args = docopt(__doc__, args)
|
||||||
|
if parsed_args['--debug']:
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
elif parsed_args['--verbose']:
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
else:
|
||||||
|
logging.basicConfig(level=logging.WARNING)
|
||||||
|
|
||||||
|
implementation = parsed_args['<implementation>']
|
||||||
|
|
||||||
|
p = Popen(['./extract.js', implementation], stdout=PIPE)
|
||||||
|
output = p.communicate()[0]
|
||||||
|
if p.returncode == 0:
|
||||||
|
b = yaml.load(output)
|
||||||
|
else:
|
||||||
|
return 1
|
||||||
|
|
||||||
|
with open(parsed_args['<design>']) as f:
|
||||||
|
a = yaml.load(f.read())
|
||||||
|
|
||||||
|
data = fsm_diff.cli.fsm_diff(a, b)
|
||||||
|
data = transform_fsm.transform_fsm(data)
|
||||||
|
|
||||||
|
env = Environment(loader=FileSystemLoader("templates"))
|
||||||
|
template = env.get_template('fsm.jst')
|
||||||
|
|
||||||
|
if parsed_args['--append']:
|
||||||
|
with open(implementation, "a") as f:
|
||||||
|
f.write(template.render(**data))
|
||||||
|
else:
|
||||||
|
print (template.render(**data))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import sys
|
||||||
|
sys.exit(main(sys.argv[1:]))
|
||||||
4
awx/network_ui/static/network_ui/tools/requirements.txt
Normal file
4
awx/network_ui/static/network_ui/tools/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
jinja2
|
||||||
|
docopt
|
||||||
|
pyyaml
|
||||||
|
|
||||||
@@ -18,19 +18,7 @@ import yaml
|
|||||||
logger = logging.getLogger('transform_fsm')
|
logger = logging.getLogger('transform_fsm')
|
||||||
|
|
||||||
|
|
||||||
def main(args=None):
|
def transform_fsm(data):
|
||||||
if args is None:
|
|
||||||
args = sys.argv[1:]
|
|
||||||
parsed_args = docopt(__doc__, args)
|
|
||||||
if parsed_args['--debug']:
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
|
||||||
elif parsed_args['--verbose']:
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
|
||||||
else:
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
|
||||||
|
|
||||||
with open(parsed_args['<input>']) as f:
|
|
||||||
data = yaml.load(f.read())
|
|
||||||
|
|
||||||
state_map = dict()
|
state_map = dict()
|
||||||
|
|
||||||
@@ -50,6 +38,24 @@ def main(args=None):
|
|||||||
for state in data['states']:
|
for state in data['states']:
|
||||||
state['functions'] = sorted(state['functions'].items())
|
state['functions'] = sorted(state['functions'].items())
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
def main(args=None):
|
||||||
|
if args is None:
|
||||||
|
args = sys.argv[1:]
|
||||||
|
parsed_args = docopt(__doc__, args)
|
||||||
|
if parsed_args['--debug']:
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
elif parsed_args['--verbose']:
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
else:
|
||||||
|
logging.basicConfig(level=logging.WARNING)
|
||||||
|
|
||||||
|
with open(parsed_args['<input>']) as f:
|
||||||
|
data = yaml.load(f.read())
|
||||||
|
|
||||||
|
data = transform_fsm(data)
|
||||||
|
|
||||||
with open(parsed_args['<output>'], 'w') as f:
|
with open(parsed_args['<output>'], 'w') as f:
|
||||||
f.write(yaml.safe_dump(data, default_flow_style=False))
|
f.write(yaml.safe_dump(data, default_flow_style=False))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user