Improvements to the user information panel
This commit is contained in:
parent
49210f2a28
commit
a85fe85358
10 changed files with 62 additions and 34 deletions
|
@ -14,7 +14,7 @@ export default class UserDetails {
|
||||||
public name = "Not logged in"
|
public name = "Not logged in"
|
||||||
public uid: number
|
public uid: number
|
||||||
public csCount = 0
|
public csCount = 0
|
||||||
public img: string
|
public img?: string
|
||||||
public unreadMessages = 0
|
public unreadMessages = 0
|
||||||
public totalMessages: number = 0
|
public totalMessages: number = 0
|
||||||
public home: { lon: number; lat: number }
|
public home: { lon: number; lat: number }
|
||||||
|
@ -257,7 +257,6 @@ export class OsmConnection {
|
||||||
if (imgEl !== undefined && imgEl[0] !== undefined) {
|
if (imgEl !== undefined && imgEl[0] !== undefined) {
|
||||||
data.img = imgEl[0].getAttribute("href")
|
data.img = imgEl[0].getAttribute("href")
|
||||||
}
|
}
|
||||||
data.img = data.img ?? Img.AsData(Svg.person_img)
|
|
||||||
|
|
||||||
const description = userInfo.getElementsByTagName("description")
|
const description = userInfo.getElementsByTagName("description")
|
||||||
if (description !== undefined && description[0] !== undefined) {
|
if (description !== undefined && description[0] !== undefined) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { VariableUiElement } from "../Base/VariableUIElement"
|
||||||
import Img from "../Base/Img"
|
import Img from "../Base/Img"
|
||||||
import { FixedUiElement } from "../Base/FixedUiElement"
|
import { FixedUiElement } from "../Base/FixedUiElement"
|
||||||
import Link from "../Base/Link"
|
import Link from "../Base/Link"
|
||||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
||||||
import Loc from "../../Models/Loc"
|
import Loc from "../../Models/Loc"
|
||||||
import BaseUIElement from "../BaseUIElement"
|
import BaseUIElement from "../BaseUIElement"
|
||||||
import Showdown from "showdown"
|
import Showdown from "showdown"
|
||||||
|
@ -21,6 +21,9 @@ import { SaveButton } from "../Popup/SaveButton"
|
||||||
import { TagUtils } from "../../Logic/Tags/TagUtils"
|
import { TagUtils } from "../../Logic/Tags/TagUtils"
|
||||||
import * as questions from "../../assets/tagRenderings/questions.json"
|
import * as questions from "../../assets/tagRenderings/questions.json"
|
||||||
import { TagRenderingConfigJson } from "../../Models/ThemeConfig/Json/TagRenderingConfigJson"
|
import { TagRenderingConfigJson } from "../../Models/ThemeConfig/Json/TagRenderingConfigJson"
|
||||||
|
import * as os from "os"
|
||||||
|
import { LoginToggle } from "../Popup/LoginButton"
|
||||||
|
import { userInfo } from "os"
|
||||||
|
|
||||||
export class ImportViewerLinks extends VariableUiElement {
|
export class ImportViewerLinks extends VariableUiElement {
|
||||||
constructor(osmConnection: OsmConnection) {
|
constructor(osmConnection: OsmConnection) {
|
||||||
|
@ -54,33 +57,30 @@ class UserInformationMainPanel extends VariableUiElement {
|
||||||
const ud = osmConnection.userDetails
|
const ud = osmConnection.userDetails
|
||||||
super(
|
super(
|
||||||
ud.map((ud) => {
|
ud.map((ud) => {
|
||||||
if (!ud?.loggedIn) {
|
let img: BaseUIElement = Svg.person_ui().SetClass("block")
|
||||||
// Not logged in
|
|
||||||
return new SubtleButton(Svg.login_svg(), "Login", { imgSize }).onClick(() =>
|
|
||||||
osmConnection.AttemptLogin()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
let img: Img = Svg.person_svg()
|
|
||||||
if (ud.img !== undefined) {
|
if (ud.img !== undefined) {
|
||||||
img = new Img(ud.img)
|
img = new Img(ud.img)
|
||||||
}
|
}
|
||||||
img.SetClass("rounded-full h-12 w-12 m-4")
|
img.SetClass("rounded-full h-12 w-12 m-4")
|
||||||
|
|
||||||
let description: BaseUIElement = undefined
|
let description: BaseUIElement = undefined
|
||||||
|
const editLink = osmConnection.Backend() + "/profile/edit"
|
||||||
if (ud.description) {
|
if (ud.description) {
|
||||||
const editButton = new Link(
|
const editButton = new Link(
|
||||||
Svg.pencil_svg().SetClass("h-4 w-4"),
|
Svg.pencil_svg().SetClass("h-4 w-4"),
|
||||||
"https://www.openstreetmap.org/profile/edit",
|
editLink,
|
||||||
true
|
true
|
||||||
).SetClass(
|
).SetClass(
|
||||||
"absolute block bg-subtle rounded-full p-2 bottom-2 right-2 w-min self-end"
|
"absolute block bg-subtle rounded-full p-2 bottom-2 right-2 w-min self-end"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const htmlString = new Showdown.Converter()
|
||||||
|
.makeHtml(ud.description)
|
||||||
|
.replace(/>/g, ">")
|
||||||
|
.replace(/</g, "<")
|
||||||
|
console.log("Before:", ud.description, "after", htmlString)
|
||||||
description = new Combine([
|
description = new Combine([
|
||||||
new FixedUiElement(
|
new FixedUiElement(htmlString).SetClass("link-underline"),
|
||||||
new Showdown.Converter().makeHtml(ud.description)
|
|
||||||
).SetClass("link-underline"),
|
|
||||||
editButton,
|
editButton,
|
||||||
]).SetClass("relative w-full m-2")
|
]).SetClass("relative w-full m-2")
|
||||||
} else {
|
} else {
|
||||||
|
@ -88,6 +88,8 @@ class UserInformationMainPanel extends VariableUiElement {
|
||||||
t.noDescription,
|
t.noDescription,
|
||||||
new SubtleButton(Svg.pencil_svg(), t.noDescriptionCallToAction, {
|
new SubtleButton(Svg.pencil_svg(), t.noDescriptionCallToAction, {
|
||||||
imgSize,
|
imgSize,
|
||||||
|
url: editLink,
|
||||||
|
newTab: true,
|
||||||
}),
|
}),
|
||||||
]).SetClass("w-full m-2")
|
]).SetClass("w-full m-2")
|
||||||
}
|
}
|
||||||
|
@ -177,9 +179,10 @@ class UserInformationMainPanel extends VariableUiElement {
|
||||||
export default class UserInformationPanel extends ScrollableFullScreen {
|
export default class UserInformationPanel extends ScrollableFullScreen {
|
||||||
constructor(
|
constructor(
|
||||||
state: {
|
state: {
|
||||||
layoutToUse: LayoutConfig
|
readonly layoutToUse: LayoutConfig
|
||||||
osmConnection: OsmConnection
|
readonly osmConnection: OsmConnection
|
||||||
locationControl: UIEventSource<Loc>
|
readonly locationControl: UIEventSource<Loc>
|
||||||
|
readonly featureSwitchUserbadge: Store<boolean>
|
||||||
},
|
},
|
||||||
options?: {
|
options?: {
|
||||||
isOpened?: UIEventSource<boolean>
|
isOpened?: UIEventSource<boolean>
|
||||||
|
@ -189,17 +192,25 @@ export default class UserInformationPanel extends ScrollableFullScreen {
|
||||||
super(
|
super(
|
||||||
() => {
|
() => {
|
||||||
return new VariableUiElement(
|
return new VariableUiElement(
|
||||||
state.osmConnection.userDetails.map((ud) => "Welcome " + ud.name)
|
state.osmConnection.userDetails.map((ud) => {
|
||||||
)
|
if (ud.loggedIn === false) {
|
||||||
},
|
return Translations.t.userinfo.titleNotLoggedIn
|
||||||
() => {
|
}
|
||||||
return new UserInformationMainPanel(
|
return Translations.t.userinfo.welcome.Subs(ud)
|
||||||
state.osmConnection,
|
})
|
||||||
state.locationControl,
|
|
||||||
state.layoutToUse,
|
|
||||||
isOpened
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
() =>
|
||||||
|
new LoginToggle(
|
||||||
|
new UserInformationMainPanel(
|
||||||
|
state.osmConnection,
|
||||||
|
state.locationControl,
|
||||||
|
state.layoutToUse,
|
||||||
|
isOpened
|
||||||
|
),
|
||||||
|
Translations.t.general.getStartedLogin,
|
||||||
|
state
|
||||||
|
),
|
||||||
"userinfo",
|
"userinfo",
|
||||||
isOpened
|
isOpened
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,7 +17,7 @@ class LoginButton extends SubtleButton {
|
||||||
},
|
},
|
||||||
icon?: BaseUIElement | string
|
icon?: BaseUIElement | string
|
||||||
) {
|
) {
|
||||||
super(icon ?? Svg.osm_logo_ui(), text)
|
super(icon ?? Svg.login_ui(), text)
|
||||||
this.onClick(() => {
|
this.onClick(() => {
|
||||||
state.osmConnection.AttemptLogin()
|
state.osmConnection.AttemptLogin()
|
||||||
})
|
})
|
||||||
|
|
|
@ -1799,4 +1799,4 @@
|
||||||
"ca": "El nom de la xarxa és <b>{internet_access:ssid}</b>"
|
"ca": "El nom de la xarxa és <b>{internet_access:ssid}</b>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -934,7 +934,7 @@
|
||||||
"newMessages": "Sie haben neue Nachrichten",
|
"newMessages": "Sie haben neue Nachrichten",
|
||||||
"noDescription": "Sie haben noch keine Beschreibung in Ihrem Profil",
|
"noDescription": "Sie haben noch keine Beschreibung in Ihrem Profil",
|
||||||
"noDescriptionCallToAction": "Profilbeschreibung hinzufügen",
|
"noDescriptionCallToAction": "Profilbeschreibung hinzufügen",
|
||||||
"welcome": "Willkommen {user}"
|
"welcome": "Willkommen {name}"
|
||||||
},
|
},
|
||||||
"validation": {
|
"validation": {
|
||||||
"color": {
|
"color": {
|
||||||
|
|
|
@ -938,7 +938,8 @@
|
||||||
"newMessages": "you have new messages",
|
"newMessages": "you have new messages",
|
||||||
"noDescription": "You don't have a description on your profile yet",
|
"noDescription": "You don't have a description on your profile yet",
|
||||||
"noDescriptionCallToAction": "Add a profile description",
|
"noDescriptionCallToAction": "Add a profile description",
|
||||||
"welcome": "Welcome {user}"
|
"titleNotLoggedIn": "Welcome",
|
||||||
|
"welcome": "Welcome {name}"
|
||||||
},
|
},
|
||||||
"validation": {
|
"validation": {
|
||||||
"color": {
|
"color": {
|
||||||
|
|
|
@ -588,7 +588,7 @@
|
||||||
},
|
},
|
||||||
"userinfo": {
|
"userinfo": {
|
||||||
"noDescriptionCallToAction": "Legg til profilbeskrivelse",
|
"noDescriptionCallToAction": "Legg til profilbeskrivelse",
|
||||||
"welcome": "Velkommen {user}"
|
"welcome": "Velkommen {name}"
|
||||||
},
|
},
|
||||||
"validation": {
|
"validation": {
|
||||||
"color": {
|
"color": {
|
||||||
|
|
|
@ -934,7 +934,7 @@
|
||||||
"newMessages": "je hebt nieuwe berichten",
|
"newMessages": "je hebt nieuwe berichten",
|
||||||
"noDescription": "Je hebt nog een beschrijving op je profiel",
|
"noDescription": "Je hebt nog een beschrijving op je profiel",
|
||||||
"noDescriptionCallToAction": "Voeg een profielbeschrijving toe",
|
"noDescriptionCallToAction": "Voeg een profielbeschrijving toe",
|
||||||
"welcome": "Welkom {user}"
|
"welcome": "Welkom {name}"
|
||||||
},
|
},
|
||||||
"validation": {
|
"validation": {
|
||||||
"color": {
|
"color": {
|
||||||
|
|
|
@ -200,7 +200,7 @@
|
||||||
"newMessages": "masz nowe wiadomości",
|
"newMessages": "masz nowe wiadomości",
|
||||||
"noDescription": "Nie masz jeszcze opisu w swoim profilu",
|
"noDescription": "Nie masz jeszcze opisu w swoim profilu",
|
||||||
"noDescriptionCallToAction": "Dodaj opis profilu",
|
"noDescriptionCallToAction": "Dodaj opis profilu",
|
||||||
"welcome": "Witaj {user}"
|
"welcome": "Witaj {name}"
|
||||||
},
|
},
|
||||||
"validation": {
|
"validation": {
|
||||||
"color": {
|
"color": {
|
||||||
|
|
|
@ -200,6 +200,23 @@
|
||||||
"phone": {
|
"phone": {
|
||||||
"question": "What is the phone number of {title()}?"
|
"question": "What is the phone number of {title()}?"
|
||||||
},
|
},
|
||||||
|
"picture-license": {
|
||||||
|
"mappings": {
|
||||||
|
"0": {
|
||||||
|
"then": "No license has been chosen yet"
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
"then": "Pictures you take will be licensed with CC0 and added to the public domain. This means that everyone can use your pictures for any purpose."
|
||||||
|
},
|
||||||
|
"2": {
|
||||||
|
"then": "Pictures you take will be licensed with CC-BY 4.0 which requires everyone using your picture that they have to attribute you"
|
||||||
|
},
|
||||||
|
"3": {
|
||||||
|
"then": "Pictures you take will be licensed with CC-BY-SA 4.0 which means that everyone using your picture must attribute you and that derivatives of your picture must be reshared with the same license."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"question": "Under what license do you want to publish your pictures?"
|
||||||
|
},
|
||||||
"service:electricity": {
|
"service:electricity": {
|
||||||
"mappings": {
|
"mappings": {
|
||||||
"0": {
|
"0": {
|
||||||
|
|
Loading…
Reference in a new issue