| 
									
										
										
										
											2020-11-18 12:50:28 +01:00
										 |  |  | import escapeHtml from "escape-html"; | 
					
						
							| 
									
										
										
										
											2021-01-04 04:36:21 +01:00
										 |  |  | // @ts-ignore
 | 
					
						
							| 
									
										
										
										
											2020-08-27 11:11:20 +02:00
										 |  |  | import {OsmConnection, UserDetails} from "./OsmConnection"; | 
					
						
							| 
									
										
										
										
											2020-08-26 15:36:04 +02:00
										 |  |  | import {UIEventSource} from "../UIEventSource"; | 
					
						
							| 
									
										
										
										
											2020-08-30 01:13:18 +02:00
										 |  |  | import {ElementStorage} from "../ElementStorage"; | 
					
						
							| 
									
										
										
										
											2020-10-02 19:00:24 +02:00
										 |  |  | import State from "../../State"; | 
					
						
							| 
									
										
										
										
											2020-09-21 23:57:50 +02:00
										 |  |  | import Locale from "../../UI/i18n/Locale"; | 
					
						
							| 
									
										
										
										
											2021-01-02 19:09:49 +01:00
										 |  |  | import Constants from "../../Models/Constants"; | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  | import {OsmObject} from "./OsmObject"; | 
					
						
							| 
									
										
										
										
											2021-08-07 23:11:34 +02:00
										 |  |  | import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig"; | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  | import {Changes} from "./Changes"; | 
					
						
							| 
									
										
										
										
											2020-08-26 15:36:04 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | export class ChangesetHandler { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-19 18:28:30 +02:00
										 |  |  |     public readonly currentChangeset: UIEventSource<string>; | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |     private readonly allElements: ElementStorage; | 
					
						
							|  |  |  |     private readonly changes: Changes; | 
					
						
							| 
									
										
										
										
											2020-09-15 02:29:31 +02:00
										 |  |  |     private readonly _dryRun: boolean; | 
					
						
							|  |  |  |     private readonly userDetails: UIEventSource<UserDetails>; | 
					
						
							|  |  |  |     private readonly auth: any; | 
					
						
							| 
									
										
										
										
											2020-08-26 15:36:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |     constructor(layoutName: string, dryRun: boolean, osmConnection: OsmConnection, | 
					
						
							|  |  |  |                 allElements: ElementStorage, | 
					
						
							|  |  |  |                 changes: Changes, | 
					
						
							|  |  |  |                 auth) { | 
					
						
							|  |  |  |         this.allElements = allElements; | 
					
						
							|  |  |  |         this.changes = changes; | 
					
						
							| 
									
										
										
										
											2020-08-26 15:36:04 +02:00
										 |  |  |         this._dryRun = dryRun; | 
					
						
							| 
									
										
										
										
											2020-08-27 11:11:20 +02:00
										 |  |  |         this.userDetails = osmConnection.userDetails; | 
					
						
							| 
									
										
										
										
											2020-08-26 15:36:04 +02:00
										 |  |  |         this.auth = auth; | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  |         this.currentChangeset = osmConnection.GetPreference("current-open-changeset-" + layoutName); | 
					
						
							| 
									
										
										
										
											2020-08-26 15:36:04 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (dryRun) { | 
					
						
							|  |  |  |             console.log("DRYRUN ENABLED"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |     private handleIdRewrite(node: any, type: string): [string, string] { | 
					
						
							|  |  |  |         const oldId = parseInt(node.attributes.old_id.value); | 
					
						
							|  |  |  |         if (node.attributes.new_id === undefined) { | 
					
						
							|  |  |  |             // We just removed this point!
 | 
					
						
							|  |  |  |             const element =this. allElements.getEventSourceById("node/" + oldId); | 
					
						
							|  |  |  |             element.data._deleted = "yes" | 
					
						
							|  |  |  |             element.ping(); | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         const newId = parseInt(node.attributes.new_id.value); | 
					
						
							|  |  |  |         const result: [string, string] = [type + "/" + oldId, type + "/" + newId] | 
					
						
							|  |  |  |         if (!(oldId !== undefined && newId !== undefined && | 
					
						
							|  |  |  |             !isNaN(oldId) && !isNaN(newId))) { | 
					
						
							|  |  |  |             return undefined; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (oldId == newId) { | 
					
						
							|  |  |  |             return undefined; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         console.log("Rewriting id: ", type + "/" + oldId, "-->", type + "/" + newId); | 
					
						
							|  |  |  |         const element = this.allElements.getEventSourceById("node/" + oldId); | 
					
						
							|  |  |  |         element.data.id = type + "/" + newId; | 
					
						
							|  |  |  |         this.allElements.addElementById(type + "/" + newId, element); | 
					
						
							|  |  |  |         this.allElements.ContainingFeatures.set(type + "/" + newId, this.allElements.ContainingFeatures.get(type + "/" + oldId)) | 
					
						
							|  |  |  |         element.ping(); | 
					
						
							|  |  |  |         return result; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private parseUploadChangesetResponse(response: XMLDocument): void { | 
					
						
							| 
									
										
										
										
											2021-06-19 18:28:30 +02:00
										 |  |  |         const nodes = response.getElementsByTagName("node"); | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |         const mappings = new Map<string, string>() | 
					
						
							| 
									
										
										
										
											2021-06-19 18:28:30 +02:00
										 |  |  |         // @ts-ignore
 | 
					
						
							|  |  |  |         for (const node of nodes) { | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |             const mapping = this.handleIdRewrite(node, "node") | 
					
						
							|  |  |  |             if (mapping !== undefined) { | 
					
						
							|  |  |  |                 mappings.set(mapping[0], mapping[1]) | 
					
						
							| 
									
										
										
										
											2021-07-03 14:35:44 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-07-03 14:35:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |         const ways = response.getElementsByTagName("way"); | 
					
						
							|  |  |  |         // @ts-ignore
 | 
					
						
							|  |  |  |         for (const way of ways) { | 
					
						
							|  |  |  |             const mapping = this.handleIdRewrite(way, "way") | 
					
						
							|  |  |  |             if (mapping !== undefined) { | 
					
						
							|  |  |  |                 mappings.set(mapping[0], mapping[1]) | 
					
						
							| 
									
										
										
										
											2021-06-19 18:28:30 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |         this.changes.registerIdRewrites(mappings) | 
					
						
							|  |  |  |          | 
					
						
							| 
									
										
										
										
											2021-06-19 18:28:30 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-08-26 15:36:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * The full logic to upload a change to one or more elements. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * This method will attempt to reuse an existing, open changeset for this theme (or open one if none available). | 
					
						
							|  |  |  |      * Then, it will upload a changes-xml within this changeset (and leave the changeset open) | 
					
						
							|  |  |  |      * When upload is successfull, eventual id-rewriting will be handled (aka: don't worry about that) | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * If 'dryrun' is specified, the changeset XML will be printed to console instead of being uploaded | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |     public async UploadChangeset( | 
					
						
							| 
									
										
										
										
											2020-11-11 16:23:49 +01:00
										 |  |  |         layout: LayoutConfig, | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |         generateChangeXML: (csid: string) => string): Promise<void> { | 
					
						
							| 
									
										
										
										
											2021-06-19 18:28:30 +02:00
										 |  |  |         if (this.userDetails.data.csCount == 0) { | 
					
						
							| 
									
										
										
										
											2020-09-15 02:29:31 +02:00
										 |  |  |             // The user became a contributor!
 | 
					
						
							|  |  |  |             this.userDetails.data.csCount = 1; | 
					
						
							|  |  |  |             this.userDetails.ping(); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-08-26 15:36:04 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (this._dryRun) { | 
					
						
							| 
									
										
										
										
											2020-08-30 01:13:18 +02:00
										 |  |  |             const changesetXML = generateChangeXML("123456"); | 
					
						
							| 
									
										
										
										
											2020-08-26 15:36:04 +02:00
										 |  |  |             console.log(changesetXML); | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-27 11:11:20 +02:00
										 |  |  |         if (this.currentChangeset.data === undefined || this.currentChangeset.data === "") { | 
					
						
							|  |  |  |             // We have to open a new changeset
 | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |             try { | 
					
						
							|  |  |  |                 const csId = await this.OpenChangeset(layout) | 
					
						
							| 
									
										
										
										
											2020-08-27 11:11:20 +02:00
										 |  |  |                 this.currentChangeset.setData(csId); | 
					
						
							| 
									
										
										
										
											2020-08-27 18:44:16 +02:00
										 |  |  |                 const changeset = generateChangeXML(csId); | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |                 console.log("Current changeset is:", changeset); | 
					
						
							|  |  |  |                 await this.AddChange(csId, changeset) | 
					
						
							|  |  |  |             } catch (e) { | 
					
						
							|  |  |  |                 console.error("Could not open/upload changeset due to ", e) | 
					
						
							|  |  |  |                 this.currentChangeset.setData("") | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2020-08-27 11:11:20 +02:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             // There still exists an open changeset (or at least we hope so)
 | 
					
						
							|  |  |  |             const csId = this.currentChangeset.data; | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |             try { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 await this.AddChange( | 
					
						
							|  |  |  |                     csId, | 
					
						
							|  |  |  |                     generateChangeXML(csId)) | 
					
						
							|  |  |  |             } catch (e) { | 
					
						
							|  |  |  |                 console.warn("Could not upload, changeset is probably closed: ", e); | 
					
						
							|  |  |  |                 // Mark the CS as closed...
 | 
					
						
							|  |  |  |                 this.currentChangeset.setData(""); | 
					
						
							|  |  |  |                 // ... and try again. As the cs is closed, no recursive loop can exist  
 | 
					
						
							|  |  |  |                 await this.UploadChangeset(layout, generateChangeXML) | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2020-08-27 11:11:20 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2020-08-26 15:36:04 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Deletes the element with the given ID from the OSM database. | 
					
						
							|  |  |  |      * DOES NOT PERFORM ANY SAFETY CHECKS! | 
					
						
							|  |  |  |      * | 
					
						
							| 
									
										
										
										
											2021-08-19 18:30:43 +02:00
										 |  |  |      * For the deletion of an element, a new, separate changeset is created with a slightly changed comment and some extra flags set. | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  |      * The CS will be closed afterwards. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * If dryrun is specified, will not actually delete the point but print the CS-XML to console instead | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public DeleteElement(object: OsmObject, | 
					
						
							|  |  |  |                          layout: LayoutConfig, | 
					
						
							|  |  |  |                          reason: string, | 
					
						
							|  |  |  |                          allElements: ElementStorage, | 
					
						
							|  |  |  |                          continuation: () => void) { | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |         return this.DeleteElementAsync(object, layout, reason, allElements).then(continuation) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public async DeleteElementAsync(object: OsmObject, | 
					
						
							|  |  |  |                                     layout: LayoutConfig, | 
					
						
							|  |  |  |                                     reason: string, | 
					
						
							|  |  |  |                                     allElements: ElementStorage): Promise<void> { | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         function generateChangeXML(csId: string) { | 
					
						
							|  |  |  |             let [lat, lon] = object.centerpoint(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             let changes = `<osmChange version='0.6' generator='Mapcomplete ${Constants.vNumber}'>`; | 
					
						
							|  |  |  |             changes += | 
					
						
							|  |  |  |                 `<delete><${object.type} id="${object.id}" version="${object.version}" changeset="${csId}" lat="${lat}" lon="${lon}" /></delete>`; | 
					
						
							|  |  |  |             changes += "</osmChange>"; | 
					
						
							|  |  |  |             return changes; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (this._dryRun) { | 
					
						
							|  |  |  |             const changesetXML = generateChangeXML("123456"); | 
					
						
							|  |  |  |             console.log(changesetXML); | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |         const csId = await this.OpenChangeset(layout, { | 
					
						
							|  |  |  |             isDeletionCS: true, | 
					
						
							|  |  |  |             deletionReason: reason | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  |         // The cs is open - let us actually upload!
 | 
					
						
							|  |  |  |         const changes = generateChangeXML(csId) | 
					
						
							|  |  |  |         await this.AddChange(csId, changes) | 
					
						
							|  |  |  |         await this.CloseChangeset(csId) | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |     private async CloseChangeset(changesetId: string = undefined): Promise<void> { | 
					
						
							|  |  |  |         const self = this | 
					
						
							|  |  |  |         return new Promise<void>(function (resolve, reject) { | 
					
						
							|  |  |  |             if (changesetId === undefined) { | 
					
						
							|  |  |  |                 changesetId = self.currentChangeset.data; | 
					
						
							| 
									
										
										
										
											2021-06-19 18:28:30 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |             if (changesetId === undefined) { | 
					
						
							|  |  |  |                 return; | 
					
						
							| 
									
										
										
										
											2021-06-19 18:28:30 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |             console.log("closing changeset", changesetId); | 
					
						
							|  |  |  |             self.currentChangeset.setData(""); | 
					
						
							|  |  |  |             self.auth.xhr({ | 
					
						
							|  |  |  |                 method: 'PUT', | 
					
						
							|  |  |  |                 path: '/api/0.6/changeset/' + changesetId + '/close', | 
					
						
							|  |  |  |             }, function (err, response) { | 
					
						
							|  |  |  |                 if (response == null) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                     console.log("err", err); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 console.log("Closed changeset ", changesetId) | 
					
						
							|  |  |  |                 resolve() | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         }) | 
					
						
							| 
									
										
										
										
											2021-06-19 18:28:30 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-08-26 15:36:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-30 01:13:18 +02:00
										 |  |  |     private OpenChangeset( | 
					
						
							| 
									
										
										
										
											2021-06-19 18:28:30 +02:00
										 |  |  |         layout: LayoutConfig, | 
					
						
							| 
									
										
										
										
											2021-07-13 00:40:27 +02:00
										 |  |  |         options?: { | 
					
						
							|  |  |  |             isDeletionCS?: boolean, | 
					
						
							|  |  |  |             deletionReason?: string, | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |     ): Promise<string> { | 
					
						
							|  |  |  |         const self = this; | 
					
						
							|  |  |  |         return new Promise<string>(function (resolve, reject) { | 
					
						
							|  |  |  |             options = options ?? {} | 
					
						
							|  |  |  |             options.isDeletionCS = options.isDeletionCS ?? false | 
					
						
							|  |  |  |             const commentExtra = layout.changesetmessage !== undefined ? " - " + layout.changesetmessage : ""; | 
					
						
							|  |  |  |             let comment = `Adding data with #MapComplete for theme #${layout.id}${commentExtra}` | 
					
						
							|  |  |  |             if (options.isDeletionCS) { | 
					
						
							|  |  |  |                 comment = `Deleting a point with #MapComplete for theme #${layout.id}${commentExtra}` | 
					
						
							|  |  |  |                 if (options.deletionReason) { | 
					
						
							|  |  |  |                     comment += ": " + options.deletionReason; | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2020-09-30 22:22:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |             let path = window.location.pathname; | 
					
						
							|  |  |  |             path = path.substr(1, path.lastIndexOf("/")); | 
					
						
							|  |  |  |             const metadata = [ | 
					
						
							|  |  |  |                 ["created_by", `MapComplete ${Constants.vNumber}`], | 
					
						
							|  |  |  |                 ["comment", comment], | 
					
						
							|  |  |  |                 ["deletion", options.isDeletionCS ? "yes" : undefined], | 
					
						
							|  |  |  |                 ["theme", layout.id], | 
					
						
							|  |  |  |                 ["language", Locale.language.data], | 
					
						
							|  |  |  |                 ["host", window.location.host], | 
					
						
							|  |  |  |                 ["path", path], | 
					
						
							|  |  |  |                 ["source", State.state.currentGPSLocation.data !== undefined ? "survey" : undefined], | 
					
						
							|  |  |  |                 ["imagery", State.state.backgroundLayer.data.id], | 
					
						
							|  |  |  |                 ["theme-creator", layout.maintainer] | 
					
						
							|  |  |  |             ] | 
					
						
							|  |  |  |                 .filter(kv => (kv[1] ?? "") !== "") | 
					
						
							|  |  |  |                 .map(kv => `<tag k="${kv[0]}" v="${escapeHtml(kv[1])}"/>`) | 
					
						
							|  |  |  |                 .join("\n") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             self.auth.xhr({ | 
					
						
							|  |  |  |                 method: 'PUT', | 
					
						
							|  |  |  |                 path: '/api/0.6/changeset/create', | 
					
						
							|  |  |  |                 options: {header: {'Content-Type': 'text/xml'}}, | 
					
						
							|  |  |  |                 content: [`<osm><changeset>`, | 
					
						
							|  |  |  |                     metadata, | 
					
						
							|  |  |  |                     `</changeset></osm>`].join("") | 
					
						
							|  |  |  |             }, function (err, response) { | 
					
						
							|  |  |  |                 if (response === undefined) { | 
					
						
							|  |  |  |                     console.log("err", err); | 
					
						
							|  |  |  |                     reject(err) | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     resolve(response); | 
					
						
							| 
									
										
										
										
											2021-07-13 00:40:27 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |             }); | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-26 15:36:04 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-30 18:48:23 +02:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Upload a changesetXML | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2020-08-26 15:36:04 +02:00
										 |  |  |     private AddChange(changesetId: string, | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |                       changesetXML: string): Promise<string> { | 
					
						
							|  |  |  |         const self = this; | 
					
						
							|  |  |  |         return new Promise(function (resolve, reject) { | 
					
						
							|  |  |  |             self.auth.xhr({ | 
					
						
							|  |  |  |                 method: 'POST', | 
					
						
							|  |  |  |                 options: {header: {'Content-Type': 'text/xml'}}, | 
					
						
							|  |  |  |                 path: '/api/0.6/changeset/' + changesetId + '/upload', | 
					
						
							|  |  |  |                 content: changesetXML | 
					
						
							|  |  |  |             }, function (err, response) { | 
					
						
							|  |  |  |                 if (response == null) { | 
					
						
							|  |  |  |                     console.log("err", err); | 
					
						
							|  |  |  |                     reject(err); | 
					
						
							| 
									
										
										
										
											2020-08-27 11:11:20 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-09-26 23:35:26 +02:00
										 |  |  |                 self.parseUploadChangesetResponse(response); | 
					
						
							|  |  |  |                 console.log("Uploaded changeset ", changesetId); | 
					
						
							|  |  |  |                 resolve(changesetId); | 
					
						
							|  |  |  |             }); | 
					
						
							|  |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-26 15:36:04 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |