Update row count as updates are received (#6642)

This commit is contained in:
Matthew McCune
2019-08-13 18:31:34 -07:00
committed by Karl Burtram
parent f48b9e1b41
commit b5fdf8c2a7
4 changed files with 24 additions and 0 deletions

1
src/sql/azdata.d.ts vendored
View File

@@ -3994,6 +3994,7 @@ declare module 'azdata' {
export namespace queryeditor {
export type QueryEvent =
| 'queryStart'
| 'queryUpdate'
| 'queryStop'
| 'executionPlan'
| 'visualize';

View File

@@ -68,6 +68,7 @@ export interface IQueryModelService {
showCommitError(error: string): void;
onRunQueryStart: Event<string>;
onRunQueryUpdate: Event<string>;
onRunQueryComplete: Event<string>;
onQueryEvent: Event<IQueryEvent>;

View File

@@ -58,12 +58,14 @@ export class QueryModelService implements IQueryModelService {
// MEMBER VARIABLES ////////////////////////////////////////////////////
private _queryInfoMap: Map<string, QueryInfo>;
private _onRunQueryStart: Emitter<string>;
private _onRunQueryUpdate: Emitter<string>;
private _onRunQueryComplete: Emitter<string>;
private _onQueryEvent: Emitter<IQueryEvent>;
private _onEditSessionReady: Emitter<azdata.EditSessionReadyParams>;
// EVENTS /////////////////////////////////////////////////////////////
public get onRunQueryStart(): Event<string> { return this._onRunQueryStart.event; }
public get onRunQueryUpdate(): Event<string> { return this._onRunQueryUpdate.event; }
public get onRunQueryComplete(): Event<string> { return this._onRunQueryComplete.event; }
public get onQueryEvent(): Event<IQueryEvent> { return this._onQueryEvent.event; }
public get onEditSessionReady(): Event<azdata.EditSessionReadyParams> { return this._onEditSessionReady.event; }
@@ -75,6 +77,7 @@ export class QueryModelService implements IQueryModelService {
) {
this._queryInfoMap = new Map<string, QueryInfo>();
this._onRunQueryStart = new Emitter<string>();
this._onRunQueryUpdate = new Emitter<string>();
this._onRunQueryComplete = new Emitter<string>();
this._onQueryEvent = new Emitter<IQueryEvent>();
this._onEditSessionReady = new Emitter<azdata.EditSessionReadyParams>();
@@ -299,6 +302,17 @@ export class QueryModelService implements IQueryModelService {
this._fireQueryEvent(uri, 'start');
});
queryRunner.onResultSetUpdate(() => {
this._onRunQueryUpdate.fire(uri);
let event: IQueryEvent = {
type: 'queryUpdate',
uri: uri
};
this._onQueryEvent.fire(event);
this._fireQueryEvent(uri, 'update');
});
queryRunner.onQueryPlanAvailable(planInfo => {
// fire extensibility API event

View File

@@ -158,6 +158,9 @@ export class RowCountStatusBarContributions extends Disposable implements IWorkb
this.disposable.add(runner.onQueryStart(e => {
this._displayValue(runner);
}));
this.disposable.add(runner.onResultSetUpdate(e => {
this._displayValue(runner);
}));
this.disposable.add(runner.onQueryEnd(e => {
this._displayValue(runner);
}));
@@ -167,6 +170,11 @@ export class RowCountStatusBarContributions extends Disposable implements IWorkb
this._displayValue(this.queryModelService.getQueryRunner(uri));
}
}));
this.disposable.add(this.queryModelService.onRunQueryUpdate(e => {
if (e === uri) {
this._displayValue(this.queryModelService.getQueryRunner(uri));
}
}));
this.disposable.add(this.queryModelService.onRunQueryComplete(e => {
if (e === uri) {
this._displayValue(this.queryModelService.getQueryRunner(uri));