Fixed single page login for a certain poor Simon with a weird browser

This commit is contained in:
Pieter Vander Vennet 2020-07-29 21:32:51 +02:00
parent 2913c28271
commit 4a85fa82c3
7 changed files with 44 additions and 26 deletions

View file

@ -37,7 +37,6 @@ export class AllKnownLayouts {
const knownKeys = []
for (const layout of layouts) {
for (const layer of layout.layers) {
console.log("Adding ", Translations.W(layer.name).InnerRender());
const key = layer.overpassFilter.asOverpass().join("");
if (knownKeys.indexOf(key) >= 0) {
continue;

View file

@ -365,8 +365,6 @@ class TagRendering extends UIElement implements TagDependantUIElement {
.split("$");
const type = prepost[1];
console.log("PrePost:", prepost);
let isValid = TagRenderingOptions.inputValidation[type];
if (isValid === undefined) {
isValid = (str) => true;

View file

@ -17,33 +17,54 @@ export class UserDetails {
export class OsmConnection {
private auth = new osmAuth({
oauth_consumer_key: 'hivV7ec2o49Two8g9h8Is1VIiVOgxQ1iYexCbvem',
oauth_secret: 'wDBRTCem0vxD7txrg1y6p5r8nvmz8tAhET7zDASI',
auto: true // show a login form if the user is not authenticated and
// you try to do a call
});
public auth;
public userDetails: UIEventSource<UserDetails>;
private _dryRun: boolean;
constructor(dryRun: boolean) {
constructor(dryRun: boolean, oauth_token: UIEventSource<string>) {
this.auth = new osmAuth({
oauth_consumer_key: 'hivV7ec2o49Two8g9h8Is1VIiVOgxQ1iYexCbvem',
oauth_secret: 'wDBRTCem0vxD7txrg1y6p5r8nvmz8tAhET7zDASI',
oauth_token: oauth_token.data,
singlepage: true,
landing: "./index.html",
auto: true // show a login form if the user is not authenticated and
// you try to do a call
});
this.userDetails = new UIEventSource<UserDetails>(new UserDetails());
this.userDetails.data.osmConnection = this;
this.userDetails.data.dryRun = dryRun;
this._dryRun = dryRun;
if(oauth_token.data !== undefined){
console.log(oauth_token.data)
const self = this;
this.auth.bootstrapToken(oauth_token.data,
(x) => {
console.log("Called back: ", x)
self.AttemptLogin();
}, this.auth);
oauth_token.setData(undefined);
}
if (this.auth.authenticated()) {
this.AttemptLogin(); // Also updates the user badge
}else{
} else {
console.log("Not authenticated");
}
if(dryRun){
if (dryRun) {
console.log("DRYRUN ENABLED");
}
}
public LogOut() {

View file

@ -7,21 +7,21 @@ import {link} from "fs";
export class SubtleButton extends UIElement{
private imageUrl: string;
private message: UIElement;
private linkTo: string = undefined;
private linkTo: { url: string, newTab?: boolean } = undefined;
constructor(imageUrl: string, message: string | UIElement, linkTo : string = undefined) {
constructor(imageUrl: string, message: string | UIElement, linkTo: { url: string, newTab?: boolean } = undefined) {
super(undefined);
this.linkTo = linkTo;
this.message = Translations.W(message);
this.imageUrl = imageUrl;
}
InnerRender(): string {
if(this.linkTo != undefined){
return new Combine([
`<a class="subtle-button" href="${this.linkTo}" target="_blank">`,
`<a class="subtle-button" href="${this.linkTo.url}" ${this.linkTo.newTab ? 'target="_blank"' : ""}>`,
this.imageUrl !== undefined ? `<img src='${this.imageUrl}'>` : "",
this.message,
'</a>'

View file

@ -44,7 +44,7 @@ export class MoreScreen extends UIElement {
"</b>",
"<br/>",
Translations.W(layout.description),
]), linkText);
]), {url: linkText, newTab: false});
els.push(link)
}

View file

@ -36,7 +36,7 @@ export class SimpleAddUI extends UIElement {
private confirmButton: UIElement = undefined;
private cancelButton: UIElement;
private goToInboxButton: UIElement = new SubtleButton("/assets/envelope.svg",
Translations.t.general.goToInbox, "https://www.openstreetmap.org/messages/inbox");
Translations.t.general.goToInbox, {url:"https://www.openstreetmap.org/messages/inbox", newTab: false});
constructor(zoomlevel: UIEventSource<{ zoom: number }>,
lastClickLocation: UIEventSource<{ lat: number, lon: number }>,

View file

@ -128,15 +128,15 @@ const locationControl = new UIEventSource<{ lat: number, lon: number, zoom: numb
locationControl.addCallback((latlonz) => {
zoom.setData(latlonz.zoom.toString());
lat.setData(latlonz.lat.toString().substr(0,6));
lon.setData(latlonz.lon.toString().substr(0,6));
lat.setData(latlonz.lat.toString().substr(0, 6));
lon.setData(latlonz.lon.toString().substr(0, 6));
})
// ----------------- Prepare the important objects -----------------
const osmConnection = new OsmConnection(
QueryParameters.GetQueryParameter("test", "false").data === "true"
const osmConnection: OsmConnection = new OsmConnection(
QueryParameters.GetQueryParameter("test", "false").data === "true",
QueryParameters.GetQueryParameter("oauth_token", undefined)
);
@ -222,7 +222,7 @@ for (const layer of layoutToUse.layers) {
tags[k] = tag.value;
}
}
preset.icon = layer.style(tags).icon.iconUrl;
preset.icon = layer.style(tags)?.icon?.iconUrl;
}
const addButton = {