| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | import FeaturePipelineState from "../Logic/State/FeaturePipelineState" | 
					
						
							|  |  |  | import { DefaultGuiState } from "./DefaultGuiState" | 
					
						
							|  |  |  | import { FixedUiElement } from "./Base/FixedUiElement" | 
					
						
							|  |  |  | import { Utils } from "../Utils" | 
					
						
							|  |  |  | import Combine from "./Base/Combine" | 
					
						
							|  |  |  | import ShowDataLayer from "./ShowDataLayer/ShowDataLayer" | 
					
						
							|  |  |  | import LayerConfig from "../Models/ThemeConfig/LayerConfig" | 
					
						
							| 
									
										
										
										
											2023-02-08 01:14:21 +01:00
										 |  |  | import home_location_json from "../assets/layers/home_location/home_location.json" | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | import State from "../State" | 
					
						
							|  |  |  | import Title from "./Base/Title" | 
					
						
							|  |  |  | import { MinimapObj } from "./Base/Minimap" | 
					
						
							|  |  |  | import BaseUIElement from "./BaseUIElement" | 
					
						
							|  |  |  | import { VariableUiElement } from "./Base/VariableUIElement" | 
					
						
							|  |  |  | import { GeoOperations } from "../Logic/GeoOperations" | 
					
						
							|  |  |  | import { OsmFeature } from "../Models/OsmFeature" | 
					
						
							|  |  |  | import SearchAndGo from "./BigComponents/SearchAndGo" | 
					
						
							|  |  |  | import FeatureInfoBox from "./Popup/FeatureInfoBox" | 
					
						
							|  |  |  | import { UIEventSource } from "../Logic/UIEventSource" | 
					
						
							|  |  |  | import LanguagePicker from "./LanguagePicker" | 
					
						
							|  |  |  | import Lazy from "./Base/Lazy" | 
					
						
							|  |  |  | import TagRenderingAnswer from "./Popup/TagRenderingAnswer" | 
					
						
							|  |  |  | import Hash from "../Logic/Web/Hash" | 
					
						
							|  |  |  | import FilterView from "./BigComponents/FilterView" | 
					
						
							|  |  |  | import Translations from "./i18n/Translations" | 
					
						
							|  |  |  | import Constants from "../Models/Constants" | 
					
						
							|  |  |  | import SimpleAddUI from "./BigComponents/SimpleAddUI" | 
					
						
							|  |  |  | import BackToIndex from "./BigComponents/BackToIndex" | 
					
						
							|  |  |  | import StatisticsPanel from "./BigComponents/StatisticsPanel" | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default class DashboardGui { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     private readonly state: FeaturePipelineState | 
					
						
							|  |  |  |     private readonly currentView: UIEventSource<{ | 
					
						
							|  |  |  |         title: string | BaseUIElement | 
					
						
							|  |  |  |         contents: string | BaseUIElement | 
					
						
							|  |  |  |     }> = new UIEventSource(undefined) | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     constructor(state: FeaturePipelineState, guiState: DefaultGuiState) { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         this.state = state | 
					
						
							| 
									
										
										
										
											2022-07-15 12:56:16 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     private viewSelector( | 
					
						
							|  |  |  |         shown: BaseUIElement, | 
					
						
							|  |  |  |         title: string | BaseUIElement, | 
					
						
							|  |  |  |         contents: string | BaseUIElement, | 
					
						
							|  |  |  |         hash?: string | 
					
						
							|  |  |  |     ): BaseUIElement { | 
					
						
							| 
									
										
										
										
											2022-07-15 12:56:16 +02:00
										 |  |  |         const currentView = this.currentView | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         const v = { title, contents } | 
					
						
							| 
									
										
										
										
											2022-07-15 12:56:16 +02:00
										 |  |  |         shown.SetClass("pl-1 pr-1 rounded-md") | 
					
						
							|  |  |  |         shown.onClick(() => { | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  |             currentView.setData(v) | 
					
						
							| 
									
										
										
										
											2022-07-15 12:56:16 +02:00
										 |  |  |         }) | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         Hash.hash.addCallbackAndRunD((h) => { | 
					
						
							| 
									
										
										
										
											2022-07-15 12:56:16 +02:00
										 |  |  |             if (h === hash) { | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  |                 currentView.setData(v) | 
					
						
							| 
									
										
										
										
											2022-07-15 12:56:16 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         }) | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         currentView.addCallbackAndRunD((cv) => { | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  |             if (cv == v) { | 
					
						
							| 
									
										
										
										
											2022-07-15 12:56:16 +02:00
										 |  |  |                 shown.SetClass("bg-unsubtle") | 
					
						
							|  |  |  |                 Hash.hash.setData(hash) | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 shown.RemoveClass("bg-unsubtle") | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }) | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         return shown | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private singleElementCache: Record<string, BaseUIElement> = {} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     private singleElementView( | 
					
						
							|  |  |  |         element: OsmFeature, | 
					
						
							|  |  |  |         layer: LayerConfig, | 
					
						
							|  |  |  |         distance: number | 
					
						
							|  |  |  |     ): BaseUIElement { | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  |         if (this.singleElementCache[element.properties.id] !== undefined) { | 
					
						
							|  |  |  |             return this.singleElementCache[element.properties.id] | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         const tags = this.state.allElements.getEventSourceById(element.properties.id) | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         const title = new Combine([ | 
					
						
							|  |  |  |             new Title(new TagRenderingAnswer(tags, layer.title, this.state), 4), | 
					
						
							|  |  |  |             distance < 900 | 
					
						
							|  |  |  |                 ? Math.floor(distance) + "m away" | 
					
						
							|  |  |  |                 : Utils.Round(distance / 1000) + "km away", | 
					
						
							|  |  |  |         ]).SetClass("flex justify-between") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return (this.singleElementCache[element.properties.id] = this.viewSelector( | 
					
						
							|  |  |  |             title, | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  |             new Lazy(() => FeatureInfoBox.GenerateTitleBar(tags, layer, this.state)), | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             new Lazy(() => FeatureInfoBox.GenerateContent(tags, layer, this.state)) | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  |             //  element.properties.id
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         )) | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     private mainElementsView( | 
					
						
							|  |  |  |         elements: { element: OsmFeature; layer: LayerConfig; distance: number }[] | 
					
						
							|  |  |  |     ): BaseUIElement { | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  |         const self = this | 
					
						
							|  |  |  |         if (elements === undefined) { | 
					
						
							|  |  |  |             return new FixedUiElement("Initializing") | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (elements.length == 0) { | 
					
						
							|  |  |  |             return new FixedUiElement("No elements in view") | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         return new Combine( | 
					
						
							|  |  |  |             elements.map((e) => self.singleElementView(e.element, e.layer, e.distance)) | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     private documentationButtonFor(layerConfig: LayerConfig): BaseUIElement { | 
					
						
							|  |  |  |         return this.viewSelector( | 
					
						
							|  |  |  |             Translations.W(layerConfig.name?.Clone() ?? layerConfig.id), | 
					
						
							|  |  |  |             new Combine(["Documentation about ", layerConfig.name?.Clone() ?? layerConfig.id]), | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  |             layerConfig.GenerateDocumentation([]), | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             "documentation-" + layerConfig.id | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private allDocumentationButtons(): BaseUIElement { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         const layers = this.state.layoutToUse.layers | 
					
						
							|  |  |  |             .filter((l) => Constants.priviliged_layers.indexOf(l.id) < 0) | 
					
						
							|  |  |  |             .filter((l) => !l.id.startsWith("note_import_")) | 
					
						
							| 
									
										
										
										
											2022-07-18 00:28:26 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (layers.length === 1) { | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  |             return this.documentationButtonFor(layers[0]) | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         return this.viewSelector( | 
					
						
							|  |  |  |             new FixedUiElement("Documentation"), | 
					
						
							|  |  |  |             "Documentation", | 
					
						
							|  |  |  |             new Combine(layers.map((l) => this.documentationButtonFor(l).SetClass("flex flex-col"))) | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  |     public setup(): void { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         const state = this.state | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (this.state.layoutToUse.customCss !== undefined) { | 
					
						
							|  |  |  |             if (window.location.pathname.indexOf("index") >= 0) { | 
					
						
							|  |  |  |                 Utils.LoadCustomCss(this.state.layoutToUse.customCss) | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         const map = this.SetupMap() | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         Utils.downloadJson("./service-worker-version") | 
					
						
							|  |  |  |             .then((data) => console.log("Service worker", data)) | 
					
						
							|  |  |  |             .catch((_) => console.log("Service worker not active")) | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         document.getElementById("centermessage").classList.add("hidden") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const layers: Record<string, LayerConfig> = {} | 
					
						
							|  |  |  |         for (const layer of state.layoutToUse.layers) { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             layers[layer.id] = layer | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         const self = this | 
					
						
							|  |  |  |         const elementsInview = new UIEventSource< | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 distance: number | 
					
						
							|  |  |  |                 center: [number, number] | 
					
						
							|  |  |  |                 element: OsmFeature | 
					
						
							|  |  |  |                 layer: LayerConfig | 
					
						
							|  |  |  |             }[] | 
					
						
							|  |  |  |         >([]) | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         function update() { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             const mapCenter = <[number, number]>[ | 
					
						
							|  |  |  |                 self.state.locationControl.data.lon, | 
					
						
							|  |  |  |                 self.state.locationControl.data.lon, | 
					
						
							|  |  |  |             ] | 
					
						
							|  |  |  |             const elements = self.state.featurePipeline | 
					
						
							|  |  |  |                 .getAllVisibleElementsWithmeta(self.state.currentBounds.data) | 
					
						
							|  |  |  |                 .map((el) => { | 
					
						
							|  |  |  |                     const distance = GeoOperations.distanceBetween(el.center, mapCenter) | 
					
						
							|  |  |  |                     return { ...el, distance } | 
					
						
							|  |  |  |                 }) | 
					
						
							| 
									
										
										
										
											2022-07-25 18:55:15 +02:00
										 |  |  |             elements.sort((e0, e1) => e0.distance - e1.distance) | 
					
						
							|  |  |  |             elementsInview.setData(elements) | 
					
						
							| 
									
										
										
										
											2022-07-15 12:56:16 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-15 12:56:16 +02:00
										 |  |  |         map.bounds.addCallbackAndRun(update) | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         state.featurePipeline.newDataLoadedSignal.addCallback(update) | 
					
						
							|  |  |  |         state.filteredLayers.addCallbackAndRun((fls) => { | 
					
						
							| 
									
										
										
										
											2022-07-15 12:56:16 +02:00
										 |  |  |             for (const fl of fls) { | 
					
						
							|  |  |  |                 fl.isDisplayed.addCallback(update) | 
					
						
							|  |  |  |                 fl.appliedFilters.addCallback(update) | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2022-07-15 12:56:16 +02:00
										 |  |  |         }) | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-18 00:28:26 +02:00
										 |  |  |         const filterView = new Lazy(() => { | 
					
						
							| 
									
										
										
										
											2022-08-20 12:46:33 +02:00
										 |  |  |             return new FilterView(state.filteredLayers, state.overlayToggles, state) | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         }) | 
					
						
							|  |  |  |         const welcome = new Combine([ | 
					
						
							|  |  |  |             state.layoutToUse.description, | 
					
						
							|  |  |  |             state.layoutToUse.descriptionTail, | 
					
						
							|  |  |  |         ]) | 
					
						
							|  |  |  |         self.currentView.setData({ title: state.layoutToUse.title, contents: welcome }) | 
					
						
							| 
									
										
										
										
											2022-07-18 00:28:26 +02:00
										 |  |  |         const filterViewIsOpened = new UIEventSource(false) | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         filterViewIsOpened.addCallback((_) => | 
					
						
							|  |  |  |             self.currentView.setData({ title: "filters", contents: filterView }) | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2022-07-20 12:04:14 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         const newPointIsShown = new UIEventSource(false) | 
					
						
							| 
									
										
										
										
											2022-07-20 12:04:14 +02:00
										 |  |  |         const addNewPoint = new SimpleAddUI( | 
					
						
							| 
									
										
										
										
											2022-07-18 00:28:26 +02:00
										 |  |  |             new UIEventSource(true), | 
					
						
							|  |  |  |             new UIEventSource(undefined), | 
					
						
							|  |  |  |             filterViewIsOpened, | 
					
						
							|  |  |  |             state, | 
					
						
							|  |  |  |             state.locationControl | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         ) | 
					
						
							| 
									
										
										
										
											2022-07-18 00:28:26 +02:00
										 |  |  |         const addNewPointTitle = "Add a missing point" | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         this.currentView.addCallbackAndRunD((cv) => { | 
					
						
							| 
									
										
										
										
											2022-07-20 12:04:14 +02:00
										 |  |  |             newPointIsShown.setData(cv.contents === addNewPoint) | 
					
						
							| 
									
										
										
										
											2022-07-18 00:28:26 +02:00
										 |  |  |         }) | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         newPointIsShown.addCallbackAndRun((isShown) => { | 
					
						
							| 
									
										
										
										
											2022-07-20 12:04:14 +02:00
										 |  |  |             if (isShown) { | 
					
						
							|  |  |  |                 if (self.currentView.data.contents !== addNewPoint) { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                     self.currentView.setData({ title: addNewPointTitle, contents: addNewPoint }) | 
					
						
							| 
									
										
										
										
											2022-07-18 00:28:26 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2022-07-20 12:04:14 +02:00
										 |  |  |             } else { | 
					
						
							|  |  |  |                 if (self.currentView.data.contents === addNewPoint) { | 
					
						
							| 
									
										
										
										
											2022-07-18 00:28:26 +02:00
										 |  |  |                     self.currentView.setData(undefined) | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         }) | 
					
						
							| 
									
										
										
										
											2022-07-20 12:04:14 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  |         new Combine([ | 
					
						
							| 
									
										
										
										
											2022-07-15 12:56:16 +02:00
										 |  |  |             new Combine([ | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 this.viewSelector( | 
					
						
							|  |  |  |                     new Title(state.layoutToUse.title.Clone(), 2), | 
					
						
							|  |  |  |                     state.layoutToUse.title.Clone(), | 
					
						
							|  |  |  |                     welcome, | 
					
						
							|  |  |  |                     "welcome" | 
					
						
							|  |  |  |                 ), | 
					
						
							| 
									
										
										
										
											2022-07-15 12:56:16 +02:00
										 |  |  |                 map.SetClass("w-full h-64 shrink-0 rounded-lg"), | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  |                 new SearchAndGo(state), | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 this.viewSelector( | 
					
						
							|  |  |  |                     new Title( | 
					
						
							|  |  |  |                         new VariableUiElement( | 
					
						
							|  |  |  |                             elementsInview.map( | 
					
						
							|  |  |  |                                 (elements) => "There are " + elements?.length + " elements in view" | 
					
						
							|  |  |  |                             ) | 
					
						
							|  |  |  |                         ) | 
					
						
							|  |  |  |                     ), | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  |                     "Statistics", | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                     new StatisticsPanel(elementsInview, this.state), | 
					
						
							|  |  |  |                     "statistics" | 
					
						
							|  |  |  |                 ), | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 this.viewSelector(new FixedUiElement("Filter"), "Filters", filterView, "filters"), | 
					
						
							|  |  |  |                 this.viewSelector( | 
					
						
							|  |  |  |                     new Combine(["Add a missing point"]), | 
					
						
							|  |  |  |                     addNewPointTitle, | 
					
						
							| 
									
										
										
										
											2022-07-20 12:04:14 +02:00
										 |  |  |                     addNewPoint | 
					
						
							| 
									
										
										
										
											2022-07-15 12:56:16 +02:00
										 |  |  |                 ), | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 new VariableUiElement( | 
					
						
							|  |  |  |                     elementsInview.map((elements) => | 
					
						
							|  |  |  |                         this.mainElementsView(elements).SetClass("block m-2") | 
					
						
							|  |  |  |                     ) | 
					
						
							|  |  |  |                 ).SetClass( | 
					
						
							|  |  |  |                     "block shrink-2 overflow-x-auto h-full border-2 border-subtle rounded-lg" | 
					
						
							|  |  |  |                 ), | 
					
						
							| 
									
										
										
										
											2022-07-16 03:57:13 +02:00
										 |  |  |                 this.allDocumentationButtons(), | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 new LanguagePicker(Object.keys(state.layoutToUse.title.translations)).SetClass( | 
					
						
							|  |  |  |                     "mt-2" | 
					
						
							|  |  |  |                 ), | 
					
						
							|  |  |  |                 new BackToIndex(), | 
					
						
							| 
									
										
										
										
											2022-07-20 14:39:19 +02:00
										 |  |  |             ]).SetClass("w-1/2 lg:w-1/4 m-4 flex flex-col shrink-0 grow-0"), | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             new VariableUiElement( | 
					
						
							|  |  |  |                 this.currentView.map(({ title, contents }) => { | 
					
						
							|  |  |  |                     return new Combine([ | 
					
						
							|  |  |  |                         new Title(Translations.W(title), 2).SetClass( | 
					
						
							|  |  |  |                             "shrink-0 border-b-4 border-subtle" | 
					
						
							|  |  |  |                         ), | 
					
						
							|  |  |  |                         Translations.W(contents).SetClass("shrink-2 overflow-y-auto block"), | 
					
						
							|  |  |  |                     ]).SetClass("flex flex-col h-full") | 
					
						
							|  |  |  |                 }) | 
					
						
							|  |  |  |             ).SetClass( | 
					
						
							|  |  |  |                 "w-1/2 lg:w-3/4 m-4 p-2 border-2 border-subtle rounded-xl m-4 ml-0 mr-8 shrink-0 grow-0" | 
					
						
							|  |  |  |             ), | 
					
						
							|  |  |  |         ]) | 
					
						
							|  |  |  |             .SetClass("flex h-full") | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  |             .AttachTo("leafletDiv") | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private SetupMap(): MinimapObj & BaseUIElement { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         const state = this.state | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         new ShowDataLayer({ | 
					
						
							|  |  |  |             leafletMap: state.leafletMap, | 
					
						
							|  |  |  |             layerToShow: new LayerConfig(home_location_json, "home_location", true), | 
					
						
							|  |  |  |             features: state.homeLocation, | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             state, | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         state.leafletMap.addCallbackAndRunD((_) => { | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  |             // Lets assume that all showDataLayers are initialized at this point
 | 
					
						
							|  |  |  |             state.selectedElement.ping() | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             State.state.locationControl.ping() | 
					
						
							|  |  |  |             return true | 
					
						
							| 
									
										
										
										
											2022-07-13 17:58:01 +02:00
										 |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return state.mainMapObject | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | } |