@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.
- package/cli/cli.js +31 -8
- package/cli/commands/open.js +88 -15
- package/cli/commands/run.js +167 -0
- package/cli/commands/serve.js +139 -0
- package/package.json +5 -5
- package/src/app/main-process/main-window.js +1 -0
- package/src/app/main-process/modal-home.js +1 -0
- package/src/app/main-process/modal-newproject.js +1 -0
- package/src/app/main-process/modal-newtab.js +1 -0
- package/src/app/main-process/modal-nodelibrary.js +1 -0
- package/src/app/main-process/modal-renameTab.js +1 -0
- package/src/app/main-process/modal-welcome.js +1 -0
- package/src/app/main.js +179 -141
- package/src/app/preload.js +225 -139
- package/src/app/ui/editor-client/public/red/red.js +1943 -783
- package/src/app/ui/editor-client/public/red/red.min.js +2 -2
- package/src/app/ui/editor-client/public/red/style.min.css +1 -1
- package/src/app/ui/editor-client/public/vendor/ace-linters/javascript-service.js +10 -2
- package/src/app/ui/editor-client/src/js/red.js +183 -179
- package/src/app/ui/editor-client/src/js/ui/common/commandBox.js +107 -0
- package/src/app/ui/editor-client/src/js/ui/common/searchBox.js +91 -90
- package/src/app/ui/editor-client/src/js/ui/modules.js +164 -0
- package/src/app/ui/editor-client/src/js/ui/search.js +171 -123
- package/src/app/ui/editor-client/src/js/ui/sidebar.js +1 -1
- package/src/app/ui/editor-client/src/js/ui/ui-settings.js +419 -410
- package/src/app/ui/editor-client/src/sass/editor.scss +745 -746
- package/src/app/ui/editor-client/src/sass/forms.scss +1 -1
- package/src/app/ui/editor-client/src/sass/search.scss +16 -2
- package/src/app/ui/editor-client/src/sass/sidebar.scss +1 -1
- package/src/app/ui/editor-client/src/sass/style.scss +72 -69
- package/src/app/ui/editor-client/src/sass/ui/common/commandBox.scss +100 -0
- package/src/app/ui/editor-client/src/sass/ui/common/searchBox.scss +3 -2
- package/src/app/ui/editor-client/src/sass/ui-settings.scss +14 -14
- package/src/app/ui/editor-client/src/vendor/ace-linters/build/javascript-service.js +10 -2
- package/src/app/ui/editor-client/templates/index.mst +2 -2
- package/src/server/DesignerServer.js +152 -153
|
@@ -1,59 +1,64 @@
|
|
|
1
|
-
RED.uiSettings = (function(){
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"
|
|
103
|
-
"
|
|
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
|
-
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
133
|
-
|
|
143
|
+
function createDialog() {
|
|
144
|
+
// remove if previous dialog exist
|
|
145
|
+
$("#ui-settings").remove();
|
|
134
146
|
|
|
135
|
-
|
|
136
|
-
|
|
147
|
+
dialog = $("<div>", {
|
|
148
|
+
id: "ui-settings",
|
|
149
|
+
class: "ui-settings",
|
|
150
|
+
}).appendTo("#main-container");
|
|
137
151
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
$('#ui-settings').height(totalHeightAvailable - offset);
|
|
157
|
+
let wrapperDiv = $("<div>", {
|
|
158
|
+
class: "ui-settings-body",
|
|
159
|
+
}).appendTo(dialog);
|
|
147
160
|
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
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
|
-
|
|
179
|
-
|
|
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
|
-
|
|
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"
|
|
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
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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
|
-
$(
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
$(
|
|
317
|
-
$(
|
|
318
|
-
$(
|
|
279
|
+
$("#proxyAuthRequired").prop("checked", true);
|
|
280
|
+
$("#proxy-auth-username").prop("readonly", false);
|
|
281
|
+
$("#proxy-auth-password").prop("readonly", false);
|
|
319
282
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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
|
-
|
|
446
|
-
|
|
447
|
-
|
|
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
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
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
|
-
|
|
464
|
-
|
|
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
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
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
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
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
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
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
|
+
})();
|