in web/frontend/src/app/pages/query/query.component.ts [151:286]
ngOnInit() {
this.isWriter$ = this.permissionsService.isWriter();
this.showDetails$ = this.tabStorageService
.flow<HasRightPanel>('rightPanel')
.getData(['selectedMessage'])
.pipe(map((data) => !!data?.selectedMessage));
this.gridType$
.pipe(
map((type) => [GridTypes.live, GridTypes.monitor].includes(type)),
takeUntil(this.destroy$)
)
.subscribe(isLiveGrid => this.isLiveGrid = isLiveGrid);
this.createForm();
this.gridService
.infinityScroll((start, end) => {
return this.tabId().pipe(
take(1),
switchMap((tabId) =>
this.queryService.query(this.storageService.getExecutedQuery(tabId), start, end - start),
),
map((data) => this.mapResponseData(data)),
);
})
.pipe(takeUntil(this.destroy$))
.subscribe();
this.liveGridName$ = this.tabId().pipe(map((id) => `gridLive${id}`));
this.gridOptions$ = this.tabId().pipe(map((tabId) => this.gridService.options(tabId)));
this.gridService
.onRowClicked()
.pipe(takeUntil(this.destroy$))
.subscribe((event) => this.messageInfoService.cellClicked(event));
this.gridService
.onPinnedChanged()
.pipe(takeUntil(this.destroy$))
.subscribe(() => this.messageInfoService.onPinnedRowDataChanged());
this.gridService
.onDoubleClicked()
.pipe(takeUntil(this.destroy$))
.subscribe((event) => {
this.messageInfoService.doubleClicked(event.data);
});
this.tabStorageService
.getData(['exportType'])
.pipe(takeUntil(this.destroy$))
.subscribe((data) => {
this.exportType$.next(data?.exportType || ExportTypes.qsmsg);
});
this.tabStorageService
.getData()
.pipe(takeUntil(this.destroy$))
.subscribe(() => {
this.messageInfoService.tabChanged();
this.setQueryError();
});
this.tabStorageService.getData().pipe(take(1)).subscribe((storage) => {
if (storage?.data?.[1]) {
this.gridTotalService.loadedFromCache(storage.data[1].length);
}
});
this.setQueryError();
this.tabStorageService
.getData(['data', 'error', 'hideColumnsByDefault', 'gridType', 'query'])
.pipe(
tap((model) => this.toggleGrid(!!model?.data)),
filter((model) => !!model?.data),
takeUntil(this.destroy$),
)
.subscribe(({data: [schema, data, rawSchema], query, hideColumnsByDefault, gridType}) => {
this.gridType$.next(gridType);
switch (this.gridType$.getValue()) {
case GridTypes.monitor:
case GridTypes.live:
this.rawSchema = rawSchema;
this.gridLiveFilters = {
symbols: null,
space: null,
fromTimestamp:
this.gridType$.getValue() === GridTypes.live ? new Date().toISOString() : null,
types: null,
destination: `/user/topic/monitor-qql`,
qql: query?.replace(/\r/g, '\\r').replace(/\n/g, '\\n'),
};
this.toggleGrid(true);
return;
case GridTypes.view:
this.schema = schema;
this.gridService.hideColumnsByDefault(hideColumnsByDefault);
this.setGridData(schema, data);
return;
}
});
this.sendBtnDisabled$ = combineLatest([
this.loading$,
this.pending$,
]).pipe(
map(([loading, pending]) => (loading && !pending)),
);
this.editorOptions = this.monacoQqlConfigService.options();
this.sendBtnText$ = combineLatest([this.pending$, this.gridType$]).pipe(
switchMap(([pending, gridType]) =>
this.translateService.get(`qqlEditor.buttons.${pending ? 'cancel' : gridType}`),
),
);
this.exportBtnText$ = this.exportType$.pipe(
switchMap((type) => this.translateService.get(`qqlEditor.buttons.export.${type}`)),
);
this.lastQueries$ = this.lastQueriesService.getQueries();
this.monacoQqlConfigService
.onColumns()
.pipe(takeUntil(this.destroy$))
.subscribe((columns) => {
this.gridService.hideColumnsByDefault(columns.includes('*'));
});
this.monacoQqlConfigService
.onCtrlEnter()
.pipe(takeUntil(this.destroy$))
.subscribe(() => this.onSubmit());
}