Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions dojo_theme/static/js/dojo/actionbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ function getRecentService(root) {
return match;
}

function sourceFailed(content, message) {
content.src = "";
animateBanner(
$(content).closest(".challenge-workspace").find("#workspace-select")[0],
message,
"error"
);
}

function specialSelect(serviceName, content) {
const url = new URL("/pwncollege_api/v1/workspace", window.location.origin);
url.searchParams.set("service", serviceName);
Expand All @@ -62,12 +71,7 @@ function specialSelect(serviceName, content) {
content.src = result["iframe_src"];
}
else {
content.src = "";
animateBanner(
{target: $(content).closest(".challenge-workspace").find("#workspace-select")[0]},
result.error,
"error"
);
sourceFailed(content, result.error);
}
});
}
Expand Down Expand Up @@ -97,7 +101,16 @@ function selectService(service, log=true) {
specialSelect(service, content);
}
else {
content.src = "/workspace/" + port + "/";
url = "/workspace/" + port + "/";
fetch(url, {
method: "GET",
credentials: "same-origin"
}).then((response) => {
if (!response.ok) {
return sourceFailed(content, "Failed to connect to service, try restarting or contact dojo admin");
}
content.src = url;
});
}
}

Expand Down
Loading