Feat(studio): add possibility to directly write into the theme files
This commit is contained in:
parent
ea133c5eff
commit
0be7c64ea1
3 changed files with 39 additions and 28 deletions
|
@ -5,7 +5,7 @@ import {
|
||||||
Conversion,
|
Conversion,
|
||||||
ConversionMessage,
|
ConversionMessage,
|
||||||
DesugaringContext,
|
DesugaringContext,
|
||||||
Pipe,
|
Pipe
|
||||||
} from "../../Models/ThemeConfig/Conversion/Conversion"
|
} from "../../Models/ThemeConfig/Conversion/Conversion"
|
||||||
import { PrepareLayer } from "../../Models/ThemeConfig/Conversion/PrepareLayer"
|
import { PrepareLayer } from "../../Models/ThemeConfig/Conversion/PrepareLayer"
|
||||||
import { PrevalidateTheme, ValidateLayer } from "../../Models/ThemeConfig/Conversion/Validation"
|
import { PrevalidateTheme, ValidateLayer } from "../../Models/ThemeConfig/Conversion/Validation"
|
||||||
|
@ -97,16 +97,19 @@ export abstract class EditJsonState<T> {
|
||||||
|
|
||||||
public startSavingUpdates(enabled = true) {
|
public startSavingUpdates(enabled = true) {
|
||||||
this.sendingUpdates = enabled
|
this.sendingUpdates = enabled
|
||||||
this.register(
|
if (!this.server.isDirect) {
|
||||||
["credits"],
|
|
||||||
this.osmConnection.userDetails.mapD((u) => u.name),
|
this.register(
|
||||||
false
|
["credits"],
|
||||||
)
|
this.osmConnection.userDetails.mapD((u) => u.name),
|
||||||
this.register(
|
false
|
||||||
["credits:uid"],
|
)
|
||||||
this.osmConnection.userDetails.mapD((u) => u.uid),
|
this.register(
|
||||||
false
|
["credits:uid"],
|
||||||
)
|
this.osmConnection.userDetails.mapD((u) => u.uid),
|
||||||
|
false
|
||||||
|
)
|
||||||
|
}
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
this.configuration.ping()
|
this.configuration.ping()
|
||||||
}
|
}
|
||||||
|
@ -159,7 +162,7 @@ export abstract class EditJsonState<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSchemaStartingWith(path: string[]) {
|
public getSchemaStartingWith(path: string[]) {
|
||||||
if(path === undefined){
|
if (path === undefined) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
return this.schema.filter(
|
return this.schema.filter(
|
||||||
|
@ -174,10 +177,10 @@ export abstract class EditJsonState<T> {
|
||||||
path,
|
path,
|
||||||
type: "translation",
|
type: "translation",
|
||||||
hints: {
|
hints: {
|
||||||
typehint: "translation",
|
typehint: "translation"
|
||||||
},
|
},
|
||||||
required: origConfig.required ?? false,
|
required: origConfig.required ?? false,
|
||||||
description: origConfig.description ?? "A translatable object",
|
description: origConfig.description ?? "A translatable object"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +332,7 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
|
||||||
public readonly imageUploadManager = {
|
public readonly imageUploadManager = {
|
||||||
getCountsFor() {
|
getCountsFor() {
|
||||||
return 0
|
return 0
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
public readonly layout: { getMatchingLayer: (key: any) => LayerConfig }
|
public readonly layout: { getMatchingLayer: (key: any) => LayerConfig }
|
||||||
public readonly featureSwitches: {
|
public readonly featureSwitches: {
|
||||||
|
@ -345,8 +348,8 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
|
||||||
properties: this.testTags.data,
|
properties: this.testTags.data,
|
||||||
geometry: {
|
geometry: {
|
||||||
type: "Point",
|
type: "Point",
|
||||||
coordinates: [3.21, 51.2],
|
coordinates: [3.21, 51.2]
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -363,10 +366,10 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
this.featureSwitches = {
|
this.featureSwitches = {
|
||||||
featureSwitchIsDebugging: new UIEventSource<boolean>(true),
|
featureSwitchIsDebugging: new UIEventSource<boolean>(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addMissingTagRenderingIds()
|
this.addMissingTagRenderingIds()
|
||||||
|
@ -455,7 +458,7 @@ export default class EditLayerState extends EditJsonState<LayerConfigJson> {
|
||||||
}
|
}
|
||||||
const state: DesugaringContext = {
|
const state: DesugaringContext = {
|
||||||
tagRenderings: sharedQuestions,
|
tagRenderings: sharedQuestions,
|
||||||
sharedLayers: layers,
|
sharedLayers: layers
|
||||||
}
|
}
|
||||||
const prepare = this.buildValidation(state)
|
const prepare = this.buildValidation(state)
|
||||||
const context = ConversionContext.construct([], ["prepare"])
|
const context = ConversionContext.construct([], ["prepare"])
|
||||||
|
@ -531,7 +534,7 @@ export class EditThemeState extends EditJsonState<LayoutConfigJson> {
|
||||||
}
|
}
|
||||||
const state: DesugaringContext = {
|
const state: DesugaringContext = {
|
||||||
tagRenderings: sharedQuestions,
|
tagRenderings: sharedQuestions,
|
||||||
sharedLayers: layers,
|
sharedLayers: layers
|
||||||
}
|
}
|
||||||
const prepare = this.buildValidation(state)
|
const prepare = this.buildValidation(state)
|
||||||
const context = ConversionContext.construct([], ["prepare"])
|
const context = ConversionContext.construct([], ["prepare"])
|
||||||
|
|
|
@ -18,8 +18,9 @@ export default class StudioServer {
|
||||||
| { error: any }
|
| { error: any }
|
||||||
| undefined
|
| undefined
|
||||||
>
|
>
|
||||||
|
public isDirect: boolean
|
||||||
|
|
||||||
constructor(url: string, userId: Store<number>) {
|
constructor(url: string, userId: Store<number | undefined>, isDirect: boolean) {
|
||||||
this.url = url
|
this.url = url
|
||||||
this._userId = userId
|
this._userId = userId
|
||||||
this.overview = UIEventSource.FromPromiseWithErr(this.fetchOverviewRaw())
|
this.overview = UIEventSource.FromPromiseWithErr(this.fetchOverviewRaw())
|
||||||
|
@ -123,7 +124,7 @@ export default class StudioServer {
|
||||||
|
|
||||||
public urlFor(id: string, category: "layers" | "themes", uid?: number) {
|
public urlFor(id: string, category: "layers" | "themes", uid?: number) {
|
||||||
uid ??= this._userId.data
|
uid ??= this._userId.data
|
||||||
const uidStr = uid !== undefined ? "/" + uid : ""
|
const uidStr = uid !== null ? "/" + uid : ""
|
||||||
return `${this.url}${uidStr}/${category}/${id}/${id}.json`
|
return `${this.url}${uidStr}/${category}/${id}/${id}.json`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,12 +31,15 @@
|
||||||
import Add from "../assets/svg/Add.svelte"
|
import Add from "../assets/svg/Add.svelte"
|
||||||
import { SearchIcon } from "@rgossiaux/svelte-heroicons/solid"
|
import { SearchIcon } from "@rgossiaux/svelte-heroicons/solid"
|
||||||
import Hash from "../Logic/Web/Hash"
|
import Hash from "../Logic/Web/Hash"
|
||||||
|
const directEntry = QueryParameters.GetBooleanQueryParameter("direct",false,"If set, write directly into the theme files")
|
||||||
|
|
||||||
export let studioUrl =
|
export let studioUrl =
|
||||||
window.location.hostname === "127.0.0.2"
|
window.location.hostname === "127.0.0.2" || directEntry.data
|
||||||
? "http://127.0.0.1:1235"
|
? "http://127.0.0.1:1235"
|
||||||
: "https://studio.mapcomplete.org"
|
: "https://studio.mapcomplete.org"
|
||||||
|
|
||||||
|
console.log("Using studio URL", studioUrl, "direct?", directEntry.data)
|
||||||
|
|
||||||
const oauth_token = QueryParameters.GetQueryParameter(
|
const oauth_token = QueryParameters.GetQueryParameter(
|
||||||
"oauth_token",
|
"oauth_token",
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -57,8 +60,8 @@
|
||||||
)
|
)
|
||||||
expertMode.addCallbackAndRunD((expert) => console.log("Expert mode is", expert))
|
expertMode.addCallbackAndRunD((expert) => console.log("Expert mode is", expert))
|
||||||
const createdBy = osmConnection.userDetails.data.name
|
const createdBy = osmConnection.userDetails.data.name
|
||||||
const uid = osmConnection.userDetails.map((ud) => ud?.uid)
|
const uid = osmConnection.userDetails.map((ud) => directEntry.data ? null : ud?.uid, [directEntry])
|
||||||
const studio = new StudioServer(studioUrl, uid)
|
const studio = new StudioServer(studioUrl, uid, directEntry.data)
|
||||||
|
|
||||||
let layersWithErr = studio.fetchOverview()
|
let layersWithErr = studio.fetchOverview()
|
||||||
let layerFilterTerm: string = ""
|
let layerFilterTerm: string = ""
|
||||||
|
@ -285,7 +288,11 @@
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
<Checkbox selected={expertMode}>Enable more options (expert mode)</Checkbox>
|
<Checkbox selected={expertMode}>Enable more options (expert mode)</Checkbox>
|
||||||
<span class="subtle">MapComplete version {version}</span>
|
<span class="subtle">MapComplete version {version}</span>
|
||||||
<div>{$uid}</div>
|
<div>{$uid} {studioUrl}
|
||||||
|
{#if $directEntry}
|
||||||
|
<b>direct</b>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{:else if state === "edit_layer"}
|
{:else if state === "edit_layer"}
|
||||||
|
@ -368,7 +375,7 @@
|
||||||
</div>
|
</div>
|
||||||
{:else if state === "loading"}
|
{:else if state === "loading"}
|
||||||
<div class="h-8 w-8">
|
<div class="h-8 w-8">
|
||||||
<Loading />
|
<Loading >Fetching information from {studioUrl}</Loading>
|
||||||
</div>
|
</div>
|
||||||
{:else if state === "editing_layer"}
|
{:else if state === "editing_layer"}
|
||||||
<EditLayer state={editLayerState} {backToStudio}>
|
<EditLayer state={editLayerState} {backToStudio}>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue