var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var Unibase;
(function (Unibase) {
let Platform;
(function (Platform) {
let Analytics;
(function (Analytics) {
let Components;
(function (Components) {
class UserDesignReportviewer extends Components._ReportViewer {
constructor() {
super(...arguments);
this.PortletWidgetId = 0;
this.totalreportWidgetData = [];
this.ReportId = 0;
}
jsFiles() {
return this._jsFiles();
}
cssFiles() {
return this._cssFiles();
}
html(id, containerid) {
var instance = this;
let html = ``;
return html;
}
load(id, containerid, callback) {
var instance = this;
}
init(containerid) {
var instance = this;
instance.loadReports(containerid);
$(".biz-highlight-opacity").mouseover(function () {
$(this).css({ "cursor": "context-menu" });
});
$('.clear_icon').click(function () {
$("#ListSearch").val('');
$('.userdesignedTreeview_' + containerid).find('.report-group-tree-view').css("display", "block");
$('.userdesignedTreeview_' + containerid).find('.report-group-tree-view').find('.lireportgrp-item a').css("display", "block");
$(".clear_icon").addClass("d-none");
});
}
reportGroupTemplate() {
let html;
html = `
{{ReportGroupName}}
`;
return html;
}
reportTemplate(containerid) {
let html = '';
if (screen.width > 1198) {
html = `
{{DisplayName}}`;
return html;
}
else {
html = `
{{DisplayName}}`;
return html;
}
}
loadReports(containerid) {
let reportid = 0;
if (jQuery("#" + containerid).html().length < 10) {
var jsfiles = [
"platform/analytics/managers/reportmanager.js",
"platform/apps/managers/appmanager.js",
"platform/analytics/infos/report.js"
];
$(`.${containerid}`).append(``);
let height = $(`.${containerid}`).siblings('#hf_portletwidgetheight').val();
if (height != '0px') {
$('.userDesignWidgetCardBody').css({ "height": `` + height + ``, "overflow-x": "hidden" }).addClass("biz-custom-scrollbar");
}
var instance = this;
this.fileCacheHelper.loadJsFiles(jsfiles, function () {
return __awaiter(this, void 0, void 0, function* () {
yield Unibase.Platform.Analytics.Managers.ReportManager.Instance().getViewableReports().then(function (response) {
if (response.result.length != 0) {
var allReports = response.result;
var reportWidgetData = response.result;
let html = "";
let groupTemplate = UserDesignReportviewer.Instance().reportGroupTemplate();
let reportTemplate = UserDesignReportviewer.Instance().reportTemplate(containerid);
var groupTemplateScript = Handlebars.compile(groupTemplate);
var reportTemplateScript = Handlebars.compile(reportTemplate);
let filterReportGroups = allReports.filter((report, index, self) => index === self.findIndex((x) => (x.ReportGroupId === report.ReportGroupId)));
filterReportGroups = filterReportGroups.filter(x => x.IsInternalGroup == false);
$.each(filterReportGroups, function (index, group) {
let context = { "ReportGroupId": group.ReportGroupId, "ReportGroupName": group.GroupName };
html += groupTemplateScript(context);
});
$(`.userdesignedTreeview_${containerid}`).append(html);
$.each(allReports, function (index, report) {
let reportHtml = "";
if (!report.DisplayName)
report.DisplayName = report.ReportName;
var context = report;
reportHtml = reportTemplateScript(context);
$(`#reportgroup-tree-${report.ReportGroupId}`).append(reportHtml);
});
if (($(window).width()) <= 575) {
$("#userdesignedTreeview").css({ "column-count": "1" });
$(".search-wrapper").css({ "display": "block !important" });
}
$('#' + containerid).find("#ListSearch").on('keyup', function () {
$(".clear_icon").removeClass("d-none");
var _value = $(this).val().toString(), value = _value.toUpperCase();
if (_value == '') {
$(".clear_icon").addClass("d-none");
}
$('.userdesignedTreeview_' + containerid).find('.report-group-tree-view').each(function () {
let reportName = $(this).find('.lireportgrp-item a').text();
if (reportName.toUpperCase().indexOf(value) > -1) {
$(this).css('display', 'block');
$(this).find('.lireportgrp-item a').each(function () {
let reportName = $(this).text();
let reportGroupName = $(this).find('.a').text();
if (reportName.toUpperCase().indexOf(value) > -1) {
$(this).parent().css('display', 'block');
}
else {
$(this).parent().css('display', 'none');
}
});
}
else {
$(this).css('display', 'none');
}
});
});
}
});
});
});
}
}
static Instance() {
if (this._instance === undefined)
this._instance = new UserDesignReportviewer();
return this._instance;
}
}
Components.UserDesignReportviewer = UserDesignReportviewer;
})(Components = Analytics.Components || (Analytics.Components = {}));
})(Analytics = Platform.Analytics || (Platform.Analytics = {}));
})(Platform = Unibase.Platform || (Unibase.Platform = {}));
})(Unibase || (Unibase = {}));