From a249776553dd70bb97f67f8a363449d418c3c068 Mon Sep 17 00:00:00 2001 From: gjsjohnmurray Date: Sat, 28 May 2022 19:20:51 +0100 Subject: [PATCH] Add diagnostic info --- src/webTerminalPanel.ts | 22 ++++++++++++++++++++-- webview/webTerminal.js | 7 ++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/webTerminalPanel.ts b/src/webTerminalPanel.ts index f104e47..96b1aa0 100644 --- a/src/webTerminalPanel.ts +++ b/src/webTerminalPanel.ts @@ -1,4 +1,5 @@ import * as vscode from "vscode"; +import { webTerminalUri } from "./utils"; /** * The schema of the message that gets sent to the webview. @@ -58,7 +59,7 @@ export class WebTerminalPanel { }; // Set the webview's initial content - this.setWebviewHtml(); + this.setWebviewHtml(webTerminalUri.toString(true)); // Register handlers this.registerEventHandlers(); @@ -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 @@ -113,6 +114,23 @@ export class WebTerminalPanel {
+ +
+ +

+ If this message remains for more than a few seconds there's a problem connecting to ${appUrl} to launch it here. Check the following: +

+ Use the WebTerminal in External Browser option from the context menu of the server's row in the Server Manager tree to verify some of these factors. +

+
+
diff --git a/webview/webTerminal.js b/webview/webTerminal.js index 0c288ce..cfdf9c7 100644 --- a/webview/webTerminal.js +++ b/webview/webTerminal.js @@ -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(); @@ -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; } } }