@kumologica/sdk 3.5.4 → 3.6.0-alpha7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/cli/cli.js +31 -8
  2. package/cli/commands/open.js +88 -15
  3. package/cli/commands/run.js +167 -0
  4. package/cli/commands/serve.js +139 -0
  5. package/package.json +5 -5
  6. package/src/app/main-process/main-window.js +1 -0
  7. package/src/app/main-process/modal-home.js +1 -0
  8. package/src/app/main-process/modal-newproject.js +1 -0
  9. package/src/app/main-process/modal-newtab.js +1 -0
  10. package/src/app/main-process/modal-nodelibrary.js +1 -0
  11. package/src/app/main-process/modal-renameTab.js +1 -0
  12. package/src/app/main-process/modal-welcome.js +1 -0
  13. package/src/app/main.js +179 -141
  14. package/src/app/preload.js +225 -139
  15. package/src/app/ui/editor-client/public/red/red.js +1943 -783
  16. package/src/app/ui/editor-client/public/red/red.min.js +2 -2
  17. package/src/app/ui/editor-client/public/red/style.min.css +1 -1
  18. package/src/app/ui/editor-client/public/vendor/ace-linters/javascript-service.js +10 -2
  19. package/src/app/ui/editor-client/src/js/red.js +183 -179
  20. package/src/app/ui/editor-client/src/js/ui/common/commandBox.js +107 -0
  21. package/src/app/ui/editor-client/src/js/ui/common/searchBox.js +91 -90
  22. package/src/app/ui/editor-client/src/js/ui/modules.js +164 -0
  23. package/src/app/ui/editor-client/src/js/ui/search.js +171 -123
  24. package/src/app/ui/editor-client/src/js/ui/sidebar.js +1 -1
  25. package/src/app/ui/editor-client/src/js/ui/ui-settings.js +419 -410
  26. package/src/app/ui/editor-client/src/sass/editor.scss +745 -746
  27. package/src/app/ui/editor-client/src/sass/forms.scss +1 -1
  28. package/src/app/ui/editor-client/src/sass/search.scss +16 -2
  29. package/src/app/ui/editor-client/src/sass/sidebar.scss +1 -1
  30. package/src/app/ui/editor-client/src/sass/style.scss +72 -69
  31. package/src/app/ui/editor-client/src/sass/ui/common/commandBox.scss +100 -0
  32. package/src/app/ui/editor-client/src/sass/ui/common/searchBox.scss +3 -2
  33. package/src/app/ui/editor-client/src/sass/ui-settings.scss +14 -14
  34. package/src/app/ui/editor-client/src/vendor/ace-linters/build/javascript-service.js +10 -2
  35. package/src/app/ui/editor-client/templates/index.mst +2 -2
  36. package/src/server/DesignerServer.js +152 -153
