Removed some obsolete code
This commit is contained in:
parent
431c90d9de
commit
77ad4ef666
5 changed files with 17 additions and 35 deletions
|
@ -33,9 +33,12 @@ export class OsmConnection {
|
||||||
console.warn("Detecting standalone mode failed", e, ". Assuming in browser and not worrying furhter")
|
console.warn("Detecting standalone mode failed", e, ". Assuming in browser and not worrying furhter")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const iframeMode = window !== window.top;
|
||||||
|
|
||||||
if (pwaStandAloneMode) {
|
|
||||||
|
if (pwaStandAloneMode || iframeMode) {
|
||||||
// In standalone mode, we DON'T use single page login, as 'redirecting' opens a new window anyway...
|
// In standalone mode, we DON'T use single page login, as 'redirecting' opens a new window anyway...
|
||||||
|
// Same for an iframe...
|
||||||
this.auth = new osmAuth({
|
this.auth = new osmAuth({
|
||||||
oauth_consumer_key: 'hivV7ec2o49Two8g9h8Is1VIiVOgxQ1iYexCbvem',
|
oauth_consumer_key: 'hivV7ec2o49Two8g9h8Is1VIiVOgxQ1iYexCbvem',
|
||||||
oauth_secret: 'wDBRTCem0vxD7txrg1y6p5r8nvmz8tAhET7zDASI',
|
oauth_secret: 'wDBRTCem0vxD7txrg1y6p5r8nvmz8tAhET7zDASI',
|
||||||
|
@ -156,22 +159,6 @@ export class OsmConnection {
|
||||||
}, 5 * 60 * 1000);
|
}, 5 * 60 * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* All elements with class 'activate-osm-authentication' are loaded and get an 'onclick' to authenticate
|
|
||||||
*/
|
|
||||||
registerActivateOsmAUthenticationClass() {
|
|
||||||
|
|
||||||
const self = this;
|
|
||||||
const authElements = document.getElementsByClassName("activate-osm-authentication");
|
|
||||||
for (let i = 0; i < authElements.length; i++) {
|
|
||||||
let element = authElements.item(i);
|
|
||||||
// @ts-ignore
|
|
||||||
element.onclick = function () {
|
|
||||||
self.AttemptLogin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public preferences = new UIEventSource<any>({});
|
public preferences = new UIEventSource<any>({});
|
||||||
public preferenceSources : any = {}
|
public preferenceSources : any = {}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ import {State} from "../State";
|
||||||
export class SimpleAddUI extends UIElement {
|
export class SimpleAddUI extends UIElement {
|
||||||
private _addButtons: UIElement[];
|
private _addButtons: UIElement[];
|
||||||
|
|
||||||
|
private _loginButton : UIElement;
|
||||||
|
|
||||||
private _confirmPreset: UIEventSource<{
|
private _confirmPreset: UIEventSource<{
|
||||||
description: string | UIElement,
|
description: string | UIElement,
|
||||||
name: string | UIElement,
|
name: string | UIElement,
|
||||||
|
@ -37,13 +39,16 @@ export class SimpleAddUI extends UIElement {
|
||||||
super(State.state.locationControl);
|
super(State.state.locationControl);
|
||||||
this.ListenTo(Locale.language);
|
this.ListenTo(Locale.language);
|
||||||
this.ListenTo(State.state.osmConnection.userDetails);
|
this.ListenTo(State.state.osmConnection.userDetails);
|
||||||
|
|
||||||
this.ListenTo(State.state.layerUpdater.runningQuery);
|
this.ListenTo(State.state.layerUpdater.runningQuery);
|
||||||
|
this.ListenTo(this._confirmPreset);
|
||||||
|
|
||||||
|
|
||||||
|
this._loginButton = Translations.t.general.add.pleaseLogin.Clone().onClick(() => State.state.osmConnection.AttemptLogin());
|
||||||
|
|
||||||
this._addButtons = [];
|
this._addButtons = [];
|
||||||
this.ListenTo(this._confirmPreset);
|
|
||||||
this.clss = "add-ui"
|
this.clss = "add-ui"
|
||||||
|
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
for (const layer of State.state.filteredLayers.data) {
|
for (const layer of State.state.filteredLayers.data) {
|
||||||
for (const preset of layer.layerDef.presets) {
|
for (const preset of layer.layerDef.presets) {
|
||||||
|
@ -134,7 +139,7 @@ export class SimpleAddUI extends UIElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!userDetails.data.loggedIn) {
|
if (!userDetails.data.loggedIn) {
|
||||||
return new Combine([header, Translations.t.general.add.pleaseLogin]).Render()
|
return new Combine([header, this._loginButton]).Render()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userDetails.data.unreadMessages > 0) {
|
if (userDetails.data.unreadMessages > 0) {
|
||||||
|
@ -177,8 +182,5 @@ export class SimpleAddUI extends UIElement {
|
||||||
return header.Render() + html;
|
return header.Render() + html;
|
||||||
}
|
}
|
||||||
|
|
||||||
InnerUpdate(htmlElement: HTMLElement) {
|
|
||||||
State.state.osmConnection.registerActivateOsmAUthenticationClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,13 +21,14 @@ export class UserBadge extends UIElement {
|
||||||
private _homeButton: UIElement;
|
private _homeButton: UIElement;
|
||||||
private _languagePicker: UIElement;
|
private _languagePicker: UIElement;
|
||||||
|
|
||||||
|
private _loginButton : UIElement;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(State.state.osmConnection.userDetails);
|
super(State.state.osmConnection.userDetails);
|
||||||
this._userDetails = State.state.osmConnection.userDetails;
|
this._userDetails = State.state.osmConnection.userDetails;
|
||||||
this._pendingChanges = new PendingChanges();
|
this._pendingChanges = new PendingChanges();
|
||||||
this._languagePicker = Utils.CreateLanguagePicker();
|
this._languagePicker = Utils.CreateLanguagePicker();
|
||||||
|
this._loginButton = Translations.t.general.loginWithOpenStreetMap.Clone().onClick(() => State.state.osmConnection.AttemptLogin());
|
||||||
this._logout = new FixedUiElement("<img src='assets/logout.svg' class='small-userbadge-icon' alt='logout'>")
|
this._logout = new FixedUiElement("<img src='assets/logout.svg' class='small-userbadge-icon' alt='logout'>")
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
State.state.osmConnection.LogOut();
|
State.state.osmConnection.LogOut();
|
||||||
|
@ -63,7 +64,7 @@ export class UserBadge extends UIElement {
|
||||||
InnerRender(): string {
|
InnerRender(): string {
|
||||||
const user = this._userDetails.data;
|
const user = this._userDetails.data;
|
||||||
if (!user.loggedIn) {
|
if (!user.loggedIn) {
|
||||||
return "<div class='activate-osm-authentication'>" + Translations.t.general.loginWithOpenStreetMap.R()+ "</div>";
|
return this._loginButton.Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,9 +124,5 @@ export class UserBadge extends UIElement {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected InnerUpdate(htmlElement: HTMLElement) {
|
|
||||||
State.state.osmConnection.registerActivateOsmAUthenticationClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -31,7 +31,7 @@ export class WelcomeMessage extends UIElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.description = fromLayout((layout) => layout.welcomeMessage);
|
this.description = fromLayout((layout) => layout.welcomeMessage);
|
||||||
this.plzLogIn = fromLayout((layout) => layout.gettingStartedPlzLogin);
|
this.plzLogIn = fromLayout((layout) => layout.gettingStartedPlzLogin.onClick(()=> State.state.osmConnection.AttemptLogin()));
|
||||||
this.welcomeBack = fromLayout((layout) => layout.welcomeBackMessage);
|
this.welcomeBack = fromLayout((layout) => layout.welcomeBackMessage);
|
||||||
this.tail = fromLayout((layout) => layout.welcomeTail);
|
this.tail = fromLayout((layout) => layout.welcomeTail);
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,5 @@ export class WelcomeMessage extends UIElement {
|
||||||
"</span>";
|
"</span>";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected InnerUpdate(htmlElement: HTMLElement) {
|
|
||||||
this.osmConnection?.registerActivateOsmAUthenticationClass()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
1
index.ts
1
index.ts
|
@ -171,6 +171,5 @@ if ((window != window.top && !State.state.featureSwitchWelcomeMessage) || State.
|
||||||
new GeoLocationHandler().AttachTo("geolocate-button");
|
new GeoLocationHandler().AttachTo("geolocate-button");
|
||||||
|
|
||||||
|
|
||||||
State.state.osmConnection.registerActivateOsmAUthenticationClass();
|
|
||||||
State.state.locationControl.ping()
|
State.state.locationControl.ping()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue