Skip to content

Commit

Permalink
Add diagnostic info
Browse files Browse the repository at this point in the history
  • Loading branch information
gjsjohnmurray committed May 28, 2022
1 parent e5c555f commit a249776
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
22 changes: 20 additions & 2 deletions src/webTerminalPanel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as vscode from "vscode";
import { webTerminalUri } from "./utils";

/**
* The schema of the message that gets sent to the webview.
Expand Down Expand Up @@ -58,7 +59,7 @@ export class WebTerminalPanel {
};

// Set the webview's initial content
this.setWebviewHtml();
this.setWebviewHtml(webTerminalUri.toString(true));

// Register handlers
this.registerEventHandlers();
Expand All @@ -70,7 +71,7 @@ export class WebTerminalPanel {
/**
* Set the static html for the webview.
*/
private setWebviewHtml() {
private setWebviewHtml(appUrl: string) {
const webview = this._panel.webview;

// Local path to script and css for the webview
Expand Down Expand Up @@ -113,6 +114,23 @@ export class WebTerminalPanel {
</head>
<body>
<div id="showText"></div>
<div id="placeholder">
<h2 id="header">Preparing your WebTerminal...</h2>
<p>
If this message remains for more than a few seconds there's a problem connecting to <b>${appUrl}</b> to launch it here. Check the following:
<ul>
<li>Credentials are correct.</li>
<li>Connection uses the <b>https</b> protocol.</li>
<li>Connection specifies a hostname which matches the target server's certificate.</li>
<li>Web application <b>/terminal-vscode</b> was added as a copy of WebTerminal's /terminal application but with <b>Session Cookie Scope</b> set to <b>None</b>.</li>
<li>The <b>Parameter HandleCorsRequest=1</b> patch was added to <b>WebTerminal.Router.cls</b> and the class was recompiled.</li>
<li>The account use by the Web Gateway (typically <b>CSPSystem</b>) has at least READ privilege on the security resource which protects WebTerminal's code database.
</ul>
Use the <b>WebTerminal in External Browser</b> option from the context menu of the server's row in the Server Manager tree to verify some of these factors.
</p>
</div>
<div id="content" class="content">
<iframe sandbox="allow-scripts allow-same-origin"></iframe>
</div>
Expand Down
7 changes: 4 additions & 3 deletions webview/webTerminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
(function () {
const iframe = document.querySelector('iframe');
const showText = document.getElementById("showText");
const placeholder = document.getElementById("placeholder");

let token = "am9obm06am9obm0="; //johnm:johnm hardcoded - TODO - fix this

const loadIframe = (url) => {

// Send an XHR request first so we can suppy an Authorization header
// Send an XHR request first so we can supply an Authorization header
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.withCredentials = true;
xhr.onreadystatechange = handler;
//xhr.responseType = 'text';
xhr.setRequestHeader('Authorization', 'Basic ' + token);
xhr.send();

Expand All @@ -22,9 +22,10 @@
if (this.readyState === this.DONE) {
if (this.status === 200) {
//showText.innerText = "Got a good XHR response";
placeholder.style.display = "none";
iframe.src = url;
} else {
showText.innerText += " - XHR auth request failed: status = " + this.status;
//showText.innerText += " - XHR auth request failed: status = " + this.status;
}
}
}
Expand Down

0 comments on commit a249776

Please sign in to comment.