Skip to content

Commit

Permalink
feat:Additional Options for showing log output panel
Browse files Browse the repository at this point in the history
  • Loading branch information
smorrisj authored Jan 30, 2024
1 parent ce44349 commit 63cb9f6
Show file tree
Hide file tree
Showing 34 changed files with 437 additions and 84 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- ODS display image inline ([#471](https://github.com/sassoftware/vscode-sas-extension/issues/471))
- sasnb extension name for save ([#607](https://github.com/sassoftware/vscode-sas-extension/issues/607))
- document symbol error ([#715](https://github.com/sassoftware/vscode-sas-extension/issues/715))
- Added extra settings options to customize when SAS log is shown ([#647](https://github.com/sassoftware/vscode-sas-extension/issues/647))

## [v1.5.0] - 2023-10-27

Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ Notebook is an interactive experience with Markdown, executable code snippets an
- To toggle log or ODS output display, click `...` at the side of the output and select `Change Presentation`.
- SAS Notebook can be saved to a `.sasnb` file, shared to others, and open in another VS Code window.

### SAS Log

Its possible to customize when the SAS log gets shown in the bottom panel by using the following extension settings. These settings will apply to all connection profiles:
| Name | Description | Additional Notes |
| ---------------------------------| --------------------------------------- | ----------------------------- |
| **SAS.log.showOnExecutionStart** | Show SAS log on start of execution | default: true |
| **SAS.log.showOnExecutionFinish**| Show SAS log on end of execution | default: true |

To see an example, please refer to the [Viya4](doc/profileExamples/viya4.json) example profile.

## Support

### SAS Communities
Expand Down
46 changes: 41 additions & 5 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"react-dom": "^18.2.0",
"ssh2": "^1.15.0",
"uuid": "^9.0.1",
"vscode-languageclient": "^9.0.1"
"vscode-languageclient": "^9.0.1",
"zustand": "^4.4.7"
},
"devDependencies": {
"@types/react": "^18.2.48",
Expand Down
32 changes: 20 additions & 12 deletions client/src/commands/run.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022-2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
// Copyright © 2022-2024, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import {
EventEmitter,
Expand All @@ -12,8 +12,11 @@ import {
} from "vscode";
import type { BaseLanguageClient } from "vscode-languageclient";

import { LogFn as LogChannelFn } from "../components/LogChannel";
import { showResult } from "../components/ResultPanel/ResultPanel";
import {
appendExecutionLogFn,
appendSessionLogFn,
} from "../components/logViewer";
import {
assign_SASProgramFile,
wrapCodeWithOutputHtml,
Expand All @@ -25,6 +28,7 @@ import {
RunResult,
getSession,
} from "../connection";
import { useRunStore } from "../store";
import { profileConfig, switchProfile } from "./profile";

interface FoldingBlock {
Expand All @@ -34,7 +38,7 @@ interface FoldingBlock {
endCol: number;
}

let running = false;
const { setIsExecutingCode } = useRunStore.getState();

function getCode(selected = false, uri?: Uri): string {
const editor = uri
Expand Down Expand Up @@ -137,7 +141,8 @@ async function runCode(selected?: boolean, uri?: Uri) {
const code = getCode(selected, uri);

const session = getSession();
session.onLogFn = LogChannelFn;
session.onExecutionLogFn = appendExecutionLogFn;
session.onSessionLogFn = appendSessionLogFn;

await window.withProgress(
{
Expand Down Expand Up @@ -167,18 +172,19 @@ async function runCode(selected?: boolean, uri?: Uri) {
}

const _run = async (selected = false, uri?: Uri) => {
if (running) {
if (useRunStore.getState().isExecutingCode) {
return;
}
running = true;

setIsExecutingCode(true);
commands.executeCommand("setContext", "SAS.running", true);

await runCode(selected, uri)
.catch((err) => {
onRunError(err);
})
.finally(() => {
running = false;
setIsExecutingCode(false);
commands.executeCommand("setContext", "SAS.running", false);
});
};
Expand All @@ -198,15 +204,16 @@ export async function runRegion(client: BaseLanguageClient): Promise<void> {
}

export function hasRunningTask() {
return running;
return useRunStore.getState().isExecutingCode;
}
export async function runTask(
code: string,
messageEmitter?: EventEmitter<string>,
closeEmitter?: EventEmitter<number>,
onLog?: OnLogFn,
onSessionLog?: OnLogFn,
): Promise<RunResult> {
if (running) {
if (useRunStore.getState().isExecutingCode) {
return;
}

Expand All @@ -215,7 +222,7 @@ export async function runTask(
return;
}

running = true;
setIsExecutingCode(true);
commands.executeCommand("setContext", "SAS.running", true);

let cancelled = false;
Expand All @@ -226,10 +233,11 @@ export async function runTask(
await session.cancel();
}

running = false;
setIsExecutingCode(false);
commands.executeCommand("setContext", "SAS.running", false);
});
session.onLogFn = onLog ?? LogChannelFn;
session.onExecutionLogFn = onLog ?? appendExecutionLogFn;
session.onSessionLogFn = onSessionLog ?? appendSessionLogFn;

messageEmitter.fire(`${l10n.t("Connecting to SAS session...")}\r\n`);
!cancelled && (await session.setup());
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/LibraryNavigator/LibraryModel.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright © 2023, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
// Copyright © 2024, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { ProgressLocation, l10n, window } from "vscode";

import { AxiosResponse } from "axios";
import { Writable } from "stream";

import { appendSessionLogFn } from "../../components/logViewer";
import { getSession } from "../../connection";
import { DataAccessApi } from "../../connection/rest/api/compute";
import { getApiConfig } from "../../connection/rest/common";
import { LogFn as LogChannelFn } from "../LogChannel";
import PaginatedResultSet from "./PaginatedResultSet";
import { DefaultRecordLimit, Messages } from "./const";
import { LibraryItem, LibraryItemType, TableData, TableRow } from "./types";
Expand All @@ -25,7 +25,7 @@ class LibraryModel {

public async connect(): Promise<void> {
const session = getSession();
session.onLogFn = LogChannelFn;
session.onSessionLogFn = appendSessionLogFn;

await window.withProgress(
{
Expand Down
17 changes: 0 additions & 17 deletions client/src/components/LogChannel.ts

This file was deleted.

29 changes: 0 additions & 29 deletions client/src/components/LogViewer.ts

This file was deleted.

Loading

0 comments on commit 63cb9f6

Please sign in to comment.