@kumologica/sdk 3.5.4 → 3.6.0-alpha10

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 +166 -69
  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 +1960 -794
  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 +441 -426
  26. package/src/app/ui/editor-client/src/sass/editor.scss +746 -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 +22 -17
  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,400 @@ 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
  }
131
-
132
- function createDialog() {
133
-
134
-
135
- // remove if previous dialog exist
136
- $('#ui-settings').remove();
137
-
138
- dialog = $('<div>', {
139
- id: 'ui-settings',
140
- class: 'ui-settings',
141
- }).appendTo('#main-container');
142
-
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);
147
-
148
- let wrapperDiv = $('<div>', {
149
- class: 'ui-settings-body'
150
- }).appendTo(dialog);
151
-
152
- // Left pannel of settings
153
- let optionsDiv = $(`
154
- <div id="ui-settings-options">
155
- </div>
156
- `).appendTo(wrapperDiv);
157
-
158
- // Left pannel of settings
159
- getScreen().forEach(option => {
160
- if (option.selected){
161
- $(`
140
+ return screen;
141
+ }
142
+
143
+ function createDialog() {
144
+ // remove if previous dialog exist
145
+ $("#ui-settings").remove();
146
+
147
+ dialog = $("<div>", {
148
+ id: "ui-settings",
149
+ class: "ui-settings",
150
+ }).appendTo("#main-container");
151
+
152
+ let dialogContainer = $(
153
+ `<div id="ui-settings-container" class="ui-settings-conatiner" style="display:flex; height: 100%" </div>`
154
+ ).appendTo(dialog);
155
+ // Programmatically calculate the height of the ui-settings window
156
+ totalHeightAvailable = $("#main-container").height();
157
+ let offset = 74;
158
+ $("#ui-settings").height(totalHeightAvailable - 200);
159
+
160
+ // Left pannel of settings
161
+ let optionsLeft = $(`<div id="ui-settings-left"></div>`).appendTo(
162
+ dialogContainer
163
+ );
164
+
165
+ let rightSide = $(`<div id="ui-settings-right" </div>`).appendTo(
166
+ dialogContainer
167
+ );
168
+
169
+ let rightSideSettingsBody = $("<div>", {
170
+ class: "ui-settings-body",
171
+ }).appendTo(rightSide);
172
+
173
+ $(`
174
+ <div class="editor-tray-toolbar">
175
+ <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>
176
+ <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>
177
+ </div>
178
+ `).appendTo(rightSide);
179
+
180
+ // Left pannel of settings
181
+ getScreen().forEach((option) => {
182
+ if (option.selected) {
183
+ $(`
162
184
  <div id="${option.id}" class="ui-settings-option ui-settings-option-selected">
163
185
  <span class="settingsOptionLabel">
164
186
  ${option.label}
165
187
  </span>
166
- </div>`).appendTo(optionsDiv);
167
- } else {
168
- $(`
188
+ </div>`).appendTo(optionsLeft);
189
+ } else {
190
+ $(`
169
191
  <div id="${option.id}" class="ui-settings-option ui-settings-option">
170
192
  <span class="settingsOptionLabel">
171
193
  ${option.label}
172
194
  </span>
173
- </div>`).appendTo(optionsDiv);
174
- }
175
-
176
- });
195
+ </div>`).appendTo(optionsLeft);
196
+ }
197
+ });
177
198
 
178
- // Right pannel of settings
179
- let optionsBodyDiv = $(`
199
+ // Right pannel of settings
200
+ let optionsBodyDiv = $(`
180
201
  <div id="ui-settings-optionsbody">
181
202
  </div>
182
- `).appendTo(wrapperDiv)
203
+ `).appendTo(rightSideSettingsBody);
183
204
 