@@ -1,59 +1,64 @@
1
- RED.uiSettings = (function(){
2
- let testConfigStore;
3
- let cloudConfigStore = window.__kumologica.settings.cloudConfigStore;
4
- let networkConfigStore = window.__kumologica.settings.networkConfigStore
5
- let shell = window.__kumologica.electron.shell;
6
- let dialog = null;
7
- let visible = false;
8
- let cmInstanceCloud = null;
9
- let cmInstanceEnvvars = null;
10
- let totalHeightAvailable;
11
-
12
- let screen;
13
-
14
- function getScreen() {
15
- if (!screen){
16
- // we get a reference here and not like the rest of the stores, as the testConfig relies on the project details set which are injected in the header.
17
- testConfigStore = window.__kumologica.settings.testConfig;
18
- // initialize the screen now
19
- screen = [
20
- { "selected": true,
21
- "id": "ui-settings-creds",
22
- "label": "Cloud Profiles",
23
- "body": {
24
- "title": "Cloud Profiles",
25
- "subtitle": `
1
+ RED.uiSettings = (function () {
2
+ let testConfigStore;
3
+ let cloudConfigStore = window.__kumologica.settings.cloudConfigStore;
4
+ let networkConfigStore = window.__kumologica.settings.networkConfigStore;
5
+ let shell = window.__kumologica.electron.shell;
6
+ let dialog = null;
7
+ let visible = false;
8
+ let cmInstanceCloud = null;
9
+ let cmInstanceEnvvars = null;
10
+ let totalHeightAvailable;
11
+
12
+ let screen;
13
+
14
+ function getScreen() {
15
+ if (!screen) {
16
+ // we get a reference here and not like the rest of the stores, as the testConfig relies on the project details set which are injected in the header.
17
+ testConfigStore = window.__kumologica.settings.testConfig;
18
+ // initialize the screen now
19
+ screen = [
20
+ {
21
+ selected: true,
22
+ id: "ui-settings-creds",
23
+ label: "Cloud Profiles",
24
+ body: {
25
+ title: "Cloud Profiles",
26
+ subtitle: `
26
27
  Configure all of your cloud profile settings that can be used by this designer to support testing or deploying.
27
28
  <a href="https://docs.kumologica.com/docs/guide/Intro.html" target="_blank">Learn more</a>`,
28
- "html": `
29
+ html: `
29
30
  <div>
30
31
  <div id="fileLocationPath">
31
32
  <span id="settingFilePath">${cloudConfigStore.getCloudConfigFileFullPath()}</span>
32
33
  </div>
33
34
  <textarea id="cloud-settings-editor" rows="20">
34
35
  </textarea>
35
- </div>`
36
- },
37
- "onInit": () => {
38
- // load content of config credentials file: ~/.kumologica/credentials
39
- let cloudConfigContent = cloudConfigStore.readCloudConfigFile();
40
- cmInstanceCloud = initEditor('cloud-settings-editor', cloudConfigContent);
41
- },
42
- "onSelect": () => {
43
- cmInstanceCloud.refresh();
44
- },
45
- "onSave": () => {
46
- cloudConfigStore.writeCloudConfigFile(cmInstanceCloud.getValue());
47
- RED.events.emit('settings:cloud-config-changed');
48
- }
36
+ </div>`,
37
+ },
38
+ onInit: () => {
39
+ // load content of config credentials file: ~/.kumologica/credentials
40
+ let cloudConfigContent = cloudConfigStore.readCloudConfigFile();
41
+ cmInstanceCloud = initEditor(
42
+ "cloud-settings-editor",
43
+ cloudConfigContent
44
+ );
45
+ },
46
+ onSelect: () => {
47
+ cmInstanceCloud.refresh();
49
48
  },
50
- {
51
- "id": "ui-settings-network",
52
- "label": "Network",
53
- "body": {
54
- "title": "Proxy Server Settings",
55
- "subtitle": "Configure the proxy settings used by the designer. Flows will use the proxy specified on the nodes instead.",
56
- "html": `
49
+ onSave: () => {
50
+ cloudConfigStore.writeCloudConfigFile(cmInstanceCloud.getValue());
51
+ RED.events.emit("settings:cloud-config-changed");
52
+ },
53
+ },
54
+ {
55
+ id: "ui-settings-network",
56
+ label: "Network",
57
+ body: {
58
+ title: "Proxy Server Settings",
59
+ subtitle:
60
+ "Configure the proxy settings used by the designer. Flows will use the proxy specified on the nodes instead.",
61
+ html: `
57
62
  <div>
58
63
  <form id="proxy-options-div">
59
64
  <input type="radio" id="proxy-option-default" name="proxy-option" style="margin:0"> Use default operating system settings<br>
@@ -64,45 +69,45 @@ RED.uiSettings = (function(){
64
69
  <div class="option"><label>Port</label><input type="text" id="proxy-port" /></div>
65
70
  </div>
66
71
  <div id="proxy-auth">
67
- <div id="proxyCredsRequiredBox" style="display: flex">
68
- <input type="checkbox" id="proxyAuthRequired" style="margin-right: 3px">
72
+ <div id="proxyCredsRequiredBox" style="display: flex; align-items: flex-start">
73
+ <input type="checkbox" id="proxyAuthRequired" style="margin-top: 3px; margin-right: 3px">
69
74
  <label>Proxy server requires username and password</label>
70
75
  </div>
71
- <div id="proxyCredsBox" style="padding-left: 40px">
76
+ <div id="proxyCredsBox" style="padding-top: 10px;padding-left: 40px">
72
77
  <div class="option"><label>Username</label><input type="text" id="proxy-auth-username" style="width:50%" /></div>
73
78
  <div class="option"><label>Password</label><input type="password" id="proxy-auth-password" style="width:50%"/></div>
74
79
  </div>
75
80
  </div>
76
81
  </div>
77
- `
78
- },
79
- "onInit": () => {
80
- // load content of config credentials file: ~/.kumologica/settings
81
- let proxySettings = networkConfigStore.getProxyDetails();
82
- initProxySettings(proxySettings);
83
- handleProxySettingsEvent();
84
- },
85
- "onSelect": () => {},
86
- "onSave": () => {
87
- // Save proxy details
88
- networkConfigStore.saveProxyDetails(
89
- $('#proxy-option-custom').is(':checked'), // custom clicked?
90
- $('#proxy-server').val(), // host
91
- $('#proxy-port').val(), // port
92
- $('#proxyAuthRequired').is(':checked'), // authentication clicked?
93
- $('#proxy-auth-username').val(), // username
94
- $('#proxy-auth-password').val() // password
95
- );
96
- }
82
+ `,
83
+ },
84
+ onInit: () => {
85
+ // load content of config credentials file: ~/.kumologica/settings
86
+ let proxySettings = networkConfigStore.getProxyDetails();
87
+ initProxySettings(proxySettings);
88
+ handleProxySettingsEvent();
97
89
  },
98
- {
99
- "id": "ui-settings-envvars",
100
- "label": "Environments",
101
- "body": {
102
- "title": "Environments",
103
- "subtitle": `
90
+ onSelect: () => {},
91
+ onSave: () => {
92
+ // Save proxy details
93
+ networkConfigStore.saveProxyDetails(
94
+ $("#proxy-option-custom").is(":checked"), // custom clicked?
95
+ $("#proxy-server").val(), // host
96
+ $("#proxy-port").val(), // port
97
+ $("#proxyAuthRequired").is(":checked"), // authentication clicked?
98
+ $("#proxy-auth-username").val(), // username
99
+ $("#proxy-auth-password").val() // password
100
+ );
101
+ },
102
+ },
103
+ {
104
+ id: "ui-settings-envvars",
105
+ label: "Environments",
106
+ body: {
107
+ title: "Environments",
108
+ subtitle: `
104
109
  Environments are groups of key value pairs (variables) that allow you to quickly set a different context for each test executions`,
105
- "html": `
110
+ html: `
106
111
  <div>
107
112
  <!--
108
113
  <div id="fileLocationPath">
@@ -110,390 +115,394 @@ RED.uiSettings = (function(){
110
115
  </div> -->
111
116
  <textarea id="envvar-settings-editor" rows="20">
112
117
  </textarea>
113
- </div>`
114
- },
115
- "onInit": () => {
116
- let envvarConfigContent = testConfigStore.getEnvironmentSectionFromConfig();
117
- cmInstanceEnvvars = initEditor('envvar-settings-editor', envvarConfigContent);
118
- },
119
- "onSelect": () => {
120
- cmInstanceEnvvars.refresh();
121
- },
122
- "onSave": () => {
123
- testConfigStore.saveEnvironmentSectionIntoConfig(cmInstanceEnvvars.getValue());
124
- RED.events.emit('settings:environment-variables-changed');
125
- }
126
- }
127
- ];
128
- }
129
- return screen;
118
+ </div>`,
119
+ },
120
+ onInit: () => {
121
+ let envvarConfigContent =
122
+ testConfigStore.getEnvironmentSectionFromConfig();
123
+ cmInstanceEnvvars = initEditor(
124
+ "envvar-settings-editor",
125
+ envvarConfigContent
126
+ );
127
+ },
128
+ onSelect: () => {
129
+ cmInstanceEnvvars.refresh();
130
+ },
131
+ onSave: () => {
132
+ testConfigStore.saveEnvironmentSectionIntoConfig(
133
+ cmInstanceEnvvars.getValue()
134
+ );
135
+ RED.events.emit("settings:environment-variables-changed");
136
+ },
137
+ },
138
+ ];
130
139
  }
140
+ return screen;
141
+ }
131
142
 
132
- function createDialog() {
133
-
143
+ function createDialog() {
144
+ // remove if previous dialog exist
145
+ $("#ui-settings").remove();
134
146
 
135
- // remove if previous dialog exist
136
- $('#ui-settings').remove();
147
+ dialog = $("<div>", {
148
+ id: "ui-settings",
149
+ class: "ui-settings",
150
+ }).appendTo("#main-container");
137
151
 
138
- dialog = $('<div>', {
139
- id: 'ui-settings',
140
- class: 'ui-settings',
141
- }).appendTo('#main-container');
152
+ // Programmatically calculate the height of the ui-settings window
153
+ totalHeightAvailable = $("#main-container").height();
154
+ let offset = 74;
155
+ $("#ui-settings").height(900);
142
156
 
143
- // Programmatically calculate the height of the ui-settings window
144
- totalHeightAvailable = $('#main-container').height();
145
- let offset = 74;
146
- $('#ui-settings').height(totalHeightAvailable - offset);
157
+ let wrapperDiv = $("<div>", {
158
+ class: "ui-settings-body",
159
+ }).appendTo(dialog);
147
160
 
148
- let wrapperDiv = $('<div>', {
149
- class: 'ui-settings-body'
150
- }).appendTo(dialog);
151
-
152
- // Left pannel of settings
153
- let optionsDiv = $(`
161
+ // Left pannel of settings
162
+ let optionsDiv = $(`
154
163
  <div id="ui-settings-options">
155
164
  </div>
156
165
  `).appendTo(wrapperDiv);
157
166
 
158
- // Left pannel of settings
159
- getScreen().forEach(option => {
160
- if (option.selected){
161
- $(`
167
+ // Left pannel of settings
168
+ getScreen().forEach((option) => {
169
+ if (option.selected) {
170
+ $(`
162
171
  <div id="${option.id}" class="ui-settings-option ui-settings-option-selected">
163
172
  <span class="settingsOptionLabel">
164
173
  ${option.label}
165
174
  </span>
166
175
  </div>`).appendTo(optionsDiv);
167
- } else {
168
- $(`
176
+ } else {
177
+ $(`
169
178
  <div id="${option.id}" class="ui-settings-option ui-settings-option">
170
179
  <span class="settingsOptionLabel">
171
180
  ${option.label}
172
181
  </span>
173
182
  </div>`).appendTo(optionsDiv);
174
- }
175
-
176
- });
183
+ }
184
+ });
177
185
 
178
- // Right pannel of settings
179
- let optionsBodyDiv = $(`
186
+ // Right pannel of settings
187
+ let optionsBodyDiv = $(`
180
188
  <div id="ui-settings-optionsbody">
181
189
  </div>
182
- `).appendTo(wrapperDiv)
190
+ `).appendTo(wrapperDiv);
183
191
 
184
- getScreen().forEach(option => {
185
- $(`
192
+ getScreen().forEach((option) => {
193
+ $(`
186
194
  <div id="${option.id}-body" class="ui-settings-general-body">
187
- <div>
195
+ <div style="display=flex; flex-direction: column; height:100%">
188
196
  <div class="settingsTitle">${option.body.title}</div>
189
197
  <div class="settingsSubtitle">${option.body.subtitle}</div>
190
198
  ${option.body.html}
191
199
  </div>
192
200
  </div>
193
- `).appendTo(optionsBodyDiv)
194
- });
195
-
196
- $(`
197
- <div class="editor-tray-toolbar" style="top: 16px !important">
201
+ `).appendTo(optionsBodyDiv);
202
+ });
203
+
204
+ $(`
205
+ <div class="editor-tray-toolbar">
198
206
  <button class="ui-button ui-widget ui-state-default ui-corner-all ui-buton-text-only secondary" role="button" aria-disabled="false" id="options-cancel">Cancel</button>
199
207
  <button class="ui-button ui-widget ui-state-default ui-corner-all ui-buton-text-only primary" role="button" aria-disabled="false" id="options-save">Save</button>
200
208
  </div>
201
209
  `).appendTo(optionsBodyDiv);
202
210
 
203
- // Initialize the options body screen
204
- getScreen().forEach(option => {
205
- // Left click on option
206
- $(`#${option.id}`).click ((e) => {
207
- resetWindows();
208
- $(`#${option.id}`).addClass('ui-settings-option-selected');
209
- $(`#${option.id}-body`).show();
210
- option.onSelect();
211
- });
212
- // Specific functionality
213
- option.onInit()
214
-
215
- // Hide screen if not default
216
- if (option.hasOwnProperty("selected") && option.selected){
217
- $(`#${option.id}-body`).show();
218
- } else {
219
- $(`#${option.id}-body`).hide();
220
- }
221
- });
222
- // Initialize the toolbar
223
- $('#options-save').click(e=> {
224
- saveSettings();
225
- });
226
-
227
- $('#options-cancel').click(e => {
228
- cancelSettings();
229
- });
230
-
231
- }
232
-
233
- function saveSettings() {
234
- getScreen().forEach(option => {
235
- option.onSave();
236
- })
237
- hide();
238
- }
239
-
240
- function cancelSettings() {
241
- hide();
242
- }
243
-
244
- function selectProxyCustom() {
245
- setTimeout(() => {
246
- $('#proxy-option-custom').prop('checked', true);
247
- $('#proxy-option-default').prop('checked', false);
248
- }, 50);
249
-
250
- $('#proxy-server').prop('readonly', false);
251
- $('#proxy-port').prop('readonly', false);
252
- }
253
-
254
- function selectProxyDefault(){
255
- setTimeout(() => {
256
- $('#proxy-option-custom').prop('checked', false);
257
- $('#proxy-option-default').prop('checked', true);
258
- }, 50);
259
-
260
- $('#proxy-server').prop('readonly', true);
261
- $('#proxy-port').prop('readonly', true);
262
- }
263
-
264
- function selectProxyAuth() {
265
- setTimeout(() => {
266
- let isChecked = $('#proxyAuthRequired').is(':checked');
267
- if (isChecked){
268
- $('#proxyAuthRequired').prop('checked', false);
269
- $('#proxy-auth-username').prop('readonly', true);
270
- $('#proxy-auth-password').prop('readonly', true);
271
- } else {
272
- $('#proxyAuthRequired').prop('checked', true);
273
- $('#proxy-auth-username').prop('readonly', false);
274
- $('#proxy-auth-password').prop('readonly', false);
275
- }
276
- }, 50);
277
- }
278
-
279
- function handleProxySettingsEvent(){
280
- $('#proxy-option-default').click( () => {
281
- RED.events.emit('settings:select-proxy-default');
282
- return false;
283
- });
284
-
285
- $('#proxy-option-custom').click( () => {
286
- RED.events.emit('settings:select-proxy-custom');
287
- return false;
211
+ // Initialize the options body screen
212
+ getScreen().forEach((option) => {
213
+ // Left click on option
214
+ $(`#${option.id}`).click((e) => {
215
+ resetWindows();
216
+ $(`#${option.id}`).addClass("ui-settings-option-selected");
217
+ $(`#${option.id}-body`).show();
218
+ option.onSelect();
288
219
  });
220
+ // Specific functionality
221
+ option.onInit();
289
222
 
290
- $('#proxyAuthRequired').click( function(e){
291
- RED.events.emit('settings:select-proxy-auth');
292
- return false;
293
- });
294
- }
295
-
296
- function initProxySettings(proxySettings){
297
- // console.log('[ui-settings] initProxySettings with settings:', proxySettings);
298
- // Proxy server
299
- if (proxySettings.custom){
300
- $('#proxy-option-custom').prop('checked', true);
301
- $('#proxy-option-default').prop('checked', false);
302
- $('#proxy-server').val(proxySettings.host);
303
- $('#proxy-port').val(proxySettings.port || '8080');
223
+ // Hide screen if not default
224
+ if (option.hasOwnProperty("selected") && option.selected) {
225
+ $(`#${option.id}-body`).show();
304
226
  } else {
305
- $('#proxy-option-default').prop('checked', true);
306
- $('#proxy-option-custom').prop('checked', false);
307
- $('#proxy-server').prop('readonly', true);
308
- $('#proxy-port').prop('readonly', true);
227
+ $(`#${option.id}-body`).hide();
309
228
  }
310
- // Proxy auth
311
- if (proxySettings.authentication){
312
- $('#proxyAuthRequired').prop('checked', true);
313
- $('#proxy-auth-username').val(proxySettings.username);
314
- $('#proxy-auth-password').val(proxySettings.password);
229
+ });
230
+ // Initialize the toolbar
231
+ $("#options-save").click((e) => {
232
+ saveSettings();
233
+ });
234
+
235
+ $("#options-cancel").click((e) => {
236
+ cancelSettings();
237
+ });
238
+ }
239
+
240
+ function saveSettings() {
241
+ getScreen().forEach((option) => {
242
+ option.onSave();
243
+ });
244
+ hide();
245
+ }
246
+
247
+ function cancelSettings() {
248
+ hide();
249
+ }
250
+
251
+ function selectProxyCustom() {
252
+ setTimeout(() => {
253
+ $("#proxy-option-custom").prop("checked", true);
254
+ $("#proxy-option-default").prop("checked", false);
255
+ }, 50);
256
+
257
+ $("#proxy-server").prop("readonly", false);
258
+ $("#proxy-port").prop("readonly", false);
259
+ }
260
+
261
+ function selectProxyDefault() {
262
+ setTimeout(() => {
263
+ $("#proxy-option-custom").prop("checked", false);
264
+ $("#proxy-option-default").prop("checked", true);
265
+ }, 50);
266
+
267
+ $("#proxy-server").prop("readonly", true);
268
+ $("#proxy-port").prop("readonly", true);
269
+ }
270
+
271
+ function selectProxyAuth() {
272
+ setTimeout(() => {
273
+ let isChecked = $("#proxyAuthRequired").is(":checked");
274
+ if (isChecked) {
275
+ $("#proxyAuthRequired").prop("checked", false);
276
+ $("#proxy-auth-username").prop("readonly", true);
277
+ $("#proxy-auth-password").prop("readonly", true);
315
278
  } else {
316
- $('#proxyAuthRequired').prop('checked', false);
317
- $('#proxy-auth-username').prop('readonly', true);
318
- $('#proxy-auth-password').prop('readonly', true);
279
+ $("#proxyAuthRequired").prop("checked", true);
280
+ $("#proxy-auth-username").prop("readonly", false);
281
+ $("#proxy-auth-password").prop("readonly", false);
319
282
  }
320
-
321
- RED.events.on('settings:select-proxy-custom', selectProxyCustom);
322
- RED.events.on('settings:select-proxy-default', selectProxyDefault);
323
- RED.events.on('settings:select-proxy-auth', selectProxyAuth);
283
+ }, 50);
284
+ }
285
+
286
+ function handleProxySettingsEvent() {
287
+ $("#proxy-option-default").click(() => {
288
+ RED.events.emit("settings:select-proxy-default");
289
+ return false;
290
+ });
291
+
292
+ $("#proxy-option-custom").click(() => {
293
+ RED.events.emit("settings:select-proxy-custom");
294
+ return false;
295
+ });
296
+
297
+ $("#proxyAuthRequired").click(function (e) {
298
+ RED.events.emit("settings:select-proxy-auth");
299
+ return false;
300
+ });
301
+ }
302
+
303
+ function initProxySettings(proxySettings) {
304
+ // console.log('[ui-settings] initProxySettings with settings:', proxySettings);
305
+ // Proxy server
306
+ if (proxySettings.custom) {
307
+ $("#proxy-option-custom").prop("checked", true);
308
+ $("#proxy-option-default").prop("checked", false);
309
+ $("#proxy-server").val(proxySettings.host);
310
+ $("#proxy-port").val(proxySettings.port || "8080");
311
+ } else {
312
+ $("#proxy-option-default").prop("checked", true);
313
+ $("#proxy-option-custom").prop("checked", false);
314
+ $("#proxy-server").prop("readonly", true);
315
+ $("#proxy-port").prop("readonly", true);
324
316
  }
325
-
326
- function initEditor(anchorId, contentBody) {
327
- CodeMirror.defineMode("properties", function() {
328
- return {
329
- token: function(stream, state) {
330
- var sol = stream.sol() || state.afterSection;
331
- var eol = stream.eol();
332
-
333
- state.afterSection = false;
334
-
335
- if (sol) {
336
- if (state.nextMultiline) {
337
- state.inMultiline = true;
338
- state.nextMultiline = false;
339
- } else {
340
- state.position = "def";
341
- }
342
- }
343
-
344
- if (eol && ! state.nextMultiline) {
345
- state.inMultiline = false;
346
- state.position = "def";
347
- }
348
-
349
- if (sol) {
350
- while(stream.eatSpace()) {}
351
- }
352
-
353
- var ch = stream.next();
354
-
355
- if (sol && (ch === "#" || ch === "!" || ch === ";")) {
356
- state.position = "comment";
357
- stream.skipToEnd();
358
- return "comment";
359
- } else if (sol && ch === "[") {
360
- state.afterSection = true;
361
- stream.skipTo("]"); stream.eat("]");
362
- return "header";
363
- } else if (ch === "=") {
364
- state.position = "quote";
365
- return null;
366
- } else if (ch === "\\" && state.position === "quote") {
367
- if (stream.eol()) { // end of line?
368
- // Multiline value
369
- state.nextMultiline = true;
370
- }
371
- }
372
-
373
- return state.position;
374
- },
375
-
376
- startState: function() {
377
- return {
378
- position : "def", // Current position, "def", "quote" or "comment"
379
- nextMultiline : false, // Is the next line multiline value
380
- inMultiline : false, // Is the current line a multiline value
381
- afterSection : false // Did we just open a section
382
- };
383
- }
384
-
385
- };
386
- });
387
- let cmInstance = CodeMirror.fromTextArea(document.getElementById(anchorId), {
388
- theme: "monokai",
389
- lineWrapping: true,
390
- mode: 'properties'
391
- });
392
-
393
- // reset the listenere
394
- cmInstance.off("change");
395
-
396
- cmInstance.getDoc().setValue(contentBody);
397
- cmInstance.focus();
398
- //console.log(`lineCount: ${cmInstance.lineCount()}`)
399
- // Set the cursor at the end of existing content
400
- cmInstance.setCursor(cmInstance.lineCount(), 0);
401
- let codeMirrorHeight = totalHeightAvailable - 400;
402
-
403
- cmInstance.setSize(null, codeMirrorHeight);
404
- // cmInstance.refresh();
405
- setTimeout(function() {
406
- cmInstance.refresh();
407
- }, 100);
408
-
409
- cmInstance.on("change", function(cm, change){
410
- // enable the save button
411
- $('#options-save').removeClass('disabled');
412
- })
413
-
414
- return cmInstance;
317
+ // Proxy auth
318
+ if (proxySettings.authentication) {
319
+ $("#proxyAuthRequired").prop("checked", true);
320
+ $("#proxy-auth-username").val(proxySettings.username);
321
+ $("#proxy-auth-password").val(proxySettings.password);
322
+ } else {
323
+ $("#proxyAuthRequired").prop("checked", false);
324
+ $("#proxy-auth-username").prop("readonly", true);
325
+ $("#proxy-auth-password").prop("readonly", true);
415
326
  }
416
327
 
417
- function show(){
418
-
419
- // Disable the search dialog if opened
420
- RED.actions.invoke('core:search:close');
421
- RED.actions.invoke('core:project-info:close');
422
- if (!visible){
423
- RED.keyboard.add('*', 'escape', () => hide() );
424
-
425
- createDialog();
426
- dialog.slideDown(300);
427
- visible = true;
428
-
429
- // UI goodies
430
- $('#ui-settings').click( e=> {
431
- e.preventDefault();
432
- if ($(e.target).is('a')){
433
- shell.openExternal(e.target.href);
434
- }
435
- e.stopImmediatePropagation();
436
- });
437
-
438
- $('#main-container').click((e)=> {
439
- hide();
440
- });
441
- }
328
+ RED.events.on("settings:select-proxy-custom", selectProxyCustom);
329
+ RED.events.on("settings:select-proxy-default", selectProxyDefault);
330
+ RED.events.on("settings:select-proxy-auth", selectProxyAuth);
331
+ }
332
+
333
+ function initEditor(anchorId, contentBody) {
334
+ CodeMirror.defineMode("properties", function () {
335
+ return {
336
+ token: function (stream, state) {
337
+ var sol = stream.sol() || state.afterSection;
338
+ var eol = stream.eol();
339
+
340
+ state.afterSection = false;
341
+
342
+ if (sol) {
343
+ if (state.nextMultiline) {
344
+ state.inMultiline = true;
345
+ state.nextMultiline = false;
346
+ } else {
347
+ state.position = "def";
348
+ }
349
+ }
442
350
 
443
- }
351
+ if (eol && !state.nextMultiline) {
352
+ state.inMultiline = false;
353
+ state.position = "def";
354
+ }
444
355
 
445
- function showEnvironments() {
446
- show();
447
- $('#ui-settings-envvars').click();
448
- }
356
+ if (sol) {
357
+ while (stream.eatSpace()) {}
358
+ }
359
+
360
+ var ch = stream.next();
361
+
362
+ if (sol && (ch === "#" || ch === "!" || ch === ";")) {
363
+ state.position = "comment";
364
+ stream.skipToEnd();
365
+ return "comment";
366
+ } else if (sol && ch === "[") {
367
+ state.afterSection = true;
368
+ stream.skipTo("]");
369
+ stream.eat("]");
370
+ return "header";
371
+ } else if (ch === "=") {
372
+ state.position = "quote";
373
+ return null;
374
+ } else if (ch === "\\" && state.position === "quote") {
375
+ if (stream.eol()) {
376
+ // end of line?
377
+ // Multiline value
378
+ state.nextMultiline = true;
379
+ }
380
+ }
449
381
 
450
- function hide(){
451
- if (visible){
452
- $('#main-container').off('click');
453
- RED.keyboard.remove('escape');
454
- visible = false;
455
- if (dialog !== null) {
456
- dialog.slideUp(200, function () {
457
- // searchInput.searchBox('value', '');
458
- });
459
- }
382
+ return state.position;
383
+ },
384
+
385
+ startState: function () {
386
+ return {
387
+ position: "def", // Current position, "def", "quote" or "comment"
388
+ nextMultiline: false, // Is the next line multiline value
389
+ inMultiline: false, // Is the current line a multiline value
390
+ afterSection: false, // Did we just open a section
391
+ };
392
+ },
393
+ };
394
+ });
395
+ let cmInstance = CodeMirror.fromTextArea(
396
+ document.getElementById(anchorId),
397
+ {
398
+ theme: "monokai",
399
+ lineWrapping: true,
400
+ mode: "properties",
401
+ }
402
+ );
403
+
404
+ // reset the listenere
405
+ cmInstance.off("change");
406
+
407
+ cmInstance.getDoc().setValue(contentBody);
408
+ cmInstance.focus();
409
+ //console.log(`lineCount: ${cmInstance.lineCount()}`)
410
+ // Set the cursor at the end of existing content
411
+ cmInstance.setCursor(cmInstance.lineCount(), 0);
412
+ let codeMirrorHeight = 650; // totalHeightAvailable - 400;
413
+
414
+ cmInstance.setSize(null, codeMirrorHeight);
415
+ // cmInstance.refresh();
416
+ setTimeout(function () {
417
+ cmInstance.refresh();
418
+ }, 100);
419
+
420
+ cmInstance.on("change", function (cm, change) {
421
+ // enable the save button
422
+ $("#options-save").removeClass("disabled");
423
+ });
424
+
425
+ return cmInstance;
426
+ }
427
+
428
+ function show() {
429
+ // Disable the search dialog if opened
430
+ RED.actions.invoke("core:search:close");
431
+ RED.actions.invoke("core:project-info:close");
432
+ if (!visible) {
433
+ RED.keyboard.add("*", "escape", () => hide());
434
+
435
+ createDialog();
436
+ dialog.slideDown(300);
437
+ visible = true;
438
+
439
+ // UI goodies
440
+ $("#ui-settings").click((e) => {
441
+ e.preventDefault();
442
+ if ($(e.target).is("a")) {
443
+ shell.openExternal(e.target.href);
460
444
  }
461
- }
445
+ e.stopImmediatePropagation();
446
+ });
462
447
 
463
- function resetWindows() {
464
- getScreen().forEach(option => {
465
- $(`#${option.id}-body`).hide();
466
- $(`#${option.id}`).removeClass('ui-settings-option-selected');
448
+ $("#main-container").click((e) => {
449
+ hide();
467
450
  });
468
451
  }
469
-
470
- function getProxyHeader() {
471
- // Read the proxy details
472
- let proxyHeader = undefined;
473
- let proxySettings = networkConfigStore.getProxyDetails();
474
- let { custom, host, port, authentication, username, password } = proxySettings;
475
- if (custom){
476
- proxyHeader = `${host}:${port}`;
477
- if (proxySettings.authentication){
478
- proxyHeader = `${username}:${password}@${proxyHeader}`
479
- }
480
- proxyHeader = `http://${proxyHeader}`;
481
- }
482
-
483
- return proxyHeader;
452
+ }
453
+
454
+ function showEnvironments() {
455
+ show();
456
+ $("#ui-settings-envvars").click();
457
+ }
458
+
459
+ function hide() {
460
+ if (visible) {
461
+ $("#main-container").off("click");
462
+ RED.keyboard.remove("escape");
463
+ visible = false;
464
+ if (dialog !== null) {
465
+ dialog.slideUp(200, function () {
466
+ // searchInput.searchBox('value', '');
467
+ });
468
+ }
484
469
  }
485
-
486
- function init() {
487
- RED.actions.add('core:settings:open', show);
488
- RED.actions.add('core:settings:close', hide);
489
- RED.actions.add('core:settings:select-environments', showEnvironments)
470
+ }
471
+
472
+ function resetWindows() {
473
+ getScreen().forEach((option) => {
474
+ $(`#${option.id}-body`).hide();
475
+ $(`#${option.id}`).removeClass("ui-settings-option-selected");
476
+ });
477
+ }
478
+
479
+ function getProxyHeader() {
480
+ // Read the proxy details
481
+ let proxyHeader = undefined;
482
+ let proxySettings = networkConfigStore.getProxyDetails();
483
+ let { custom, host, port, authentication, username, password } =
484
+ proxySettings;
485
+ if (custom) {
486
+ proxyHeader = `${host}:${port}`;
487
+ if (proxySettings.authentication) {
488
+ proxyHeader = `${username}:${password}@${proxyHeader}`;
489
+ }
490
+ proxyHeader = `http://${proxyHeader}`;
490
491
  }
491
492
 
492
-
493
- return {
494
- init: init,
495
- show: show,
496
- hide: hide,
497
- getProxyHeader: getProxyHeader,
498
- }
499
- })();
493
+ return proxyHeader;
494
+ }
495
+
496
+ function init() {
497
+ RED.actions.add("core:settings:open", show);
498
+ RED.actions.add("core:settings:close", hide);
499
+ RED.actions.add("core:settings:select-environments", showEnvironments);
500
+ }
501
+
502
+ return {
503
+ init: init,
504
+ show: show,
505
+ hide: hide,
506
+ getProxyHeader: getProxyHeader,
507
+ };
508
+ })();