@@ -2,6 +2,8 @@ import { AppComponent, Component, AnchorComponent, UListComponent } from './app'
2
2
import { solver } from "./solver" ;
3
3
import { library , icon } from '@fortawesome/fontawesome-svg-core'
4
4
import { faBrain , faPauseCircle , faPlayCircle , faCheckCircle , faXmarkCircle } from '@fortawesome/free-solid-svg-icons'
5
+ import { TimelinesChart } from './solver_timelines' ;
6
+ import { SolverGraph } from './solver_graph' ;
5
7
6
8
library . add ( faBrain , faPauseCircle , faPlayCircle , faCheckCircle , faXmarkCircle ) ;
7
9
@@ -10,7 +12,7 @@ export class SolverAnchor extends AnchorComponent<solver.Solver> implements solv
10
12
constructor ( solver : solver . Solver ) {
11
13
super ( solver ) ;
12
14
solver . add_solver_listener ( this ) ;
13
- this . element . addEventListener ( 'click' , ( ) => { AppComponent . get_instance ( ) . selected_component ( this ) ; } ) ;
15
+ this . element . addEventListener ( 'click' , ( ) => { AppComponent . get_instance ( ) . payload . selected_component ( this ) ; } ) ;
14
16
}
15
17
16
18
init ( items : Map < string , solver . values . Value > , atoms : Map < number , solver . values . Atom > , state : solver . SolverState , flaws : Map < number , solver . graph . Flaw > , resolvers : Map < number , solver . graph . Resolver > , c_flaw : solver . graph . Flaw | null , c_resolver : solver . graph . Resolver | null ) : void { this . render ( ) ; }
@@ -25,10 +27,10 @@ export class SolverAnchor extends AnchorComponent<solver.Solver> implements solv
25
27
this . element . innerHTML = to_icon ( this . payload . get_state ( ) ) + ' ' + this . payload . get_name ( ) ;
26
28
}
27
29
28
- unmounted ( ) : void {
30
+ unmounting ( ) : void {
29
31
this . payload . remove_solver_listener ( this ) ;
30
- if ( AppComponent . get_instance ( ) . get_selected_component ( ) === this )
31
- AppComponent . get_instance ( ) . selected_component ( null ) ;
32
+ if ( AppComponent . get_instance ( ) . payload . get_selected_component ( ) === this )
33
+ AppComponent . get_instance ( ) . payload . selected_component ( null ) ;
32
34
}
33
35
}
34
36
@@ -52,9 +54,73 @@ export class SolverListComponent extends UListComponent<solver.Solver> {
52
54
53
55
export class SolverComponent extends Component < solver . Solver , HTMLDivElement > {
54
56
57
+ private timelines_chart : TimelinesChart ;
58
+ private graph_component : SolverGraph ;
59
+
55
60
constructor ( solver : solver . Solver ) {
56
61
super ( solver , document . createElement ( 'div' ) ) ;
57
- this . element . classList . add ( 'flex-grow-1' , 'd-flex' , 'flex-column' ) ;
62
+ this . element . classList . add ( 'd-flex' , 'flex-column' , 'flex-grow-1' ) ;
63
+ const fragment = document . createDocumentFragment ( ) ;
64
+ const pills = document . createElement ( 'ul' ) ;
65
+ pills . classList . add ( 'nav' , 'nav-pills' , 'mb-3' ) ;
66
+
67
+ const timelines_pill = document . createElement ( 'li' ) ;
68
+ timelines_pill . role = 'presentation' ;
69
+ const timelines_pill_link = document . createElement ( 'a' ) ;
70
+ timelines_pill_link . classList . add ( 'nav-link' , 'active' ) ;
71
+ timelines_pill_link . id = 'timelines-tab' ;
72
+ timelines_pill_link . setAttribute ( 'data-bs-toggle' , 'pill' ) ;
73
+ timelines_pill_link . setAttribute ( 'data-bs-target' , '#slv-' + solver . get_id ( ) + '-timelines' ) ;
74
+ timelines_pill_link . setAttribute ( 'role' , 'tab' ) ;
75
+ timelines_pill_link . setAttribute ( 'aria-controls' , 'timelines' ) ;
76
+ timelines_pill_link . setAttribute ( 'aria-selected' , 'true' ) ;
77
+ timelines_pill_link . innerText = 'Timelines' ;
78
+ timelines_pill . appendChild ( timelines_pill_link ) ;
79
+ pills . appendChild ( timelines_pill ) ;
80
+
81
+ const graph_pill = document . createElement ( 'li' ) ;
82
+ graph_pill . role = 'presentation' ;
83
+ const graph_pill_link = document . createElement ( 'a' ) ;
84
+ graph_pill_link . classList . add ( 'nav-link' ) ;
85
+ graph_pill_link . id = 'graph-tab' ;
86
+ graph_pill_link . setAttribute ( 'data-bs-toggle' , 'pill' ) ;
87
+ graph_pill_link . setAttribute ( 'data-bs-target' , '#slv-' + solver . get_id ( ) + '-graph' ) ;
88
+ graph_pill_link . setAttribute ( 'role' , 'tab' ) ;
89
+ graph_pill_link . setAttribute ( 'aria-controls' , 'graph' ) ;
90
+ graph_pill_link . setAttribute ( 'aria-selected' , 'false' ) ;
91
+ graph_pill_link . innerText = 'Graph' ;
92
+ graph_pill . appendChild ( graph_pill_link ) ;
93
+ pills . appendChild ( graph_pill ) ;
94
+
95
+ fragment . appendChild ( pills ) ;
96
+
97
+ const tab_content = document . createElement ( 'div' ) ;
98
+ tab_content . classList . add ( 'tab-content' ) ;
99
+ tab_content . id = 'slv-' + solver . get_id ( ) + '-tab-content' ;
100
+
101
+ const timelines = document . createElement ( 'div' ) ;
102
+ timelines . classList . add ( 'tab-pane' , 'fade' , 'show' , 'active' ) ;
103
+ timelines . id = 'slv-' + solver . get_id ( ) + '-timelines' ;
104
+ timelines . setAttribute ( 'role' , 'tabpanel' ) ;
105
+ timelines . setAttribute ( 'aria-labelledby' , 'timelines-tab' ) ;
106
+ tab_content . appendChild ( timelines ) ;
107
+
108
+ const graph = document . createElement ( 'div' ) ;
109
+ graph . classList . add ( 'tab-pane' , 'fade' ) ;
110
+ graph . id = 'slv-' + solver . get_id ( ) + '-graph' ;
111
+ graph . setAttribute ( 'role' , 'tabpanel' ) ;
112
+ graph . setAttribute ( 'aria-labelledby' , 'graph-tab' ) ;
113
+ tab_content . appendChild ( graph ) ;
114
+
115
+ fragment . appendChild ( tab_content ) ;
116
+
117
+ this . timelines_chart = new TimelinesChart ( solver ) ;
118
+ this . graph_component = new SolverGraph ( solver ) ;
119
+ }
120
+
121
+ unmounting ( ) : void {
122
+ this . timelines_chart . remove ( ) ;
123
+ this . graph_component . remove ( ) ;
58
124
}
59
125
}
60
126
0 commit comments