/*Data loading start here*/
import {getCookie, isAuthenticated} from "./cookiehelper.js";
import {getData, getDataObj} from "./base.js";
import {_serverUrl} from "./setting.js";
export var connection;
export function dateTimeFormat(dateTime) {
var date = moment.utc(dateTime).local();
var difmonths = moment().diff(date, "months");
if (difmonths == 0) {
return moment(dateTime).fromNow();
}
return date.format("DD MMM, YYYY HH:mm");
}
function createLoad(data) {
let html = "";
if (data.length != 0) {
for (var i = 0; i < data.length; i++) {
html += `
`;
}
$("#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 = "";
let width = iFrmeWdth();
if (cookie) {
const {unibaseId, tenantId, userId} = JSON.parse(cookie);
fomrhtml = `
${appName}
`;
}
$("#list-page").parent("body").append(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();
$(".list-page").css({filter: "unset", opacity: 1});
$(`.frm-ifre-${id} .frm-bdy`).toggleClass("d-none");
if (isPopUpState == "true") {
// popup large
$(this).attr("data-ispopup", "false");
$(this).parents('.frm-hdr').removeClass('d-none').attr('data-frm_hdr', 'false');
$(`.frm-ifre-${id} .maximum`).addClass("d-none");
$(`.frm-ifre-${id} .minimize`).attr("data-ispopup", "false");
$(`.frm-ifre-${id}`).parent().removeClass("wrap-iframe");
$(`.frm-ifre-${id}`).attr("data-ispop_up", "false");
$(`.frm-ifre-${id}`).css({
width: "20%",
height: height,
bottom: "0px",
});
} else {
// popup small
$(this).attr("data-ispopup", "true");
$(this).parents('.frm-hdr').addClass('d-none').attr('data-frm_hdr', 'true');
$(`.frm-ifre-${id} .maximum`).removeClass("d-none");
$(`.frm-ifre-${id} .minimize`).attr("data-ispopup", "true");
$(`.frm-ifre-${id}`).attr("data-ispop_up", "true");
$(`.frm-ifre-${id}`).css({
width: "",
height: "",
bottom: "",
});
if($(this).parents('.frm-hdr').attr("data-saveform") == 'true'){
$(this).parents('.frm-hdr').removeClass('d-none')
}
}
resetwidth();
});
$(`.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}`).parent().addClass("wrap-iframe");
$(`.frm-ifre-${id}`).css({width: "75%", position: "unset"});
$(`.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-${id}`).find(".minimize").toggleClass("d-none");
});
$(`.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}`).parent().removeClass("wrap-iframe");
$(`.frm-ifre-${id}`).css({width: "", position: ""});
$(`.frm-ifre-${id} .ld-frm-src`).css({width: ""});
$("#list-page").css({filter: "", opacity: ""});
$(`.frm-ifre-${id}`).find(".minimize").toggleClass("d-none");
});
$(`.frm-ifre-${number} .close`).on("click", function () {
let id = $(this).attr("data-unid");
$("#list-page").css({filter: "unset", opacity: "1"});
$(`.frm-ifre-${id}`).parent().remove();
resetwidth();
});
}
function loadData(ApiPath, isSentBy) {
$(".bdy-ul").empty().removeClass("d-none");
$(".hdr-ul").removeClass("d-none");
getData(ApiPath).then(function (result) {
let response = JSON.parse(result.result),
html = "";
const cookie = getCookie("_idty");
if (response.length != 0) {
response.forEach(function (Item, index) {
let isSent = false;
if (Item.FromUserName == JSON.parse(cookie).name) {
isSent = true;
}
if (Item.FromUserName == null) {
Item.FromUserName = 'Please check it Notification Team';
}
//if(window.innerWidth >1024){ // Desktop Width
html += `
`;
html += `
`;
if (Item.ReminderTypeId == 1) {
html += ``;
} else {
html += ``;
}
html += `
`; // check-box
html += `
`;
html += `
${Item.FromUserName}
`;
html += `
${Item.Subject}
-
`; // Subject
html += `
${Item.Message}
`; // Message
html += `
`;
html += `
${dateTimeFormat(
Item.ReminderDate
)}
`;
html += `
`;
if (Item.RedirectOptions.CreateFormId != 0) {
html += `