4
4
* Licensed under The Universal Permissive License (UPL), Version 1.0 as shown at https://oss.oracle.com/licenses/upl/
5
5
*/
6
6
define ( [ 'accUtils' , 'utils/i18n' , 'knockout' , 'models/wkt-project' , 'utils/url-catalog' , 'utils/view-helper' ,
7
- 'utils/wkt-logger' , 'wrc-frontend/core/parsers/ yaml' , 'wrc-frontend/integration/viewModels/utils' ,
8
- 'wdt-model-designer/loader' , ' ojs/ojinputtext', 'ojs/ojlabel' , 'ojs/ojbutton' , 'ojs/ojformlayout' ] ,
9
- function ( accUtils , i18n , ko , project , urlCatalog , viewHelper , wktLogger , YamlParser , ViewModelUtils ) {
7
+ 'utils/wkt-logger' , 'js- yaml' , 'wrc-frontend/integration/viewModels/utils' , 'wdt-model-designer/loader ',
8
+ 'ojs/ojinputtext' , 'ojs/ojlabel' , 'ojs/ojbutton' , 'ojs/ojformlayout' ] ,
9
+ function ( accUtils , i18n , ko , project , urlCatalog , viewHelper , wktLogger , jsYaml , ViewModelUtils ) {
10
10
function ModelDesignViewModel ( ) {
11
11
12
12
let subscriptions = [ ] ;
@@ -15,6 +15,7 @@ function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, YamlPar
15
15
this . designer = undefined ;
16
16
this . dataProvider = { } ;
17
17
this . disableStartButton = ko . observable ( false ) ;
18
+ this . wrcBackendTriggerChange = false ;
18
19
19
20
this . connected = ( ) => {
20
21
accUtils . announce ( 'Model design view loaded.' , 'assertive' ) ;
@@ -29,7 +30,11 @@ function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, YamlPar
29
30
wktLogger . debug ( 'Model Design View got event for Model contents changed' ) ;
30
31
31
32
if ( this . designer ) {
32
- this . createRemoteConsoleProvider ( this . designer , true ) ;
33
+ if ( this . wrcBackendTriggerChange ) {
34
+ this . wrcBackendTriggerChange = false ;
35
+ } else {
36
+ this . createRemoteConsoleProvider ( this . designer , true ) ;
37
+ }
33
38
}
34
39
} , this ) ) ;
35
40
@@ -134,44 +139,49 @@ function(accUtils, i18n, ko, project, urlCatalog, viewHelper, wktLogger, YamlPar
134
139
}
135
140
136
141
const providerOptions = this . getRemoteConsoleProviderOptions ( ) ;
137
- // TODO - Do we need to use the Remote Console parser or can we just use js-yaml?
138
- //
139
- YamlParser . parse ( providerOptions . fileContents ) . then ( data => {
142
+ try {
143
+ const data = jsYaml . load ( providerOptions . fileContents ) ;
140
144
wdtModelDesigner . createProvider ( providerOptions . name , data ) ;
141
- } ) . catch ( err => {
145
+ } catch ( err ) {
142
146
ViewModelUtils . failureResponseDefaultHandling ( err ) ;
143
- } ) ;
147
+ }
144
148
} ;
145
149
146
150
// Triggered when WDT Model File provider has been activated with the WRC backend.
147
151
//
148
152
this . providerActivated = ( event ) => {
149
153
this . dataProvider = event . detail . value ;
154
+ wktLogger . debug ( 'Received providerActivated event with dataProvider = %s' , JSON . stringify ( this . dataProvider ) ) ;
150
155
this . designer . selectLastVisitedSlice ( ) ;
151
156
} ;
152
157
153
158
// Triggered when changes have been downloaded from the WRC backend, for the active WDT Model File provider.
154
159
//
155
160
this . changesAutoDownloaded = ( event ) => {
156
- wktLogger . debug ( 'changesAutoDownloaded event: %s' , event . detail . value ) ;
161
+ wktLogger . debug ( 'Received changesAutoDownloaded event with modelContent = %s' , event . detail . value ) ;
162
+ this . wrcBackendTriggerChange = true ;
157
163
this . project . wdtModel . modelContent ( event . detail . value ) ;
158
164
} ;
159
165
160
166
// Triggered when WDT Model File provider has been deactivated with the WRC backend.
161
167
//
162
168
this . providerDeactivated = ( event ) => {
163
169
const result = event . detail . value ;
170
+ wktLogger . debug ( 'Received providerDeactivated event with dataProvider = %s' , JSON . stringify ( result ) ) ;
164
171
delete result . data ;
165
172
this . dataProvider = { state : 'disconnected' } ;
166
173
} ;
167
174
168
175
// Triggered when WDT Model Designer has lost its connection to the WRC backend.
169
176
//
170
177
this . connectionLostRefused = ( event ) => {
171
- wktLogger . debug ( 'connectionLostRefused: backendUrl= %s' , event . detail . value ) ;
178
+ wktLogger . debug ( 'Received connectionLostRefused event with backendUrl = %s' , event . detail . value ) ;
172
179
if ( this . designer ) {
173
180
this . designer . visible = false ;
174
181
}
182
+ // Technically, this should not be needed since the electron side should be pushing this port
183
+ // change to the window when the backend process exits, but it doesn't hurt anything.
184
+ //
175
185
this . project . wdtModel . internal . wlRemoteConsolePort ( undefined ) ;
176
186
} ;
177
187
0 commit comments