Built files from Bizgaze WebServer
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.

dashboard.js 79KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  1. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3. return new (P || (P = Promise))(function (resolve, reject) {
  4. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  5. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  6. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  7. step((generator = generator.apply(thisArg, _arguments || [])).next());
  8. });
  9. };
  10. var Unibase;
  11. (function (Unibase) {
  12. let Themes;
  13. (function (Themes) {
  14. let Compact;
  15. (function (Compact) {
  16. let Components;
  17. (function (Components) {
  18. class Dashboard extends Unibase.Platform.Core.BaseComponent {
  19. constructor() {
  20. super(...arguments);
  21. this.firstLoad = true;
  22. this.filterClickBtn = true;
  23. this.jsindex = 0;
  24. this.htmlindex = 0;
  25. this.evalExecuted = 0;
  26. this._bizgaze_core_activeinstalledappId = 0;
  27. this._bizgaze_core_activeportletid = 0;
  28. this._dashboard_first_load = 0;
  29. }
  30. jsFiles() {
  31. return ["platform/bundle/dashboard.min.js"];
  32. }
  33. cssFiles() {
  34. return [];
  35. }
  36. html(id, containerid) {
  37. var _a;
  38. let width = $(window).width(), mx;
  39. if (width <= 576) {
  40. mx = 'mx-2';
  41. }
  42. else {
  43. mx = 'mx-20';
  44. }
  45. let isRestrictHidden = '', isSupportHidden = '';
  46. if (Unibase.Platform.Membership.Infos.Identity.currentUser.isRestrictedUser == true) {
  47. isRestrictHidden = 'd-none';
  48. }
  49. let isSupportHeader = window.location.hash;
  50. if (isSupportHeader.includes('ticket')) {
  51. isSupportHidden = 'd-none';
  52. }
  53. var html = `<input type="hidden" id="hf_DashboardPortletId" value="" />
  54. <input type="hidden" id="hf_DashboardPortletName" value="0" />
  55. <input type="hidden" id="hf_PortletId" />
  56. <input type="hidden" id="hf_App_DefaultWidgetId" value="0" />
  57. <input type="hidden" id="hf_AppUniqueId" value="0" />
  58. <div class="biz-db-header pt-10 pb-2 pb-sm-15 px-sm-0 ${mx} invisible" id="bizDbHeader">
  59. <div class="db-top-header d-flex justify-content-between align-items-center position-relative px-0 pb-5" id="dbTopHeader"><div class="db-header-left dashboard-tab d-flex align-items-center w-85">
  60. <div class="d-flex align-items-center biz-highlight-bg-color text-truncate biz-dropdown db-dropdown-wrap">
  61. <span id="lblDbGroup_Title" class="db-group-title font-20 font-weight-600 font-sm-20 text-truncate ${isSupportHidden}">No Dashboards</span><a class="dp-toggle-icon btn btn-icon btn-flush-biz-theme btn-rounded flush-soft-hover d-xl-none flex-shrink-0 ${isRestrictHidden}" href="javascript:;" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="btn-icon-wrap"><i class="fa fa-caret-down"></i></span></a>
  62. <div class="dropdown-menu biz-custom-dropdown biz-custom-scrollbar biz-db-groups-dropdown" id="dbGroupsDropdownMenu"><ul id="dbGroupsDropdownList" class="custom-dropdown-body biz-custom-scrollbar db-groups-dropdown-list row mx-0"></ul></div>
  63. </div>
  64. </div>
  65. <div class="db-header-right d-flex align-items-center" id="dbHeaderRight"><div class="dashboard-fav exclude-tab"><a href="javascript:;" class="biz-highlight-bg-color ml-10" onclick="bizgaze.extensions.web.themes.compact.nav.setAsFavorite();" id="Biz_favorite"><span class="glyphicon glyphicon-heart"></span></a><a href="javascript:;" class="hidden ml-10" id="Biz_Unfavorite" onclick="bizgaze.extensions.web.themes.compact.nav.removeFromFavorite();"><span class="glyphicon glyphicon-heart"></span></a>
  66. </div>
  67. <a id="filter_toggle_btn${containerid}" class="btn btn-outline-light border d-flex align-items-center rounded biz-highlight-bg-color common-filter-dp-btn line-height-0 order-last ${isRestrictHidden}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-tooltip="true" title="Common Filters"><i class="la la-filter font-weight-700" style="height:auto"></i></a>
  68. <div class="dropdown-menu biz-custom-dropdown biz-common-filter-dropdown" id="bizCmnFilterDp_${containerid}" onclick="event.stopPropagation();"><div class="cmn-filter-content-wrap position-relative"><div class="custom-dropdown-body biz-custom-scrollbar row mx-0 common-filter-dropdown-body cmn-filters-body" id="dynamic-filters${containerid}"></div><div class="common-filter-footer mt-10" id="commonfilter_footerbuttons${containerid}"></div><div class="cmn-filter-errmsg text-center d-none" id="cmnFilterErrMsg_${containerid}"><p class="text-danger">No Filters Found!</p><a class="btn btn-outline-primary btn-sm mt-10" href="javascript:;" id="btnCreateCommonFilter" onclick="Unibase.Platform.Analytics.Components._CommonFilter.Instance().loadCommonFilterForm(0)">Create Filter</a></div><a href="javascript:;" class="btn btn-icon btn-flush-biz-theme btn-rounded flush-soft-hover h-30p w-30p shadow cmn-filter-panel-pin d-none" id="cmnFilterPanelPin_${containerid}" onclick="Unibase.Themes.Compact.Components.Dashboard.Instance().loadCommonFilterPanel('${containerid}');" data-tooltip="true" title="Pin Filters"><span class="btn-icon-wrap"><i class="las la-thumbtack font-18"></i></span></a></div></div>
  69. <div class="admin-user-only d-none d-xl-block mr-10">
  70. <div class="btn-group dropdown dashboard-setting-dp ${!((_a = this.currentUser) === null || _a === void 0 ? void 0 : _a.isAdmin) ? 'd-none' : ''}" id="dashboardSettingsDp">
  71. <a class="btn btn-outline-light border d-flex align-items-center rounded biz-highlight-bg-color line-height-0 dashboard-settings-btn" data-tooltip="true" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="javascript:void(0);" data-tooltip="true" title="Dashboard Settings"><i class="la la-cog"></i></a>
  72. <div class="dropdown-menu">
  73. <a class="dropdown-item" href="javascript:;" onclick="Unibase.Themes.Compact.Components.Nav.Instance().addWidget()"><i class="la la-pencil mr-1"></i>Edit Dashboard</a>
  74. <a class="dropdown-item " href="javascript:;" onclick="Unibase.Themes.Compact.Components.Nav.Instance().manageDashboards()" ><i class="la la-newspaper-o mr-1"></i>Manage Dashboard</a>
  75. </div></div></div>
  76. </div></div>
  77. <div class="layout-dashboard-tab" id="layout-dashboard-tabs">
  78. <div class="dashboard-tab card-header-filters" id="card-header-filters${containerid}">
  79. <ul class="biz-report-filters dashboard-options-list" id="filters-list${containerid}"></ul>
  80. <a href="javascript:;" class="filter-left-icon filter-nav-icon biz-highlight-bg-color hidden" onclick="Unibase.Themes.Compact.Components.Nav.Instance().changeFilterScroll(this,'${containerid}')" data-operation="-"><i class="fa fa-chevron-left"></i></a>
  81. <a href="javascript:;" class="filter-right-icon filter-nav-icon biz-highlight-bg-color hidden" onclick="Unibase.Themes.Compact.Components.Nav.Instance().changeFilterScroll(this,'${containerid}')" data-operation="+"><i class="fa fa-chevron-right"></i></a>
  82. </div>
  83. </div>
  84. <div class="dashboardfooter hidden" id="dashboardfooter">
  85. <a class="btn btn-outline-primary bg-white dashboardcreatewidgetbtn mr-10" href="javascript:;" id="AddWidget_btnCreateWidget" onclick="Unibase.Platform.Widgets.Components.Widget.Instance().createWidget(` + id + `)">Create Widget</a>
  86. <div class="Dashboard_SaveChanges pull-right">
  87. <a href="javascript:;" class="btn btn-outline-danger mr-10" onclick="Unibase.Platform.Widgets.Components.Widget.Instance().loadportlet();">Close</a>
  88. <a href="javascript:;" class="btn btn-primary" onclick="Unibase.Platform.Widgets.Components.Widget.Instance().SaveScreen();" data-dismiss="modal">Save changes</a>
  89. <a class="btn btn-sm btn-success hidden" href="javascript:;" data-toggle="modal" data-target="#SaveEditScreen" onclick="Unibase.Themes.Compact.Components.Dashboard.Instance().confirmSave();" id="AddWidget_btnSelectWidget">Done</a>
  90. </div></div>
  91. </div>
  92. <div id="dashboardwidget-container-outer" class="px-0 flex-grow-1 overflow-auto"><div data-simplebar class="simple-scroll-bar container-fluid scrollable pb-15 px-0" id="dashboardwidget-container-scroll"><div id="dashboardwidget-container" class="row dashboardwidget-container px-2 px-sm-2 px-md-20 px-lg-20 mx-0 mx-sm-1" data-id="dashboardwidget-container"></div></div>
  93. </div>`;
  94. return html;
  95. }
  96. load(id, containerid, callback) {
  97. Unibase.Platform.Helpers.FileCacheHelper.Instance().addCacheFiles([
  98. "tenants/themes/compact/widgets/kpiwidgets/manager/kpimanager.js", "tenants/themes/compact/widgets/kpiwidgets/manager/interfaces/ikpimanager.js", "tenants/themes/compact/widgets/reportwidgets/default.js", "tenants/themes/compact/widgets/kpiwidgets/default.js", "tenants/themes/compact/widgets/detailwidgets/default.js", "tenants/themes/compact/widgets/detailwidgets/singledata.js", "tenants/themes/compact/widgets/detailwidgets/singlecolumn.js", "tenants/themes/compact/widgets/detailwidgets/singlecolumn_noborder.js", "tenants/themes/compact/widgets/kpiwidgets/comparision.js", "tenants/themes/compact/widgets/kpiwidgets/icon.js", "tenants/themes/compact/widgets/kpiwidgets/valuewithpercentage.js", "tenants/themes/compact/widgets/kpiwidgets/twovalue.js", "tenants/themes/compact/widgets/reportwidgets/withnoheaderandfooter.js", "platform/widgets/components/widgetpermission.js", "tenants/themes/compact/widgets/kpiwidgets/twovaluebgcolor.js", "tenants/themes/compact/widgets/kpiwidgets/valuewithpercentagebgcolor.js", "tenants/themes/compact/widgets/kpiwidgets/twovaluecenterline.js", "tenants/themes/compact/widgets/kpiwidgets/owlcarouselslider.js", "tenants/themes/compact/widgets/kpiwidgets/valuewithpercentageprogressbar.js", "tenants/themes/compact/widgets/kpiwidgets/kpi_fulfillment.js", "tenants/themes/compact/widgets/kpiwidgets/carouselslider.js", "tenants/themes/compact/widgets/kpiwidgets/carouselsliderbgcolor.js", "platform/analytics/components/reportviewer/reportviewer.js", "tenants/themes/compact/widgets/detailwidgets/customdesign.js", "tenants/themes/compact/widgets/kpiwidgets/comparisionrightbarcolor.js", "tenants/themes/compact/widgets/kpiwidgets/comparisionbottombarcolor.js", "tenants/themes/compact/widgets/kpiwidgets/singlevalueborder.js", "tenants/themes/compact/widgets/kpiwidgets/twovaluebottombarcolor.js", "tenants/themes/compact/widgets/kpiwidgets/singlevaluepiechart.js", "tenants/themes/compact/widgets/kpiwidgets/iconbgcolor.js", "tenants/themes/compact/widgets/kpiwidgets/iconcolor.js", "tenants/themes/compact/widgets/kpiwidgets/iconleftbarcolor.js", "tenants/themes/compact/components/dashboard/walkthrough.js"
  99. ]);
  100. let instance = this;
  101. if ($(window).outerWidth() <= 575) {
  102. $("#dashboardwidget-container-outer").css("margin-left", "-15px").css("margin-right", "-15px");
  103. $("#dashboardwidget-container-scroll").removeClass("px-0");
  104. }
  105. $(`#filter_toggle_btn${containerid}`).click(function () {
  106. if ($(`#bizCmnFilterDp_${containerid}`).hasClass('show')) {
  107. return;
  108. }
  109. let portleId = Number($("#hf_PortletId").val());
  110. Unibase.Platform.Analytics.Components._CommonFilter.Instance().commonFilter(portleId, containerid);
  111. });
  112. $(document).on("click", ".daterangepicker", function (e) {
  113. e.stopPropagation();
  114. });
  115. $('#dbHeaderRight').on('shown.bs.dropdown', function () {
  116. if ($(this).hasClass('show')) {
  117. $(`#filter_toggle_btn${containerid}`).find('.la-filter').removeClass('la-filter').addClass('la-times');
  118. }
  119. });
  120. $('#dbHeaderRight').on('hide.bs.dropdown', function () {
  121. $(`#filter_toggle_btn${containerid}`).find('.la-times').removeClass('la-times').addClass('la-filter');
  122. });
  123. Unibase.Platform.Analytics.Components._CommonFilter.Instance().commonFilter(0, containerid);
  124. if (isMobileApp()) {
  125. eval(`jquerySwipeHandler.handleSwipe("#dashboardwidget-container-outer", [jquerySwipeHandler.SWIPE_LEFT, jquerySwipeHandler.SWIPE_RIGHT], function (direction) {
  126. if(direction == 'SWIPE_LEFT' || direction == 'SWIPE_RIGHT'){
  127. Unibase.Themes.Compact.Components.Dashboard.Instance().DashBoardSwipe(direction);
  128. }
  129. });`);
  130. }
  131. }
  132. init(containerid) {
  133. }
  134. loadDashboard(dashboardid, containerid, callback) {
  135. var instance = this;
  136. }
  137. loadCreateDashboard() {
  138. var instance = this;
  139. instance.fileCacheHelper.loadJsFile('platform/dashboards/components/createdashboard.js', function () {
  140. instance.navigationHelper.popup(0, "", Unibase.Platform.Dashboards.Components.CreateDashboard.Instance(), null, Unibase.Platform.Helpers.Size.DockLeft);
  141. });
  142. }
  143. confirmSave() {
  144. var html = '<div class="modal fade" id="SaveEditScreen" tabindex="-1" role="dialog" aria-labelledby="SaveEditScreenLabel" style="display: none;" aria-hidden="true">' +
  145. '<div class="modal-dialog" role = "document" >' +
  146. '<div class="modal-content">' +
  147. '<div class="modal-header d-none">' +
  148. '<h5 class="modal-title" id="SaveEditScreenLabel"></h5>' +
  149. '<button type="button" class="close" data-dismiss="modal" aria-label="Close">' +
  150. '<span aria-hidden="true">×</span>' +
  151. '</button>' +
  152. '</div>' +
  153. '<div class="modal-body">' +
  154. '<p>Do you want to Save Changes?</p >' +
  155. '</div>' +
  156. '<div class="modal-footer">' +
  157. '<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>' +
  158. '<button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="Unibase.Platform.Widgets.Components.Widget.Instance().loadportlet()">Discard Changes</button>' +
  159. '<button type="button" class="btn btn-primary" onclick="Unibase.Platform.Widgets.Components.Widget.Instance().SaveScreen(true)" data-dismiss="modal">Save changes</button>' +
  160. '</div>' +
  161. '</div>' +
  162. '</div>' +
  163. '</div >';
  164. $("#_bizgaze_modal").before(html);
  165. $("#SaveEditScreen").modal();
  166. }
  167. sortportletWidgets(a, b) {
  168. const sortA = a.PortletWidgetId;
  169. const sortB = b.PortletWidgetId;
  170. let comparison = 0;
  171. if (sortA > sortB) {
  172. comparison = 1;
  173. }
  174. else if (sortA < sortB) {
  175. comparison = -1;
  176. }
  177. return comparison;
  178. }
  179. loadWidgetData(portletWidgetdata) {
  180. let data;
  181. if (portletWidgetdata != undefined) {
  182. data = portletWidgetdata.sort(this.sortStructureWidgets);
  183. }
  184. if (data != null && data != undefined) {
  185. var html = "";
  186. var instance = this;
  187. var datalength = data.length;
  188. var isFirstTime = true;
  189. for (let i = 0; i < datalength; i++) {
  190. var model = data[i];
  191. var widgetUrl = model.WidgetUrl;
  192. var Width = model.Width;
  193. var WidgetName = "";
  194. if (model.DisplayText == "" || model.displayText == null) {
  195. WidgetName = model.WidgetName;
  196. }
  197. else {
  198. WidgetName = model.DisplayText;
  199. }
  200. var IsFiltarable = model.IsFilterable;
  201. var filterhtml = "";
  202. if (IsFiltarable == null || IsFiltarable == false || IsFiltarable == "") {
  203. filterhtml = "hidden";
  204. }
  205. var widgetdata = '<div class="widgetdataHere w-100 mb-2 mb-sm-15 widgetid-' + model.WidgetId + '" id ="widgetid-' + model.WidgetId + '" data-strctwidgetindex="' + model.StrctWidgetIndex + '" data-boxid="' + model.StructureDesignId + '"><div class="rounded portlet dashboardwidget-item dashboardwidget-addeditem widgetItem-' + model.PortletWidgetId + ' widgetid-' + model.WidgetId + '" id=' + model.WidgetId + '>' +
  206. '<div class="Border bg-transparent mb-1 mb-sm-3" >' +
  207. '<div class="Border1 hidden">' +
  208. '<div class="editwidget card-action-wrap editwidget-' + model.WidgetId + ' pull-right m-t-sm m-r-lg" id="editwidget">' +
  209. '<a href="javascript:;" data-tooltip="true" title="Edit Widget" onclick="Unibase.Themes.Compact.Components.Dashboard.Instance().EditWidget(' + model.WidgetId + ',' + 0 + ',' + model.PortletWidgetId + ')" ><i class="ti-pencil text-info mr-3" id = "EditWidget-' + model.PortletWidgetId + '" ></i></a>' +
  210. '<a href="javascript:;" id="WidgetSettings-' + model.PortletWidgetId + '" data-tooltip="true" title="Settings" ><i class="ti-settings mr-3" id = "EditWidget-' + model.PortletWidgetId + '"></i></a>' +
  211. '<a href = "javascript:;" data-tooltip="true" title="Permissions" onclick = "Unibase.Themes.Compact.Components.Dashboard.Instance().ShowWidgetPermissions(' + model.PortletWidgetId + ')";><i class="ti-key mr-2" id = "ShowWidgetPermissions-' + model.PortletWidgetId + '"></i></a>' +
  212. '<a href="javascript:;" data-tooltip="true" title="delete widget" onclick="Unibase.Platform.Widgets.Components.Widget.Instance().deletePortletWidgets(' + model.PortletWidgetId + ')"> <i class="ti-trash text-danger mr-2" id = "EditWidget-' + model.PortletWidgetId + '"></i></a>' +
  213. '<a href="javascript:;" title = "Export Widget" onclick = "Unibase.Platform.Widgets.Components.Widget.Instance().exportWidgetByWidgetId(' + model.WidgetId + ')" > <i class="fa fa-download text-info mr-2" id = "ExportWidget-' + model.PortletWidgetId + '" > </i></a >' +
  214. '</div>' +
  215. '<div class="dragWidget dargwidget-' + model.WidgetId + ' pull-left" id="dragWidget">' +
  216. '<a class="pull-left btn btn-sm">' +
  217. '<i class="ti-fullscreen"></i>' +
  218. '</a>' +
  219. '</div>' +
  220. '</div>' +
  221. '<input type="hidden" id="hf_widgetId" value="' + model.WidgetId + '" />' +
  222. '<input type="hidden" id="hf_widgetId_' + model.WidgetId + '" value="' + model.WidgetId + '" />' +
  223. '<input type="hidden" id="hf_widgetName_' + model.PortletWidgetId + '" value="' + WidgetName + '" />' +
  224. '<input type="hidden" id="hf_widgetUniqueId_' + model.PortletWidgetId + '" value="' + model.UniqueId + '" />' +
  225. '<input type="hidden" class="hf_portletwidgetId" id="hf_portletwidgetId" value="' + model.PortletWidgetId + '" />' +
  226. '<input type="hidden" class="hf_portletwidgetheight" id="hf_portletwidgetheight" value="' + model.PortletWidgetHeight + 'px" />' +
  227. '<input type="hidden"id="hf_PortletId" value="' + model.PortletId + '"/>';
  228. if (model.WidgetLayoutName == 'KPI') {
  229. widgetdata += '<div class="bg-white d-block position-relative h-90p line-loader"></div><div id="div_dashboardportletwidget_' + model.PortletWidgetId + '" class="widgetsstructure hidden div_dashboardwidget_' + model.PortletWidgetId + ' div_dashboardportletwidget_' + model.PortletWidgetId + '" />';
  230. }
  231. else {
  232. widgetdata += '<div id="div_dashboardportletwidget_' + model.PortletWidgetId + '" class="widgetsstructure div_dashboardwidget_' + model.PortletWidgetId + ' div_dashboardportletwidget_' + model.PortletWidgetId + '" />';
  233. }
  234. widgetdata += '</div></div></div></div>';
  235. let afterchild, beforechild;
  236. if ($('#structureId_' + model.StructureDesignId).length != 0) {
  237. if (model.StrctWidgetIndex == 1 || model.StrctWidgetIndex == 0) {
  238. $('#structureId_' + model.StructureDesignId).find('.widgetplace').first().prepend(widgetdata);
  239. }
  240. else {
  241. afterchild = model.StrctWidgetIndex - 1;
  242. beforechild = model.StrctWidgetIndex + 1;
  243. if (($('#structureId_' + model.StructureDesignId + ' .widgetplace').find('[data-strctwidgetindex="' + afterchild + '"][data-boxid="' + model.StructureDesignId + '"]').length) > 0) {
  244. $('#structureId_' + model.StructureDesignId + ' .widgetplace').find('[data-strctwidgetindex="' + afterchild + '"][data-boxid="' + model.StructureDesignId + '"]').after(widgetdata);
  245. }
  246. else if (($('#structureId_' + model.StructureDesignId + ' .widgetplace').find('[data-strctwidgetindex="' + beforechild + '"][data-boxid="' + model.StructureDesignId + '"]').length) > 0) {
  247. $('#structureId_' + model.StructureDesignId + ' .widgetplace').find('[data-strctwidgetindex="' + beforechild + '"][data-boxid="' + model.StructureDesignId + '"]').before(widgetdata);
  248. }
  249. else if (model.StrctWidgetIndex < Number($('#structureId_' + model.StructureDesignId + ' [data-boxid="' + model.StructureDesignId + '"]').attr('data-strctwidgetindex'))) {
  250. $('#structureId_' + model.StructureDesignId + ' [data-boxid="' + model.StructureDesignId + '"]').before(widgetdata);
  251. }
  252. else if (model.StrctWidgetIndex > Number($('#structureId_' + model.StructureDesignId + ' [data-boxid="' + model.StructureDesignId + '"]').attr('data-strctwidgetindex'))) {
  253. $('#structureId_' + model.StructureDesignId + ' [data-boxid="' + model.StructureDesignId + '"]').after(widgetdata);
  254. }
  255. else {
  256. $('#structureId_' + model.StructureDesignId + ' .widgetplace').append(widgetdata);
  257. }
  258. }
  259. }
  260. else {
  261. $('[data-divstructureid="default-structure"]').find('.widgetplace').append(widgetdata);
  262. }
  263. var StrWidgetID = '.widgetdataHere.widgetid-' + model.WidgetId + '';
  264. var FindStrutreLength = $(StrWidgetID).length;
  265. if (FindStrutreLength >= 2) {
  266. $('#dashboardwidget-container .widgetdataHere.widgetid-' + model.WidgetId + '').not(':last').remove();
  267. }
  268. $(widgetdata).addClass("mb-2");
  269. $(".structureToDelete .structureToDelete").find(".PaddingMoveRight").addClass("p-0 pr-1").removeClass("p-1");
  270. $(".structureToDelete .structureToDelete").find(".PaddingMoveLeft").addClass("p-0 pl-1").removeClass("p-1");
  271. $(".structureToDelete .structureToDelete").find(".PaddingMoveX").addClass("p-0 px-1").removeClass("p-1");
  272. $(".structureToDelete ").find(".PaddingMoveRight").addClass("p-0 pr-1").removeClass("p-1");
  273. $(".structureToDelete ").find(".PaddingMoveLeft").addClass("p-0 pl-1").removeClass("p-1");
  274. $(".structureToDelete ").find(".PaddingMoveX").addClass("p-0 px-1").removeClass("p-1");
  275. $("#deleteWidget-" + model.PortletWidgetId).click(function () {
  276. instance.fileCacheHelper.loadJsFile("platform/widgets/components/widget.js", function () {
  277. Unibase.Platform.Widgets.Components.Widget.Instance().deletePortletWidgets(model.PortletWidgetId);
  278. });
  279. });
  280. }
  281. var _fileCacheHelper = this.fileCacheHelper;
  282. this.models = data;
  283. this.jsindex = 0;
  284. this.htmlindex = 0;
  285. this.evalExecuted = 0;
  286. instance.evaluateJs(data);
  287. $("#section_bizgaze_main").removeClass("hidden");
  288. }
  289. }
  290. ShowWidgetPermissions(PortletWidgetId) {
  291. var instance = this;
  292. $('.btn_addportlt').addClass('hidden');
  293. $('.btnEdit_portlet').addClass('hidden');
  294. $('.manage_pPermissions').addClass('hidden');
  295. $('.btn_dltportlet').addClass('hidden');
  296. instance.navigationHelper.popup(0, "", Unibase.Platform.Widgets.Components.WidgetPermission.Instance(), function () {
  297. $("#chkIsWidgetViewable").change(function () {
  298. Unibase.Platform.Widgets.Components.WidgetPermission.Instance().setViewable();
  299. });
  300. Unibase.Platform.Widgets.Components.WidgetPermission.Instance().showPermissions(PortletWidgetId, 'widget', Unibase.Platform.Widgets.WidgetHiddenFields.Instance().unix_pwid);
  301. }, Unibase.Platform.Helpers.Size.Medium);
  302. }
  303. EditWidget(Wid, x, PortletWidgetId, isFromAddWidget) {
  304. var instance = this;
  305. $(".biz-submenu").css({ "z-index": "1040" });
  306. $(".biz-layout-3-left-nav").css({ "z-index": "1040" });
  307. $(".toplayout-structures-panel").css({ "z-index": "1040" });
  308. instance.fileCacheHelper.loadJsFile("platform/widgets/components/widget.js", function () {
  309. Unibase.Platform.Widgets.Components.Widget.Instance().loadWidgetData(Wid, 0, true, PortletWidgetId, isFromAddWidget);
  310. });
  311. }
  312. filterStructures(data, containerid, parentId) {
  313. let myStructures, instance = this;
  314. let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
  315. if (VisibleContainerId.includes('_viewall')) {
  316. VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 2];
  317. }
  318. $('#' + VisibleContainerId).find('#' + containerid).attr({ 'data-isedit': 'false' });
  319. if (!parentId) {
  320. var myStructuresSort = data.filter(structure => structure.ParentId == 0);
  321. }
  322. else {
  323. var myStructuresSort = data.filter(structure => structure.ParentId == parentId);
  324. }
  325. if (myStructuresSort.length)
  326. myStructures = myStructuresSort.sort(this.sortStructureWidgets);
  327. let width, innerHtml = '', outerHtml = '', ParentDiv, binding, mobileWidth = [], tabWidth = [], _tabWidth = '', _mobileWidth = '', desktopPdng = '', tabPdng = '', MobilePdng = '';
  328. if (myStructures != undefined) {
  329. for (var i = 0; i < myStructures.length; i++) {
  330. if (myStructures[i].ParentId == 0) {
  331. ParentDiv = containerid;
  332. outerHtml = '<div class="d-flex flex-wrap structureToDelete w-100 structureDiv" data-divstructureid=' + myStructures[i].StructureId + ' data-clone="clonestruct" data-parent=' + ParentDiv + ' id="divStructure_' + myStructures[i].ParentId + '-' + myStructures[i].StructureId + '-' + myStructures[i].StructureVIndex + '" data-isEdit="false" data-strctwidgetindex=' + myStructures[i].StrctWidgetIndex + ' data-boxid="' + myStructures[i].ParentId + '" data-ParentIndex="' + myStructures[i].ParentId + '"></div>';
  333. if (myStructures[i].StructureHIndex == 0) {
  334. $('#' + VisibleContainerId).find('#' + ParentDiv).append(outerHtml);
  335. }
  336. }
  337. else {
  338. ParentDiv = 'structureId_' + myStructures[i].ParentId;
  339. outerHtml = '<div class="d-flex flex-wrap structureToDelete w-100 structureDiv" data-divstructureid=' + myStructures[i].StructureId + ' data-clone="clonestruct" data-parent="' + ParentDiv + '" id="divStructure_' + myStructures[i].ParentId + '-' + myStructures[i].StructureId + '-' + myStructures[i].StructureVIndex + '" data-isEdit="false" data-strctwidgetindex=' + myStructures[i].StrctWidgetIndex + ' data-boxid="' + myStructures[i].ParentId + '" data-ParentIndex="' + myStructures[i].ParentId + '"></div>';
  340. if (myStructures[i].StructureHIndex == 0) {
  341. $('#' + VisibleContainerId).find('#structureId_' + myStructures[i].ParentId).find('.widgetplace ').first().append(outerHtml);
  342. }
  343. }
  344. width = myStructures[i].StructureWidth.split('|'), _mobileWidth = '', _tabWidth = '';
  345. let desktopWidth = width[myStructures[i].StructureHIndex];
  346. if (myStructures[i].StructureMobileWidth != '' && myStructures[i].StructureMobileWidth != null && myStructures[i].StructureMobileWidth != undefined) {
  347. mobileWidth = myStructures[i].StructureMobileWidth.split('|');
  348. if (mobileWidth == null || mobileWidth[myStructures[i].StructureHIndex] == '' || mobileWidth[myStructures[i].StructureHIndex] == '0' || mobileWidth[myStructures[i].StructureHIndex] == undefined) {
  349. _mobileWidth = '';
  350. }
  351. else {
  352. _mobileWidth = ' col-' + mobileWidth[myStructures[i].StructureHIndex] + ' col-xs-' + mobileWidth[myStructures[i].StructureHIndex] + ' col-sm-' + mobileWidth[myStructures[i].StructureHIndex];
  353. }
  354. }
  355. if (myStructures[i].StructureTabWidth != '' && myStructures[i].StructureTabWidth != null && myStructures[i].StructureTabWidth != undefined) {
  356. tabWidth = myStructures[i].StructureTabWidth.split('|');
  357. if (tabWidth == null || tabWidth[myStructures[i].StructureHIndex] == '' || tabWidth[myStructures[i].StructureHIndex] == '0' || tabWidth[myStructures[i].StructureHIndex] == undefined) {
  358. _tabWidth = '';
  359. }
  360. else {
  361. _tabWidth = ' col-md-' + tabWidth[myStructures[i].StructureHIndex] + ' col-lg-' + tabWidth[myStructures[i].StructureHIndex];
  362. }
  363. }
  364. desktopPdng = instance.pdng_Algn(myStructures[i].StructureWidth, myStructures[i].StructureHIndex, "Desktop", myStructures[i].StrctWidgetIndex);
  365. tabPdng = instance.pdng_Algn(myStructures[i].StructureTabWidth, myStructures[i].StructureHIndex, "Tab", myStructures[i].StrctWidgetIndex);
  366. MobilePdng = instance.pdng_Algn(myStructures[i].StructureMobileWidth, myStructures[i].StructureHIndex, "Mobile", myStructures[i].StrctWidgetIndex);
  367. innerHtml = '<div class="' + _mobileWidth + ' ' + _tabWidth + ' col-xl-' + desktopWidth + ' droppablePlaceCol ui-sortable-handle ' + desktopPdng + ' ' + tabPdng + ' ' + MobilePdng + '" data-isblock="1" data-structureindex="' + myStructures[i].StructureHIndex + '" data-parent="divStructure_' + myStructures[i].ParentId + '-' + myStructures[i].StructureId + '-' + myStructures[i].StructureVIndex + '" id="structureId_' + myStructures[i].StructureDesignId + '" data-mobile_settingwidth="' + myStructures[i].StructureMobileWidth + '" data-tab_settingwidth="' + myStructures[i].StructureTabWidth + '" data-parentIndex="' + myStructures[i].ParentId + '"><div class="blocks-droppable-items-place ui-sortable-handle widgetplace ui-sortable" id="12"></div></div>';
  368. if (myStructures[i].StructureHIndex == 0) {
  369. binding = 'divStructure_' + myStructures[i].ParentId + '-' + myStructures[i].StructureId + '-' + myStructures[i].StructureVIndex;
  370. $('#' + VisibleContainerId).find('#divStructure_' + myStructures[i].ParentId + '-' + myStructures[i].StructureId + '-' + myStructures[i].StructureVIndex).append(innerHtml);
  371. }
  372. else {
  373. $('#' + VisibleContainerId).find('#' + binding).append(innerHtml);
  374. }
  375. }
  376. myStructures.forEach(structure => {
  377. this.filterStructures(data, containerid, structure.StructureDesignId);
  378. });
  379. }
  380. }
  381. pdng_Algn(width, HIndex, resolution, WSIndex) {
  382. let instance = this, padding;
  383. let curIndex = instance.padding(width, HIndex, WSIndex);
  384. if (resolution == "Desktop") {
  385. if (width != '') {
  386. if (curIndex == 0) {
  387. padding = 'px-xl-0';
  388. }
  389. if (curIndex == 1) {
  390. padding = 'pl-xl-0 pr-xl-10';
  391. }
  392. if (curIndex == 2) {
  393. padding = 'px-xl-10';
  394. }
  395. if (curIndex == 3) {
  396. padding = 'pl-xl-10 pr-xl-0';
  397. }
  398. }
  399. else {
  400. padding = 'px-xl-0';
  401. }
  402. }
  403. if (resolution == "Tab") {
  404. if (width != '') {
  405. if (curIndex == 0) {
  406. padding = 'px-lg-0 px-md-0';
  407. }
  408. if (curIndex == 1) {
  409. padding = 'pl-md-0 pr-md-10 pl-lg-0 pr-lg-10';
  410. }
  411. if (curIndex == 2) {
  412. padding = 'px-lg-10 px-md-10';
  413. }
  414. if (curIndex == 3) {
  415. padding = 'pl-md-10 pr-md-0 pl-lg-10 pr-lg-0';
  416. }
  417. }
  418. else {
  419. padding = 'px-md-0 px-lg-0';
  420. }
  421. }
  422. if (resolution == "Mobile") {
  423. if (width != '') {
  424. if (curIndex == 0) {
  425. padding = 'px-0 px-sm-0';
  426. }
  427. if (curIndex == 1) {
  428. padding = 'pl-0 pr-10 pl-sm-0 pr-sm-10';
  429. }
  430. if (curIndex == 2) {
  431. padding = 'px-10 px-sm-10';
  432. }
  433. if (curIndex == 3) {
  434. padding = 'pl-10 pr-0 pl-sm-10 pr-sm-0';
  435. }
  436. }
  437. else {
  438. padding = 'px-0 px-sm-0';
  439. }
  440. }
  441. return padding;
  442. }
  443. padding(width, AcutalIndex, WSIndex) {
  444. let ElmntWidth = width.split('|'), currentIndex, breakIndex, breakarray = [], _breakarray = [], isBreak = false, sumWidth = ElmntWidth.reduce((x, y) => parseInt(x) + parseInt(y), 0), preBreakIndex = [], sliceWidth = ElmntWidth.slice(0, AcutalIndex + 1), _sliceWidth, _sumSliceWidth, sumSliceWidth = sliceWidth.reduce((x, y) => parseInt(x) + parseInt(y), 0);
  445. if (parseInt(ElmntWidth[AcutalIndex]) == 12) {
  446. currentIndex = 0;
  447. }
  448. else {
  449. if (sumSliceWidth < 12 && AcutalIndex == 0) {
  450. currentIndex = 1;
  451. }
  452. if (sumSliceWidth < 12 && AcutalIndex != 0) {
  453. currentIndex = 2;
  454. }
  455. if (sumSliceWidth == 12) {
  456. currentIndex = 3;
  457. }
  458. if (sumSliceWidth > 12) {
  459. if (parseInt(ElmntWidth[AcutalIndex]) == 12) {
  460. currentIndex = 0;
  461. }
  462. else {
  463. currentIndex = 1;
  464. for (let i = 0; i < ElmntWidth.length; i++) {
  465. breakarray.push(parseInt(ElmntWidth[i]));
  466. let sumbreakarray = breakarray.reduce((x, y) => parseInt(x) + parseInt(y), 0);
  467. if (sumbreakarray > 12 && !isBreak) {
  468. isBreak = true;
  469. breakIndex = i;
  470. preBreakIndex.push({ "breakIndex": breakIndex, "isBreak": isBreak, "AcutalIndex": AcutalIndex });
  471. }
  472. }
  473. _sliceWidth = ElmntWidth.slice((breakIndex), (AcutalIndex + 1));
  474. _sumSliceWidth = _sliceWidth.reduce((x, y) => parseInt(x) + parseInt(y), 0);
  475. if (_sumSliceWidth < 12 && AcutalIndex == breakIndex) {
  476. currentIndex = 1;
  477. }
  478. if (_sumSliceWidth < 12 && AcutalIndex != breakIndex) {
  479. currentIndex = 2;
  480. }
  481. if (_sumSliceWidth == 12) {
  482. currentIndex = 3;
  483. }
  484. if (_sumSliceWidth > 12) {
  485. currentIndex = 1;
  486. isBreak = false;
  487. for (let k = 0; k < _sliceWidth.length; k++) {
  488. _breakarray.push(parseInt(_sliceWidth[k]));
  489. let sumbreakarray = _breakarray.reduce((x, y) => parseInt(x) + parseInt(y), 0);
  490. if (sumbreakarray > 12 && !isBreak) {
  491. isBreak = true;
  492. breakIndex = k;
  493. preBreakIndex.push({ "breakIndex": breakIndex, "isBreak": isBreak, "AcutalIndex": AcutalIndex });
  494. }
  495. }
  496. _sliceWidth = _sliceWidth.slice((breakIndex), (AcutalIndex + 1));
  497. _sumSliceWidth = _sliceWidth.reduce((x, y) => parseInt(x) + parseInt(y), 0);
  498. if (_sumSliceWidth < 12 && _sliceWidth.length == 1) {
  499. currentIndex = 1;
  500. }
  501. if (_sumSliceWidth < 12 && _sliceWidth.length != 1) {
  502. currentIndex = 2;
  503. }
  504. if (_sumSliceWidth == 12) {
  505. currentIndex = 3;
  506. }
  507. }
  508. }
  509. }
  510. }
  511. return currentIndex;
  512. }
  513. sortStructureWidgets(a, b) {
  514. const sortA = a.StrctWidgetIndex;
  515. const sortB = b.StrctWidgetIndex;
  516. let comparison = 0;
  517. if (sortA > sortB) {
  518. comparison = 1;
  519. }
  520. else if (sortA < sortB) {
  521. comparison = -1;
  522. }
  523. return comparison;
  524. }
  525. navigationClickEvent(dashboards, groupid, dashboardOptionList, dashboardId) {
  526. const instance = this;
  527. const modalContainerId = instance.navigationHelper.getLastContainerId();
  528. let optionTemplate = Components.Nav_Template.Instance().DashboardItemTemplate();
  529. $('li.li-dashboard-item.active-item').removeClass('active-item');
  530. $('.liDashboardGroup_' + groupid).addClass('active-item');
  531. let groupTitle = dashboards[0].DashboardGroupName;
  532. $('#lblDbGroup_Title').text(groupTitle);
  533. const dbOptionEl = $(dashboardOptionList);
  534. dbOptionEl.html('');
  535. dashboards.forEach(function (dashboard, index) {
  536. let context = dashboard;
  537. let optiontemplatescript = Handlebars.compile(optionTemplate);
  538. let optionhtml = optiontemplatescript(context);
  539. dbOptionEl.append(optionhtml);
  540. });
  541. let filterEl;
  542. if (dashboardId) {
  543. filterEl = dbOptionEl.find(`#filterItem_${dashboardId}`);
  544. }
  545. else {
  546. filterEl = dbOptionEl.find('.filter-item').first();
  547. }
  548. filterEl.addClass("active");
  549. if (filterEl.attr('data-pincmnfilters') === 'true') {
  550. instance.loadCommonFilterPanel(modalContainerId);
  551. }
  552. if (groupTitle == "") {
  553. $('#lblDbGroup_Title').text($(`.liDashboardGroup_${groupid} .nav-link`).first().text());
  554. }
  555. Unibase.Themes.Compact.Components.Nav.Instance().removeToolTipForFilterItem(dbOptionEl);
  556. $('.biz-wrapper').removeClass('biz__nav__toggle');
  557. $('.biz-nav-fullwidth').addClass('hidden');
  558. }
  559. loadDashboards(dashboards, dashboardId, IsEvent) {
  560. const instance = this;
  561. if (IsEvent) {
  562. var groupid = dashboards[0].DashboardGroupId, dashboardOptionList = '.dashboard-options-list';
  563. this.navigationClickEvent(dashboards, groupid, dashboardOptionList, dashboardId);
  564. }
  565. $(".layout-dashboard-tabs").removeClass('hidden');
  566. $(".layout-dashboard-tabs").find('.filter-nav-icon').addClass('hidden');
  567. if (dashboards.length == 0) {
  568. $(".layout-dashboard-tabs .tab-addeditem").empty();
  569. $("#dashboardwidget-container").empty();
  570. }
  571. else {
  572. var html = "";
  573. $(".tab-addeditem").remove();
  574. if (this._bizgaze_core_activeinstalledappId != 0) {
  575. this._bizgaze_core_activeportletid = 0;
  576. }
  577. this._bizgaze_core_activeinstalledappId = 0;
  578. if (dashboardId) {
  579. this._bizgaze_core_activeportletid = dashboardId;
  580. }
  581. var firstdashboardid = this._bizgaze_core_activeportletid;
  582. var firstdashboardname = "";
  583. $("#layout-dashboard-tabs").find('.dashboard-tab').first().before(html);
  584. if (firstdashboardid == 0) {
  585. var dashboard = dashboards[0];
  586. var dashboardId = dashboard.DashboardId;
  587. var dashboardName = dashboard.DashboardName;
  588. firstdashboardid = dashboardId;
  589. firstdashboardname = dashboardName;
  590. }
  591. $(".tabid-" + firstdashboardid).find(".nav-link").addClass("active");
  592. this._bizgaze_core_activeportletid = firstdashboardid;
  593. if (firstdashboardid != 0 && this.firstLoad) {
  594. this.firstLoad = false;
  595. let dbContainerId = instance.navigationHelper.getLastContainerId();
  596. let rvInsArray = Unibase.Platform.Helpers.NavigationHelper.reportViewerInstance.filter(x => x.parentcontainerid == dbContainerId);
  597. let cmnFilIns = Unibase.Platform.Analytics.Components._CommonFilter.Instance();
  598. cmnFilIns.appliedFilters = [];
  599. for (var i = 0; i < rvInsArray.length; i++) {
  600. rvInsArray[i].instance.inputParameters = [];
  601. rvInsArray[i].instance.Filter = [];
  602. rvInsArray[i].instance.dynamicFilters = [];
  603. }
  604. cmnFilIns.cascadingFilters = [];
  605. cmnFilIns.selectedCommonFilters = [];
  606. cmnFilIns.commonFilter(0, dbContainerId);
  607. if (!Unibase.Themes.Compact.Components.Nav.Instance().isDshboardBck) {
  608. Unibase.Themes.Compact.Components.Nav.Instance().isDshboardBckArray.push({
  609. "DashbaordId": firstdashboardid, "DashboardName": firstdashboardname, "isBack": "Dashboard"
  610. });
  611. }
  612. else {
  613. Unibase.Themes.Compact.Components.Nav.Instance().isDshboardBck = false;
  614. }
  615. this.loadWidgets(firstdashboardid, firstdashboardname);
  616. }
  617. $("#collapsed").find("a").removeClass("nav-link").addClass("h-30p");
  618. $("#div-layout-report").addClass('hidden');
  619. }
  620. }
  621. loadWidgets(portalid, portletName) {
  622. if ($('.dashboard-options-list .filter-item.active').length) {
  623. $('.dashboard-options-list .filter-item.active').removeClass('active');
  624. $(`.dashboard-options-list #filterItem_${portalid}`).addClass('active');
  625. $(`#nav-dashboards .ligrp-item.active-item`).removeClass('active-item');
  626. $(`#nav-dashboards .UlItem_${portalid}`).addClass('active-item');
  627. }
  628. $(".tabid-" + portalid).find(".nav-link").addClass("active");
  629. $("#hfLayout_InstalledPageId").val(0);
  630. $("#hf_DashboardPortletId").val(portalid);
  631. $("#hf_DashboardPortletName").val(portletName);
  632. $("#hf_PortletId").val(portalid);
  633. $("#Stage").removeClass('hidden');
  634. $(".EditPortlets").addClass('hidden');
  635. $(".Detail_Configurations").removeClass('hidden');
  636. $(".portletmenu-addeditem").remove();
  637. $("#AddPortlet").addClass("hidden");
  638. $("#SavePortlet").addClass("hidden");
  639. $("#chkLayout_PortletsSelector").addClass("hidden");
  640. $("#layout-list").hide();
  641. $("#layout-dashboard").show();
  642. $("#layout-report").hide();
  643. this._bizgaze_core_activeportletid = portalid;
  644. $("#dashboard-title").html(portletName);
  645. $("#txt_global_search").val('');
  646. $("#txt_global_clearSearch").addClass("hidden");
  647. var instance = this;
  648. if (this._dashboard_first_load == 0) {
  649. if ($('.skelton_loader').length == 0) {
  650. let skelHtml = '<div class="skelton_loader biz-secondary-color position-absolute px-2 px-sm-15 px-md-20 w-100 z-index-10">';
  651. skelHtml += Unibase.Themes.Compact.Components.Nav_Template.Instance().skelTonDashboardStructure();
  652. skelHtml += '</div>';
  653. $("#bizDbHeader").after(skelHtml);
  654. if (window.innerWidth < 575) {
  655. $('.skelton_loader').removeClass('px-2');
  656. }
  657. }
  658. $(".dashboardwidget-container").html("");
  659. $(".dashboardwidget-container").addClass('invisible');
  660. Unibase.Platform.Portlets.Managers.PortletManager.Instance().getPortletStructureDesign(portalid).then(function (response) {
  661. return __awaiter(this, void 0, void 0, function* () {
  662. var data = response.result;
  663. if (data.length == 0) {
  664. let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds[Unibase.Platform.Helpers.NavigationHelper.ModalContainerIds.length - 1];
  665. let divStructure = 'divStructure_' + Math.floor(Math.random() * Date.now());
  666. let boxId = 'structureId_' + Math.floor(Math.random() * Date.now());
  667. let html = `<div class="d-flex flex-wrap structureToDelete w-100 structureDiv" data-divstructureid="default-structure" data-clone="clonestruct" data-parent="dashboardwidget-container" id="${divStructure}" data-isedit="true" data-strctwidgetindex="0" data-parentindex="0"> <div class="col-lg-12 droppablePlaceCol ui-sortable-handle px-md-0 px-0" data-isblock="1" data-structureindex="0" data-parent="${divStructure}" id="${boxId}" data-mobile_settingwidth="" data-tab_settingwidth="" data-parentindex="0"> <div class="blocks-droppable-items-place ui-sortable-handle widgetplace ui-sortable d-flex flex-wrap" id="12"></div></div></div>`;
  668. $('#' + VisibleContainerId).find('.dashboardwidget-container').html(html);
  669. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  670. }
  671. else {
  672. if (data != null) {
  673. yield instance.filterStructures(data, 'dashboardwidget-container');
  674. yield Unibase.Platform.Portlets.Managers.PortletManager.Instance().getPortletWidgets(portalid, 0).then(function (response) {
  675. return __awaiter(this, void 0, void 0, function* () {
  676. var data = response.result;
  677. yield instance.loadWidgetData(data);
  678. });
  679. });
  680. $('#dashboardwidget-container-scroll').css('background-color', 'unset');
  681. yield instance.navigationHelper.hideLoading();
  682. }
  683. else {
  684. return MessageHelper.Instance().showError(response.message, 'bizgaze_message');
  685. }
  686. }
  687. });
  688. });
  689. }
  690. if (this._dashboard_first_load == 1)
  691. this._dashboard_first_load = 0;
  692. this.Biz_FavoriteStatus();
  693. this.trackPortlet(portalid);
  694. }
  695. DashBoardSwipe(direction) {
  696. let VisibleContainerId = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
  697. const dbFiltersEl = $(`#${VisibleContainerId} .dashboard-options-list`);
  698. const filtersLength = dbFiltersEl.find('.filter-item').length;
  699. let activeIndex = dbFiltersEl.find('.filter-item.active').index();
  700. if (direction == 'SWIPE_RIGHT') {
  701. let pos = activeIndex < 1 ? filtersLength - 1 : activeIndex - 1;
  702. dbFiltersEl.find('.filter-link').eq(pos).trigger('click');
  703. }
  704. if (direction == 'SWIPE_LEFT') {
  705. let pos = activeIndex < filtersLength - 1 ? activeIndex + 1 : 0;
  706. dbFiltersEl.find('.filter-link').eq(pos).trigger('click');
  707. }
  708. }
  709. Biz_FavoriteStatus() {
  710. var installedPageaId = $('#hfLayout_InstalledPageId').val();
  711. var portletId = $('#hf_DashboardPortletId').val();
  712. if (installedPageaId == 0 && portletId !== null) {
  713. var url = "/api/v3/Portlets/UserPortletStatus/" + portletId;
  714. }
  715. }
  716. trackPortlet(portletid) {
  717. var url = "/api/v3/Portlets/SavePortletTrack/" + portletid;
  718. }
  719. evaluateJs(data) {
  720. var currentinstance = this, url;
  721. this.evalExecuted = 1;
  722. let k = 0;
  723. var staticfileaarry = [];
  724. var staticwidetfiles = data.filter(function (o) { return o.WidgetUrl !== '' && o.WidgetUrl !== null; });
  725. if (staticwidetfiles != null && staticwidetfiles != '') {
  726. for (var i = 0; i < staticwidetfiles.length; i++) {
  727. var staticjs = staticwidetfiles[i].WidgetUrl.split(',');
  728. staticfileaarry.push(staticjs[0]);
  729. }
  730. }
  731. currentinstance.fileCacheHelper.loadJsFiles(staticfileaarry, function () {
  732. for (const model of data) {
  733. let containerid = "div_dashboardportletwidget_" + model.PortletWidgetId;
  734. if (model.WidgetUrl != null && model.WidgetUrl != '') {
  735. url = model.WidgetUrl.split(',');
  736. currentinstance.fileCacheHelper.loadJsFile(url[0], function () {
  737. eval(url[1] + '.init("' + containerid + '")');
  738. });
  739. }
  740. else {
  741. if (model != null) {
  742. if (model.StaticJsPath != null) {
  743. var instance1 = eval(model.StaticJsPath);
  744. }
  745. if (model.Js != null) {
  746. if (model.JsPath != null && model.Js != "") {
  747. currentinstance.fileCacheHelper.loadJsFile(model.JsPath, function () {
  748. var instance = eval(model.Js);
  749. var wclist = [];
  750. var wc = instance;
  751. var DetailContainerId = currentinstance._dashboard_container;
  752. wclist.push({ PortletWidgetId: model.PortletWidgetId, WidgetId: model.WidgetId, WidgetParameters: model.Parameter, WidgetName: model.WidgetName, InstalledAppId: 0, DetailContainerId: DetailContainerId, StaticJsPath: model.StaticJsPath, ReportId: model.ReportId, StructureDesignId: 'structureId_' + model.StructureDesignId, IsFilterable: model.IsFilterable, WidgetDesignName: model.WidgetDesignName, CustomHtml: model.CustomHtml });
  753. currentinstance.navigationHelper.loadSection(wclist, containerid, instance, null, null);
  754. });
  755. }
  756. }
  757. }
  758. }
  759. k++;
  760. if (k == data.length) {
  761. if (Unibase.Themes.Compact.Components.Index.Instance().isIframe) {
  762. Unibase.Themes.Compact.Components.Nav.Instance().loadChat();
  763. $("#bizgaze_body").removeClass('invisible');
  764. }
  765. if (Unibase.Platform.Membership.Infos.Identity.currentUser.tenant.isLoggedIn != undefined && !Unibase.Platform.Membership.Infos.Identity.currentUser.tenant.isLoggedIn) {
  766. Unibase.Themes.Compact.Components.Nav.Instance().wizard();
  767. }
  768. else {
  769. let array = Unibase.Platform.Membership.Infos.Identity.currentUser.settings.filter(function (x) { return x.settingName == "isloginfirsttime"; });
  770. if (array.length != 0) {
  771. if (array[0].settingValue != undefined && array[0].settingValue == true) {
  772. currentinstance.appTourGuide();
  773. }
  774. }
  775. }
  776. }
  777. }
  778. });
  779. }
  780. replaceWidgetParameterValues(Parameter, Installedappid) {
  781. let installedappid = Installedappid;
  782. let ReplaceText = [];
  783. if (Parameter != "" && Parameter != null) {
  784. let identityparameter = [];
  785. let appparameter = [];
  786. let Parameters = Parameter.split('|');
  787. if (Parameters.length > 0) {
  788. let len = Parameters.length;
  789. for (let i = 0; i < Parameters.length; i++) {
  790. if (Parameters[i].includes('identity_'))
  791. identityparameter.push(Parameters[i]);
  792. else
  793. appparameter.push(Parameters[i]);
  794. }
  795. }
  796. if (identityparameter.length > 0) {
  797. for (let x = 0; x < identityparameter.length; x++) {
  798. let split = identityparameter[x].split(':');
  799. ReplaceText.push({
  800. Key: split[0],
  801. Value: (Unibase.Themes.Compact.Components.Dashboard.inputparameters[split[2].split('_')[1]]).toString(),
  802. DataType: split[4]
  803. });
  804. }
  805. }
  806. if (appparameter.length > 0) {
  807. for (let x = 0; x < appparameter.length; x++) {
  808. let split = appparameter[x].split(':');
  809. if (split[3] == 2) {
  810. ReplaceText.push({
  811. Key: split[0],
  812. Value: split[2],
  813. DataType: split[4]
  814. });
  815. }
  816. else {
  817. if (installedappid != 0) {
  818. for (let obj of Unibase.Themes.Compact.Components.Details.inputparameters) {
  819. if (obj.Key === "hf_" + installedappid + "_" + split[2])
  820. ReplaceText.push({
  821. Key: split[0],
  822. Value: obj.Value.toString(),
  823. DataType: obj.DataType.toString()
  824. });
  825. }
  826. }
  827. }
  828. }
  829. }
  830. }
  831. return ReplaceText;
  832. }
  833. loadIdentity() {
  834. var identityinfo = Unibase.Platform.Membership.Infos.Identity.getCurrentUser();
  835. var keys = Object.keys(identityinfo);
  836. for (let i = 0; i < keys.length; i++) {
  837. let val = identityinfo[keys[i]];
  838. Unibase.Themes.Compact.Components.Dashboard.inputparameters[keys[i]] = val;
  839. }
  840. }
  841. exportPortlet(portletId) {
  842. var instance = this;
  843. if (portletId == 0) {
  844. portletId = $("#hf_PortletId").val();
  845. portletId = Number(portletId);
  846. }
  847. instance.fileCacheHelper.loadJsFile("platform/dashboards/managers/dashboardmanager.js", function () {
  848. Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading();
  849. Unibase.Platform.Dashboards.Managers.DashboardManager.Instance().getDashboard(portletId).then(function (portletresponse) {
  850. if (portletresponse.result != null && portletresponse.result != undefined) {
  851. Unibase.Platform.Dashboards.Managers.DashboardManager.Instance().exportPortlet(portletId).then((response) => {
  852. if (response.status == Unibase.Data.Status.Error) {
  853. instance.navigationHelper.hideLoading();
  854. MessageHelper.Instance().showError(response.message, "divBizgaze_MessagesPlaceholder");
  855. }
  856. else if (response.result != null && response.result != undefined && portletresponse.result != null && portletresponse.result != undefined) {
  857. var filename = portletresponse.result.DashboardName + " - Dashboard.xml";
  858. var xmltext = response.result;
  859. var pom = document.createElement('a');
  860. var bb = new Blob([xmltext], { type: 'text/plain' });
  861. pom.setAttribute('href', window.URL.createObjectURL(bb));
  862. pom.setAttribute('download', filename);
  863. pom.dataset.downloadurl = ['text/plain', pom.download, pom.href].join(':');
  864. pom.draggable = true;
  865. pom.classList.add('dragout');
  866. pom.click();
  867. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  868. }
  869. });
  870. }
  871. });
  872. });
  873. }
  874. appTourGuide() {
  875. let instance = this;
  876. var _fileCacheHelper = Unibase.Platform.Helpers.FileCacheHelper.Instance();
  877. _fileCacheHelper.loadCssFile("libs/tourguide/tour.min.css", null);
  878. _fileCacheHelper.loadJsFiles(["libs/tourguide/tour.min.js", "tenants/themes/compact/components/dashboard/walkthrough.js"], function () {
  879. let layouts = Unibase.Platform.Membership.Infos.Identity.getCurrentUser().settings.filter(function (o) { return o.settingName === "themeobj"; });
  880. let type, data = [];
  881. let JSONdata = JSON.parse(layouts[0].settingValue.layoutSettings.settingValue);
  882. let LayoutName = layouts[0].settingValue.layoutName.replace(/\s/g, '');
  883. if (Unibase.Themes.Providers.DetailHelper.installedAppId == 0) {
  884. let detailContid = 'card-header-filters' + Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
  885. let listContid = 'filters-list' + Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
  886. if ($('#' + listContid).length == 1 && $('#' + detailContid).length == 1 && $('#' + detailContid).hasClass('dashboard-tab')) {
  887. type = `Unibase.Themes.Compact.Components.WalkThrough.Instance().${LayoutName}()`;
  888. data = eval(type);
  889. }
  890. else if ($('#' + listContid).length == 1) {
  891. type = `Unibase.Themes.Compact.Components.WalkThrough.Instance().app()`;
  892. data = eval(type);
  893. }
  894. }
  895. else if (Unibase.Themes.Providers.DetailHelper.installedAppId != 0) {
  896. type = `Unibase.Themes.Compact.Components.WalkThrough.Instance().details()`;
  897. data = eval(type);
  898. }
  899. if (JSONdata.dashboards.IsEnabled == false) {
  900. data.splice(data.findIndex(obj => obj.title == 'DashBoard'), 1);
  901. }
  902. if (JSONdata.apps.IsEnabled == false) {
  903. data.splice(data.findIndex(obj => obj.title == "Apps"), 1);
  904. }
  905. if (JSONdata.reports.IsEnabled == false) {
  906. data.splice(data.findIndex(obj => obj.title == "Reports"), 1);
  907. }
  908. let _data = JSON.stringify(data);
  909. let script = '';
  910. script += `window.tour = new Tour({
  911. padding: 0,
  912. nextText: 'More',
  913. doneText: 'Finito',
  914. prevText: 'Less',
  915. tipClasses: 'tip-class active',
  916. steps:${_data}
  917. });
  918. $('#bizgaze_body').css('pointer-events', 'none').find('.hk-wrapper').css('z-index','0');
  919. tour.override('showStep', function(self, step) {
  920. self(step);
  921. $('.ttour-header').addClass('d-flex justify-content-between align-items-center').find('h1').addClass('list-item-main-title');
  922. $('.ttour-header').append('<a href="javascript:;" onclick="tour.end()" title="skip" class="btn btn-flush-biz-theme btn-icon btn-rounded flush-soft-hover"><span class="btn-icon-wrap"><i class="fa fa-fast-forward" ></span></i></a>');
  923. $('.ttour-footer button').addClass('btn btn-flush-biz-theme btn-icon btn-rounded flush-soft-hover shadow-none');
  924. $('.ttour-footer .next').html('<span class="btn-icon-wrap" title="Next"><i class="font-20 la la-angle-right"></i></span>')
  925. $('.ttour-footer .prev').html('<span class="btn-icon-wrap" title="Prev"><i class="font-20 la la-angle-left"></i></span>')
  926. $('.ttour-bullets').append('<span>(<span class="current_step"></span> Of <span class="total_steps"></span>)</span>');
  927. let noOfSteps = $('.ttour-bullet').length;
  928. let currentStep = $('.ttour-bullet.active').index() + 1;
  929. $('.current_step').html(currentStep);
  930. $('.total_steps').html(noOfSteps);
  931. })
  932. tour.override('end', function(self, step) {
  933. self(step);
  934. $("#bizgaze_body").css("pointer-events", "auto").find('.hk-wrapper').removeAttr('style');
  935. })
  936. tour.start();
  937. if($('#layoutMainNavbar li.nav-group-container:not(.d-none)').length == 1){
  938. let offHeight = $("[data-target='#dash_drp']").offset().top - 15;
  939. // let innerHeight = $("[data-target='#dash_drp']").height() + 20;
  940. $('.ttour-tip.bottom').css('top', offHeight +'px');
  941. }`;
  942. eval(script);
  943. });
  944. }
  945. loadCommonFilterPanel(containerid) {
  946. const indexInstance = Unibase.Themes.Compact.Components.Index.Instance();
  947. $(`#bizCmnFilterDp_${containerid}`).removeClass('show');
  948. $(`#filter_toggle_btn${containerid}`).removeClass('d-flex').addClass('d-none');
  949. $(`#dynamic-filters${containerid}`).empty();
  950. $('.biz-pg-wrapper').first().addClass('has-cmn-filter-panel');
  951. $('#bizCmnFilterPanel').html(`<div class="cmn-filter-panel-wrap h-100 d-flex flex-column pa-0"><div class="cmn-filter-panel-head d-flex justify-content-between align-items-center border-bottom pa-10"><span class="cmn-filter-panel-head-title biz-secondary-text-color font-16">Common Filters</span><a href="javascript:void(0);" id="cmnFilterPanelClose" class="cmn-filter-panel-close btn btn-icon btn-flush-danger btn-rounded flush-soft-hover h-30p w-30p" onclick="Unibase.Themes.Compact.Components.Dashboard.Instance().closeCmnFilterPanel('${containerid}');" data-tooltip="true" title="Unpin Filters"><span class="btn-icon-wrap"><img src="tenants/themes/compact/imgs/unpin.png" class="img-fluid w-75" style="padding:3px;"/></span></a></div><div data-simplebar id="cmnFilterPanelBodyWrap" class="simple-scroll-bar cmn-filter-panel-body-wrap flex-grow-1"><div class="cmn-filter-panel-body cmn-filters-body pb-10" id="dynamic-filters_CmnFilterPanel_${containerid}"></div></div><div class="cmn-filter-panel-footer pa-10 pb-15 border-top" id="commonfilter_footerbuttons_CmnFilterPanel_${containerid}"></div>`).addClass('show');
  952. if (indexInstance.isTopLeftLayout()) {
  953. $('.biz-layout-3-top-navbar,.biz-layout-3-biz-pg-wrapper').addClass('hk-nav-toggle');
  954. $('.biz-layout-3-left-nav').addClass('biz__nav__toggle');
  955. }
  956. const portletId = +$("#hf_PortletId").val();
  957. Unibase.Platform.Analytics.Components._CommonFilter.Instance().commonFilter(portletId, `_CmnFilterPanel_${containerid}`);
  958. setTimeout(() => {
  959. Unibase.Themes.Compact.Components.Nav.Instance().showHideFilterNavIcons(containerid);
  960. }, 400);
  961. }
  962. closeCmnFilterPanel(containerid) {
  963. const indexInstance = Unibase.Themes.Compact.Components.Index.Instance();
  964. $('.biz-pg-wrapper').first().removeClass('has-cmn-filter-panel');
  965. $('#bizCmnFilterPanel').empty().removeClass('show');
  966. $(`.common-filter-dp-btn`).removeClass('d-none').addClass('d-flex');
  967. $('.common-filter-dropdown-body').removeClass('d-none');
  968. if (indexInstance.isTopLeftLayout()) {
  969. }
  970. let cls_fnav = $("#bizgaze_body").find('.biz-layout-3-top-navbar').hasClass("hk-nav-toggle");
  971. let cls_nav = $("#bizgaze_body").find('.biz-layout-3-top-navbar').hasClass("biz__nav__toggle");
  972. if (cls_fnav == true && cls_nav == false) {
  973. $('.biz-layout-3-top-navbar,.biz-layout-3-biz-pg-wrapper').removeClass('hk-nav-toggle');
  974. }
  975. setTimeout(() => {
  976. Unibase.Themes.Compact.Components.Nav.Instance().showHideFilterNavIcons(containerid);
  977. }, 400);
  978. }
  979. static Instance() {
  980. return new Dashboard();
  981. }
  982. }
  983. Dashboard.inputparameters = {};
  984. Components.Dashboard = Dashboard;
  985. })(Components = Compact.Components || (Compact.Components = {}));
  986. })(Compact = Themes.Compact || (Themes.Compact = {}));
  987. })(Themes = Unibase.Themes || (Unibase.Themes = {}));
  988. })(Unibase || (Unibase = {}));