| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  | import Link from "../Base/Link"; | 
					
						
							|  |  |  | import Svg from "../../Svg"; | 
					
						
							|  |  |  | import Combine from "../Base/Combine"; | 
					
						
							|  |  |  | import {UIEventSource} from "../../Logic/UIEventSource"; | 
					
						
							| 
									
										
										
										
											2021-01-04 04:36:21 +01:00
										 |  |  | import UserDetails from "../../Logic/Osm/OsmConnection"; | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  | import Constants from "../../Models/Constants"; | 
					
						
							|  |  |  | import Loc from "../../Models/Loc"; | 
					
						
							| 
									
										
										
										
											2021-06-12 02:58:32 +02:00
										 |  |  | import {VariableUiElement} from "../Base/VariableUIElement"; | 
					
						
							| 
									
										
										
										
											2021-08-07 23:11:34 +02:00
										 |  |  | import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"; | 
					
						
							| 
									
										
										
										
											2021-09-28 17:30:48 +02:00
										 |  |  | import {BBox} from "../../Logic/BBox"; | 
					
						
							| 
									
										
										
										
											2021-10-16 18:30:24 +02:00
										 |  |  | import {Utils} from "../../Utils"; | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-07 01:32:39 +02:00
										 |  |  | /** | 
					
						
							|  |  |  |  * The bottom right attribution panel in the leaflet map | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-06-12 02:58:32 +02:00
										 |  |  | export default class Attribution extends Combine { | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |     constructor(location: UIEventSource<Loc>, | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |                 userDetails: UIEventSource<UserDetails>, | 
					
						
							| 
									
										
										
										
											2021-09-28 18:00:44 +02:00
										 |  |  |                 layoutToUse: LayoutConfig, | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |                 currentBounds: UIEventSource<BBox>) { | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  |         const mapComplete = new Link(`Mapcomplete ${Constants.vNumber}`, 'https://github.com/pietervdvn/MapComplete', true); | 
					
						
							| 
									
										
										
										
											2021-06-12 02:58:32 +02:00
										 |  |  |         const reportBug = new Link(Svg.bug_ui().SetClass("small-image"), "https://github.com/pietervdvn/MapComplete/issues", true); | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-28 18:00:44 +02:00
										 |  |  |         const layoutId = layoutToUse?.id; | 
					
						
							| 
									
										
										
										
											2021-10-16 18:30:24 +02:00
										 |  |  |         const stats = new Link(Svg.statistics_ui().SetClass("small-image"), Utils.OsmChaLinkFor(31, layoutId), true) | 
					
						
							| 
									
										
										
										
											2021-06-12 02:58:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  |         const idLink = location.map(location => `https://www.openstreetmap.org/edit?editor=id#map=${location?.zoom ?? 0}/${location?.lat ?? 0}/${location?.lon ?? 0}`) | 
					
						
							| 
									
										
										
										
											2021-06-12 02:58:32 +02:00
										 |  |  |         const editHere = new Link(Svg.pencil_ui().SetClass("small-image"), idLink, true) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const mapillaryLink = location.map(location => `https://www.mapillary.com/app/?focus=map&lat=${location?.lat ?? 0}&lng=${location?.lon ?? 0}&z=${Math.max((location?.zoom ?? 2) - 1, 1)}`) | 
					
						
							|  |  |  |         const mapillary = new Link(Svg.mapillary_black_ui().SetClass("small-image"), mapillaryLink, true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-23 12:56:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-12 02:58:32 +02:00
										 |  |  |         let editWithJosm = new VariableUiElement( | 
					
						
							|  |  |  |             userDetails.map(userDetails => { | 
					
						
							| 
									
										
										
										
											2021-04-23 12:56:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-28 00:59:30 +02:00
										 |  |  |                     if (userDetails.csCount < Constants.userJourney.tagsVisibleAndWikiLinked) { | 
					
						
							| 
									
										
										
										
											2021-06-12 02:58:32 +02:00
										 |  |  |                         return undefined; | 
					
						
							|  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |                     const bounds: any = currentBounds.data; | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  |                     if (bounds === undefined) { | 
					
						
							| 
									
										
										
										
											2021-06-12 02:58:32 +02:00
										 |  |  |                         return undefined | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     const top = bounds.getNorth(); | 
					
						
							|  |  |  |                     const bottom = bounds.getSouth(); | 
					
						
							|  |  |  |                     const right = bounds.getEast(); | 
					
						
							|  |  |  |                     const left = bounds.getWest(); | 
					
						
							| 
									
										
										
										
											2021-04-23 12:56:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-12 02:58:32 +02:00
										 |  |  |                     const josmLink = `http://127.0.0.1:8111/load_and_zoom?left=${left}&right=${right}&top=${top}&bottom=${bottom}` | 
					
						
							|  |  |  |                     return new Link(Svg.josm_logo_ui().SetClass("small-image"), josmLink, true); | 
					
						
							|  |  |  |                 }, | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |                 [location, currentBounds] | 
					
						
							| 
									
										
										
										
											2021-06-12 02:58:32 +02:00
										 |  |  |             ) | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         super([mapComplete, reportBug, stats, editHere, editWithJosm, mapillary]); | 
					
						
							| 
									
										
										
										
											2021-10-30 01:55:32 +02:00
										 |  |  |         this.SetClass("flex") | 
					
						
							| 
									
										
										
										
											2021-01-02 16:04:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |