forked from MapComplete/MapComplete
Improve maproulette documentation, add possibility to change the maproulette state with a special rendering
This commit is contained in:
parent
509b237d02
commit
2e5aef35b8
9 changed files with 334 additions and 118 deletions
|
@ -1,7 +1,27 @@
|
|||
import Constants from "../Models/Constants"
|
||||
|
||||
export default class Maproulette {
|
||||
/**
|
||||
public static readonly STATUS_OPEN = 0
|
||||
public static readonly STATUS_FIXED = 1
|
||||
public static readonly STATUS_FALSE_POSITIVE = 2
|
||||
public static readonly STATUS_SKIPPED = 3
|
||||
public static readonly STATUS_DELETED = 4
|
||||
public static readonly STATUS_ALREADY_FIXED = 5
|
||||
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",
|
||||
}
|
||||
|
||||
/*
|
||||
* The API endpoint to use
|
||||
*/
|
||||
endpoint: string
|
||||
|
@ -21,19 +41,34 @@ export default class Maproulette {
|
|||
}
|
||||
|
||||
/**
|
||||
* Close a task
|
||||
* Close a task; might throw an error
|
||||
*
|
||||
* Also see:https://maproulette.org/docs/swagger-ui/index.html?url=/assets/swagger.json&docExpansion=none#/Task/setTaskStatus
|
||||
* @param taskId The task to close
|
||||
* @param status A number indicating the status. Use MapRoulette.STATUS_*
|
||||
* @param options Additional settings to pass. Refer to the API-docs for more information
|
||||
*/
|
||||
async closeTask(taskId: number): Promise<void> {
|
||||
const response = await fetch(`${this.endpoint}/task/${taskId}/1`, {
|
||||
async closeTask(
|
||||
taskId: number,
|
||||
status = Maproulette.STATUS_FIXED,
|
||||
options?: {
|
||||
comment?: string
|
||||
tags?: string
|
||||
requestReview?: boolean
|
||||
completionResponses?: Record<string, string>
|
||||
}
|
||||
): Promise<void> {
|
||||
const response = await fetch(`${this.endpoint}/task/${taskId}/${status}`, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
apiKey: this.apiKey,
|
||||
},
|
||||
body: options !== undefined ? JSON.stringify(options) : undefined,
|
||||
})
|
||||
if (response.status !== 304) {
|
||||
if (response.status !== 204) {
|
||||
console.log(`Failed to close task: ${response.status}`)
|
||||
throw `Failed to close task: ${response.status}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue