-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.html
312 lines (282 loc) Β· 9.49 KB
/
settings.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Jasper Settings</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
}
hr {
border: none;
border-top: 1px dotted black;
}
.label-column {
display: grid;
grid-gap: 8px;
grid-template-columns: min-content auto;
}
label, button, .cb span {
white-space: nowrap;
}
input[type="checkbox"] {
width: 15px;
height: 15px;
}
.form-array {
display: flex;
}
.form-array *:not(:first-child) {
margin-left: 3px;
}
.form-array > input {
flex: 1;
}
.form-array > input + select {
margin-left: -3px !important;
}
.au > label {
vertical-align: top;
font-size: 18px;
}
.loading {
display: none;
pointer-events: none;
opacity: 0;
position: relative;
top: -25px;
text-align: center;
font-size: 40px;
height: 21.5px;
min-width: 116px;
overflow: visible;
animation: fadein 2s ease-in-out 1s;
animation-iteration-count: infinite;
}
select {
width: 20px;
}
@keyframes fadein {
from {
opacity: 0;
}
50% {
opacity: 1;
}
to {
opacity: 0;
}
}
@media (prefers-color-scheme: dark) {
body {
background-color: #242424;
color: #c9c9c9;
color-scheme: dark;
}
hr {
border-top: 1px dotted lightgrey;
}
}
</style>
<script>
const fields = [
'userTag',
'appVersion',
'serverVersion',
'serverPort',
'serverProfiles',
'storageDir',
'clientVersion',
'clientTitle',
'clientPort',
'databaseVersion',
'dataDir',
];
const profiles = [
'prod',
'debug',
'scripts',
'proxy',
'file-cache',
'recycler',
'preload',
];
const flags = [
'autoUpdate',
'pullClient',
'pullServer',
'pullDatabase',
'showLogsOnStart',
];
window.electronAPI.handleSettings((event, settings) => {
if (settings.serverProfiles) {
const activeProfiles = settings.serverProfiles.replace(/\s+/g, '').split(',');
for (const p of profiles) {
$(`#serverProfiles_${p}`).prop('checked', activeProfiles.includes(p));
}
}
for (const f of fields) {
$('#' + f).val(settings[f] ?? '');
}
for (const f of flags) {
$('#' + f).prop('checked', settings[f] ?? false);
}
});
window.electronAPI.notifyFinished((event, command) => {
finished(command);
});
window.electronAPI.updateImageTags((event, imageTags) => {
for (const [key, value] of Object.entries(imageTags)) {
if (!value || !value.length) continue;
const $select = $(`#${key}`);
$select.html('');
value.reverse();
$select.append($(`<option>latest</option>`));
for (const tag of value) {
$select.append($(`<option>${tag}</option>`));
}
$select.val($(`#${key}Version`).val());
}
});
function save() {
const settings = {};
for (const f of fields) {
settings[f] = $('#' + f).val();
}
for (const f of flags) {
settings[f] = $('#' + f).prop('checked');
}
window.electronAPI.saveSettings(settings);
window.close();
}
function patch(f) {
window.electronAPI.patchSettings({name: f, value: $('#' + f).checked});
}
function openDir(dir) {
window.electronAPI.openDir(dir);
}
function sendCommand(id, ...args) {
window.electronAPI.command(id, args);
$(`#${id}-button`).css('display', 'none');
$(`#${id}-loading`).css('display', 'block');
}
function finished(id) {
$(`#${id}-button`).css('display', 'block');
$(`#${id}-loading`).css('display', 'none');
}
function updateProfiles() {
const activeProfiles = ['prod', 'storage', 'jwt'];
for (const p of profiles) {
if ($(`#serverProfiles_${p}`).prop('checked')) activeProfiles.push(p)
}
$('#serverProfiles').val(activeProfiles.join(','));
}
window.onload = () => {
window.electronAPI.fetchSettings();
$('input')
.focus(e => $(e.currentTarget).css('z-index', 1))
.blur(e => $(e.currentTarget).css('z-index', ''));
};
</script>
</head>
<body>
<h1>Jasper Application Settings</h1>
<div class="label-column">
<label for="userTag">User Tag</label>
<input id="userTag" type="text">
<label for="appVersion">App Version</label>
<div class="form-array">
<input id="appVersion" type="text" disabled>
<div title="Check for updates on startup" class="au"><label for="autoUpdate">π</label><input id="autoUpdate" type="checkbox" onchange="patch('autoUpdate')"></div>
</div>
<label for="serverVersion">Server Version</label>
<div class="form-array">
<input id="serverVersion" type="text">
<select id="server" onchange="$('#serverVersion').val($('#server').val())">
<option>latest</option>
<option>v1</option>
<option>v1.2</option>
</select>
<div title="Check for updates on startup" class="au"><label for="pullServer">π</label><input id="pullServer" type="checkbox"></div>
</div>
<label for="serverPort">Server Port</label>
<input id="serverPort" type="text">
<label for="serverProfiles">Server Profiles</label>
<div class="cb">
<span><input type="checkbox" id="serverProfiles_scripts" onclick="updateProfiles()"><label for="serverProfiles_scripts">Server Scripts</label></span>
<span><input type="checkbox" id="serverProfiles_proxy" onclick="updateProfiles()"><label for="serverProfiles_proxy">Proxy</label></span>
<span><input type="checkbox" id="serverProfiles_file-cache" onclick="updateProfiles()"><label for="serverProfiles_file-cache">File Cache</label></span>
<span><input type="checkbox" id="serverProfiles_recycler" onclick="updateProfiles()"><label for="serverProfiles_recycler">Recycler</label></span>
<span><input type="checkbox" id="serverProfiles_preload" onclick="updateProfiles()"><label for="serverProfiles_preload">Preload</label></span>
<span><input type="checkbox" id="serverProfiles_debug" onclick="updateProfiles()"><label for="serverProfiles_debug">Debug</label></span>
</div>
<span></span>
<input id="serverProfiles" type="text">
<label for="storageDir">Server Storage</label>
<div class="form-array">
<input id="storageDir" type="text">
<button type="button" onclick="openDir($('#storageDir').val())">ποΈ</button>
</div>
<label for="clientVersion">UI Version</label>
<div class="form-array">
<input id="clientVersion" type="text">
<select id="client" onchange="$('#clientVersion').val($('#client').val())">
<option>latest</option>
<option>v1</option>
<option>v1.2</option>
</select>
<div title="Check for updates on startup" class="au"><label for="pullClient">π</label><input id="pullClient" type="checkbox"></div>
</div>
<label for="clientTitle">UI Title</label>
<input id="clientTitle" type="text">
<label for="clientPort">UI Port</label>
<input id="clientPort" type="text">
<label for="databaseVersion">Postgres Version</label>
<div class="form-array">
<input id="databaseVersion" type="text">
<select id="database" onchange="$('#databaseVersion').val($('#database').val())">
<option>latest</option>
<option>14</option>
<option>15</option>
</select>
<div title="Check for updates on startup" class="au"><label for="pullDatabase">π</label><input id="pullDatabase" type="checkbox"></div>
</div>
<label for="dataDir">Postgres Directory</label>
<div class="form-array">
<input id="dataDir" type="text">
<button type="button" onclick="openDir($('#dataDir').val())">ποΈ</button>
</div>
<label for="showLogsOnStart">Show Logs on Startup</label>
<div><input id="showLogsOnStart" type="checkbox" onchange="patch('showLogsOnStart')"></div>
<span><!-- Buttons --></span>
<div>
<button type="button" onclick="save()">Save & Hard Reload</button>
</div>
</div>
<br>
<hr>
<h2>Troubleshooting</h2>
<div class="label-column">
<button id="restart-button" type="button" onclick="sendCommand('restart')">Restart</button>
<span id="restart-loading" class="loading">...</span>
<label>Restart the servers and database</label>
<button id="pull-button" type="button" onclick="sendCommand('pull')">Pull New Images</button>
<span id="pull-loading" class="loading">...</span>
<label>Check for updates and download them if available</label>
<button id="down-button" type="button" onclick="sendCommand('down')">Stop</button>
<span id="down-loading" class="loading">...</span>
<label>Stop all servers and database</label>
<button id="up-button" type="button" onclick="sendCommand('up')">Start</button>
<span id="up-loading" class="loading">...</span>
<label>Start all servers and database if not already started</label>
<button id="pause-button" type="button" onclick="sendCommand('pause')">Pause</button>
<span id="pause-loading" class="loading">...</span>
<label>Pause all servers and database</label>
<button id="unpause-button" type="button" onclick="sendCommand('unpause')">Unpause</button>
<span id="unpause-loading" class="loading">...</span>
<label>Unpause all servers and database</label>
</div>
</body>
</html>