"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.UserBadge = void 0; var UIElement_1 = require("./UIElement"); var leaflet_1 = require("leaflet"); var FixedUiElement_1 = require("./Base/FixedUiElement"); var VariableUIElement_1 = require("./Base/VariableUIElement"); /** * Handles and updates the user badge */ var UserBadge = /** @class */ (function (_super) { __extends(UserBadge, _super); function UserBadge(userDetails, pendingChanges, basemap) { var _this = _super.call(this, userDetails) || this; _this._userDetails = userDetails; _this._pendingChanges = pendingChanges; _this._basemap = basemap; _this._logout = new FixedUiElement_1.FixedUiElement("logout") .onClick(function () { userDetails.data.osmConnection.LogOut(); }); userDetails.addCallback(function () { var profilePic = document.getElementById("profile-pic"); if (profilePic) { profilePic.onload = function () { profilePic.style.opacity = "1"; }; } }); _this._homeButton = new VariableUIElement_1.VariableUiElement(userDetails.map(function (userinfo) { if (userinfo.home) { return "home "; } return ""; })).onClick(function () { var _a; var home = (_a = userDetails.data) === null || _a === void 0 ? void 0 : _a.home; if (home === undefined) { return; } basemap.map.flyTo([home.lat, home.lon], 18); }); return _this; } UserBadge.prototype.InnerRender = function () { var user = this._userDetails.data; if (!user.loggedIn) { return "
Klik hier om aan te melden bij OSM
"; } var messageSpan = "" + " msgs" + user.totalMessages + ""; if (user.unreadMessages > 0) { messageSpan = "" + " msgs" + " " + "" + user.unreadMessages.toString() + ""; } var dryrun = ""; if (user.dryRun) { dryrun = " TESTING"; } if (user.home !== undefined) { var icon = leaflet_1.default.icon({ iconUrl: 'assets/home.svg', iconSize: [20, 20], iconAnchor: [10, 10] }); leaflet_1.default.marker([user.home.lat, user.home.lon], { icon: icon }).addTo(this._basemap.map); } var settings = "" + "settings" + " "; return "" + "profile-pic " + "" + "
" + "

" + "" + user.name + "" + dryrun + "

" + "

" + this._homeButton.Render() + settings + messageSpan + " " + " star " + user.csCount + " " + this._logout.Render() + this._pendingChanges.Render() + "

" + "
"; }; return UserBadge; }(UIElement_1.UIElement)); exports.UserBadge = UserBadge;