forked from MapComplete/MapComplete
Studio: improve error handling, fix renumbering
This commit is contained in:
parent
7afe58e6a5
commit
079a3f8694
10 changed files with 187 additions and 62 deletions
|
@ -35,19 +35,18 @@
|
|||
? "http://127.0.0.1:1235"
|
||||
: "https://studio.mapcomplete.org"
|
||||
|
||||
let osmConnection = new OsmConnection(
|
||||
new OsmConnection({
|
||||
oauth_token: QueryParameters.GetQueryParameter(
|
||||
"oauth_token",
|
||||
undefined,
|
||||
"Used to complete the login"
|
||||
),
|
||||
})
|
||||
const oauth_token = QueryParameters.GetQueryParameter(
|
||||
"oauth_token",
|
||||
undefined,
|
||||
"Used to complete the login",
|
||||
)
|
||||
let osmConnection = new OsmConnection({
|
||||
oauth_token,
|
||||
})
|
||||
const expertMode = UIEventSource.asBoolean(
|
||||
osmConnection.GetPreference("studio-expert-mode", "false", {
|
||||
documentation: "Indicates if more options are shown in mapcomplete studio",
|
||||
})
|
||||
}),
|
||||
)
|
||||
expertMode.addCallbackAndRunD((expert) => console.log("Expert mode is", expert))
|
||||
const createdBy = osmConnection.userDetails.data.name
|
||||
|
@ -55,23 +54,23 @@
|
|||
const studio = new StudioServer(studioUrl, uid)
|
||||
|
||||
let layersWithErr = UIEventSource.FromPromiseWithErr(studio.fetchOverview())
|
||||
let layers: Store<{ owner: number }[]> = layersWithErr.mapD((l) =>
|
||||
l.success?.filter((l) => l.category === "layers")
|
||||
let layers: Store<{ owner: number, id: string }[]> = layersWithErr.mapD((l) =>
|
||||
l["success"]?.filter((l) => l.category === "layers"),
|
||||
)
|
||||
let selfLayers = layers.mapD((ls) => ls.filter((l) => l.owner === uid.data), [uid])
|
||||
let otherLayers = layers.mapD(
|
||||
(ls) => ls.filter((l) => l.owner !== undefined && l.owner !== uid.data),
|
||||
[uid]
|
||||
[uid],
|
||||
)
|
||||
let officialLayers = layers.mapD((ls) => ls.filter((l) => l.owner === undefined), [uid])
|
||||
|
||||
let themes: Store<{ owner: number }[]> = layersWithErr.mapD((l) =>
|
||||
l.success?.filter((l) => l.category === "themes")
|
||||
let themes: Store<{ owner: number, id: string }[]> = layersWithErr.mapD((l) =>
|
||||
l["success"]?.filter((l) => l.category === "themes"),
|
||||
)
|
||||
let selfThemes = themes.mapD((ls) => ls.filter((l) => l.owner === uid.data), [uid])
|
||||
let otherThemes = themes.mapD(
|
||||
(ls) => ls.filter((l) => l.owner !== undefined && l.owner !== uid.data),
|
||||
[uid]
|
||||
[uid],
|
||||
)
|
||||
let officialThemes = themes.mapD((ls) => ls.filter((l) => l.owner === undefined), [uid])
|
||||
|
||||
|
@ -90,8 +89,6 @@
|
|||
const layoutSchema: ConfigMeta[] = <any>layoutSchemaRaw
|
||||
let editThemeState = new EditThemeState(layoutSchema, studio, { expertMode })
|
||||
|
||||
let layerId = editLayerState.configuration.map((layerConfig) => layerConfig.id)
|
||||
|
||||
const version = meta.version
|
||||
|
||||
async function editLayer(event: Event) {
|
||||
|
@ -107,7 +104,8 @@
|
|||
const id: { id: string; owner: number } = event["detail"]
|
||||
state = "loading"
|
||||
editThemeState.startSavingUpdates(false)
|
||||
editThemeState.configuration.setData(await studio.fetch(id.id, "themes", id.owner))
|
||||
const layout = await studio.fetch(id.id, "themes", id.owner)
|
||||
editThemeState.configuration.setData(layout)
|
||||
editThemeState.startSavingUpdates()
|
||||
state = "editing_theme"
|
||||
}
|
||||
|
@ -142,7 +140,7 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<If condition={layersWithErr.map((d) => d?.error !== undefined)}>
|
||||
<If condition={layersWithErr.map((d) => d?.["error"] !== undefined) }>
|
||||
<div>
|
||||
<div class="alert">
|
||||
Something went wrong while contacting the MapComplete Studio Server: {$layersWithErr["error"]}
|
||||
|
@ -152,8 +150,8 @@
|
|||
<li>Try again in a few minutes</li>
|
||||
<li>
|
||||
Contact <a href="https://app.element.io/#/room/#MapComplete:matrix.org">
|
||||
the MapComplete community via the chat.
|
||||
</a>
|
||||
the MapComplete community via the chat.
|
||||
</a>
|
||||
Someone might be able to help you
|
||||
</li>
|
||||
<li>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue