mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 17:22:48 -05:00
Refresh master with initial release/0.24 snapshot (#332)
* Initial port of release/0.24 source code * Fix additional headers * Fix a typo in launch.json
This commit is contained in:
@@ -13,7 +13,17 @@ export const IAngularEventingService = createDecorator<IAngularEventingService>(
|
||||
|
||||
export enum AngularEventType {
|
||||
NAV_DATABASE,
|
||||
NAV_SERVER
|
||||
NAV_SERVER,
|
||||
DELETE_WIDGET
|
||||
}
|
||||
|
||||
export interface IDeleteWidgetPayload {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface IAngularEvent {
|
||||
event: AngularEventType;
|
||||
payload: any;
|
||||
}
|
||||
|
||||
export interface IAngularEventingService {
|
||||
@@ -24,24 +34,24 @@ export interface IAngularEventingService {
|
||||
* @param cb Listening function
|
||||
* @returns
|
||||
*/
|
||||
onAngularEvent(uri: string, cb: (event: AngularEventType) => void): Subscription;
|
||||
onAngularEvent(uri: string, cb: (event: IAngularEvent) => void): Subscription;
|
||||
|
||||
/**
|
||||
* Send an event to the dashboard; no op if the dashboard has not started listening yet
|
||||
* @param uri Uri of the dashboard to send the event to
|
||||
* @param event event to send
|
||||
*/
|
||||
sendAngularEvent(uri: string, event: AngularEventType): void;
|
||||
sendAngularEvent(uri: string, event: AngularEventType, payload?: any): void;
|
||||
}
|
||||
|
||||
export class AngularEventingService implements IAngularEventingService {
|
||||
public _serviceBrand: any;
|
||||
private _angularMap = new Map<string, Subject<AngularEventType>>();
|
||||
private _angularMap = new Map<string, Subject<IAngularEvent>>();
|
||||
|
||||
public onAngularEvent(uri: string, cb: (event: AngularEventType) => void): Subscription {
|
||||
let subject: Subject<AngularEventType>;
|
||||
public onAngularEvent(uri: string, cb: (event: IAngularEvent) => void): Subscription {
|
||||
let subject: Subject<IAngularEvent>;
|
||||
if (!this._angularMap.has(uri)) {
|
||||
subject = new Subject<AngularEventType>();
|
||||
subject = new Subject<IAngularEvent>();
|
||||
this._angularMap.set(uri, subject);
|
||||
} else {
|
||||
subject = this._angularMap.get(uri);
|
||||
@@ -50,11 +60,11 @@ export class AngularEventingService implements IAngularEventingService {
|
||||
return sub;
|
||||
}
|
||||
|
||||
public sendAngularEvent(uri: string, event: AngularEventType): void {
|
||||
public sendAngularEvent(uri: string, event: AngularEventType, payload?: any): void {
|
||||
if (!this._angularMap.has(uri)) {
|
||||
warn('Got request to send an event to a dashboard that has not started listening');
|
||||
} else {
|
||||
this._angularMap.get(uri).next(event);
|
||||
this._angularMap.get(uri).next({ event, payload });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user