From 4948524f910b138639416526ce99e54b2b6ef199 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 4 Jan 2021 04:36:21 +0100 Subject: [PATCH] More cleaning up --- Logic/Actors/AvailableBaseLayers.ts | 3 +-- Logic/Actors/LayerResetter.ts | 2 +- Logic/Osm/ChangesetHandler.ts | 1 + Logic/Osm/Geocoding.ts | 1 - Logic/Osm/OsmPreferences.ts | 2 +- Logic/Web/CodeGrid.ts | 26 --------------------- UI/BigComponents/Attribution.ts | 6 ++--- UI/BigComponents/BackgroundSelector.ts | 2 +- UI/BigComponents/SimpleAddUI.ts | 5 ++-- UI/BigComponents/UserBadge.ts | 2 +- UI/CustomGenerator/AllLayersPanel.ts | 2 +- UI/CustomGenerator/CustomGeneratorPanel.ts | 3 +-- UI/CustomGenerator/LayerPanel.ts | 3 +-- UI/CustomGenerator/LayerPanelWithPreview.ts | 2 +- UI/CustomGenerator/SharePanel.ts | 2 +- UI/CustomGenerator/TagRenderingPanel.ts | 3 +-- UI/Reviews/ReviewForm.ts | 2 +- UI/ShowDataLayer.ts | 4 +--- index.html | 2 +- package-lock.json | 13 +++++++++++ package.json | 2 ++ test.ts | 13 ----------- 22 files changed, 36 insertions(+), 65 deletions(-) delete mode 100644 Logic/Web/CodeGrid.ts diff --git a/Logic/Actors/AvailableBaseLayers.ts b/Logic/Actors/AvailableBaseLayers.ts index b5eabd3..db178dd 100644 --- a/Logic/Actors/AvailableBaseLayers.ts +++ b/Logic/Actors/AvailableBaseLayers.ts @@ -1,6 +1,5 @@ -console.log("AVAILABLE LAYERS") import * as editorlayerindex from "../../assets/editor-layer-index.json" -import {BaseLayer} from "../../Models/BaseLayer"; +import BaseLayer from "../../Models/BaseLayer"; import * as L from "leaflet"; import * as X from "leaflet-providers"; import {UIEventSource} from "../UIEventSource"; diff --git a/Logic/Actors/LayerResetter.ts b/Logic/Actors/LayerResetter.ts index a38ac2b..3a4aa56 100644 --- a/Logic/Actors/LayerResetter.ts +++ b/Logic/Actors/LayerResetter.ts @@ -1,5 +1,5 @@ import {UIEventSource} from "../UIEventSource"; -import {BaseLayer} from "../../Models/BaseLayer"; +import BaseLayer from "../../Models/BaseLayer"; import AvailableBaseLayers from "./AvailableBaseLayers"; import Loc from "../../Models/Loc"; diff --git a/Logic/Osm/ChangesetHandler.ts b/Logic/Osm/ChangesetHandler.ts index 3cae888..5e05e6e 100644 --- a/Logic/Osm/ChangesetHandler.ts +++ b/Logic/Osm/ChangesetHandler.ts @@ -1,4 +1,5 @@ import escapeHtml from "escape-html"; +// @ts-ignore import {OsmConnection, UserDetails} from "./OsmConnection"; import {UIEventSource} from "../UIEventSource"; import {ElementStorage} from "../ElementStorage"; diff --git a/Logic/Osm/Geocoding.ts b/Logic/Osm/Geocoding.ts index 5629fa1..85f5c5e 100644 --- a/Logic/Osm/Geocoding.ts +++ b/Logic/Osm/Geocoding.ts @@ -1,4 +1,3 @@ -import {Basemap} from "../Leaflet/Basemap"; import $ from "jquery" import State from "../../State"; export class Geocoding { diff --git a/Logic/Osm/OsmPreferences.ts b/Logic/Osm/OsmPreferences.ts index 7a00639..7b82c21 100644 --- a/Logic/Osm/OsmPreferences.ts +++ b/Logic/Osm/OsmPreferences.ts @@ -1,5 +1,5 @@ import {UIEventSource} from "../UIEventSource"; -import {OsmConnection, UserDetails} from "./OsmConnection"; +import UserDetails, {OsmConnection} from "./OsmConnection"; import {Utils} from "../../Utils"; export class OsmPreferences { diff --git a/Logic/Web/CodeGrid.ts b/Logic/Web/CodeGrid.ts deleted file mode 100644 index 78bb5f5..0000000 --- a/Logic/Web/CodeGrid.ts +++ /dev/null @@ -1,26 +0,0 @@ -import codegrid from "codegrid-js"; - -export default class CodeGrid { - private static readonly grid = CodeGrid.InitGrid(); - - - public static getCode(lat: any, lon: any, handle: (error, code) => void) { - CodeGrid.grid.getCode(lat, lon, handle); - } - - - private static InitGrid(): any { - const grid = codegrid.CodeGrid("./tiles/"); - - // Heat up the caches - grid.getCode(50.2, 3.2, (error, code) => { - }); - grid.getCode(52.5072, 13.4248, (error, code) => { - }); - grid.getCode(40.4781, -3.7034, () => { - }); - return grid; - } - - -} \ No newline at end of file diff --git a/UI/BigComponents/Attribution.ts b/UI/BigComponents/Attribution.ts index 43f2c8b..a419a1d 100644 --- a/UI/BigComponents/Attribution.ts +++ b/UI/BigComponents/Attribution.ts @@ -3,7 +3,7 @@ import Link from "../Base/Link"; import Svg from "../../Svg"; import Combine from "../Base/Combine"; import {UIEventSource} from "../../Logic/UIEventSource"; -import {UserDetails} from "../../Logic/Osm/OsmConnection"; +import UserDetails from "../../Logic/Osm/OsmConnection"; import Constants from "../../Models/Constants"; import LayoutConfig from "../../Customizations/JSON/LayoutConfig"; import Loc from "../../Models/Loc"; @@ -19,7 +19,7 @@ export default class Attribution extends UIElement { constructor(location: UIEventSource, userDetails: UIEventSource, layoutToUse: UIEventSource, - leafletMap: UIEventSource) { + leafletMap: UIEventSource) { super(location); this._layoutToUse = layoutToUse; this.ListenTo(layoutToUse); @@ -49,7 +49,7 @@ export default class Attribution extends UIElement { if (location !== undefined && this._leafletMap.data !== undefined && userDetails.csCount >= Constants.userJourney.tagsVisibleAndWikiLinked) { - const bounds = this._leafletMap.data.getBounds(); + const bounds : any= this._leafletMap.data.getBounds(); const top = bounds.getNorth(); const bottom = bounds.getSouth(); const right = bounds.getEast(); diff --git a/UI/BigComponents/BackgroundSelector.ts b/UI/BigComponents/BackgroundSelector.ts index 2f58245..c04eba3 100644 --- a/UI/BigComponents/BackgroundSelector.ts +++ b/UI/BigComponents/BackgroundSelector.ts @@ -3,7 +3,7 @@ import {DropDown} from "../Input/DropDown"; import Translations from "../i18n/Translations"; import State from "../../State"; import {UIEventSource} from "../../Logic/UIEventSource"; -import {BaseLayer} from "../../Models/BaseLayer"; +import BaseLayer from "../../Models/BaseLayer"; export default class BackgroundSelector extends UIElement { diff --git a/UI/BigComponents/SimpleAddUI.ts b/UI/BigComponents/SimpleAddUI.ts index 83309e3..c2c73ae 100644 --- a/UI/BigComponents/SimpleAddUI.ts +++ b/UI/BigComponents/SimpleAddUI.ts @@ -12,6 +12,7 @@ import Combine from "../Base/Combine"; import {FixedUiElement} from "../Base/FixedUiElement"; import Translations from "../i18n/Translations"; import Constants from "../../Models/Constants"; +import LayerConfig from "../../Customizations/JSON/LayerConfig"; export default class SimpleAddUI extends UIElement { private readonly _addButtons: UIElement[]; @@ -24,7 +25,7 @@ export default class SimpleAddUI extends UIElement { icon: UIElement, tags: Tag[], layerToAddTo: { - name: UIElement | string, + layerDef: LayerConfig, isDisplayed: UIEventSource } }> = new UIEventSource(undefined); @@ -128,7 +129,7 @@ export default class SimpleAddUI extends UIElement { if(!this._confirmPreset.data.layerToAddTo.isDisplayed.data){ return new Combine([ - Translations.t.general.add.layerNotEnabled.Subs({layer: this._confirmPreset.data.layerToAddTo.name}) + Translations.t.general.add.layerNotEnabled.Subs({layer: this._confirmPreset.data.layerToAddTo.layerDef.name}) .SetClass("alert"), this.openLayerControl, diff --git a/UI/BigComponents/UserBadge.ts b/UI/BigComponents/UserBadge.ts index a1ad4b5..19de2db 100644 --- a/UI/BigComponents/UserBadge.ts +++ b/UI/BigComponents/UserBadge.ts @@ -4,7 +4,7 @@ import {UIEventSource} from "../../Logic/UIEventSource"; import {UIElement} from "../UIElement"; import {VariableUiElement} from "../Base/VariableUIElement"; -import {UserDetails} from "../../Logic/Osm/OsmConnection"; +import UserDetails from "../../Logic/Osm/OsmConnection"; import Svg from "../../Svg"; import State from "../../State"; import Combine from "../Base/Combine"; diff --git a/UI/CustomGenerator/AllLayersPanel.ts b/UI/CustomGenerator/AllLayersPanel.ts index c214f93..588af7f 100644 --- a/UI/CustomGenerator/AllLayersPanel.ts +++ b/UI/CustomGenerator/AllLayersPanel.ts @@ -6,7 +6,7 @@ import {LayoutConfigJson} from "../../Customizations/JSON/LayoutConfigJson"; import Combine from "../Base/Combine"; import {GenerateEmpty} from "./GenerateEmpty"; import LayerPanelWithPreview from "./LayerPanelWithPreview"; -import {UserDetails} from "../../Logic/Osm/OsmConnection"; +import UserDetails from "../../Logic/Osm/OsmConnection"; import {MultiInput} from "../Input/MultiInput"; import TagRenderingPanel from "./TagRenderingPanel"; import SingleSetting from "./SingleSetting"; diff --git a/UI/CustomGenerator/CustomGeneratorPanel.ts b/UI/CustomGenerator/CustomGeneratorPanel.ts index 2d5f1a2..99414cb 100644 --- a/UI/CustomGenerator/CustomGeneratorPanel.ts +++ b/UI/CustomGenerator/CustomGeneratorPanel.ts @@ -1,5 +1,5 @@ import {UIElement} from "../UIElement"; -import {OsmConnection, UserDetails} from "../../Logic/Osm/OsmConnection"; +import UserDetails, {OsmConnection} from "../../Logic/Osm/OsmConnection"; import {UIEventSource} from "../../Logic/UIEventSource"; import SingleSetting from "./SingleSetting"; import GeneralSettings from "./GeneralSettings"; @@ -11,7 +11,6 @@ import AllLayersPanel from "./AllLayersPanel"; import SharePanel from "./SharePanel"; import {LayoutConfigJson} from "../../Customizations/JSON/LayoutConfigJson"; import {SubtleButton} from "../Base/SubtleButton"; -import State from "../../State"; import {FixedUiElement} from "../Base/FixedUiElement"; import SavePanel from "./SavePanel"; import {LocalStorageSource} from "../../Logic/Web/LocalStorageSource"; diff --git a/UI/CustomGenerator/LayerPanel.ts b/UI/CustomGenerator/LayerPanel.ts index 7591040..9dcaa9d 100644 --- a/UI/CustomGenerator/LayerPanel.ts +++ b/UI/CustomGenerator/LayerPanel.ts @@ -16,8 +16,7 @@ import {TagRenderingConfigJson} from "../../Customizations/JSON/TagRenderingConf import {MultiInput} from "../Input/MultiInput"; import {LayerConfigJson} from "../../Customizations/JSON/LayerConfigJson"; import PresetInputPanel from "./PresetInputPanel"; -import {UserDetails} from "../../Logic/Osm/OsmConnection"; -import State from "../../State"; +import UserDetails from "../../Logic/Osm/OsmConnection"; import {FixedUiElement} from "../Base/FixedUiElement"; import ValidatedTextField from "../Input/ValidatedTextField"; import Svg from "../../Svg"; diff --git a/UI/CustomGenerator/LayerPanelWithPreview.ts b/UI/CustomGenerator/LayerPanelWithPreview.ts index ec2e56f..3c0d19c 100644 --- a/UI/CustomGenerator/LayerPanelWithPreview.ts +++ b/UI/CustomGenerator/LayerPanelWithPreview.ts @@ -8,7 +8,7 @@ import {FromJSON} from "../../Customizations/JSON/FromJSON"; import Combine from "../Base/Combine"; import PageSplit from "../Base/PageSplit"; import TagRenderingPreview from "./TagRenderingPreview"; -import {UserDetails} from "../../Logic/Osm/OsmConnection"; +import UserDetails from "../../Logic/Osm/OsmConnection"; export default class LayerPanelWithPreview extends UIElement{ diff --git a/UI/CustomGenerator/SharePanel.ts b/UI/CustomGenerator/SharePanel.ts index ec72af7..ddb6d13 100644 --- a/UI/CustomGenerator/SharePanel.ts +++ b/UI/CustomGenerator/SharePanel.ts @@ -3,7 +3,7 @@ import {UIEventSource} from "../../Logic/UIEventSource"; import {LayoutConfigJson} from "../../Customizations/JSON/LayoutConfigJson"; import Combine from "../Base/Combine"; import {VariableUiElement} from "../Base/VariableUIElement"; -import {UserDetails} from "../../Logic/Osm/OsmConnection"; +import UserDetails from "../../Logic/Osm/OsmConnection"; export default class SharePanel extends UIElement { private _config: UIEventSource; diff --git a/UI/CustomGenerator/TagRenderingPanel.ts b/UI/CustomGenerator/TagRenderingPanel.ts index bc52462..2114004 100644 --- a/UI/CustomGenerator/TagRenderingPanel.ts +++ b/UI/CustomGenerator/TagRenderingPanel.ts @@ -12,8 +12,7 @@ import {MultiInput} from "../Input/MultiInput"; import MappingInput from "./MappingInput"; import {AndOrTagConfigJson} from "../../Customizations/JSON/TagConfigJson"; import {TagRenderingConfigJson} from "../../Customizations/JSON/TagRenderingConfigJson"; -import {UserDetails} from "../../Logic/Osm/OsmConnection"; -import State from "../../State"; +import UserDetails from "../../Logic/Osm/OsmConnection"; import {VariableUiElement} from "../Base/VariableUIElement"; import ValidatedTextField from "../Input/ValidatedTextField"; import SpecialVisualizations from "../SpecialVisualizations"; diff --git a/UI/Reviews/ReviewForm.ts b/UI/Reviews/ReviewForm.ts index 8502ee3..55379b7 100644 --- a/UI/Reviews/ReviewForm.ts +++ b/UI/Reviews/ReviewForm.ts @@ -9,7 +9,7 @@ import Svg from "../../Svg"; import {VariableUiElement} from "../Base/VariableUIElement"; import {SaveButton} from "../Popup/SaveButton"; import CheckBoxes from "../Input/Checkboxes"; -import {UserDetails} from "../../Logic/Osm/OsmConnection"; +import UserDetails from "../../Logic/Osm/OsmConnection"; export default class ReviewForm extends InputElement { diff --git a/UI/ShowDataLayer.ts b/UI/ShowDataLayer.ts index 18d2986..55c9957 100644 --- a/UI/ShowDataLayer.ts +++ b/UI/ShowDataLayer.ts @@ -39,12 +39,10 @@ export default class ShowDataLayer { const feats = features.data.map(ff => ff.feature); const geoLayer = self.CreateGeojsonLayer(feats); - if (oldGeoLayer) { mp.removeLayer(oldGeoLayer); } - - geoLayer.addTo(mp); + mp.addLayer(geoLayer); oldGeoLayer = geoLayer; } diff --git a/index.html b/index.html index abc12e7..c1aa020 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,7 @@ - + diff --git a/package-lock.json b/package-lock.json index 1dee075..7016245 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3589,6 +3589,14 @@ "@types/leaflet": "*" } }, + "@types/leaflet.markercluster": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/@types/leaflet.markercluster/-/leaflet.markercluster-1.4.3.tgz", + "integrity": "sha512-X/b/Enz84PzmcA9z7pxsHEBEUNghmvznEBcRQeuxyYL/QU6jAR7LIb/ot03ATNPO56wSFzbCnsOf7yJ+7FzS1Q==", + "requires": { + "@types/leaflet": "*" + } + }, "@types/node": { "version": "7.10.11", "resolved": "https://registry.npmjs.org/@types/node/-/node-7.10.11.tgz", @@ -7058,6 +7066,11 @@ "resolved": "https://registry.npmjs.org/leaflet-providers/-/leaflet-providers-1.10.2.tgz", "integrity": "sha512-1l867LObxwuFBeyPeBewip8PAXKOnvEoujq4/9y2TKTiZNHH76ksBD6dfktGjgUrOF+IdjsGHkpASPE+v2DQLw==" }, + "leaflet.markercluster": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/leaflet.markercluster/-/leaflet.markercluster-1.4.1.tgz", + "integrity": "sha512-ZSEpE/EFApR0bJ1w/dUGwTSUvWlpalKqIzkaYdYB7jaftQA/Y2Jav+eT4CMtEYFj+ZK4mswP13Q2acnPBnhGOw==" + }, "leven": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", diff --git a/package.json b/package.json index dada662..5e604d7 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "license": "GPL", "dependencies": { "@types/leaflet-providers": "^1.2.0", + "@types/leaflet.markercluster": "^1.4.3", "country-language": "^0.1.7", "email-validator": "^2.0.4", "escape-html": "^1.0.3", @@ -38,6 +39,7 @@ "latlon2country": "^1.0.8", "leaflet": "^1.7.1", "leaflet-providers": "^1.10.2", + "leaflet.markercluster": "^1.4.1", "libphonenumber": "0.0.10", "libphonenumber-js": "^1.7.55", "mangrove-reviews": "^0.1.3", diff --git a/test.ts b/test.ts index 2c47420..d4ebb85 100644 --- a/test.ts +++ b/test.ts @@ -6,19 +6,6 @@ import ReviewForm from "./UI/Reviews/ReviewForm"; import Combine from "./UI/Base/Combine"; import {FixedUiElement} from "./UI/Base/FixedUiElement"; -const identity = '{"crv":"P-256","d":"6NHPmTFRedjNl-ZfLRAXhOaNKtRR9GYzPHsO1CzN5wQ","ext":true,"key_ops":["sign"],"kty":"EC","x":"Thm_pL5m0m9Jl41z9vgMTHNyja-9H58v0stJWT4KhTI","y":"PjBldCW85b8K6jEZbw0c2UZskpo-rrkwfPnD7s1MXSM","metadata":"Mangrove private key"}' - -const mangroveReviews = new MangroveReviews(0, 0, "Null Island", - new UIEventSource(identity), true) - -new ReviewElement(mangroveReviews.GetSubjectUri(), mangroveReviews.GetReviews()).AttachTo("maindiv"); -const form = new ReviewForm((r,done) => { - mangroveReviews.AddReview(r, done); -}); -form.AttachTo("extradiv") - -form.GetValue().map(r => form.IsValid(r)).addCallback(d => console.log(d)) - /* window.setTimeout( () => {