Fix(linkeddata): velopark deals with sections, fix image loading

This commit is contained in:
Pieter Vander Vennet 2024-12-17 03:31:28 +01:00
parent 7a06bb9930
commit ef1d2c9f56
8 changed files with 242 additions and 123 deletions

View file

@ -6,6 +6,17 @@ export interface MaprouletteTask {
description: string
instruction: string
}
export const maprouletteStatus = ["Open",
"Fixed",
"False_positive",
"Skipped",
"Deleted",
"Already fixed",
"Too_Hard",
"Disabled",
] as const
export type MaprouletteStatus = typeof maprouletteStatus[number]
export default class Maproulette {
public static readonly defaultEndpoint = "https://maproulette.org/api/v2"
@ -19,16 +30,7 @@ export default class Maproulette {
public static readonly STATUS_TOO_HARD = 6
public static readonly STATUS_DISABLED = 9
public static readonly STATUS_MEANING = {
0: "Open",
1: "Fixed",
2: "False_positive",
3: "Skipped",
4: "Deleted",
5: "Already fixed",
6: "Too_Hard",
9: "Disabled"
}
public static singleton = new Maproulette()
/*
* The API endpoint to use
@ -62,12 +64,11 @@ export default class Maproulette {
if (code === "Created") {
return Maproulette.STATUS_OPEN
}
for (let i = 0; i < 9; i++) {
if (Maproulette.STATUS_MEANING["" + i] === code) {
return i
}
const i = maprouletteStatus.findIndex(<any> code)
if(i < 0){
return undefined
}
return undefined
return i
}
/**
@ -87,7 +88,7 @@ export default class Maproulette {
tags?: string
requestReview?: boolean
completionResponses?: Record<string, string>
}
},
): Promise<void> {
console.log("Maproulette: setting", `${this.endpoint}/task/${taskId}/${status}`, options)
options ??= {}
@ -97,9 +98,9 @@ export default class Maproulette {
method: "PUT",
headers: {
"Content-Type": "application/json",
apiKey: this.apiKey
apiKey: this.apiKey,
},
body: JSON.stringify(options)
body: JSON.stringify(options),
})
if (response.status !== 204) {
console.log(`Failed to close task: ${response.status}`)