Skip to content

Commit fd31ad3

Browse files
authored
Merge pull request #211 from SaaShup/fix_terminal_ws_connection
🐛 Fix terminal websocket connection with https protocol
2 parents 6d8e020 + 590cba3 commit fd31ad3

File tree

3 files changed

+90
-90
lines changed

3 files changed

+90
-90
lines changed

package-lock.json

Lines changed: 56 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "netbox-docker-agent",
3-
"version": "1.19.0",
3+
"version": "1.19.1",
44
"description": "Saashup agent for netbox manager",
55
"main": "index.js",
66
"scripts": {

public/index.html

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -203,35 +203,35 @@ <h5 class="modal-title" id="modalNotificationTitle"></h5>
203203
var dockerAgent = [];
204204

205205
$.ajax({
206-
url: "/api/containers"
206+
url: "/api/containers"
207+
}).done(function (result) {
208+
dockerAgent["containers"] = result;
209+
$("#containers_num").text(result.length);
210+
$.ajax({
211+
url: "/api/volumes",
207212
}).done(function (result) {
208-
dockerAgent["containers"] = result;
209-
$("#containers_num").text(result.length);
210-
$.ajax({
211-
url: "/api/volumes",
212-
}).done(function (result) {
213-
dockerAgent["volumes"] = result;
214-
$("#volumes_num").text(result.Volumes.length);
215-
});
216-
$.ajax({
217-
url: "/api/images",
218-
}).done(function (result) {
219-
dockerAgent["images"] = result;
220-
$("#images_num").text(result.length);
221-
});
222-
$.ajax({
223-
url: "/api/networks",
224-
}).done(function (result) {
225-
dockerAgent["networks"] = result;
226-
$("#networks_num").text(result.length);
227-
});
228-
$.ajax({
229-
url: "/api/registries",
230-
}).done(function (result) {
231-
dockerAgent["registries"] = result;
232-
$("#registries_num").text(result.length);
233-
});
234-
})
213+
dockerAgent["volumes"] = result;
214+
$("#volumes_num").text(result.Volumes.length);
215+
});
216+
$.ajax({
217+
url: "/api/images",
218+
}).done(function (result) {
219+
dockerAgent["images"] = result;
220+
$("#images_num").text(result.length);
221+
});
222+
$.ajax({
223+
url: "/api/networks",
224+
}).done(function (result) {
225+
dockerAgent["networks"] = result;
226+
$("#networks_num").text(result.length);
227+
});
228+
$.ajax({
229+
url: "/api/registries",
230+
}).done(function (result) {
231+
dockerAgent["registries"] = result;
232+
$("#registries_num").text(result.length);
233+
});
234+
})
235235
.fail(function (result) {
236236
if (result.status == 403) $('#system-usage-chart').html(
237237
'<span class="badge bg-danger"><h3>Error</h3></span>');
@@ -353,11 +353,11 @@ <h5 class="modal-title" id="modalNotificationTitle"></h5>
353353
'" disabled/></div></div><div class="col-4"><div class="input-group flex-nowrap"><span class="input-group-text bg-white text-primary">container</span><input class="form-control" value="' +
354354
po.split('/')[0] +
355355
'" disabled/></div></div><div class="col-2"><input class="form-control" disabled value="' + po
356-
.split('/')[1] + '"></div></div>'
356+
.split('/')[1] + '"></div></div>'
357357
}
358358
} else {
359359
if ('PortBindings' in c.HostConfig && c.HostConfig.PortBindings !== null && Object.keys(c.HostConfig
360-
.PortBindings).length > 0) {
360+
.PortBindings).length > 0) {
361361
for (const po of Object.keys(c.HostConfig.PortBindings)) {
362362
containers +=
363363
'<div class="row m-2 ports"><div class="col-4"><div class="input-group flex-nowrap"><span class="input-group-text bg-white text-primary">host</span><input class="form-control ports-host" placeholder="name" value="' +
@@ -670,7 +670,7 @@ <h5 class="modal-title" id="modalNotificationTitle"></h5>
670670
let used_by = "";
671671
for (gc in dockerAgent["containers"]) {
672672
if (c.Name in dockerAgent["containers"][gc].NetworkSettings.Networks) used_by += dockerAgent[
673-
"containers"][gc].Name
673+
"containers"][gc].Name
674674
.replace('/', '') + " "
675675
}
676676
networks +=
@@ -1016,7 +1016,7 @@ <h5 class="modal-title" id="modalNotificationTitle"></h5>
10161016
dataType: "json"
10171017
}).done(result => {
10181018
let url = new URL(window.location.origin);
1019-
url.protocol = url.protocol == "https" ? "wss" : "ws";
1019+
url.protocol = url.protocol.startsWith("https") ? "wss" : "ws";
10201020

10211021
let client = new DockerExecWebsocketClient({
10221022
url: url.toString().slice(0, -1) + result.path,
@@ -1212,7 +1212,7 @@ <h5 class="modal-title" id="modalNotificationTitle"></h5>
12121212
if (dockerAgent["images"]) {
12131213
for (const d of dockerAgent["images"]) {
12141214
if (d.registry === false) {
1215-
if (d.RepoTags.length >0) s += '<br><span class="badge rounded-pill bg-danger">error</span> ' + d.RepoTags[0];
1215+
if (d.RepoTags.length > 0) s += '<br><span class="badge rounded-pill bg-danger">error</span> ' + d.RepoTags[0];
12161216
else s += '<br><span class="badge rounded-pill bg-danger">error</span> ' + d.RepoDigests[0];
12171217
count++;
12181218
}

0 commit comments

Comments
 (0)