forked from MapComplete/MapComplete
Fixing too many bugs, cleaning up some old parts of the code
This commit is contained in:
parent
3d05999f85
commit
00a6611e1f
21 changed files with 706 additions and 436 deletions
|
@ -1,70 +1,25 @@
|
|||
import {UIEventSource} from "./Logic/UIEventSource";
|
||||
import SingleSetting from "./UI/CustomGenerator/SingleSetting";
|
||||
import Combine from "./UI/Base/Combine";
|
||||
import {VariableUiElement} from "./UI/Base/VariableUIElement";
|
||||
import GeneralSettings from "./UI/CustomGenerator/GeneralSettings";
|
||||
import {TabbedComponent} from "./UI/Base/TabbedComponent";
|
||||
import AllLayersPanel from "./UI/CustomGenerator/AllLayersPanel";
|
||||
import SharePanel from "./UI/CustomGenerator/SharePanel";
|
||||
import {GenerateEmpty} from "./UI/CustomGenerator/GenerateEmpty";
|
||||
import PageSplit from "./UI/Base/PageSplit";
|
||||
import HelpText from "./Customizations/HelpText";
|
||||
import {TagRendering} from "./Customizations/TagRendering";
|
||||
import {LayoutConfigJson} from "./Customizations/JSON/LayoutConfigJson";
|
||||
|
||||
import {OsmConnection} from "./Logic/Osm/OsmConnection";
|
||||
import CustomGeneratorPanel from "./UI/CustomGenerator/CustomGeneratorPanel";
|
||||
import {LocalStorageSource} from "./Logic/Web/LocalStorageSource";
|
||||
|
||||
let layout = GenerateEmpty.createEmptyLayout();
|
||||
if(window.location.hash.length > 10){
|
||||
if (window.location.hash.length > 10) {
|
||||
layout = JSON.parse(atob(window.location.hash.substr(1))) as LayoutConfigJson;
|
||||
} else {
|
||||
const hash = LocalStorageSource.Get("last-custom-theme").data
|
||||
if (hash !== undefined) {
|
||||
layout = JSON.parse(atob(hash)) as LayoutConfigJson;
|
||||
}
|
||||
}
|
||||
const es = new UIEventSource(layout);
|
||||
const encoded = es.map(config => btoa(JSON.stringify(config)));
|
||||
const liveUrl = encoded.map(encoded => `./index.html?userlayout=${es.data.id}#${encoded}`)
|
||||
const iframe = liveUrl.map(url => `<iframe src='${url}' width='100%' height='99%' style="box-sizing: border-box" title='Theme Preview'></iframe>`);
|
||||
|
||||
TagRendering.injectFunction();
|
||||
|
||||
const currentSetting = new UIEventSource<SingleSetting<any>>(undefined)
|
||||
const connection = new OsmConnection(false, new UIEventSource<string>(undefined), "customGenerator", false);
|
||||
|
||||
const generalSettings = new GeneralSettings(es, currentSetting);
|
||||
const languages = generalSettings.languages;
|
||||
|
||||
|
||||
// The preview
|
||||
const preview = new Combine([
|
||||
new VariableUiElement(iframe.stabilized(2500))
|
||||
]).SetClass("preview")
|
||||
|
||||
|
||||
new TabbedComponent([
|
||||
{
|
||||
header: "<img src='./assets/gear.svg'>",
|
||||
content:
|
||||
new PageSplit(
|
||||
generalSettings.SetStyle("width: 50vw;"),
|
||||
new Combine([
|
||||
new HelpText(currentSetting).SetStyle("height:calc(100% - 65vh); width: 100%; display:block; overflow-y: auto"),
|
||||
preview.SetStyle("height:65vh; width:100%; display:block")
|
||||
]).SetStyle("position:relative; width: 50%;")
|
||||
)
|
||||
},
|
||||
{
|
||||
header: "<img src='./assets/layers.svg'>",
|
||||
content: new AllLayersPanel(es, languages)
|
||||
},
|
||||
{
|
||||
header: "<img src='./assets/floppy.svg'>",
|
||||
content: new VariableUiElement(es.map(config => {
|
||||
return JSON.stringify(config, null, 2)
|
||||
.replace(/\n/g, "<br/>")
|
||||
.replace(/ /g, " ");
|
||||
}))
|
||||
|
||||
},
|
||||
{
|
||||
header: "<img src='./assets/share.svg'>",
|
||||
content: new SharePanel(es, liveUrl)
|
||||
}
|
||||
]).SetClass("main-tabs")
|
||||
new CustomGeneratorPanel(connection, layout)
|
||||
.AttachTo("maindiv");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue