-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
500 lines (465 loc) · 24.6 KB
/
index.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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<title>PotaPaaS</title>
</head>
<body>
<div id="loginRegisterFormWrapper">
<div id="loginRegisterForm">
<h1>Log in to PotaPaaS</h1>
<div class="w-25">
<input type="text" id="login-username" class="form-control" placeholder="Username">
<input type="password" id="login-password" class="form-control" placeholder="Password">
<button type="button" id="loginRegisterButton" class="btn btn-primary btn-block" onclick="logInOnclick()">Log in</button>
</div>
<a href="/register.html" id="logInRegisterLink">Don't have account? Click here to register</a>
<p id="loginRegisterFailedMessage"></p>
</div>
</div>
<div id="pageContent" style="display: none">
<nav class="navbar navbar-expand-lg navbar-light bg-light navbar navbar-dark bg-dark">
<div class="navbar-brand" id="navbar-brand-text">PotaPaaS</div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav navbar-text-color">
<li class="nav-item">
<a class="nav-link" href="#user" onclick="setWindowLocation('#user')">My account</a>
</li>
<!-- app -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="appDropdownMenuLink" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
Apps
</a>
<div class="dropdown-menu" aria-labelledby="appDropdownMenuLink">
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#newOrRedeployAppModal"
onclick="initAppModal('new')">Create new</a>
<div class="dropdown-divider"></div>
<div id="app-dropdown-list">
<!-- <a class="dropdown-item" href="#app-uuid">app-name</a> -->
</div>
</div>
</li>
<!-- datastore -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="datastoreDropdownMenuLink" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
Datastores
</a>
<div class="dropdown-menu" aria-labelledby="datastoreDropdownMenuLink">
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#newDatastoreModal"
onclick="initDatastoreModal()">Create new
</a>
<div class="dropdown-divider"></div>
<div id="datastore-dropdown-list">
<!-- <a class="dropdown-item" href="#datastore-uuid">datastore-name</a> -->
</div>
</div>
</li>
</ul>
<ul class="navbar-nav ml-auto navbar-text-color">
<li class="nav-item" id="tokenExpirationItem">
<a class="navbar-text disableButtonOutline" href="https://stackoverflow.com" onclick="refreshTokenOnclick(); return false"
id="tokenExpirationTime" title="Session expiration time (click to refresh)"></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" onclick="logout()">Logout</a>
</li>
</ul>
</div>
</nav>
<!-- content -->
<div id="mainContent">
<h2 id="mainContentErrorMessage">error message here</h2>
<div id="welcomeMessageBlockWrapper">
<div id="welcomeMessage">
<h2>
Welcome to PotaPaaS!
<hr>
</h2>
<a href="https://github.com/Potat0x/PotaPaaS-Service" id="welcomeMessageGithubUrl"
target="_blank">https://github.com/Potat0x/PotaPaaS-Service</a>
</div>
</div>
<div id="appContent">
<h2 id="appResponseName">my-app-123</h2>
<table id="appTable">
<tr>
<th>UUID</th>
<th id="appResponseUuid">123-f45f-67g8-39as-0d98d-7sg6g-5432</th>
</tr>
<tr>
<td>Type</td>
<td id="appResponseType">Node.js (NPM)</td>
</tr>
<tr>
<td>Created at</td>
<td id="appResponseCreatedAt">06.12.2019 21:11:19</td>
</tr>
<tr>
<td>Repository URL</td>
<td id="appResponseSourceRepoUrl">https://github.com/Potat0x/potapaas-test-cases</td>
</tr>
<tr>
<td>Branch</td>
<td id="appResponseSourceBranchName">nodejs-test-ok</td>
</tr>
<tr>
<td>Commit</td>
<td id="appResponseSourceCommitHash">b595a6712ecc533447fe5dfb01dfce0c73e293c6</td>
</tr>
<tr>
<td>Autodeploy</td>
<td id="appResponseAutodeployEnabled">enabled</td>
</tr>
<tr>
<td>Datastore</td>
<td id="appResponseDatastoreUuid">271e98127e98asdu8927rsdf</td>
</tr>
<tr>
<td>Status</td>
<td id="appResponseStatus">Running</td>
</tr>
<tr>
<td>Webhook secret</td>
<td id="appResponseStatus">
<input id="webhookSecretField" type="password" name="pwd" readonly>
<button type="button" id="webhookSecretVisibilityButton" class="btn fa fa-eye-slash disableButtonOutline"
onclick="webhookSecretVisibilityButtonOnclick()">
</td>
</tr>
</table>
<div id="appContentButtons">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newOrRedeployAppModal"
onclick="initAppModal('redeploy')">Redeploy</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#changeWebhookSecretModal"
onclick="initWebhookSecretModal()">Change webhook
secret</button>
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#deleting-confirmation-modal"
onclick="prepareConfirmationModalForDeletingApp()">Delete</button>
</div>
<hr>
<div id="logsBox">
<h4 id="logsHeader">Logs</h4>
<div id="logsTextAndButtonBox">
<button id="logsRefreshButton" type="button" class="btn fa fa-refresh disableButtonOutline" onclick="refreshLogs()">
</button>
<pre id="logsText"></pre>
</div>
</div>
</div>
<div id="datastoreContent">
<h2 id="datastoreResponseName">my-datastore-2</h2>
<table id="datastoreTable">
<tr>
<th>UUID</th>
<th id="datastoreResponseUuid">123-f45f-67g8-39as-0d98d-7sg6g-5432</th>
</tr>
<tr>
<td>Type</td>
<td id="datastoreResponseType">PostgreSQL</td>
</tr>
<tr>
<td>Created at</td>
<td id="datastoreResponseCreatedAt">06.12.2019 21:11:19</td>
</tr>
<tr>
<td>Status</td>
<td id="datastoreResponseStatus">Running</td>
</tr>
</table>
<div>
Attached apps:
<p id="noAttachedApps">no attached apps.</p>
<ul id="datastoreResponseAttachedApps">
<!-- <li><a href="#">app-2</a></li> -->
</ul>
</div>
<div id="datastoreContentButtons">
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#deleting-confirmation-modal"
onclick="prepareConfirmationModalForDeletingDatastore()">Delete</button>
</div>
</div>
<div id="userContent">
<h2 id="userResponseName">user</h2>
<table id="userTable">
<tr>
<td>Email</td>
<td id="userResponseEmail">@</td>
</tr>
<tr>
<td>Registered</td>
<td id="userResponseCreatedAt">23.12.2019 21:11:19</td>
</tr>
</table>
<div id="userProfileButtons">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#changePasswordModal"
onclick="initChangePasswordModal()">Change password</button>
</div>
</div>
</div>
<!-- change password modal -->
<div id="changePasswordModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Change password</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="current-password" class="col-form-label">Current password</label>
<input type="password" class="form-control" id="current-password">
<label for="new-password" class="col-form-label">New password</label>
<input type="password" class="form-control" id="new-password">
<label for="confirm-password" class="col-form-label">Confirm password</label>
<input type="password" class="form-control" id="confirm-password">
</div>
</form>
<hr>
<div class="modalMessage" id="changePasswordModalMessage">
text
</div>
</div>
<div class="modal-footer" id="changePasswordModalFooter">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" onclick="changePasswordOnclick()">Change</button>
</div>
</div>
</div>
</div>
<!-- webhook secret modal -->
<div id="changeWebhookSecretModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Change webhook secret</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="webhook-secret" class="col-form-label">New secret</label>
<input type="password" class="form-control" id="webhook-secret">
</div>
</form>
<hr>
<div class="modalMessage" id="webhookSecretModalMessage">
text
</div>
</div>
<div class="modal-footer" id="webhookSecretModalFooter">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" onclick="changeWebhookSecretOnclick()">Change</button>
</div>
</div>
</div>
</div>
<!-- app modal -->
<div id="newOrRedeployAppModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="appModalTitle">App</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="app-name" class="col-form-label">Name</label>
<input type="text" class="form-control" id="app-name">
</div>
<div class="form-group">
<label for="app-type">Type</label>
<select class="form-control" id="app-type">
<option value=NODEJS>Node.js (NPM)</option>
</select>
</div>
<div class="form-group">
<label for="app-sourceRepoUrl" class="col-form-label">URL to GitHub repository</label>
<input type="text" class="form-control" id="app-sourceRepoUrl">
</div>
<div class="form-group">
<label for="app-sourceBranchName" class="col-form-label">Branch</label>
<input type="text" class="form-control" id="app-sourceBranchName">
</div>
<div class="form-group">
<label for="app-commitHash" class="col-form-label">Commit hash (optional)</label>
<input type="text" class="form-control" id="app-commitHash">
</div>
<div class="form-group">
<label for="app-datastoreUuid" class="col-form-label">Datastore UUID (optional)</label>
<input type="text" class="form-control" id="app-datastoreUuid">
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="app-autodeployEnabled">
<label class="form-check-label" for="app-autodeployEnabled">
Enable autodeploy
</label>
</div>
</form>
<hr>
<div class="modalMessage" id="appModalMessage">
message
</div>
<div class="d-flex justify-content-center">
<div class="spinner-border" role="status" id="createAppModalSpinner">
</div>
</div>
</div>
<div class="modal-footer" id="appModalFooter">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="appModalActionButton"
onclick="console.log('app modal action')">Create</button>
</div>
</div>
</div>
</div>
<!-- datastore modal -->
<div id="newDatastoreModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">New datastore</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<div class="form-group">
<label for="datastore-name" class="col-form-label">Name</label>
<input type="text" class="form-control" id="datastore-name">
</div>
<div class="form-group">
<label for="datastore-type">Type</label>
<select class="form-control" id="datastore-type">
<option value="POSTGRESQL">PostgreSQL</option>
<option value="MYSQL">MySQL</option>
<option value="MARIADB">MariaDB</option>
</select>
</div>
</form>
<hr>
<div class="modalMessage" id="datastoreModalMessage">
text
</div>
<div class="d-flex justify-content-center">
<div class="spinner-border" role="status" id="createDatastoreModalSpinner">
</div>
</div>
</div>
<div class="modal-footer" id="datastoreModalFooter">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" onclick="createDatastoreOnclick()">Create</button>
</div>
</div>
</div>
</div>
<div class="alert alert-dismissible fade show" role="alert" id="operationResultAlert" style="display: none">
<div id="operationResultAlertMessage">alert message</div>
<button type="button" class="close" onclick="hideOperationResultAlert()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal" tabindex="-1" role="dialog" id="deleting-confirmation-modal">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Are you sure?</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" data-dismiss="modal" id="deleting-confirmation-yes">Delete</button>
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="scripts/jwt-decode.min.js"></script>
<script src="scripts/spaState.js"></script>
<script src="scripts/utils.js"></script>
<script src="scripts/requestBody.js"></script>
<script src="scripts/url.js"></script>
<script src="scripts/nameTransform.js"></script>
<script src="scripts/main.js"></script>
<script src="scripts/httpService.js"></script>
<script>
function showLoginScreen() {
setElementVisible("loginRegisterFormWrapper", true)
setElementVisible("loginRegisterFailedMessage", false)
setElementVisible("pageContent", false)
}
function showPageContent() {
refreshElementsApperance()
refreshDropdownMenus()
refreshMainContent()
}
function refreshPage() {
showPageContentIfAuthorizedOrElseShowLoginScreen(showPageContent, showLoginScreen)
}
function refreshDropdownMenus() {
initDatastoreDropdown()
initAppDropdown()
}
function refreshElementsApperance() {
setElementVisible("appContent", false)
setElementVisible("datastoreContent", false)
setElementVisible("userContent", false)
setElementVisible("operationResultAlert", false)
setElementVisible("mainContentErrorMessage", false)
setElementVisible("loginRegisterFormWrapper", false)
setElementVisible("pageContent", true)
setElementVisible("welcomeMessageBlockWrapper", false)
setButtonsInsideDivDisabled("appContentButtons", false)
setButtonsInsideDivDisabled("datastoreContentButtons", false)
hideWebhookSecret()
}
function refreshMainContent() {
const currentPageUrl = window.location.href
if (currentPageUrl.includes("#datastore=")) {
let pos = currentPageUrl.indexOf("#datastore=")
const datastoreUrl = currentPageUrl.substr(pos + "#datastore=".length)
initDatastoreInfo(datastoreUrl)
} else if (currentPageUrl.includes("#app=")) {
let pos = currentPageUrl.indexOf("#app=")
const appUrl = currentPageUrl.substr(pos + "#app=".length)
initAppInfo(appUrl)
} else if (currentPageUrl.endsWith("#user")) {
initUserInfo()
} else {
setElementVisible("welcomeMessageBlockWrapper", true)
}
}
window.addEventListener("popstate", function (event) {
refreshPage()
})
setInterval(refreshTokenExpirationTimeIndicator, 1000)
</script>
</body>
</html>