Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.6.0 #657

Merged
master from
Nov 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
cbf87be
build(deps-dev): bump @types/node from 14.11.10 to 14.14.0 in /src
dependabot[bot] Oct 21, 2020
1c93005
build(deps-dev): bump @types/node in /src/projects/media/webview
dependabot[bot] Oct 21, 2020
2a6a423
Merge pull request #621 from q-masters/master
konne Oct 21, 2020
026d7ae
Merge pull request #620 from q-masters/dependabot/npm_and_yarn/src/pr…
konne Oct 21, 2020
d58b2cb
Merge pull request #619 from q-masters/dependabot/npm_and_yarn/src/de…
konne Oct 21, 2020
689912e
feat: improve error messages on load data
r-hannuschka Oct 21, 2020
0d7a930
build(deps-dev): bump @types/node from 14.14.0 to 14.14.2 in /src
dependabot[bot] Oct 22, 2020
94b2611
build(deps-dev): bump @angular/language-service
dependabot[bot] Oct 22, 2020
30e9b82
Merge pull request #623 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 22, 2020
7c640df
Merge pull request #624 from q-masters/dependabot/npm_and_yarn/src/pr…
dependabot[bot] Oct 22, 2020
ef965fa
build(deps-dev): bump @types/node in /src/projects/media/webview
dependabot[bot] Oct 22, 2020
ebebaf0
Merge pull request #625 from q-masters/dependabot/npm_and_yarn/src/pr…
dependabot[bot] Oct 22, 2020
a7b1f06
fix: fixed bug openDoc was called multiple times
r-hannuschka Oct 22, 2020
a60e38b
clean up
r-hannuschka Oct 22, 2020
3765d17
build(deps-dev): bump webpack from 5.1.3 to 5.2.0 in /src
dependabot[bot] Oct 23, 2020
d216ae8
build(deps-dev): bump @angular/cli in /src/projects/media/webview
dependabot[bot] Oct 23, 2020
10246bb
Merge pull request #628 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 23, 2020
c60aecc
Merge pull request #629 from q-masters/dependabot/npm_and_yarn/src/pr…
dependabot[bot] Oct 23, 2020
5e16041
build(deps-dev): bump @angular-devkit/build-ng-packagr
dependabot[bot] Oct 23, 2020
8b795f1
Merge pull request #631 from q-masters/dependabot/npm_and_yarn/src/pr…
dependabot[bot] Oct 23, 2020
74b268a
build(deps-dev): bump @angular-devkit/build-angular
dependabot[bot] Oct 23, 2020
bf77242
Merge pull request #630 from q-masters/dependabot/npm_and_yarn/src/pr…
dependabot[bot] Oct 23, 2020
43366c5
Merge pull request #622 from q-masters/feat/618_better_error_messages
konne Oct 25, 2020
0029ecf
Merge pull request #627 from q-masters/bug/626_open_doc_called_multip…
konne Oct 25, 2020
8e9f296
[feat #543] show diff app has changed on sever
r-hannuschka Oct 23, 2020
5e22e36
[feat #543] show diff if server script has been changed
r-hannuschka Oct 24, 2020
314b005
[feat #543] switch to qix filesystem provider for diff files
r-hannuschka Oct 25, 2020
5f0dc01
[feat #543] ensure server not override if we reopen the app
r-hannuschka Oct 25, 2020
49b2b76
[feat #543] unlock script if document is closed
r-hannuschka Oct 25, 2020
dba507a
build(deps-dev): bump ts-loader from 8.0.6 to 8.0.7 in /src
dependabot[bot] Oct 26, 2020
3a7793a
build(deps-dev): bump eslint from 7.11.0 to 7.12.0 in /src
dependabot[bot] Oct 26, 2020
0fb5e2e
build(deps-dev): bump @types/node from 14.14.2 to 14.14.3 in /src
dependabot[bot] Oct 26, 2020
30455bc
Merge pull request #633 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 26, 2020
127ebe0
Merge pull request #634 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 26, 2020
0d4f539
Merge pull request #635 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 26, 2020
e20aab9
build(deps-dev): bump @types/jasmine in /src/projects/media/webview
dependabot[bot] Oct 26, 2020
51a913d
Merge pull request #636 from q-masters/dependabot/npm_and_yarn/src/pr…
dependabot[bot] Oct 26, 2020
8ed7604
build(deps-dev): bump @types/node in /src/projects/media/webview
dependabot[bot] Oct 26, 2020
b37df77
Merge pull request #637 from q-masters/dependabot/npm_and_yarn/src/pr…
dependabot[bot] Oct 26, 2020
4c98f57
clean up
r-hannuschka Oct 26, 2020
b585cd9
fix: fixed bug visible elements not shown if not defined
r-hannuschka Oct 26, 2020
10a318f
[feat #543] add some improvements
r-hannuschka Oct 27, 2020
84c9d82
build(deps-dev): bump eslint from 7.12.0 to 7.12.1 in /src
dependabot[bot] Oct 27, 2020
002c6fa
build(deps-dev): bump typescript from 4.0.3 to 4.0.5 in /src
dependabot[bot] Oct 27, 2020
f5569f7
build(deps-dev): bump @types/ws from 7.2.7 to 7.2.8 in /src
dependabot[bot] Oct 27, 2020
8aa464f
build(deps-dev): bump @types/node from 14.14.3 to 14.14.5 in /src
dependabot[bot] Oct 27, 2020
be27e00
Merge pull request #639 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 27, 2020
f353abd
Merge pull request #640 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 27, 2020
f3528ef
Merge pull request #641 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 27, 2020
94771e6
Merge pull request #642 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 27, 2020
3cddf06
build(deps-dev): bump @types/node in /src/projects/media/webview
dependabot[bot] Oct 27, 2020
1d2c819
Merge pull request #643 from q-masters/dependabot/npm_and_yarn/src/pr…
dependabot[bot] Oct 27, 2020
1069fe7
[feat #543] some refactoring new logic
r-hannuschka Oct 27, 2020
c321188
build(deps-dev): bump webpack from 5.2.0 to 5.3.0 in /src
dependabot[bot] Oct 28, 2020
a6cf81a
build(deps): bump @angular/material in /src/projects/media/webview
dependabot[bot] Oct 28, 2020
94f9369
Merge pull request #644 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 28, 2020
6ff4d60
Merge pull request #645 from q-masters/dependabot/npm_and_yarn/src/pr…
dependabot[bot] Oct 28, 2020
fbc271c
feat: add diff support for qlik script if remote script / local scrip…
r-hannuschka Oct 29, 2020
41d21cc
build(deps-dev): bump @types/ws from 7.2.8 to 7.2.9 in /src
dependabot[bot] Oct 29, 2020
35ce16a
build(deps-dev): bump webpack from 5.3.0 to 5.3.1 in /src
dependabot[bot] Oct 29, 2020
ab3904d
Merge pull request #647 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 29, 2020
785b6bf
Merge pull request #649 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 29, 2020
addf5fe
build(deps-dev): bump @types/node from 14.14.5 to 14.14.6 in /src
dependabot[bot] Oct 29, 2020
03fac26
build(deps-dev): bump sinon from 9.2.0 to 9.2.1 in /src
dependabot[bot] Oct 29, 2020
ffb94f7
build(deps-dev): bump @angular/language-service
dependabot[bot] Oct 29, 2020
9d71caa
Merge pull request #650 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 29, 2020
1aa2650
Merge pull request #648 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 29, 2020
566e441
Merge pull request #651 from q-masters/dependabot/npm_and_yarn/src/pr…
dependabot[bot] Oct 29, 2020
9e7cd4f
build(deps-dev): bump @types/node in /src/projects/media/webview
dependabot[bot] Oct 29, 2020
16f2fd4
Merge pull request #652 from q-masters/dependabot/npm_and_yarn/src/pr…
dependabot[bot] Oct 29, 2020
6f39f3b
[feat #543] save last working copy of script (after it has been saved…
r-hannuschka Oct 29, 2020
8656d85
build(deps-dev): bump webpack from 5.3.1 to 5.3.2 in /src
dependabot[bot] Oct 30, 2020
bedb53b
Merge pull request #653 from q-masters/dependabot/npm_and_yarn/src/de…
dependabot[bot] Oct 30, 2020
8615526
fixed bug script was saved before data was on server
r-hannuschka Oct 30, 2020
19bd038
Merge pull request #638 from q-masters/bug/487_visible_elements
konne Nov 1, 2020
bc387be
Merge pull request #646 from q-masters/feat/543_show_diff_on_script_c…
konne Nov 1, 2020
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
Prev Previous commit
Next Next commit
[feat #543] show diff app has changed on sever
- added Application which holds the document to know when app has been changed
- added logic if we open a script file to register for app changed event
  • Loading branch information
r-hannuschka committed Oct 25, 2020
commit 8e9f29685b96da9e17ff02db6e8ff4a4cfb63fb9
106 changes: 106 additions & 0 deletions src/projects/extension/connection/utils/application.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { from, Observable, Subject } from "rxjs";
import { bufferCount, debounce, debounceTime, switchMap, take, takeWhile, tap } from "rxjs/operators";

export class Application {

private close$: Subject<void> = new Subject();

/**
* broadcast all app changes
*/
private appChange$: Subject<any> = new Subject();

private docChangeListener: () => void;

/**
* current count of registered observers
*/
private observerCount = 0;

private doc: Promise<EngineAPI.IApp>;

public constructor(
private globalContext: EngineAPI.IGlobal,
private name: string
) {}

/**
* return global context for app
*/
public get global(): EngineAPI.IGlobal {
return this.globalContext;
}

/**
* returns the active doc, cache the promise since this one
* has exactly one of those states fulfilled, rejected which never
* changes
*/
public get document(): Promise<EngineAPI.IApp> {
if (!this.doc) {
this.doc = this.global.openDoc(this.name);
}
return this.doc;
}

/**
* close current app
*/
public async close(): Promise<void> {
this.close$.next();

(await this.document as any).removeListener('changed', this.onDocumentChange.bind(this));
await this.global.session.close();

this.appChange$.complete();
this.close$.complete();
}

public onClose(): Observable<void> {
return this.close$.asObservable();
}

/**
* create a warm observeable which registerns once on app changed event
* if the the first one subscribe, for unsusubscript if no listeners left
* unregister again from app changed event
*/
public onChanged(): Observable<any> {
/** subscribe */
return new Observable((observer) => {

if (this.observerCount === 0) {
this.observerCount += 1;
this.registerOnDocumentChange();
}

/** subscribe to app changes stream */
this.appChange$
/** seems to emit twice ... but why ? */
.subscribe(observer);

/** unsubscribe */
return () => {
this.observerCount -= 1;

if (this.observerCount === 0) {
this.unregisterOnDocumentChange();
}
};
});
}

private onDocumentChange() {
this.appChange$.next();
}

private async registerOnDocumentChange() {
const doc = await this.document;
doc.on("changed", this.onDocumentChange.bind(this));
}

private async unregisterOnDocumentChange() {
const doc = await this.document;
(doc as any).removeListener("changed", this.onDocumentChange.bind(this));
}
}
3 changes: 3 additions & 0 deletions src/projects/extension/connection/utils/connection.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export abstract class ConnectionHelper {
rejectUnauthorized: !connection.isUntrusted
});

logger.debug(uri);

ws.on("message", (message) => logger.verbose(message.toString()));
ws.on("error", (e) => logger.error(`${connection.setting.label} ${e.message}`));
return ws;
Expand Down Expand Up @@ -102,6 +104,7 @@ export abstract class ConnectionHelper {
port : port && !isNaN(port) ? port : connection.secure ? 443 : 80,
subpath : connection.path ?? ""
};

return buildUrl(options);
}

Expand Down
53 changes: 40 additions & 13 deletions src/projects/extension/connection/utils/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ConnectionHelper } from "./connection.helper";
import { EnigmaSession } from "./enigma.provider";
import { VsQlikLoggerConnection } from "../api";
import { fetchServerInformation } from "../commands";
import { Application } from "./application";

/**
* represents the connection to a server, which is a workspace folder in vscode
Expand All @@ -36,6 +37,9 @@ export class Connection {
*/
private serverStorage: Storage;

/**
*
*/
private stateChange$: BehaviorSubject<ConnectionState> = new BehaviorSubject(ConnectionState.CLOSED);

/**
Expand All @@ -44,9 +48,18 @@ export class Connection {
private destroy$: Subject<boolean> = new Subject();

/**
* file mapping, so we could easier find a filesystem entry
*/
private serverFilesystem: FileSystemStorage = new FileSystemStorage();

/**
* open applications
*/
private applications: Map<string, Application> = new Map();

/**
* vsqlik logger for connections
*/
private logger: VsQlikLogger;

public constructor(
Expand Down Expand Up @@ -114,20 +127,36 @@ export class Connection {
this.stateChange$.next(ConnectionState.CLOSED);
}

public closeSession(appId?: string): Promise<void> {
return this.engimaProvider.close(appId);
}

public openSession(appId?: string): Promise<EngineAPI.IGlobal | undefined> {
return this.engimaProvider.open(appId);
public openSession(): Promise<EngineAPI.IGlobal | undefined> {
return this.engimaProvider.open();
}

/**
* create complete new independed session
*/
public createSession(keepAlive = false): Promise<EngineAPI.IGlobal | undefined> {
return this.engimaProvider.createSession(keepAlive);
}

public async openDoc(id: string): Promise<EngineAPI.IApp | undefined> {
return this.engimaProvider.openDoc(id);
/**
* create application wrapper for existing qlik app
*/
public async getApplication(id: string): Promise<Application | undefined> {
if (!this.applications.has(id)) {
const global = await this.engimaProvider.open(id);

if (global) {
const app = new Application(global, id);

app.onClose()
.pipe(take(1))
.subscribe(() => this.applications.delete(id));

/** cache app */
this.applications.set(id, app);
}
}
return this.applications.get(id);
}

/**
Expand Down Expand Up @@ -205,10 +234,8 @@ export class Connection {
protected checkAuthState(): Promise<AuthorizationState> {
return new Promise((resolve, reject) => {
const session = ConnectionHelper.createEnigmaSession(this.connectionModel);
session.on("traffic:received", (response) => {
(session as any).removeAllListeners();
session.close();

session.on("traffic:received", async (response) => {
await session.close();
switch (response.method) {
case 'OnAuthenticationInformation':
this.connectionModel.isAuthorizationRequired = true;
Expand All @@ -220,10 +247,10 @@ export class Connection {
break;

default:
console.log(response);
reject(response);
}
});
session.on('closed', () => (session as any).removeAllListeners());
session.open();
});
}
Expand Down
1 change: 1 addition & 0 deletions src/projects/extension/connection/utils/enigma.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class EnigmaSession {
if (global) {
if (!this.docCache.has(global)) {
const app = await global.openDoc(name);
// global.getActiveDoc();
this.docCache.set(global, app);
logger.debug(`open new app for ${name} and cached it to docCache`);
}
Expand Down
5 changes: 3 additions & 2 deletions src/projects/extension/file-system/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ export * from "./routes";

export enum EntryType {
APPLICATION,
MEASURE,
DIMENSION,
STREAM,
MEASURE,
SCRIPT,
SHEET,
STREAM,
VARIABLE,
VISUALIZATION,
UNKNOWN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ export class AppListMyWorkDirectory extends AppListDirectory {
}

await this.applicationProvider.deleteApp(connection, fsEntry.id);
await connection.closeSession(fsEntry.id);

connection.fileSystem.deleteDirectory(uri);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { injectable, inject } from "tsyringe";
import { QixFsDirectoryAdapter } from "../qix/qixfs-entry";
import { FileSystemHelper } from "../../utils/file-system.helper";
import { DataNode } from "@core/qix/utils/qix-list.provider";
import { ConnectionProvider } from "@core/public.api";
import path from "path";
import { EntryType } from "@vsqlik/fs/data";

@injectable()
export class ScriptDirectory extends QixFsDirectoryAdapter{
Expand All @@ -22,8 +25,20 @@ export class ScriptDirectory extends QixFsDirectoryAdapter{
};
}

public async readDirectory(): Promise<[string, vscode.FileType][]> {
return [["main.qvs", vscode.FileType.File]];
public async readDirectory(uri: vscode.Uri): Promise<[string, vscode.FileType][]> {
const connection = await this.getConnection(uri);
if (connection) {
const fileUri = uri.with({path: path.posix.resolve(uri.path, `main.qvs`)});
connection.fileSystem.write(fileUri.toString(true), {
id: 'main.qvs',
name: 'main',
raw: {},
type: EntryType.SCRIPT,
readonly: false
});
return [["main.qvs", vscode.FileType.File]];
}
return [];
}

public async delete(uri: vscode.Uri, params: DataNode): Promise<void> {
Expand Down
9 changes: 6 additions & 3 deletions src/projects/extension/script/commands/check-syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@ export async function CheckScriptSyntax(uri: vscode.Uri): Promise<void> {
}

/** open the app */
const app = await connection.openDoc(appEntry.id);
const app = await connection.getApplication(appEntry.id);

if (!app) {
vscode.window.showInformationMessage(`check syntax for file: ${uri.toString(true)} failed. Could not open app.`);
return;
}

/** final syntax checks */
const errors = await app.checkScriptSyntax();
const document = await app.document;
const errors = await document.checkScriptSyntax();

const diagnostics: vscode.Diagnostic[] = [];

if (errors.length) {
const script = await app.getScript();
const script = await document.getScript();

errors.forEach((error) => {
const line = script.substring(0, error.qTextPos).split(EOL).length - 1;
Expand Down
42 changes: 37 additions & 5 deletions src/projects/extension/script/script.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import { ExtensionContext } from "@data/tokens";
import * as vscode from "vscode";
import { inject, singleton } from "tsyringe";
import { CheckScriptSyntax, ScriptLoadDataCommand, ScriptResolveActiveCommand } from "./commands";
import { ConnectionProvider } from "../connection/utils/connection.provider";
import { EntryType } from "@vsqlik/fs/data";
import { takeUntil } from "rxjs/operators";

@singleton()
export class ScriptModule {

constructor(
@inject(ExtensionContext) private extensionContext: vscode.ExtensionContext
@inject(ExtensionContext) private extensionContext: vscode.ExtensionContext,
@inject(ConnectionProvider) private connectionProvider: ConnectionProvider
) {}

public bootstrap(): void {
Expand All @@ -28,10 +32,38 @@ export class ScriptModule {
* register connection storage where all sessions are saved to
*/
private registerEvents(): void {
vscode.workspace.onDidOpenTextDocument((doc: vscode.TextDocument) => {
if(doc.fileName.match(/\.qvs$/)) {
vscode.commands.executeCommand(`VsQlik.Script.CheckSyntax`, doc.uri);
}

vscode.workspace.onDidOpenTextDocument((document) => this.onOpenDocument(document));
vscode.workspace.onDidCloseTextDocument((document) => {
console.log(`close document`);
console.log(document);
});
}

/**
* a new textdocument has been opened
* check we handle a script file and if we do connect to appChange stream
*/
private async onOpenDocument(doc: vscode.TextDocument) {

if (doc.uri.scheme !== "qix") {
return;
}

/** resolve connection and entry type */
const connection = await this.connectionProvider.resolve(doc.uri);
const fileEntry = connection?.fileSystem.read(doc.uri.toString(true));
const appEntry = connection?.fileSystem.parent(doc.uri, EntryType.APPLICATION);

if (!appEntry || fileEntry?.type !== EntryType.SCRIPT) {
return;
}

/** since we handle a script listen to onchange for app here until app get closed */
const app = await connection?.getApplication(appEntry.id);
app?.onChanged()
.subscribe(() => console.log('app changed'));

vscode.commands.executeCommand(`VsQlik.Script.CheckSyntax`, doc.uri);
}
}
Loading