New UI layout
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

list.index.js 30KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. /*Data loading start here*/
  2. import {getCookie, isAuthenticated} from "./cookiehelper.js";
  3. import {getData, getDataObj} from "./base.js";
  4. import {_serverUrl} from "./setting.js";
  5. export var connection;
  6. export function dateTimeFormat(dateTime) {
  7. var date = moment.utc(dateTime).local();
  8. var difmonths = moment().diff(date, "months");
  9. if (difmonths == 0) {
  10. return moment(dateTime).fromNow();
  11. }
  12. return date.format("DD MMM, YYYY HH:mm");
  13. }
  14. function createLoad(data) {
  15. let html = "";
  16. if (data.length != 0) {
  17. for (var i = 0; i < data.length; i++) {
  18. html += `<li class="p-0">
  19. <a href="javascript:;" class="dropdown-item create-form-btn" data-AppConfigType="${data[i].AppConfigType}" data-AppPermissionId="${data[i].AppPermissionId}" data-AppConfigurationId="${data[i].AppConfigurationId}" data-formid="${data[i].FormId}" data-installedAppid="${data[i].InstalledAppId}">${data[i].AppTitle}</a>
  20. </li>`;
  21. }
  22. } else {
  23. html += `<li class="p-0">Apps are Not Installed</li>`;
  24. }
  25. $("#crte-btn-lst").html(html);
  26. $(".create-form-btn").on("click", function () {
  27. const date = new Date();
  28. let number = date.getTime();
  29. let serverUrl = _serverUrl();
  30. let appName = $(this).text();
  31. let formId = $(this).attr("data-formid");
  32. let installedAppId = $(this).attr("data-installedappid");
  33. let appConfigurationId = $(this).attr("data-appconfigurationid");
  34. let pk_id = 0;
  35. const cookie = getCookie("_idty");
  36. let fomrhtml = "";
  37. let width = iFrmeWdth();
  38. if (cookie) {
  39. const {unibaseId, tenantId, userId} = JSON.parse(cookie);
  40. fomrhtml = `<div>
  41. <div class="frm-ifre frm-ifre-${number}" data-formId="${formId}" id="frm-ifre-${number}" style="right:${width}px">
  42. <div>
  43. <ul class="m-0 p-0">
  44. <li class="frm-hdr d-none" data-frm_hdr="true">
  45. <div class="app-title-ifrm">${appName}</div>
  46. <div class="ctrl">
  47. <a href="javascript:;" class="minimize" data-unid="${number}" data-ispopup="true"><span><i class="la la-minus"></i></span></a>
  48. <a href="javascript:;" class="maximum" data-unid="${number}"><span><i class="la la-expand"></i></span></a>
  49. <a href="javascript:;" class="compress d-none" data-unid="${number}"><span><i class="las la-compress"></i></span></a>
  50. <a href="javascript:;" class="close" data-unid="${number}"><span><i class="la la-times"></i></span></a>
  51. </div>
  52. </li>
  53. <li class="frm-bdy">
  54. <iframe class="ld-frm-src" data-ispopup="false" src="${serverUrl}#/${unibaseId}/${tenantId}/${userId}/${installedAppId}/${formId}/0/${appConfigurationId}/false/0/loadform"></iframe>
  55. </li>
  56. <li class="frm-ftr"></li>
  57. </ul>
  58. </div>
  59. </div>
  60. </div>`;
  61. }
  62. $("#list-page").parent("body").append(fomrhtml);
  63. window.window.postMessage("ld-frm-ifrme", "*");
  64. hdrCrtnClckEvnt(number);
  65. });
  66. }
  67. function hdrCrtnClckEvnt(number) {
  68. $(`.frm-ifre-${number} .minimize`).on("click", function () {
  69. let id = $(this).attr("data-unid");
  70. let isPopUpState = $(this).attr("data-ispopup");
  71. let height = $(`.frm-ifre-${id}`).find(".frm-hdr").height();
  72. $(".list-page").css({filter: "unset", opacity: 1});
  73. $(`.frm-ifre-${id} .frm-bdy`).toggleClass("d-none");
  74. if (isPopUpState == "true") {
  75. // popup large
  76. $(this).attr("data-ispopup", "false");
  77. $(this).parents('.frm-hdr').removeClass('d-none').attr('data-frm_hdr', 'false');
  78. $(`.frm-ifre-${id} .maximum`).addClass("d-none");
  79. $(`.frm-ifre-${id} .minimize`).attr("data-ispopup", "false");
  80. $(`.frm-ifre-${id}`).parent().removeClass("wrap-iframe");
  81. $(`.frm-ifre-${id}`).attr("data-ispop_up", "false");
  82. $(`.frm-ifre-${id}`).css({
  83. width: "20%",
  84. height: height,
  85. bottom: "0px",
  86. });
  87. } else {
  88. // popup small
  89. $(this).attr("data-ispopup", "true");
  90. $(this).parents('.frm-hdr').addClass('d-none').attr('data-frm_hdr', 'true');
  91. $(`.frm-ifre-${id} .maximum`).removeClass("d-none");
  92. $(`.frm-ifre-${id} .minimize`).attr("data-ispopup", "true");
  93. $(`.frm-ifre-${id}`).attr("data-ispop_up", "true");
  94. $(`.frm-ifre-${id}`).css({
  95. width: "",
  96. height: "",
  97. bottom: "",
  98. });
  99. if($(this).parents('.frm-hdr').attr("data-saveform") == 'true'){
  100. $(this).parents('.frm-hdr').removeClass('d-none')
  101. }
  102. }
  103. resetwidth();
  104. });
  105. $(`.frm-ifre-${number} .maximum`).on("click", function () {
  106. let id = $(this).attr("data-unid");
  107. $(this).addClass("d-none");
  108. $(this).siblings(".compress").removeClass("d-none");
  109. $(`.frm-ifre-${id}`).find(".ld-frm-src").attr("data-ispopup", "true");
  110. $(`.frm-ifre-${id}`).parent().addClass("wrap-iframe");
  111. $(`.frm-ifre-${id}`).css({width: "75%", position: "unset"});
  112. $(`.frm-ifre-${id} .ld-frm-src`).css({width: "100%"});
  113. $(`.frm-ifre-${id} .frm-bdy`).removeClass("d-none");
  114. $("#list-page").css({filter: "blur(2px)", opacity: "0.5"});
  115. $(`.frm-ifre-${id}`).find(".minimize").toggleClass("d-none");
  116. });
  117. $(`.frm-ifre-${number} .compress`).on("click", function () {
  118. let id = $(this).attr("data-unid");
  119. $(this).addClass("d-none");
  120. $(this).siblings(".maximum").removeClass("d-none");
  121. $(`.frm-ifre-${id}`).parent().removeClass("wrap-iframe");
  122. $(`.frm-ifre-${id}`).css({width: "", position: ""});
  123. $(`.frm-ifre-${id} .ld-frm-src`).css({width: ""});
  124. $("#list-page").css({filter: "", opacity: ""});
  125. $(`.frm-ifre-${id}`).find(".minimize").toggleClass("d-none");
  126. });
  127. $(`.frm-ifre-${number} .close`).on("click", function () {
  128. let id = $(this).attr("data-unid");
  129. $("#list-page").css({filter: "unset", opacity: "1"});
  130. $(`.frm-ifre-${id}`).parent().remove();
  131. resetwidth();
  132. });
  133. }
  134. function loadData(ApiPath, isSentBy) {
  135. $(".bdy-ul").empty().removeClass("d-none");
  136. $(".hdr-ul").removeClass("d-none");
  137. getData(ApiPath).then(function (result) {
  138. let response = JSON.parse(result.result),
  139. html = "";
  140. const cookie = getCookie("_idty");
  141. if (response.length != 0) {
  142. response.forEach(function (Item, index) {
  143. let isSent = false;
  144. if (Item.FromUserName == JSON.parse(cookie).name) {
  145. isSent = true;
  146. }
  147. if (Item.FromUserName == null) {
  148. Item.FromUserName = 'Please check it Notification Team';
  149. }
  150. //if(window.innerWidth >1024){ // Desktop Width
  151. html += `<li class="pdng lst-Notifi" data-ReminderTypeId="${Item.ReminderTypeId}" data-reminderurl="${Item.ReminderUrl}" data-reminderId="${Item.ReminderId}" data-isreaded="${Item.ReminderStatusId}" data-issentby=${isSent} data-refId="${Item.RedirectOptions.RefId}" data-instlledAppId="${Item.RedirectOptions.InstalledAppId}" data-formid="${Item.RedirectOptions.CreateFormId}" data-urlType="${Item.UrlType}">`;
  152. html += `<div class="flex-shrink-0 wi-chck"><div class="wi-item ml-0"><input class="form-check-input mr-2" type="checkbox" value="" id="flexCheckDefault"></div><div class="wi-item">`;
  153. if (Item.ReminderTypeId == 1) {
  154. html += `<i class="ri-star-fill" style="opacity:0.6"></i>`;
  155. } else {
  156. html += `<i class="ri-star-line"></i>`;
  157. }
  158. html += `</div></div>`; // check-box
  159. html += `<div class="wi-sbjt-msge mx-1">`;
  160. html += `<div class="wi-from wi-item text-truncate"><span data-isreaded="${Item.ReminderStatusId}">${Item.FromUserName}</span></div>`;
  161. html += `<div class="wi-sbjt wi-item text-truncate flex-shrink-1"><span class="mx-2">${Item.Subject}</span></div><div>-</div>`; // Subject
  162. html += `<div class="wi-msge wi-item text-truncate"><span class="mx-2">${Item.Message}</span></div>`; // Message
  163. html += `</div>`;
  164. html += `<div class="wi-time time flex-shrink-0 ml-auto"><span>${dateTimeFormat(
  165. Item.ReminderDate
  166. )}</span></div>`;
  167. html += `<div class="hover">
  168. <ul>`;
  169. if (Item.RedirectOptions.CreateFormId != 0) {
  170. html += ` <li class="mx-2 hover-item"><a class="formBtn" data-urltype="Form" href="javascript:;"><i class="ri-store-line"></i></a></li>`;
  171. } else {
  172. html += ` <li class="mx-2 hover-item"><a class="detailBtn" data-urltype=${Item.UrlType} href="javascript:;"><i class="ri-information-line"></i></a></li>`;
  173. }
  174. html += ` </ul>
  175. </div>`;
  176. html += "</li>";
  177. /* }else{ // Mobile Width card view
  178. html += `<li class="pdng lst-Notifi" data-ReminderTypeId="${Item.ReminderTypeId}" data-reminderurl="${Item.ReminderUrl}" data-reminderId="${Item.ReminderId}" data-isreaded="${Item.ReminderStatusId}" data-issentby=${isSent} data-refId="${Item.RedirectOptions.RefId}" data-instlledAppId="${Item.RedirectOptions.InstalledAppId}" data-formid="${Item.RedirectOptions.CreateFormId}" data-urlType="${Item.UrlType}">`
  179. html += ` <div><span class="align-items-center d-flex justify-content-center sdr-nme fs-4">S</span></div>
  180. <div class="d-flex flex-column ms-2 w-100">
  181. <div class="d-flex justify-content-between align-items-baseline">
  182. <span class="me-2 text-truncate">${Item.FromUserName}</span>
  183. <span class="w-60p text-truncate font-11">${dateTimeFormat(
  184. Item.ReminderDate
  185. )}</span>
  186. </div>
  187. <div><span class="fw-500">${Item.Subject}</span></div>
  188. <div class="d-flex justify-content-between"><span>${Item.Message}</span><span>`;
  189. if (Item.ReminderTypeId == 1) {
  190. html += `<i class="ri-star-fill" style="opacity:0.6"></i>`;
  191. } else {
  192. html += `<i class="ri-star-line"></i>`;
  193. }
  194. html += `</span></div>
  195. </div>`
  196. html +=`</li>`
  197. }*/
  198. });
  199. $(".ctr-lst-pge .bdy-ul").html(html);
  200. if (isSentBy) {
  201. $(".pdng.lst-Notifi").addClass("d-none");
  202. $(".pdng.lst-Notifi[data-issentby='true']").removeClass("d-none");
  203. }
  204. detailClick();
  205. //stagesLoad();
  206. }
  207. });
  208. getData("apis/v4/unibase/reminders/platform/getunreadreminderscount").then(
  209. function (response) {
  210. let result = JSON.parse(response.result);
  211. let count = Number(result.NotificationCount) + Number(result.TasksCount);
  212. $('[data-buttontype="inbox"] .length.rounded-pill').remove();
  213. $('[data-buttontype="inbox"]').append(
  214. `<span class="length badge rounded-pill bg-light text-dark ml-auto" data-TasksCount="${result.TasksCount}" data-notifiCount="${result.NotificationCount}">${count}</span>`
  215. );
  216. $('[data-notification="count"]').text(count);
  217. if (count > 40) {
  218. $('[data-paggtn="true"]').text(`1-40`);
  219. } else {
  220. $(".li-pgn").empty();
  221. }
  222. }
  223. );
  224. if(window.innerWidth < 1024){
  225. $('.ctr-lst-pge').on('click', function(){
  226. $('.mnNvIcn').click()
  227. })
  228. }
  229. }
  230. function iFrmeWdth() {
  231. let width = 0,
  232. erwdth = 15;
  233. $(".frm-ifre").each(function (i, e) {
  234. if ($(this).length == 0) {
  235. erwdth = 0;
  236. }
  237. if (window.innerWidth > width) {
  238. width = width + $(this).width() + erwdth;
  239. }
  240. });
  241. return width;
  242. }
  243. function resetwidth() {
  244. let width = 0,
  245. erwdth = 15;
  246. $(".frm-ifre").each(function (i, e) {
  247. if (i == 0) {
  248. $(this).css("right", width + "px");
  249. }
  250. if (i != 0) {
  251. $(this).css("right", width + "px");
  252. }
  253. if (window.innerWidth > width) {
  254. width = width + $(this).width() + erwdth;
  255. }
  256. });
  257. }
  258. export function detailClick() {
  259. // Details Popup Abihram popup page
  260. $(".wi-sbjt-msge").on("click", function (e) {
  261. e.stopPropagation();
  262. detailsPage(this, true, "Details-page");
  263. });
  264. // Details Page Loading
  265. $(".detailBtn[data-urltype='Details']").click(function (e) {
  266. e.stopPropagation();
  267. detailsPage(this, false, "Details-page");
  268. });
  269. //Form Page Loading
  270. $(".formBtn[data-urltype='Form']").on("click", function (e) {
  271. e.stopPropagation();
  272. detailsPage(this, true, "Form-page");
  273. });
  274. //List Page Loading
  275. $("[data-urltype='List']").on("click", function (e) {
  276. e.stopPropagation();
  277. detailsPage(this, true, "List-page");
  278. });
  279. // get stages
  280. }
  281. export function detailsPage(e, ifrmPopup, isPage) {
  282. let serverUrl = _serverUrl();
  283. $(".bdy-ul").addClass("d-none");
  284. $(".hdr-ul").addClass("d-none");
  285. let installedAppId = $(e)
  286. .parents(".pdng.lst-Notifi")
  287. .attr("data-instlledappid");
  288. let recordId = $(e).parents(".pdng.lst-Notifi").attr("data-refid");
  289. let reminderid = $(e).parents(".pdng.lst-Notifi").attr("data-reminderid");
  290. let remindertype = $(e)
  291. .parents(".pdng.lst-Notifi")
  292. .attr("data-remindertypeid");
  293. // Unibase.Themes.Compact.Components.Notification.Instance().loadReminderDetails(105013010001972,105010260000090,'Details','null',6,0,null)
  294. const cookie = getCookie("_idty");
  295. if (cookie) {
  296. const {unibaseId, tenantId, userId} = JSON.parse(cookie);
  297. if (isPage == "Details-page") {
  298. $("#detailIframe").html(
  299. `<iframe width="100%" style="min-height:calc(100vh - ${$(
  300. ".tp-bar"
  301. ).height()}px)"  name="srcframe" id="srcframe" class="srcframe" src="${serverUrl}#/${unibaseId}/${tenantId}/${userId}/${recordId}/${installedAppId}/${remindertype}/${reminderid}/${ifrmPopup}/loadDetail"></iframe>`
  302. );
  303. } else if (isPage == "Form-page") {
  304. getData(
  305. `apis/v4/unibase/platform/apps/listappconfigurations/installedappid/${installedAppId}`
  306. ).then(function (result) {
  307. let _data = JSON.parse(result.result);
  308. let data = _data.filter((x) => x.SettingUrlType == 1);
  309. $("#detailIframe").html(
  310. `<iframe width="100%" style="min-height:calc(100vh - ${$(
  311. ".tp-bar"
  312. ).height()}px)"  name="srcframe" id="srcframe" class="srcframe" src="${serverUrl}#/${unibaseId}/${tenantId}/${userId}/${installedAppId}/${
  313. data[0].FormId
  314. }/0/${
  315. data[0].AppConfigurationId
  316. }/${reminderid}/${ifrmPopup}/loadform"></iframe>`
  317. );
  318. });
  319. } else if (isPage == "List-page") {
  320. $("#detailIframe").html(
  321. `<iframe width="100%" style="min-height:calc(100vh - ${$(
  322. ".tp-bar"
  323. ).height()}px)"  name="srcframe" id="srcframe" class="srcframe" src="${serverUrl}#/${unibaseId}/${tenantId}/${userId}/${installedAppId}/${reminderid}/${ifrmPopup}/loadList"></iframe>`
  324. );
  325. }
  326. }
  327. }
  328. export function signaRInit() {
  329. var huburl = _serverUrl() + "notificationhub";
  330. connection = new window["signalR"].HubConnectionBuilder()
  331. .withUrl(huburl)
  332. .build();
  333. register();
  334. }
  335. export async function register() {
  336. connection.on("sendnotification", (obj) => {
  337. $(".ctr-lst-pge .bdy-ul").empty();
  338. loadData(
  339. "apis/v4/unibase/reminders/platform/getuserreminders/PageSize/0",
  340. false
  341. );
  342. });
  343. const cookie = getCookie("_idty");
  344. const {unibaseId, tenantId, userId, sessionId, name} = JSON.parse(cookie);
  345. let packet = {
  346. UserId: Number(userId),
  347. UserName: name,
  348. UnibaseId: unibaseId,
  349. TenantId: Number(tenantId),
  350. SessionId: sessionId,
  351. };
  352. try {
  353. const stringConnection = await connection.start();
  354. await connection.invoke("Connect", packet);
  355. } catch (error) {
  356. console.log(error);
  357. }
  358. }
  359. export function resetClckEvnt() {
  360. $(".ChtAppIfrme").remove();
  361. $(".lft-nav-bar .lft-nav-bar-2").removeClass("d-none");
  362. $(".ctr-lst-pge, .rtr-nav-bar").removeClass("d-none");
  363. $(".lft-nav-bar").css("width", "");
  364. }
  365. export function initListIndex() {
  366. let userInfo = JSON.parse(getCookie("_idty"));
  367. let sessionId = userInfo.sessionId;
  368. signaRInit();
  369. let usrinfoHTML = `<li><a class="dropdown-item text-capitalize" href="javascript:void(0);">${userInfo.name}</a></li>
  370. <li><a class="dropdown-item" href="javascript:void(0);">Help</a></li>
  371. <li><a class="dropdown-item" href="javascript:void(0);" data-btn="logoff">Logoff</a></li>`;
  372. $(".icn-circle").text(userInfo?.name?.charAt(0)?.toUpperCase());
  373. $(".uindtls").html(usrinfoHTML);
  374. $('[data-btn="logoff"]').on("click", function () {
  375. document.cookie = "_idty=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
  376. window.location = "../login";
  377. });
  378. // List Page loading
  379. /*Data loading start here*/
  380. $(".nav-lft-item").on("click", function () {
  381. $(".nav-lft-item").removeClass("active");
  382. $(this).addClass("active");
  383. if ($(this).attr("data-application") != "Chat Application") {
  384. resetClckEvnt();
  385. }
  386. });
  387. $(".nav-lft-item[data-application='Chat Application']").on(
  388. "click",
  389. function () {
  390. const serverUrl = _serverUrl();
  391. const cookie = getCookie("_idty");
  392. const {unibaseId, tenantId, userId} = JSON.parse(cookie);
  393. $(".lft-nav-bar .lft-nav-bar-2").addClass("d-none");
  394. $(".ctr-lst-pge, .rtr-nav-bar").addClass("d-none");
  395. $(".lft-nav-bar").css("width", "var(--rtrWidth)");
  396. $(".btm-bar .ChtAppIfrme").remove();
  397. $(".btm-bar").append(`<div class="ChtAppIfrme w-100">
  398. <iframe class="" style="height:100%; width:100%" data-ispopup="false" src="${serverUrl}#/${unibaseId}/${tenantId}/${userId}/loadChat"></iframe>
  399. </div>`);
  400. }
  401. );
  402. $(".mnNvIcn").click(function () {
  403. $(".lft-nav-bar").toggleClass("lft-nav-bar-Wrap");
  404. $(".ctr-lst-pge").toggleClass("lft-nav-bar-Wrap");
  405. if ($(".apps-loading:visible").length != 0) {
  406. $(".ctr-lst-pge").css("width", "");
  407. $(".ctr-lst-pge").toggleClass("apps-loaded");
  408. $(".ctr-lst-pge").toggleClass("apps-loaded-tr");
  409. }
  410. if(window.innerWidth < 1025){
  411. $(".ctr-lst-pge").toggleClass('d-block');
  412. $(".lft-nav-bar").toggleClass("lft-nav-bar-Wrap d-flex w-100").css('background-color','rgb(0 0 0 / 50%)');
  413. }
  414. });
  415. $(".mre-drp a.sub-nav-item.more").on("click", function () {
  416. $(".sub-nav-item").removeClass("active");
  417. if ($(this)[0].className.includes("active")) {
  418. $(this).find("i").css("transform", "rotate(0deg)");
  419. $(this).removeClass("active");
  420. } else {
  421. $(this).find("i").css("transform", "rotate(180deg)");
  422. $(this).addClass("active");
  423. }
  424. $(this).siblings(".ul-drpdown").toggleClass("d-none");
  425. });
  426. $("a.sub-nav-item")
  427. .not(".more.active")
  428. .on("click", function () {
  429. $(".sub-nav-item").not(".more.active").removeClass("active");
  430. $(this).addClass("active");
  431. });
  432. $('[data-buttontype="inbox"], [data-application="Mail Application"]').on(
  433. "click",
  434. function () {
  435. $("#detailIframe").empty();
  436. loadData(
  437. "apis/v4/unibase/reminders/platform/getuserreminders/PageSize/0",
  438. false
  439. );
  440. }
  441. );
  442. window.addEventListener("message", function (e) {
  443. if (e.data != undefined) {
  444. if(e.data == "Edit-form"){
  445. $('.frm-hdr').addClass('d-none')
  446. }
  447. if (e.data == "closeForm") {
  448. $("#detailIframe").empty();
  449. $(".hdr-ul, .bdy-ul").removeClass("d-none");
  450. $('.frm-bdy [class="close"]')[0].click();
  451. }
  452. if (e.data == "clickToBack") {
  453. $("#detailIframe").empty();
  454. loadData(
  455. "apis/v4/unibase/reminders/platform/getuserreminders/PageSize/0",
  456. false
  457. );
  458. }
  459. if (e.data.includes("save-form")) {
  460. let spilt = e.data.split("/");
  461. $(`.frm-ifre[data-formid="${spilt[1]}"] .frm-hdr`).removeClass(
  462. "d-none"
  463. ).attr('data-frm_hdr','false');
  464. }
  465. if (e.data == "close apps") {
  466. $("body").removeClass("d-flex flex-row");
  467. $("#detailIframe").empty();
  468. $(".hdr-ul, .bdy-ul").removeClass("d-none");
  469. $(".apps-loading").remove();
  470. $("#list-page").css("width", "100%");
  471. $(".lft-nav-bar").removeClass(".lft-nav-bar-Wrap");
  472. $(".ctr-lst-pge").removeClass("apps-loaded");
  473. $(".ctr-lst-pge").removeClass("apps-loaded-tr");
  474. }
  475. if (e.data.includes("/")) {
  476. let spilt = e.data.split("/");
  477. $(
  478. `.frm-ifre[data-formid="${spilt[1]}"] .frm-hdr .ctrl .${spilt[0]}`
  479. ).click();
  480. if(spilt[0].includes('success')){
  481. $(`.frm-ifre[data-formid="${spilt[1]}"] .frm-hdr`).removeClass("d-none").attr({'data-frm_hdr': 'false', 'data-saveform':'true'});
  482. }
  483. if(!spilt[0].includes('maximum') && !spilt[0].includes('compress')){
  484. $(`.frm-ifre[data-formid="${spilt[1]}"] .frm-hdr`).removeClass("d-none").attr({'data-frm_hdr': 'false'});
  485. }
  486. }
  487. if (e.data == "closeForm_detailIframe") {
  488. $("#detailIframe").empty();
  489. $(".hdr-ul, .bdy-ul").removeClass("d-none");
  490. }
  491. }
  492. });
  493. $('[class="refrsh"]').on("click", function () {
  494. loadData(
  495. "apis/v4/unibase/reminders/platform/getuserreminders/PageSize/0",
  496. false
  497. );
  498. });
  499. getData("apis/v4/unibase/platform/apps/myapps").then(function (response) {
  500. if(response.message.includes("User Authentication Failed")){
  501. window.location = "../login";
  502. }else{
  503. let result = JSON.parse(response.result);
  504. let html = "<li class='m-0 p-0'><ul class='d-flex flex-wrap m-0 p-0'>";
  505. for (var i = 0; i < result.length; i++) {
  506. html += `<li class="appsBind" data-myappid="${result[i].MyAppId}">`;
  507. if (
  508. result[i].SvgIconUrl != undefined &&
  509. result[i].SvgIconUrl != null &&
  510. result[i].SvgIconUrl != ""
  511. ) {
  512. html += `<span class="svg-icons">${result[i].SvgIconUrl}</span>`;
  513. } else {
  514. html +=
  515. '<span class="svg-icons"><svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"> <path class="biz-svg-highlight-color" d="M16.01,31c-1.38,0-2.77-.09-4.14-.28-3.57-.49-6.58-1.42-9.21-2.86-.25-.14-.53-.42-.57-.71-.02-.19-.05-.37-.07-.56-.17-1.33-.34-2.7-.12-4.09,.31-1.92,1.27-3.07,2.95-3.5,1.88-.49,3.74-1.32,5.7-2.55,.07-.04,.14-.08,.24-.13,.04-.02,.09-.05,.15-.08l.28-.15,2.84,8.94c.03-.07,.05-.14,.08-.21,.05-.14,.1-.28,.15-.42,.19-.51,.38-1.04,.53-1.56,0,0,0-.01,0-.02-.03-.03-.05-.07-.06-.11l-1.46-3.77c-.06-.14-.04-.31,.05-.44,.09-.13,.23-.2,.39-.2h4.52c.16,0,.3,.08,.39,.2,.09,.13,.11,.29,.05,.44l-1.46,3.77s-.04,.09-.07,.13c.01,.05,.02,.09,.04,.14,.23,.6,.45,1.22,.66,1.82,.03,.07,.05,.15,.08,.22l2.83-8.89,.28,.14c.35,.18,.7,.37,1.04,.55,.79,.42,1.53,.81,2.3,1.16,.91,.41,1.82,.74,2.72,.98,1.71,.45,2.69,1.61,2.99,3.54h0c.22,1.38,.04,2.74-.13,4.06-.03,.2-.05,.39-.08,.59-.04,.33-.39,.6-.58,.7-2.61,1.43-5.61,2.36-9.16,2.85-1.38,.19-2.77,.28-4.16,.28Zm-5.11-14.14s-.05,.03-.07,.04c-2,1.26-3.91,2.11-5.85,2.61-1.48,.38-2.29,1.36-2.56,3.07-.21,1.31-.04,2.65,.12,3.94,.02,.19,.05,.37,.07,.56,0,.06,.14,.22,.29,.31,2.57,1.4,5.52,2.32,9.03,2.8,2.71,.37,5.45,.37,8.16,0,3.49-.48,6.43-1.39,8.98-2.79,.16-.09,.3-.24,.3-.3,.02-.2,.05-.39,.08-.59,.17-1.28,.34-2.6,.13-3.91h0c-.27-1.72-1.1-2.71-2.6-3.11-.93-.25-1.87-.59-2.8-1.01-.79-.36-1.54-.76-2.33-1.18-.25-.13-.5-.27-.75-.4l-3.11,9.79-.27-.74c-.12-.32-.23-.65-.34-.97-.21-.6-.42-1.21-.65-1.81-.06-.15-.09-.29-.1-.43v-.18s.14-.06,.14-.06l1.42-3.66h-4.34l1.42,3.66,.11,.07v.15c0,.1-.01,.19-.03,.27-.16,.54-.35,1.08-.54,1.6-.05,.14-.1,.28-.15,.42-.06,.18-.14,.35-.21,.51-.05,.13-.11,.26-.16,.39l-.27,.71-3.1-9.76Z"></path> <path class="biz-svg-highlight-color" d="M16.09,16.2c-.81,0-1.63-.16-2.42-.48-2.36-.98-3.89-3.26-3.89-5.82,0-.62,.51-1.13,1.13-1.13s1.13,.51,1.13,1.13c0,1.64,.98,3.11,2.5,3.74,1.52,.63,3.25,.28,4.41-.88,1.16-1.16,1.51-2.89,.88-4.41-.63-1.52-2.1-2.5-3.74-2.5h-2.45l.66,.66c.44,.44,.44,1.16,0,1.6-.21,.21-.5,.33-.8,.33s-.59-.12-.8-.33l-2.59-2.59c-.21-.21-.33-.5-.33-.8s.12-.59,.33-.8l2.59-2.59c.21-.21,.5-.33,.8-.33s.59,.12,.8,.33c.21,.21,.33,.5,.33,.8s-.12,.59-.33,.8l-.66,.66h2.45c2.56,0,4.84,1.53,5.82,3.89,.98,2.36,.44,5.06-1.37,6.87-1.21,1.21-2.81,1.85-4.45,1.85Zm-5.18-6.9c-.33,0-.6,.27-.6,.6,0,2.34,1.4,4.44,3.56,5.33,2.16,.9,4.63,.41,6.29-1.25s2.15-4.13,1.25-6.29c-.9-2.16-2.99-3.56-5.33-3.56h-3.74l1.58-1.57c.23-.23,.23-.61,0-.85-.23-.23-.62-.23-.85,0l-2.59,2.59c-.11,.11-.18,.27-.18,.42s.06,.31,.18,.42l2.59,2.59c.23,.23,.62,.23,.85,0,.23-.23,.23-.61,0-.85l-1.58-1.57h3.74c1.86,0,3.52,1.11,4.23,2.83,.71,1.72,.32,3.68-.99,4.99-1.31,1.31-3.27,1.7-4.99,.99-1.72-.71-2.83-2.37-2.83-4.23,0-.33-.27-.6-.6-.6Z"></path> </svg></span>';
  516. }
  517. html += `<span class="appTitle">${result[i].AppTitle}</span></li>`;
  518. }
  519. html += "</ul></li>";
  520. $("#apps-list").html(html);
  521. $(".appsBind").on("click", function () {
  522. let width = "330px";
  523. if(window.innerWidth> 1024){
  524. $("#list-page").css("width", `calc(100% - ${width})`);
  525. }
  526. if( $('.lft-nav-bar-2:visible').length !=0 ){
  527. $(".ctr-lst-pge").addClass("apps-loaded-tr");
  528. }else{
  529. $(".ctr-lst-pge").addClass("apps-loaded lft-nav-bar-Wrap")
  530. }
  531. let installedAppId = $(this).attr("data-myappid");
  532. const cookie = getCookie("_idty");
  533. if (cookie) {
  534. let serverUrl = _serverUrl();
  535. const {unibaseId, tenantId, userId} = JSON.parse(cookie);
  536. $("body").addClass("d-flex flex-row");
  537. $(".apps-loading").remove();
  538. $("#list-page").after(
  539. `<section id="" class="apps-loading"><iframe width="100%" style="height:inherit"  name="lstSrcFrame" id="lstSrcFrame" class="lstSrcFrame" src="${serverUrl}#/${unibaseId}/${tenantId}/${userId}/${installedAppId}/0/false/loadList"></iframe></section>`
  540. );
  541. }
  542. });
  543. }
  544. });
  545. $(".btn.dropdown-toggle.create").on("click", function () {
  546. let appName = [];
  547. getData("apis/v4/unibase/platform/apps/myapps").then(async function (res) {
  548. let response = await JSON.parse(res.result);
  549. jQuery.each(response, async function (index, item) {
  550. let installedAppId = Number(item.MyAppId);
  551. await getData(
  552. `apis/v4/unibase/platform/apps/listappconfigurations/installedappid/${installedAppId}`
  553. ).then(function (result) {
  554. if (
  555. result.result != null &&
  556. result.result != "" &&
  557. result.result != "[]"
  558. ) {
  559. let _data = JSON.parse(result.result);
  560. let data = _data.filter((x) => x.SettingUrlType == 1);
  561. if (data.length != 0) {
  562. appName.push({
  563. SettingUrlType: data[0].SettingUrlType,
  564. AppTitle: data[0].AppTitle,
  565. FormId: data[0].FormId,
  566. InstalledAppId: data[0].InstalledAppId,
  567. RoleSettingAppId: data[0].RoleSettingAppId,
  568. InstalledAppGuid: data[0].InstalledAppGuid,
  569. AppConfigurationId: data[0].AppConfigurationId,
  570. AppPermissionId: data[0].AppPermissionId,
  571. AppConfigType: data[0].AppConfigType,
  572. });
  573. }
  574. }
  575. });
  576. await appName.sort(function (a, b) {
  577. var a1 = a.AppTitle.toLowerCase().trim(), b1 = b.AppTitle.toLowerCase().trim();
  578. if (a1 == b1) return 0;
  579. return a1 > b1 ? 1 : -1;
  580. });
  581. await createLoad(appName);
  582. });
  583. });
  584. });
  585. $('[data-buttontype="Starred"]').on("click", function () {
  586. let count = 20;
  587. if (
  588. $('[data-buttontype="inbox"] .length').attr("data-taskscount") !=
  589. undefined
  590. ) {
  591. count = $('[data-buttontype="inbox"] .length').attr("data-taskscount");
  592. }
  593. loadData(
  594. `apis/v4/unibase/reminders/platform/getunreadreminders/ReminderType/1/PageSize/${count}`,
  595. false
  596. );
  597. });
  598. $('[data-buttontype="unstarred"]').on("click", function () {
  599. let count = 20;
  600. if (
  601. $('[data-buttontype="inbox"] .length').attr("data-notificount") !=
  602. undefined
  603. ) {
  604. count = $('[data-buttontype="inbox"] .length').attr("data-notificount");
  605. }
  606. loadData(
  607. `apis/v4/unibase/reminders/platform/getunreadreminders/ReminderType/6/PageSize/${count}`,
  608. false
  609. );
  610. });
  611. $('[data-buttontype="all"]').on("click", function () {
  612. loadData(
  613. "apis/v4/unibase/reminders/platform/getuserreminders/PageSize/0",
  614. false
  615. );
  616. });
  617. $('[data-buttontype="read"]').on("click", function () {
  618. $(".pdng.lst-Notifi").addClass("d-none");
  619. $(".pdng.lst-Notifi[data-isreaded='2']").removeClass("d-none");
  620. });
  621. $('[data-buttontype="unread"]').on("click", function () {
  622. $(".pdng.lst-Notifi").addClass("d-none");
  623. $(".pdng.lst-Notifi[data-isreaded='8']").removeClass("d-none");
  624. });
  625. $('[data-buttontype="sent"]').on("click", function () {
  626. loadData(
  627. "apis/v4/unibase/reminders/platform/getuserreminders/PageSize/0",
  628. true
  629. );
  630. });
  631. try {
  632. loadData(
  633. "apis/v4/unibase/reminders/platform/getuserreminders/PageSize/0",
  634. false
  635. );
  636. } catch (error) {
  637. console.log("LoadData Method is not loading, and getting error");
  638. }
  639. }
  640. export function stagesLoad() {
  641. $(".stgs-li").each(function () {
  642. let html = "";
  643. let InstalledAppId = $(this).attr("data-installedappid");
  644. getData(
  645. `apis/v4/unibase/platform/apps/getallchangestageroles/installedappid/${InstalledAppId}`
  646. ).then(function (stg_rslt) {
  647. let data = JSON.parse(stg_rslt.result);
  648. let _stage = data.filter(function (o) {
  649. return o.IsDefault == true;
  650. });
  651. html += `<button type="button" class="btn btn-sm btn-info dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" data-isdefault="${_stage[0].IsDefault}" data-stageid="${_stage[0].StageId}" >
  652. ${_stage[0].StageName}
  653. </button>
  654. <ul class="dropdown-menu">`;
  655. for (var s = 0; s < data.length; s++) {
  656. let stage = data[s];
  657. if (!stage.IsDefault) {
  658. html += `<li><a class="dropdown-item" href="javascript:;" data-isdefault="${stage.IsDefault}" data-stageid="${stage.StageId}">${stage.StageName}</a></li>`;
  659. }
  660. }
  661. html += "</ul>";
  662. $(`.stgs-li[data-installedappid='${InstalledAppId}']`).html(html);
  663. });
  664. });
  665. }