171 lines
5.0 KiB
JavaScript
171 lines
5.0 KiB
JavaScript
/*
|
|
Copyright (c) 2023-forever Douglas Malnati. All rights reserved.
|
|
|
|
See the /faq/tos page for details.
|
|
|
|
(If this generated header is stamped on a file which is a 3rd party file or under a different license or copyright, then ignore this copyright statement and use that file's terms.)
|
|
*/
|
|
|
|
import { Base } from './Base.js';
|
|
|
|
import { WsprSearch } from './WsprSearch.js';
|
|
|
|
import { PreLoadChartExternalResources } from './Chart.js';
|
|
import { WsprSearchUiChartsController } from './WsprSearchUiChartsController.js';
|
|
import { WsprSearchUiFlightStatsController } from './WsprSearchUiFlightStatsController.js';
|
|
import { WsprSearchUiInputController } from './WsprSearchUiInputController.js';
|
|
import { WsprSearchUiDataTableController } from './WsprSearchUiDataTableController.js';
|
|
import { WsprSearchUiMapController } from './WsprSearchUiMapController.js';
|
|
import { WsprSearchUiStatsSearchController } from './WsprSearchUiStatsSearchController.js';
|
|
import { WsprSearchUiStatsFilterController } from './WsprSearchUiStatsFilterController.js';
|
|
import { TabularData } from '../../../../js/TabularData.js';
|
|
|
|
|
|
export class WsprSearchUi
|
|
extends Base
|
|
{
|
|
constructor(cfg)
|
|
{
|
|
super();
|
|
|
|
this.cfg = cfg;
|
|
|
|
PreLoadChartExternalResources();
|
|
|
|
// search
|
|
this.wsprSearch = new WsprSearch();
|
|
this.wsprSearch.AddOnSearchCompleteEventHandler(() => {
|
|
this.OnSearchComplete();
|
|
})
|
|
|
|
// ui input
|
|
this.uiInput = new WsprSearchUiInputController({
|
|
container: this.cfg.searchInput,
|
|
helpLink: this.cfg.helpLink,
|
|
mapContainer: this.cfg.map,
|
|
});
|
|
|
|
// ui map
|
|
this.uiMap = new WsprSearchUiMapController({
|
|
container: this.cfg.map,
|
|
});
|
|
|
|
// ui charts
|
|
this.uiCharts = new WsprSearchUiChartsController({
|
|
container: this.cfg.charts,
|
|
wsprSearch: this.wsprSearch,
|
|
});
|
|
|
|
// ui flight stats
|
|
this.uiFlightStats = new WsprSearchUiFlightStatsController({
|
|
container: this.cfg.flightStats,
|
|
});
|
|
|
|
// ui data table
|
|
this.uiDataTable = new WsprSearchUiDataTableController({
|
|
container: this.cfg.dataTable,
|
|
wsprSearch: this.wsprSearch,
|
|
});
|
|
|
|
// ui stats
|
|
this.uiStatsSearch = new WsprSearchUiStatsSearchController({
|
|
container: this.cfg.searchStats,
|
|
wsprSearch: this.wsprSearch,
|
|
});
|
|
|
|
this.uiStatsFilter = new WsprSearchUiStatsFilterController({
|
|
container: this.cfg.filterStats,
|
|
wsprSearch: this.wsprSearch,
|
|
});
|
|
|
|
window.addEventListener("message", evt => {
|
|
if (evt?.data?.type == "JUMP_TO_DATA" && evt.data.ts)
|
|
{
|
|
this.Emit({
|
|
type: "JUMP_TO_DATA",
|
|
ts: evt.data.ts,
|
|
});
|
|
}
|
|
});
|
|
|
|
this.PrimeEmptyResults();
|
|
}
|
|
|
|
SetDebug(tf)
|
|
{
|
|
super.SetDebug(tf);
|
|
|
|
this.t.SetCcGlobal(tf);
|
|
|
|
this.wsprSearch.SetDebug(tf);
|
|
|
|
this.uiInput.SetDebug(tf);
|
|
this.uiMap.SetDebug(tf);
|
|
this.uiCharts.SetDebug(tf);
|
|
this.uiDataTable.SetDebug(tf);
|
|
this.uiStatsSearch.SetDebug(tf);
|
|
this.uiStatsFilter.SetDebug(tf);
|
|
}
|
|
|
|
OnEvent(evt)
|
|
{
|
|
switch (evt.type) {
|
|
case "SEARCH_REQUESTED": this.OnSearchRequest(evt); break;
|
|
}
|
|
}
|
|
|
|
OnSearchRequest(evt)
|
|
{
|
|
this.t.Global().Reset();
|
|
this.t.Reset();
|
|
this.t.Event("WsprSearchUi::OnSearchRequest Callback Start");
|
|
|
|
this.wsprSearch.Search(evt.band, evt.channel, evt.callsign, evt.gte, evt.lte);
|
|
|
|
if (evt.msgDefinitionUserDefinedList)
|
|
{
|
|
this.wsprSearch.SetMsgDefinitionUserDefinedList(evt.msgDefinitionUserDefinedList);
|
|
this.uiDataTable.SetMsgDefinitionUserDefinedList(evt.msgDefinitionUserDefinedList);
|
|
}
|
|
|
|
if (evt.msgDefinitionVendorDefinedList)
|
|
{
|
|
this.wsprSearch.SetMsgDefinitionVendorDefinedList(evt.msgDefinitionVendorDefinedList);
|
|
this.uiDataTable.SetMsgDefinitionVendorDefinedList(evt.msgDefinitionVendorDefinedList);
|
|
}
|
|
|
|
this.t.Event("WsprSearchUi::OnSearchRequest Callback End");
|
|
}
|
|
|
|
OnSearchComplete()
|
|
{
|
|
this.t.Event("WsprSearchUi::OnSearchComplete Callback Start");
|
|
|
|
this.Emit("SEARCH_COMPLETE");
|
|
|
|
let td = this.wsprSearch.GetDataTable();
|
|
this.Emit({
|
|
type: "DATA_TABLE_RAW_READY",
|
|
tabularDataReadOnly: td,
|
|
});
|
|
|
|
this.t.Event("WsprSearchUi::OnSearchComplete Callback End");
|
|
|
|
// this.t.Global().Report(`WsprSearchUi Global`)
|
|
}
|
|
|
|
PrimeEmptyResults()
|
|
{
|
|
let td = new TabularData([[
|
|
"DateTimeUtc",
|
|
"DateTimeLocal",
|
|
]]);
|
|
|
|
this.Emit({
|
|
type: "DATA_TABLE_RAW_READY",
|
|
tabularDataReadOnly: td,
|
|
isPlaceholder: true,
|
|
});
|
|
}
|
|
}
|