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 uid: number
|
||||
public csCount = 0
|
||||
public img: string
|
||||
public img?: string
|
||||
public unreadMessages = 0
|
||||
public totalMessages: number = 0
|
||||
public home: { lon: number; lat: number }
|
||||
|
@ -257,7 +257,6 @@ export class OsmConnection {
|
|||
if (imgEl !== undefined && imgEl[0] !== undefined) {
|
||||
data.img = imgEl[0].getAttribute("href")
|
||||
}
|
||||
data.img = data.img ?? Img.AsData(Svg.person_img)
|
||||
|
||||
const description = userInfo.getElementsByTagName("description")
|
||||
if (description !== undefined && description[0] !== undefined) {
|
||||
|
|
|
@ -8,7 +8,7 @@ import { VariableUiElement } from "../Base/VariableUIElement"
|
|||
import Img from "../Base/Img"
|
||||
import { FixedUiElement } from "../Base/FixedUiElement"
|
||||
import Link from "../Base/Link"
|
||||
import { UIEventSource } from "../../Logic/UIEventSource"
|
||||
import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
||||
import Loc from "../../Models/Loc"
|
||||
import BaseUIElement from "../BaseUIElement"
|
||||
import Showdown from "showdown"
|
||||
|
@ -21,6 +21,9 @@ import { SaveButton } from "../Popup/SaveButton"
|
|||
import { TagUtils } from "../../Logic/Tags/TagUtils"
|
||||
import * as questions from "../../assets/tagRenderings/questions.json"
|
||||
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 {
|
||||
constructor(osmConnection: OsmConnection) {
|
||||
|
@ -54,33 +57,30 @@ class UserInformationMainPanel extends VariableUiElement {
|
|||
const ud = osmConnection.userDetails
|
||||
super(
|
||||
ud.map((ud) => {
|
||||
if (!ud?.loggedIn) {
|
||||
// Not logged in
|
||||
return new SubtleButton(Svg.login_svg(), "Login", { imgSize }).onClick(() =>
|
||||
osmConnection.AttemptLogin()
|
||||
)
|
||||
}
|
||||
|
||||
let img: Img = Svg.person_svg()
|
||||
let img: BaseUIElement = Svg.person_ui().SetClass("block")
|
||||
if (ud.img !== undefined) {
|
||||
img = new Img(ud.img)
|
||||
}
|
||||
img.SetClass("rounded-full h-12 w-12 m-4")
|
||||
|
||||
let description: BaseUIElement = undefined
|
||||
const editLink = osmConnection.Backend() + "/profile/edit"
|
||||
if (ud.description) {
|
||||
const editButton = new Link(
|
||||
Svg.pencil_svg().SetClass("h-4 w-4"),
|
||||
"https://www.openstreetmap.org/profile/edit",
|
||||
editLink,
|
||||
true
|
||||
).SetClass(
|
||||
"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([
|
||||
new FixedUiElement(
|
||||
new Showdown.Converter().makeHtml(ud.description)
|
||||
).SetClass("link-underline"),
|
||||
new FixedUiElement(htmlString).SetClass("link-underline"),
|
||||
editButton,
|
||||
]).SetClass("relative w-full m-2")
|
||||
} else {
|
||||
|
@ -88,6 +88,8 @@ class UserInformationMainPanel extends VariableUiElement {
|
|||
t.noDescription,
|
||||
new SubtleButton(Svg.pencil_svg(), t.noDescriptionCallToAction, {
|
||||
imgSize,
|
||||
url: editLink,
|
||||
newTab: true,
|
||||
}),
|
||||
]).SetClass("w-full m-2")
|
||||
}
|
||||
|
@ -177,9 +179,10 @@ class UserInformationMainPanel extends VariableUiElement {
|
|||
export default class UserInformationPanel extends ScrollableFullScreen {
|
||||
constructor(
|
||||
state: {
|
||||
layoutToUse: LayoutConfig
|
||||
osmConnection: OsmConnection
|
||||
locationControl: UIEventSource<Loc>
|
||||
readonly layoutToUse: LayoutConfig
|
||||
readonly osmConnection: OsmConnection
|
||||
readonly locationControl: UIEventSource<Loc>
|
||||
readonly featureSwitchUserbadge: Store<boolean>
|
||||
},
|
||||
options?: {
|
||||
isOpened?: UIEventSource<boolean>
|
||||
|
@ -189,17 +192,25 @@ export default class UserInformationPanel extends ScrollableFullScreen {
|
|||
super(
|
||||
() => {
|
||||
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 Translations.t.userinfo.welcome.Subs(ud)
|
||||
})
|
||||
)
|
||||
},
|
||||
() => {
|
||||
return new UserInformationMainPanel(
|
||||
() =>
|
||||
new LoginToggle(
|
||||
new UserInformationMainPanel(
|
||||
state.osmConnection,
|
||||
state.locationControl,
|
||||
state.layoutToUse,
|
||||
isOpened
|
||||
)
|
||||
},
|
||||
),
|
||||
Translations.t.general.getStartedLogin,
|
||||
state
|
||||
),
|
||||
"userinfo",
|
||||
isOpened
|
||||
)
|
||||
|
|
|
@ -17,7 +17,7 @@ class LoginButton extends SubtleButton {
|
|||
},
|
||||
icon?: BaseUIElement | string
|
||||
) {
|
||||
super(icon ?? Svg.osm_logo_ui(), text)
|
||||
super(icon ?? Svg.login_ui(), text)
|
||||
this.onClick(() => {
|
||||
state.osmConnection.AttemptLogin()
|
||||
})
|
||||
|
|
|
@ -934,7 +934,7 @@
|
|||
"newMessages": "Sie haben neue Nachrichten",
|
||||
"noDescription": "Sie haben noch keine Beschreibung in Ihrem Profil",
|
||||
"noDescriptionCallToAction": "Profilbeschreibung hinzufügen",
|
||||
"welcome": "Willkommen {user}"
|
||||
"welcome": "Willkommen {name}"
|
||||
},
|
||||
"validation": {
|
||||
"color": {
|
||||
|
|
|
@ -938,7 +938,8 @@
|
|||
"newMessages": "you have new messages",
|
||||
"noDescription": "You don't have a description on your profile yet",
|
||||
"noDescriptionCallToAction": "Add a profile description",
|
||||
"welcome": "Welcome {user}"
|
||||
"titleNotLoggedIn": "Welcome",
|
||||
"welcome": "Welcome {name}"
|
||||
},
|
||||
"validation": {
|
||||
"color": {
|
||||
|
|
|
@ -588,7 +588,7 @@
|
|||
},
|
||||
"userinfo": {
|
||||
"noDescriptionCallToAction": "Legg til profilbeskrivelse",
|
||||
"welcome": "Velkommen {user}"
|
||||
"welcome": "Velkommen {name}"
|
||||
},
|
||||
"validation": {
|
||||
"color": {
|
||||
|
|
|
@ -934,7 +934,7 @@
|
|||
"newMessages": "je hebt nieuwe berichten",
|
||||
"noDescription": "Je hebt nog een beschrijving op je profiel",
|
||||
"noDescriptionCallToAction": "Voeg een profielbeschrijving toe",
|
||||
"welcome": "Welkom {user}"
|
||||
"welcome": "Welkom {name}"
|
||||
},
|
||||
"validation": {
|
||||
"color": {
|
||||
|
|
|
@ -200,7 +200,7 @@
|
|||
"newMessages": "masz nowe wiadomości",
|
||||
"noDescription": "Nie masz jeszcze opisu w swoim profilu",
|
||||
"noDescriptionCallToAction": "Dodaj opis profilu",
|
||||
"welcome": "Witaj {user}"
|
||||
"welcome": "Witaj {name}"
|
||||
},
|
||||
"validation": {
|
||||
"color": {
|
||||
|
|
|
@ -200,6 +200,23 @@
|
|||
"phone": {
|
||||
"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": {
|
||||
"mappings": {
|
||||
"0": {
|
||||
|
|
Loading…
Reference in a new issue