forked from MapComplete/MapComplete
More work on the custom theme generator, add aed template, move bookcases to json template
This commit is contained in:
parent
146552e62c
commit
560c8e1567
34 changed files with 1048 additions and 590 deletions
|
|
@ -2,32 +2,53 @@ import {LayoutConfigJson} from "../../Customizations/JSON/CustomLayoutFromJSON";
|
|||
import {UIEventSource} from "../../Logic/UIEventSource";
|
||||
import {UIElement} from "../UIElement";
|
||||
import Combine from "../Base/Combine";
|
||||
import {Button} from "../Base/Button";
|
||||
import {VariableUiElement} from "../Base/VariableUIElement";
|
||||
|
||||
export class Preview extends UIElement {
|
||||
private url: UIEventSource<string>;
|
||||
private config: UIEventSource<LayoutConfigJson>;
|
||||
|
||||
private currentPreview = new UIEventSource<string>("")
|
||||
private reloadButton: Button;
|
||||
private otherPreviews: VariableUiElement;
|
||||
|
||||
constructor(url: UIEventSource<string>, config: UIEventSource<LayoutConfigJson>) {
|
||||
super(url);
|
||||
super(undefined);
|
||||
this.config = config;
|
||||
this.url = url;
|
||||
this.reloadButton = new Button("Reload the preview", () => {
|
||||
this.currentPreview.setData(`<iframe width="99%" height="70%" src="${this.url.data}"></iframe>` +
|
||||
'<p class="alert">The above preview is in testmode. Changes will not be sent to OSM, so feel free to add points and answer questions</p> ',
|
||||
);
|
||||
});
|
||||
this.ListenTo(this.currentPreview);
|
||||
|
||||
|
||||
this.otherPreviews = new VariableUiElement(this.url.map(url => {
|
||||
|
||||
return [
|
||||
`<h2>Your link</h2>`,
|
||||
'<span class="alert">Bookmark the link below</span><br/>',
|
||||
'MapComplete has no backend. The <i>entire</i> theme configuration is saved in the following URL. This means that this URL is needed to revive and change your MapComplete instance.<br/>',
|
||||
`<a target='_blank' href='${this.url.data}'>${this.url.data}</a><br/>`,
|
||||
'<h2>JSON-configuration</h2>',
|
||||
'You can see the configuration in JSON format below.<br/>',
|
||||
'<span class=\'literal-code iframe-code-block\' style="width:95%">',
|
||||
JSON.stringify(this.config.data, null, 2).replace(/\n/g, "<br/>").replace(/ /g, " "),
|
||||
'</span>'
|
||||
|
||||
].join("")
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
InnerRender(): string {
|
||||
const url = this.url.data;
|
||||
return new Combine([
|
||||
`<iframe width="99%" height="70%" src="${this.url.data}"></iframe>`,
|
||||
'<p class="alert">The above preview is in testmode. Changes will not be sent to OSM, so feel free to add points and answer questions</p> ',
|
||||
`<h2>Your link</h2>`,
|
||||
'<span class="alert">Bookmark the link below</span><br/>',
|
||||
'MapComplete has no backend. The <i>entire</i> theme configuration is saved in the following URL. This means that this URL is needed to revive and change your MapComplete instance.<br/>',
|
||||
`<a target='_blank' href='${this.url.data}'>${this.url.data}</a><br/>`,
|
||||
'<h2>JSON-configuration</h2>',
|
||||
'You can see the configuration in JSON format below.<br/>',
|
||||
'<span class=\'literal-code iframe-code-block\' style="width:95%">',
|
||||
JSON.stringify(this.config.data, null, 2).replace(/\n/g, "<br/>").replace(/ /g, " "),
|
||||
'</span>'
|
||||
|
||||
new VariableUiElement(this.currentPreview),
|
||||
this.reloadButton,
|
||||
this.otherPreviews
|
||||
]).Render();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue