Skip to content

Commit

Permalink
fix(results): Don't persist web instances
Browse files Browse the repository at this point in the history
Improved readme

Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
  • Loading branch information
GordonSmith committed Oct 20, 2020
1 parent 0e98e7a commit 9c75b95
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 75 deletions.
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,55 @@ This extension adds rich language support for [HPCC Systems](https://hpccsystems
* HPCC-Platform server support
* Integrated result viewer

## Version 2.4 Quick Start
## Recent Highlights

### v2.5.0

* Added context menu items for Workunits in the Workunit Tree:
* Abort Workunit (only available for running WUs)
* Delete Workunit (Only available for completed WUs)

![Version 2.5](resources/readme-v2_5.gif)

### v2.4.0

* Added result viewer to bottom pane
* Added "Copy Results as ECL"

![Version 2.4](resources/readme-v2_4.gif)

### v2.3.0

* Added list of "found" logical files to Insert Record Definition

![Version 2.3](resources/readme-v2_3.gif)

### v2.2.0

* Added Insert Record Definition menu item

### v2.1.0

Reworked submission process:
* Launch configuration:
* Simplified
* Can be selected from the status bar
* Can be pinned to specific ECL files
* Target Cluster:
* Can be selected from the status bar
* Can be pinned to specific ECL files
* Submit / Compile now available from:
* Context menu
* Top of editor
* Recent Workunits:
* Tree view of recent workunits
* Toggle between "Mine" and "All"
* Open in external browser icon added to several locations

## Quick Start
_Version 2.x introduces a new streamlined submission process. The "old" Run/Debug pane support has been deprecated and will be removed in the future._

![Version 2.4 Quick Start](resources/QuickStart.gif)
![Quick Start](resources/QuickStart.gif)

1. Open folder
2. Open ECL file
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -635,15 +635,15 @@
"name": "HPCC Platform",
"icon": "resources/ecl-explorer.svg",
"contextualTitle": "HPCC Platform",
"when": "resourceLangId == ecl"
"when": "hpccPlatformActive"
}
],
"ecl-watch-lite": [
{
"type": "webview",
"id": "ecl.watch.lite",
"name": "",
"when": "resourceLangId == ecl"
"when": "hpccPlatformActive"
}
]
},
Expand Down Expand Up @@ -966,4 +966,4 @@
}
]
}
}
}
Binary file added resources/readme-v2_3.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/readme-v2_4.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/readme-v2_5.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/ecl/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export class ECLCommands {
}
}

showWUDetails(launchRequestArgs: LaunchRequestArguments, title: string, wuid: string, result?: number) {
eclWatchPanelView.navigateTo(launchRequestArgs, title, wuid, result);
showWUDetails(launchRequestArgs: LaunchRequestArguments, wuid: string, result?: number) {
eclWatchPanelView.navigateTo(launchRequestArgs, wuid, result);
}

openECLWatchExternal(source: ECLWUNode | ECLResultNode) {
Expand Down
72 changes: 43 additions & 29 deletions src/ecl/eclWatchPanelView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ interface PartialLaunchRequestArgumentss {
}

interface NavigateParams extends PartialLaunchRequestArgumentss {
title: string;
wuid: string;
result?: number;
show: boolean;
Expand All @@ -28,36 +27,24 @@ export class ECLWatchPanelView implements vscode.WebviewViewProvider {
protected _ctx: vscode.ExtensionContext;
private readonly _extensionUri: vscode.Uri
private _webviewView?: vscode.WebviewView;
private _currParams: NavigateParams;

private constructor(ctx: vscode.ExtensionContext) {
this._ctx = ctx;
this._extensionUri = this._ctx.extensionUri;

ctx.subscriptions.push(vscode.window.registerWebviewViewProvider(ECLWatchPanelView.viewType, this, {
webviewOptions: {
retainContextWhenHidden: true
retainContextWhenHidden: false
}
}));
}

static attach(ctx: vscode.ExtensionContext): ECLWatchPanelView {
if (!eclWatchPanelView) {
eclWatchPanelView = new ECLWatchPanelView(ctx);
}
return eclWatchPanelView;
}

private _currParams: NavigateParams;
private _resolveParams: NavigateParams;
public resolveWebviewView(webviewView: vscode.WebviewView, context: vscode.WebviewViewResolveContext, _token: vscode.CancellationToken) {
this._webviewView = webviewView;

sessionManager.onDidChangeSession(launchRequestArgs => {
this.navigateTo(launchRequestArgs, "", "", 0, false);
this.navigateTo(launchRequestArgs, "", 0, false);
});

sessionManager.onDidCreateWorkunit(wu => {
this.navigateTo(sessionManager.session.launchRequestArgs, wu.Wuid, wu.Wuid);
this.navigateTo(sessionManager.session.launchRequestArgs, wu.Wuid);
});

vscode.commands.registerCommand("ecl.watch.lite.openECLWatchExternal", async () => {
Expand All @@ -69,7 +56,26 @@ export class ECLWatchPanelView implements vscode.WebviewViewProvider {
}
}
});
}

static attach(ctx: vscode.ExtensionContext): ECLWatchPanelView {
if (!eclWatchPanelView) {
eclWatchPanelView = new ECLWatchPanelView(ctx);
}
return eclWatchPanelView;
}

private _initialParams: NavigateParams;
public resolveWebviewView(webviewView: vscode.WebviewView, context: vscode.WebviewViewResolveContext<any>, _token: vscode.CancellationToken) {
if (this._webviewView === undefined) {

const handle = webviewView.onDidDispose(() => {
delete this._webviewView;
handle.dispose();
});

}
this._webviewView = webviewView;
this._webviewView.webview.options = {
enableScripts: true,
enableCommandUris: true,
Expand All @@ -81,37 +87,45 @@ export class ECLWatchPanelView implements vscode.WebviewViewProvider {
this._webviewView.webview.onDidReceiveMessage((message: Messages) => {
switch (message.command) {
case "loaded":
if (this._resolveParams) {
this.navigateTo(this._resolveParams, this._resolveParams.title, this._resolveParams.wuid, this._resolveParams.result, this._resolveParams.show);
if (this._initialParams) {
this.navigateTo(this._initialParams, this._initialParams.wuid, this._initialParams.result, this._initialParams.show);
delete this._initialParams;
} else {
this._webviewView.title = this._currParams?.wuid;
vscode.commands.executeCommand("setContext", "ecl.watch.lite.hasWuid", !!this._currParams?.wuid);
}
break;
}
});

if (context.state) {
this._currParams = context.state;
}

this._webviewView.webview.html = this._getHtmlForWebview(webviewView.webview);
}

private _prevHash: string;
navigateTo(launchRequestArgs: PartialLaunchRequestArgumentss, title: string, wuid: string, result?: number, show = true) {
navigateTo(launchRequestArgs: PartialLaunchRequestArgumentss, wuid: string, result?: number, show = true) {
const { protocol, serverAddress, port, user, password } = launchRequestArgs;
this._currParams = { protocol, serverAddress, port, user, password, title, wuid, result, show };
if (this._webviewView) {
this._currParams = { protocol, serverAddress, port, user, password, wuid, result, show };
if (!this._webviewView) {
this._initialParams = this._currParams;
if (show) {
vscode.commands.executeCommand("ecl.watch.lite.focus");
}
} else {
const hash = hashSum(this._currParams);
if (this._prevHash !== hash) {
this._prevHash = hash;
this._webviewView.title = title;
this._webviewView.title = this._currParams?.wuid;
this._webviewView.webview.postMessage({ command: "navigate", data: this._currParams });
if (show) {
this._webviewView.show(true);
}
}
} else {
this._resolveParams = this._currParams;
if (show) {
vscode.commands.executeCommand("ecl.watch.lite.focus");
vscode.commands.executeCommand("setContext", "ecl.watch.lite.hasWuid", !!this._currParams?.wuid);
}
}
vscode.commands.executeCommand("setContext", "ecl.watch.lite.hasWuid", !!wuid);
}

private _getHtmlForWebview(webview: vscode.Webview) {
Expand Down
6 changes: 3 additions & 3 deletions src/ecl/eclWatchTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ export class ECLResultNode extends ECLNode {
command(): vscode.Command | undefined {
return {
command: "ecl.showWUDetails",
arguments: [sessionManager.session.launchRequestArgs, `${this._result.Name} - ${this._result.Wuid}`, this._result.Wuid, this._result.Sequence],
arguments: [sessionManager.session.launchRequestArgs, this._result.Wuid, this._result.Sequence],
title: "Open ECL Workunit Details"
};
}
Expand Down Expand Up @@ -331,7 +331,7 @@ class ECLOutputsNode extends ECLNode {
command(): vscode.Command | undefined {
return {
command: "ecl.showWUDetails",
arguments: [sessionManager.session.launchRequestArgs, this._wu.Wuid, this._wu.Wuid],
arguments: [sessionManager.session.launchRequestArgs, this._wu.Wuid],
title: "Open ECL Workunit Details"
};
}
Expand Down Expand Up @@ -418,7 +418,7 @@ export class ECLWUNode extends ECLNode {
command(): vscode.Command | undefined {
return {
command: "ecl.showWUDetails",
arguments: [sessionManager.session.launchRequestArgs, this._wu.Wuid, this._wu.Wuid],
arguments: [sessionManager.session.launchRequestArgs, this._wu.Wuid],
title: "Open ECL Workunit Details"
};
}
Expand Down
75 changes: 42 additions & 33 deletions src/eclwatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ const placeholder = document.getElementById("placeholder");
const themeProvider = new ThemeProvider(foreColour, backColor);
themeProvider.loadThemeForColor(bodyStyles.getPropertyValue("--vscode-progressBar-background") || "navy");

interface State {
protocol: string;
serverAddress: string;
port: string;
user: string;
password: string;
wuid: string;
result?: number;
}

interface VSCodeAPI {
postMessage: <T extends Message>(msg: T) => void;
setState: (newState) => void;
getState: () => any;
setState: (newState: State) => void;
getState: () => State;
}

declare const acquireVsCodeApi: () => VSCodeAPI;
Expand All @@ -37,47 +47,46 @@ window.addEventListener("message", function (event) {
const message = event.data; // The JSON data our extension sent
switch (message.command) {
case "navigate":
render(message.data.protocol, message.data.serverAddress, message.data.port, message.data.user, message.data.password, message.data.wuid, message.data.result);
render(message.data as State);
break;
}
});

vscode.postMessage<LoadedMessage>({
command: "loaded"
});

let prevProtocol;
let prevServerAddress;
let prevPort;
let prevUser;
let prevPassword;
let prevWuid;
let prevResult;
function render(protocol, serverAddress, port, user, password, wuid, result?) {
prevProtocol = protocol;
prevServerAddress = serverAddress;
prevPort = port;
prevUser = user;
prevPassword = password;
prevWuid = wuid;
prevResult = result;
ReactDOM.render(<WUDetails
baseUrl={`${protocol}://${serverAddress}:${port}`}
wuid={wuid}
user={user}
password={password}
sequence={result}
/>, placeholder);
function render(state: State) {
if (state) {
vscode.setState(state);
ReactDOM.render(<WUDetails
baseUrl={`${state.protocol}://${state.serverAddress}:${state.port}`}
wuid={state.wuid}
user={state.user}
password={state.password}
sequence={state.result}
/>, placeholder);
}
}

function rerender() {
render(vscode.getState());
}

// Local debugging without VS Code
if (document.location.protocol === "file:") {
render("https", "play.hpccsystems.com", "18010", "gosmith", "", "W20200917-150837");
render({
protocol: "https",
serverAddress: "play.hpccsystems.com",
port: "18010",
user: "gosmith",
password: "",
wuid: "W20200917-150837"
});
}

window.addEventListener("resize", () => {
if (prevProtocol) {
render(prevProtocol, prevServerAddress, prevPort, prevUser, prevPassword, prevWuid, prevResult);
}
rerender();
});

rerender();

vscode.postMessage<LoadedMessage>({
command: "loaded"
});
6 changes: 3 additions & 3 deletions src/hpccplatform/launchConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,9 @@ export class LaunchConfig implements LaunchRequestArguments {
logger.info(`Submitted: ${this.wuDetailsUrl(wu.Wuid)}.${os.EOL}`);
failedWU = undefined;
return wu;
}).catch((e) => {
logger.info(`Launch failed - ${e}.${os.EOL}`);
logger.debug("InitializeEvent");
}).catch(e => {
logger.info(`Launch failed - ${e.message}.${os.EOL}`);
logger.debug("launchConfig.submit");
if (failedWU) {
failedWU.setToFailed();
return failedWU;
Expand Down
2 changes: 2 additions & 0 deletions src/hpccplatform/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ class SessionManager {
const launchConfig = eclConfig.get<string>("launchConfiguration");
const targetCluster = eclConfig.get<object>("targetCluster")[launchConfig];
this.switchTo(launchConfig, targetCluster);
// Don't load HPCC Platform tree until session is fully initialized
vscode.commands.executeCommand("setContext", "hpccPlatformActive", true);
}

private get activeDocument() {
Expand Down

0 comments on commit 9c75b95

Please sign in to comment.