@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.
- package/cli/cli.js +31 -8
- package/cli/commands/open.js +166 -69
- 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 +1960 -794
- 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 +441 -426
- package/src/app/ui/editor-client/src/sass/editor.scss +746 -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 +22 -17
- 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,400 @@ 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
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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(
|
|
167
|
-
|
|
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(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
});
|
|
195
|
+
</div>`).appendTo(optionsLeft);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
177
198
|
|
|
178
|
-
|
|
179
|
-
|
|
199
|
+
// Right pannel of settings
|
|
200
|
+
let optionsBodyDiv = $(`
|
|
180
201
|
<div id="ui-settings-optionsbody">
|
|
181
202
|
</div>
|
|
182
|
-
`).appendTo(
|
|
203
|
+
`).appendTo(rightSideSettingsBody);
|
|
183
204
|
|
|
184
|
-
|
|
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
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
`).
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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
|
-
$(
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
$(
|
|
317
|
-
$(
|
|
318
|
-
$(
|
|
285
|
+
$("#proxyAuthRequired").prop("checked", true);
|
|
286
|
+
$("#proxy-auth-username").prop("readonly", false);
|
|
287
|
+
$("#proxy-auth-password").prop("readonly", false);
|
|
319
288
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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
|
-
|
|
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;
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
}
|
|
362
|
+
if (sol) {
|
|
363
|
+
while (stream.eatSpace()) {}
|
|
364
|
+
}
|
|
449
365
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
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
|
-
|
|
464
|
-
|
|
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
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
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
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
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
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
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
|
+
})();
|