From 118a60c80537f890ebc371b45c6557471228743e Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 1 Jul 2020 17:51:55 +0200 Subject: [PATCH] Add logout button, fix # 23 --- Logic/OsmConnection.ts | 5 ++- README.md | 2 + UI/UserBadge.ts | 19 ++++++--- assets/logout.svg | 94 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 7 deletions(-) create mode 100644 assets/logout.svg diff --git a/Logic/OsmConnection.ts b/Logic/OsmConnection.ts index c347fe7..ca10f13 100644 --- a/Logic/OsmConnection.ts +++ b/Logic/OsmConnection.ts @@ -49,6 +49,9 @@ export class OsmConnection { public LogOut() { this.auth.logout(); + this.userDetails.data.loggedIn = false; + this.userDetails.ping(); + console.log("Logged out") } public AttemptLogin() { @@ -76,7 +79,7 @@ export class OsmConnection { let data = self.userDetails.data; data.loggedIn = true; - console.log(userInfo); + console.log("Log incompleted, userinfo is ", userInfo); data.name = userInfo.getAttribute('display_name'); data.csCount = userInfo.getElementsByTagName("changesets")[0].getAttribute("count"); diff --git a/README.md b/README.md index 45a305a..5cd3832 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,8 @@ Camera Icon, Dave Gandy, CC-BY-SA 3.0 https://commons.wikimedia.org/wiki/File:OOjs_UI_indicator_search-rtl.svg Search Icon, MIT + + https://commons.wikimedia.org/wiki/File:Home-icon.svg Home icon by Timothy Miller, CC-BY-SA 3.0 diff --git a/UI/UserBadge.ts b/UI/UserBadge.ts index 21bd7d0..26eb303 100644 --- a/UI/UserBadge.ts +++ b/UI/UserBadge.ts @@ -22,15 +22,20 @@ export class UserBadge extends UIElement { this._userDetails = userDetails; this._pendingChanges = pendingChanges; this._basemap = basemap; - - this._logout = new FixedUiElement("logout") - .onClick(() => {userDetails.data.osmConnection.LogOut();}); + + this._logout = new FixedUiElement("logout") + .onClick(() => { + userDetails.data.osmConnection.LogOut(); + }); userDetails.addCallback(function () { const profilePic = document.getElementById("profile-pic"); - profilePic.onload = function () { - profilePic.style.opacity = "1" - }; + if (profilePic) { + + profilePic.onload = function () { + profilePic.style.opacity = "1" + }; + } }); } @@ -92,6 +97,7 @@ export class UserBadge extends UIElement { " " + " star " + user.csCount + " " + + this._logout.Render() + this._pendingChanges.Render() + "

" + @@ -112,6 +118,7 @@ export class UserBadge extends UIElement { } } + this._logout.Update(); } Activate() { diff --git a/assets/logout.svg b/assets/logout.svg new file mode 100644 index 0000000..d9d6538 --- /dev/null +++ b/assets/logout.svg @@ -0,0 +1,94 @@ + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + +