"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("")
.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 "
";
}
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 "
" + "" + user.name + "" + dryrun + "
" + "" +
this._homeButton.Render() +
settings +
messageSpan +
" " +
" " + user.csCount +
" " +
this._logout.Render() +
this._pendingChanges.Render() +
"