/*Data loading start here*/ import {getCookie} from "./cookiehelper.js"; import {getData, getDataObj} from "./base.js"; import {_serverUrl} from "./setting.js"; function createLoad(data) { let html = ""; if (data.length != 0) { for (var i = 0; i < data.length; i++) { html += `
  • ${data[i].AppTitle}
  • `; } } else { html += `
  • Apps are Not Installed
  • `; } $("#crte-btn-lst").html(html); $(".create-form-btn").on("click", function () { const date = new Date(); let number = date.getTime(); let serverUrl = _serverUrl(); let appName = $(this).text(); let formId = $(this).attr("data-formid"); let installedAppId = $(this).attr("data-installedappid"); let appConfigurationId = $(this).attr("data-appconfigurationid"); let pk_id = 0; const cookie = getCookie("_idty"); let fomrhtml = ""; if (cookie) { const {unibaseId, tenantId, userId} = JSON.parse(cookie); fomrhtml = `
    `; } $("#list-page").after(fomrhtml); window.window.postMessage("ld-frm-ifrme", "*"); hdrCrtnClckEvnt(number); }); } function hdrCrtnClckEvnt(number) { $(`.frm-ifre-${number} .minimize`).on("click", function () { let id = $(this).attr("data-unid"); let isPopUpState = $(this).attr("data-ispopup"); let height = $(`.frm-ifre-${id}`).find(".frm-hdr").height(); $(`.frm-ifre-${id} .frm-bdy`).toggleClass("d-none"); if (isPopUpState == "true") { // popup large $(this).attr("data-ispopup", "false"); $(`.frm-ifre-${id}`).css({ width: "22%", height: height, bottom: "0px", }); } else { // popup small $(this).attr("data-ispopup", "true"); $(`.frm-ifre-${id}`).css({ width: "", height: "", bottom: "", }); } }); $(`.frm-ifre-${number} .maximum`).on("click", function () { let id = $(this).attr("data-unid"); $(this).addClass("d-none"); $(this).siblings(".compress").removeClass("d-none"); $(`.frm-ifre-${id}`).find(".ld-frm-src").attr("data-ispopup", "true"); $(`.frm-ifre-${id}`).css({width: "75%", height: "", bottom: "auto"}); $(`.frm-ifre-${id} .ld-frm-src`).css({width: "100%"}); $(`.frm-ifre-${id} .frm-bdy`).removeClass("d-none"); $("#list-page").css({filter: "blur(2px)", opacity: "0.5"}); }); $(`.frm-ifre-${number} .compress`).on("click", function () { let id = $(this).attr("data-unid"); $(this).addClass("d-none"); $(this).siblings(".maximum").removeClass("d-none"); $(`.frm-ifre-${id}`).css({width: "", bottom: ""}); $(`.frm-ifre-${id} .ld-frm-src`).css({width: ""}); $("#list-page").css({filter: "", opacity: ""}); }); $(`.frm-ifre-${number} .close`).on("click", function () { let id = $(this).attr("data-unid"); $("#list-page").css({filter: "unset", opacity: "1"}); $(`.frm-ifre-${id}`).remove(); }); } function loadData() { getData( "apis/v4/unibase/reminders/platform/getunreadreminders/ReminderType/6/PageSize/20" ).then(function (result) { let response = JSON.parse(result.result); if (response.length != 0) { // Notifcations let bdyUI = '
    '; for (var i = 0; i < response.length; i++) { bdyUI += `
  • `; } bdyUI += "
    "; $(".bdy-ul").append(bdyUI); $(".notifiListItms").on("click", function () { let _this = $(this).parents(".item-li"); let obj = { FromDate: "2022/11/30", InstalledAppId: Number($(_this).attr("data-installedAppId")), RecordId: Number($(_this).attr("data-ref")), ToDate: "2022/11/30", }; //let obj = { "FromDate": "2022/11/30", "InstalledAppId": 102530270000109, "RecordId": 102533490346298, "ToDate": "2022/11/30" }; getDataObj( "apis/v4/unibase/platform/widgets/getdefaultwidget", obj, true, "POST" ).then(function (response) { let res = JSON.parse(response.result), html = ""; if (response.message == "200" && response.errors == null) { html = ``; } else { html += ``; } $(_this).find(".accordion-body").html(html); detailClick(); }); }); } }); getData( "apis/v4/unibase/reminders/platform/getunreadreminders/ReminderType/1/PageSize/20" ).then(function (tskResp) { let response = JSON.parse(tskResp.result); if (response.length != 0) { let _tskhtml = '
    '; for (var i = 0; i < response.length; i++) { _tskhtml += `
    • Confirm
    • Reject
    • Close
    • Details-Page
  • `; } _tskhtml += "
    "; $(".bdy-ul").append(_tskhtml); detailClick(); } }); // create button apps load let appName = []; getData("apis/v4/unibase/platform/apps/myapps").then(function (res) { let response = JSON.parse(res.result); jQuery.each(response, async function (index, item) { let installedAppId = Number(item.MyAppId); await getData( `apis/v4/unibase/platform/apps/listappconfigurations/installedappid/${installedAppId}` ).then(function (result) { if ( result.result != null && result.result != "" && result.result != "[]" ) { let _data = JSON.parse(result.result); let data = _data.filter((x) => x.SettingUrlType == 1); if (data.length != 0) { appName.push({ SettingUrlType: data[0].SettingUrlType, AppTitle: data[0].AppTitle, FormId: data[0].FormId, InstalledAppId: data[0].InstalledAppId, RoleSettingAppId: data[0].RoleSettingAppId, InstalledAppGuid: data[0].InstalledAppGuid, AppConfigurationId: data[0].AppConfigurationId, AppPermissionId: data[0].AppPermissionId, AppConfigType: data[0].AppConfigType, }); } } }); await createLoad(appName); }); }); } export function detailClick() { $(".detailBtn").click(function () { let serverUrl = _serverUrl(); $(".bdy-ul").addClass("d-none"); let installedAppId = +$(this).attr("data-appId"); let recordId = +$(this).attr("data-recordId"); // Unibase.Themes.Compact.Components.Notification.Instance().loadReminderDetails(105013010001972,105010260000090,'Details','null',6,0,null) const cookie = getCookie("_idty"); if (cookie) { const {unibaseId, tenantId, userId} = JSON.parse(cookie); debugger; $("#detailIframe").html( `` ); } }); } export function initListIndex() { let _userInfo = atob(document.cookie.split("=")[1]); let userInfo = " JSON.parse(_userInfo).result"; let sessionId = "userInfo.sessionId"; let usrinfoHTML = `
  • ${userInfo.name}
  • Cloud Settings
  • Help
  • Logoff
  • `; $(".icn-circle").text(userInfo?.name?.charAt(0)?.toUpperCase()); $(".uindtls").html(usrinfoHTML); // List Page loading /*Data loading start here*/ $(".mnNvIcn").click(function () { $(".lft-nav-bar").toggleClass("lft-nav-bar-Wrap"); $(".ctr-lst-pge").toggleClass("lft-nav-bar-Wrap"); }); $(".mre-drp a.sub-nav-item.more").on("click", function () { $(".sub-nav-item").removeClass("active"); if ($(this)[0].className.includes("active")) { $(this).find("i").css("transform", "rotate(0deg)"); $(this).removeClass("active"); } else { $(this).find("i").css("transform", "rotate(180deg)"); $(this).addClass("active"); } $(this).siblings(".ul-drpdown").toggleClass("d-none"); }); $("a.sub-nav-item") .not(".more.active") .on("click", function () { $(".sub-nav-item").not(".more.active").removeClass("active"); $(this).addClass("active"); }); loadData(); }