in web/frontend/src/app/pages/streams/modules/monitor-log/components/monitor-log-layout/monitor-log-layout.component.ts [87:219]
ngOnInit() {
this.streamDetails = this.streamDetailsStore.pipe(select(streamsDetailsStateSelector));
this.selectedMessage = this.appStore.pipe(select(getSelectedMessage));
this.activeTab = this.appStore.pipe(select(getActiveOrFirstTab));
this.appStore
.pipe(select(getOpenNewTabState))
.subscribe((_openNewTab) => (this.isOpenInNewTab = _openNewTab));
this.appStore
.pipe(
select(streamsListStateSelector),
filter(() => !!this.currentTab),
takeUntil(this.destroy$),
)
.subscribe((listState: ListState) => {
if (listState.dbState) {
if (listState.dbState.renamed && listState.dbState.renamed.length) {
const eqItem = listState.dbState.renamed.find((item) => item.oldName === this.tabName);
if (eqItem) {
const tab = new TabModel({...{}, ...this.currentTab});
tab.stream = eqItem.newName;
this.streamsStore.dispatch(
new StreamsTabsActions.AddTab({
tab: tab,
position: this.currentPosition,
}),
);
this.streamsStore.dispatch(
new StreamsTabsActions.RemoveTab({
tab: this.currentTab,
}),
);
}
}
if (
listState.dbState.added.find((item) => item === this.tabName) ||
listState.dbState.changed.find((item) => item === this.tabName)
) {
this.appStore.dispatch(new StreamsTabsActions.SetFilters({filter: this.tabFilter}));
}
if (listState.dbState.deleted.find((item) => item === this.tabName)) {
this.streamsStore.dispatch(
new StreamsTabsActions.RemoveTab({
tab: this.currentTab,
}),
);
}
}
});
this.appStore
.pipe(
select(getActiveTabFilters),
filter((filter) => !!filter),
takeUntil(this.destroy$),
)
.subscribe((filter: FilterModel) => {
this.tabFilter = {...filter};
});
this.tabSettings$ = this.appStore.pipe(select(getActiveTabSettings));
this.tabSettings$
.pipe(takeUntil(this.destroy$))
.subscribe((settings: TabSettingsModel) => (this.tabSettings = settings));
this.appStore
.pipe(
select(getStreamsList),
filter((streams) => !!streams),
switchMap(() => this.appStore.pipe(select(getTabs))),
filter((tabs) => !!tabs),
withLatestFrom(
this.appStore.pipe(
select(getActiveTab),
map((activeTab) => (activeTab ? activeTab.id : '')),
),
),
take(1),
takeUntil(this.destroy$),
switchMap(([tabs, activeTabId]: [TabModel[], string]) => {
return this.route.params.pipe(
filter((params: {stream: string; id: string; symbol?: string}) => !!params.stream),
withLatestFrom(this.route.data),
withLatestFrom(this.route.queryParams),
switchMap(
([[params, data], queryParams]: [
[{stream: string; id: string; symbol?: string}, Data],
Params,
]) => {
return this.appStore.pipe(
select(getStreamOrSymbolByID, {
streamID: params.stream,
symbol: params.symbol,
uid: params.id,
space: queryParams.space,
}),
filter((tabModel: TabModel) => !!tabModel),
take(1),
map((tabModel: TabModel) => {
return [tabModel, data, tabs, activeTabId];
}),
);
},
),
);
}),
takeUntil(this.destroy$),
)
.subscribe(([tabModel, data, tabs, activeTabId]: [TabModel, Data, TabModel[], string]) => {
if (tabModel.stream && tabModel.stream !== this.lastStream) {
this.lastStream = tabModel.stream;
this.streamDetailsStore.dispatch(
new StreamDetailsActions.GetSymbols({
streamId: tabModel.stream,
...(tabModel.space ? {spaceId: tabModel.space} : {}),
}),
);
}
this.live = data.hasOwnProperty('live');
// this.reverse = data.hasOwnProperty('reverse');
this.streamName = tabModel.stream;
if (!tabModel.stream) return;
this.tabName = tabModel.stream;
if (tabModel.symbol) {
this.tabName += tabModel.symbol;
}
});
}