var Unibase;
(function (Unibase) {
let Platform;
(function (Platform) {
let Membership;
(function (Membership) {
let Components;
(function (Components) {
class UserLoginDetailsWidget extends Platform.Core.BaseComponent {
init(containerid) {
var instance = this;
instance.userdetails(containerid);
$(".user-toggle-notification-btn").click(function () {
$(".biz-wrapper").addClass("biz-settings-toggle");
$(".hk-wrapper").addClass("biz-settings-toggle");
if (($(window).width()) <= 575) {
$(".settings-panel-head").find("#myTab").remove();
var notification_header = $(".settings-panel-head").find("#settings-panel-head-title").length;
if (notification_header == 0) {
$(".settings-panel-head #settings_panel_close").before(` Notifications `).parent().addClass('px-3 border-bottom').removeClass('py-10');
}
Unibase.Themes.Compact.Components.Notification.Instance().loadReminders();
}
else {
Unibase.Themes.Compact.Components.Notification.Instance().loadReminders();
}
});
$(".user-toggle-task-btn").click(function () {
$(".biz-wrapper").addClass("biz-settings-toggle");
$(".hk-wrapper").addClass("biz-settings-toggle");
if (($(window).width()) <= 575) {
$(".settings-panel-head").find("#myTab").remove();
var notification_header = $(".settings-panel-head").find("#settings-panel-head-title").length;
if (notification_header == 0) {
$(".settings-panel-head #settings_panel_close").before(` Tasks `).parent().addClass('px-3 border-bottom').removeClass('py-10');
}
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('/tenants/themes/compact/components/notifications/notification.js', function () {
Unibase.Themes.Compact.Components.Notification.Instance().loadTasks();
});
}
else {
Unibase.Themes.Compact.Components.Notification.Instance().loadTasks();
}
});
}
userdetails(containerid) {
let notification, task;
let data = Unibase.Platform.Membership.Infos.Identity.getCurrentUser();
let imageurl = data.photoUrl;
let companyname = data.settings.filter(function (o) { return o.settingName === "companyname"; })[0].settingValue;
let branchname = data.settings.filter(function (o) { return o.settingName === "branchname"; })[0].settingValue;
let branchcode = data.settings.filter(function (o) { return o.settingName === "branchcode"; })[0].settingValue;
let username = data.name;
let html = '';
html = `
Hi Welcome,
` + username + `
` + companyname + `
` + branchname + ` (` + branchcode + `)
`;
$(`#${containerid}`).html(html);
$(".user-login-img-div")
.mouseover(function () {
$(this).find(".edit-picture").removeClass("d-none").addClass("d-flex").css("cursor", "pointer");
})
.mouseout(function () {
$(this).find(".edit-picture").addClass("d-none").removeClass("d-flex");
});
let dataSrc = $('.biz-login-image').data('src');
if (dataSrc == '' || dataSrc == null || dataSrc == 'undefined') {
let avatarTxt = "";
let headingTxt = $('.user_Name').text();
let matches = headingTxt.match(/\b(\w)/g);
if (matches && matches.length == 1) {
avatarTxt = $.trim(headingTxt).substr(0, 2).toUpperCase();
}
else {
avatarTxt = matches.join('').slice(0, 2).toUpperCase();
}
$('.user-login-img').html(`${avatarTxt}
`);
}
else {
if (dataSrc && dataSrc.includes("~")) {
dataSrc = dataSrc.slice(2);
}
$('.user-login-img').html(`
`);
}
let uniqueid = 'Bizgaze_Crm_Employess_App_AddPhotoUrl_Dashboard';
Unibase.Platform.Forms.Managers.FormManager.Instance().getFormbyUniqueId(uniqueid).then(function (response) {
$('.edit-picture').attr("onclick", `Unibase.Platform.Membership.Components.UserLoginDetailsWidget.Instance().profileupdate(${response.result.FormId}, 0)`);
$('[data-btnclick="profile"]').attr("onclick", `Unibase.Platform.Membership.Components.UserLoginDetailsWidget.Instance().profileupdate(${response.result.FormId}, 0)`);
});
$(".user_login_detials").closest(".col-lg-12.droppablePlaceCol").removeClass("px-md-5");
Unibase.Platform.Communications.Managers.ReminderManager.Instance().getUnreadRemindersCountByUserId().then(function (response) {
var obj = response.result;
notification = obj.NotificationCount;
task = obj.TasksCount;
$(".notification_count").html(notification);
$(".tasks_count").html(task);
});
return html;
}
profilePicSuccess() {
$('#layout-dashboard-tabs .filter-item.active a').trigger('click');
}
profileupdate(formid, appConfigId, employeeid) {
var successobj = {
CallBack: function () { Unibase.Platform.Membership.Components.UserLoginDetailsWidget.Instance().profilePicSuccess(); },
Parameters: null,
};
var formviewerObj = {
FormId: formid,
AppConfigurationId: 0,
Pk_Value: 0,
PortletWidgetId: 0,
OnSuccess: successobj,
OnFail: null,
OnLoad: null,
FormSize: Unibase.Platform.Helpers.Size.Large
};
Unibase.Platform.Forms.Components.FormViewer.Instance().init(formviewerObj);
}
jsFiles() {
return ['tenants/themes/compact/components/nav/nav.js'];
}
cssFiles() {
return [];
}
html(id, containerid) {
var html = ``;
return html;
}
load(id, containerid, callback) {
}
static Instance() {
if (this._instance === undefined)
this._instance = new UserLoginDetailsWidget();
return this._instance;
}
}
Components.UserLoginDetailsWidget = UserLoginDetailsWidget;
})(Components = Membership.Components || (Membership.Components = {}));
})(Membership = Platform.Membership || (Platform.Membership = {}));
})(Platform = Unibase.Platform || (Unibase.Platform = {}));
})(Unibase || (Unibase = {}));