184
- getScreen().forEach(option => {
185
- $(`
205
+ getScreen().forEach((option) => {
206
+ $(`
186
207
  <div id="${option.id}-body" class="ui-settings-general-body">
187
- <div>
208
+ <div style="display=flex; flex-direction: column; height:100%">
188
209
  <div class="settingsTitle">${option.body.title}</div>
189
210
  <div class="settingsSubtitle">${option.body.subtitle}</div>
190
211
  ${option.body.html}
191
212
  </div>
192
213
  </div>
193
- `).appendTo(optionsBodyDiv)
194
- });
195
-
196
- $(`
197
- <div class="editor-tray-toolbar" style="top: 16px !important">
198
- <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
- <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
- </div>
201
- `).appendTo(optionsBodyDiv);
202
-
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;
214
+ `).appendTo(optionsBodyDiv);
215
+ });
216
+
217
+ // Initialize the options body screen
218
+ getScreen().forEach((option) => {
219
+ // Left click on option
220
+ $(`#${option.id}`).click((e) => {
221
+ resetWindows();
222
+ $(`#${option.id}`).addClass("ui-settings-option-selected");
223
+ $(`#${option.id}-body`).show();
224
+ option.onSelect();
283
225
  });
226
+ // Specific functionality
227
+ option.onInit();
284
228
 
285
- $('#proxy-option-custom').click( () => {
286
- RED.events.emit('settings:select-proxy-custom');
287
- return false;
288
- });
289
-
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');
229
+ // Hide screen if not default
230
+ if (option.hasOwnProperty("selected") && option.selected) {
231
+ $(`#${option.id}-body`).show();
304
232
  } 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);
233
+ $(`#${option.id}-body`).hide();
309
234
  }
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);
235
+ });
236
+ // Initialize the toolbar
237
+ $("#options-save").click((e) => {
238
+ saveSettings();
239
+ });
240
+
241
+ $("#options-cancel").click((e) => {
242
+ cancelSettings();
243
+ });
244
+ }
245
+
246
+ function saveSettings() {
247
+ getScreen().forEach((option) => {
248
+ option.onSave();
249
+ });
250
+ hide();
251
+ }
252
+
253
+ function cancelSettings() {
254
+ hide();
255
+ }
256
+
257
+ function selectProxyCustom() {
258
+ setTimeout(() => {
259
+ $("#proxy-option-custom").prop("checked", true);
260
+ $("#proxy-option-default").prop("checked", false);
261
+ }, 50);
262
+
263
+ $("#proxy-server").prop("readonly", false);
264
+ $("#proxy-port").prop("readonly", false);
265
+ }
266
+
267
+ function selectProxyDefault() {
268
+ setTimeout(() => {
269
+ $("#proxy-option-custom").prop("checked", false);
270
+ $("#proxy-option-default").prop("checked", true);
271
+ }, 50);
272
+
273
+ $("#proxy-server").prop("readonly", true);
274
+ $("#proxy-port").prop("readonly", true);
275
+ }
276
+
277
+ function selectProxyAuth() {
278
+ setTimeout(() => {
279
+ let isChecked = $("#proxyAuthRequired").is(":checked");
280
+ if (isChecked) {
281
+ $("#proxyAuthRequired").prop("checked", false);
282
+ $("#proxy-auth-username").prop("readonly", true);
283
+ $("#proxy-auth-password").prop("readonly", true);
315
284
  } else {
316
- $('#proxyAuthRequired').prop('checked', false);
317
- $('#proxy-auth-username').prop('readonly', true);
318
- $('#proxy-auth-password').prop('readonly', true);
285
+ $("#proxyAuthRequired").prop("checked", true);
286
+ $("#proxy-auth-username").prop("readonly", false);
287
+ $("#proxy-auth-password").prop("readonly", false);
319
288
  }
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);
289
+ }, 50);
290
+ }
291
+
292
+ function handleProxySettingsEvent() {
293
+ $("#proxy-option-default").click(() => {
294
+ RED.events.emit("settings:select-proxy-default");
295
+ return false;
296
+ });
297
+
298
+ $("#proxy-option-custom").click(() => {
299
+ RED.events.emit("settings:select-proxy-custom");
300
+ return false;
301
+ });
302
+
303
+ $("#proxyAuthRequired").click(function (e) {
304
+ RED.events.emit("settings:select-proxy-auth");
305
+ return false;
306
+ });
307
+ }
308
+
309
+ function initProxySettings(proxySettings) {
310
+ // console.log('[ui-settings] initProxySettings with settings:', proxySettings);
311
+ // Proxy server
312
+ if (proxySettings.custom) {
313
+ $("#proxy-option-custom").prop("checked", true);
314
+ $("#proxy-option-default").prop("checked", false);
315
+ $("#proxy-server").val(proxySettings.host);
316
+ $("#proxy-port").val(proxySettings.port || "8080");
317
+ } else {
318
+ $("#proxy-option-default").prop("checked", true);
319
+ $("#proxy-option-custom").prop("checked", false);
320
+ $("#proxy-server").prop("readonly", true);
321
+ $("#proxy-port").prop("readonly", true);
324
322
  }
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;
323
+ // Proxy auth
324
+ if (proxySettings.authentication) {
325
+ $("#proxyAuthRequired").prop("checked", true);
326
+ $("#proxy-auth-username").val(proxySettings.username);
327
+ $("#proxy-auth-password").val(proxySettings.password);
328
+ } else {
329
+ $("#proxyAuthRequired").prop("checked", false);
330
+ $("#proxy-auth-username").prop("readonly", true);
331
+ $("#proxy-auth-password").prop("readonly", true);
415
332
  }
416
333
 
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
- }
334
+ RED.events.on("settings:select-proxy-custom", selectProxyCustom);
335
+ RED.events.on("settings:select-proxy-default", selectProxyDefault);
336
+ RED.events.on("settings:select-proxy-auth", selectProxyAuth);
337
+ }
338
+
339
+ function initEditor(anchorId, contentBody) {
340
+ CodeMirror.defineMode("properties", function () {
341
+ return {
342
+ token: function (stream, state) {
343
+ var sol = stream.sol() || state.afterSection;
344
+ var eol = stream.eol();
345
+
346
+ state.afterSection = false;
347
+
348
+ if (sol) {
349
+ if (state.nextMultiline) {
350
+ state.inMultiline = true;
351
+ state.nextMultiline = false;
352
+ } else {
353
+ state.position = "def";
354
+ }
355
+ }
442
356
 
443
- }
357
+ if (eol && !state.nextMultiline) {
358
+ state.inMultiline = false;
359
+ state.position = "def";
360
+ }
444
361
 
445
- function showEnvironments() {
446
- show();
447
- $('#ui-settings-envvars').click();
448
- }
362
+ if (sol) {
363
+ while (stream.eatSpace()) {}
364
+ }
449
365
 
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
- }
366
+ var ch = stream.next();
367
+
368
+ if (sol && (ch === "#" || ch === "!" || ch === ";")) {
369
+ state.position = "comment";
370
+ stream.skipToEnd();
371
+ return "comment";
372
+ } else if (sol && ch === "[") {
373
+ state.afterSection = true;
374
+ stream.skipTo("]");
375
+ stream.eat("]");
376
+ return "header";
377
+ } else if (ch === "=") {
378
+ state.position = "quote";
379
+ return null;
380
+ } else if (ch === "\\" && state.position === "quote") {
381
+ if (stream.eol()) {
382
+ // end of line?
383
+ // Multiline value
384
+ state.nextMultiline = true;
385
+ }
386
+ }
387
+
388
+ return state.position;
389
+ },
390
+
391
+ startState: function () {
392
+ return {
393
+ position: "def", // Current position, "def", "quote" or "comment"
394
+ nextMultiline: false, // Is the next line multiline value
395
+ inMultiline: false, // Is the current line a multiline value
396
+ afterSection: false, // Did we just open a section
397
+ };
398
+ },
399
+ };
400
+ });
401
+ let cmInstance = CodeMirror.fromTextArea(
402
+ document.getElementById(anchorId),
403
+ {
404
+ theme: "monokai",
405
+ lineWrapping: true,
406
+ mode: "properties",
407
+ }
408
+ );
409
+
410
+ // reset the listenere
411
+ cmInstance.off("change");
412
+
413
+ cmInstance.getDoc().setValue(contentBody);
414
+ cmInstance.focus();
415
+ //console.log(`lineCount: ${cmInstance.lineCount()}`)
416
+ // Set the cursor at the end of existing content
417
+ cmInstance.setCursor(cmInstance.lineCount(), 0);
418
+ let codeMirrorHeight = totalHeightAvailable - 440;
419
+
420
+ cmInstance.setSize(null, codeMirrorHeight);
421
+ // cmInstance.refresh();
422
+ setTimeout(function () {
423
+ cmInstance.refresh();
424
+ }, 100);
425
+
426
+ cmInstance.on("change", function (cm, change) {
427
+ // enable the save button
428
+ $("#options-save").removeClass("disabled");
429
+ });
430
+
431
+ return cmInstance;
432
+ }
433
+
434
+ function show() {
435
+ // Disable the search dialog if opened
436
+ RED.actions.invoke("core:search:close");
437
+ RED.actions.invoke("core:project-info:close");
438
+ if (!visible) {
439
+ RED.keyboard.add("*", "escape", () => hide());
440
+
441
+ createDialog();
442
+ dialog.slideDown(300);
443
+ visible = true;
444
+
445
+ // UI goodies
446
+ $("#ui-settings").click((e) => {
447
+ e.preventDefault();
448
+ if ($(e.target).is("a")) {
449
+ shell.openExternal(e.target.href);
460
450
  }
461
- }
451
+ e.stopImmediatePropagation();
452
+ });
462
453
 
463
- function resetWindows() {
464
- getScreen().forEach(option => {
465
- $(`#${option.id}-body`).hide();
466
- $(`#${option.id}`).removeClass('ui-settings-option-selected');
454
+ $("#main-container").click((e) => {
455
+ hide();
467
456
  });
468
457
  }
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;
458
+ }
459
+
460
+ function showEnvironments() {
461
+ show();
462
+ $("#ui-settings-envvars").click();
463
+ }
464
+
465
+ function hide() {
466
+ if (visible) {
467
+ $("#main-container").off("click");
468
+ RED.keyboard.remove("escape");
469
+ visible = false;
470
+ if (dialog !== null) {
471
+ dialog.slideUp(200, function () {
472
+ // searchInput.searchBox('value', '');
473
+ });
474
+ }
484
475
  }
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)
476
+ }
477
+
478
+ function resetWindows() {
479
+ getScreen().forEach((option) => {
480
+ $(`#${option.id}-body`).hide();
481
+ $(`#${option.id}`).removeClass("ui-settings-option-selected");
482
+ });
483
+ }
484
+
485
+ function getProxyHeader() {
486
+ // Read the proxy details
487
+ let proxyHeader = undefined;
488
+ let proxySettings = networkConfigStore.getProxyDetails();
489
+ let { custom, host, port, authentication, username, password } =
490
+ proxySettings;
491
+ if (custom) {
492
+ proxyHeader = `${host}:${port}`;
493
+ if (proxySettings.authentication) {
494
+ proxyHeader = `${username}:${password}@${proxyHeader}`;
495
+ }
496
+ proxyHeader = `http://${proxyHeader}`;
490
497
  }
491
498
 
492
-
493
- return {
494
- init: init,
495
- show: show,
496
- hide: hide,
497
- getProxyHeader: getProxyHeader,
498
- }
499
- })();
499
+ return proxyHeader;
500
+ }
501
+
502
+ function init() {
503
+ RED.actions.add("core:settings:open", show);
504
+ RED.actions.add("core:settings:close", hide);
505
+ RED.actions.add("core:settings:select-environments", showEnvironments);
506
+ }
507
+
508
+ return {
509
+ init: init,
510
+ show: show,
511
+ hide: hide,
512
+ getProxyHeader: getProxyHeader,
513
+ };
514
+ })();