123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- var Unibase;
- (function (Unibase) {
- let Themes;
- (function (Themes) {
- let Compact;
- (function (Compact) {
- let KpiWidgets;
- (function (KpiWidgets) {
- class TwoValue extends Unibase.Platform.Core.BaseComponent {
- jsFiles() {
- return [];
- }
- cssFiles() {
- return [];
- }
- html(id, containerid) {
- let title = id[0].WidgetName;
- let html = '<div class="card mb-0 card-sm kpi-card" id="widget_kpis_TwoValue">' +
- '<a href="javascript:;" class="kpi-link-report" onclick = "Unibase.Themes.Compact.KpiWidgets.TwoValue.Instance().linkReport(' + id[0].WidgetId + ',' + id[0].PortletWidgetId + ',' + "'" + containerid + "'" + ')" style = "margin-top:-20px;" > <small id="showreport_' + id[0].PortletWidgetId + '" class="font-sm-11"><span class="nav-icon-wrap"><i class="font-14 dripicons dripicons-graph-pie text-dark"></i></span></small></a>' +
- '<div class="card-body p-2">' +
- '<span class="d-block mb-10" ><span id="hf_kpi_widgetName_' + id[0].PortletWidgetId + '" data-kpi="kpi_font">' + title + '</span>' +
- '<span class="d-block align-items-center card-action-wrap pull-right font-11" >' +
- '<a href="#" class="inline-block full-screen mr-15 hidden" id="kpi_FullScreen_' + id[0].PortletWidgetId + '">' +
- '<i class="ion ion-md-expand"></i>' +
- '</a>' +
- '</span>' +
- '<span id="config_widget_' + id[0].PortletWidgetId + '"></span>' +
- '</span>' +
- '<div class="pull-right" style="margin-top:-10px;"><div id="span_kpi_icon_' + id[0].PortletWidgetId + '" ></div></div>' +
- '<span class="d-block display-7" style="font-weight:400;font-size:20px;" id="kpi_Twovalue_1_' + id[0].PortletWidgetId + '">000000</span>' +
- '<small id="kpi_Twovalue_2_' + id[0].PortletWidgetId + '">000</small><br>' +
- '</div>' +
- '</div>';
- return html;
- }
- load(id, containerid, callback) {
- let instance = this;
- let inputparameters = Unibase.Themes.Providers.DashboardHelper.Instance().replaceWidgetParameterValues(id[0].WidgetParameters, id[0].InstalledAppId);
- let fromDate = "", toDate = "";
- var cf_fromDate = Unibase.Platform.Membership.Infos.Identity.currentUser.fromDate;
- var cf_toDate = Unibase.Platform.Membership.Infos.Identity.currentUser.toDate;
- if (cf_fromDate != null && cf_toDate != null) {
- fromDate = cf_fromDate.toString();
- toDate = cf_toDate.toString();
- }
- else {
- fromDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(new Date(Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate()), "YYYY/MM/DD");
- toDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateformat(new Date(Unibase.Platform.Helpers.DateTimeHelper.Instance().currentDate()), "YYYY/MM/DD");
- }
- var parameters = {
- WidgetId: id[0].WidgetId,
- PortletWidgetId: id[0].PortletWidgetId,
- InstalledAppId: id[0].InstalledAppId,
- InputParameters: inputparameters,
- FromDate: fromDate,
- ToDate: toDate
- };
- instance.loadResponseData(id[0].PortletWidgetId, containerid, parameters);
- }
- loadResponseData(portletwidgetid, detailContainer, parameters) {
- let instance = this;
- instance.inputParameters = parameters.InputParameters;
- Unibase.Platform.Widgets.Managers.WidgetManager.Instance().getKpiWidgetData(parameters).then(function (response) {
- instance.loadData(portletwidgetid, detailContainer, parameters, false, response);
- });
- }
- loadData(portletwidgetid, detailcontainer, parameters, IsPreview, response) {
- detailcontainer = '.' + detailcontainer;
- var post = response.result;
- if (post != null) {
- if (post.IsMaximize == true) {
- $("#kpi_FullScreen_" + portletwidgetid).removeClass("hidden");
- }
- if (post.Data == null || post.Data == "" || post.Data == '[]') {
- $(detailcontainer).find("#kpi_Twovalue_1_" + portletwidgetid).removeClass('display-6');
- $(detailcontainer).find("#kpi_Twovalue_1_" + portletwidgetid).addClass('display-8');
- $(detailcontainer).find("#kpi_Twovalue_1_" + portletwidgetid).text("No Data");
- }
- else {
- var data = JSON.parse(post.Data)[0];
- var selected_values = post.Selected_Columns;
- if (selected_values != null) {
- var sp = selected_values.split(',');
- var column1 = sp[0];
- var column2 = sp[1];
- }
- var Value_1 = data[column1];
- var Value_2 = data[column2];
- if (isNaN(Value_1)) {
- }
- else {
- Value_1 = Unibase.Core.Helpers.NumberHelper.Instance().roundNumber(Value_1, 2);
- }
- $(detailcontainer).find("#kpi_Twovalue_1_" + portletwidgetid).text(Value_1);
- $(detailcontainer).find("#kpi_Twovalue_2_" + portletwidgetid).text(Value_2);
- if (post.Icon != "" || post.Icon != null) {
- let iconhtml = '<img id="kpi_icon_' + portletwidgetid + '"src="' + post.Icon + '" style="width:50px;"/>';
- $("#span_kpi_icon_" + portletwidgetid).html(iconhtml);
- }
- }
- var color = post.Color;
- if (post.Color != "" && post.Color != null) {
- $(detailcontainer).find("#kpi_Twovalue_1_" + portletwidgetid).addClass("text-" + color);
- }
- var colors = ["primary", "success", "warning", "danger", "info", "light", "secondary", "dark"];
- if (response.result.AppConfigurations != null) {
- if (response.result.AppConfigurations.length != 0) {
- var designhtml = "";
- var appconfig = response.result.AppConfigurations;
- for (var i = 0; i < appconfig.length; i++) {
- var onlickurl = "";
- var sname = appconfig[i].SettingName.replace(/ /g, '');
- designhtml += ' <span class="mr-10"><a href="javascript:;" id="widgetconfig_' + sname + '" onclick="' + onlickurl + '">' +
- '<button class="btn btn-sm btn-' + colors[i] + ' pull-right btn-rounded text-white">' + appconfig[i].SettingName + '</button>' +
- '</a> </span>';
- }
- designhtml += "</div>";
- $(detailcontainer).find("#config_widget_" + portletwidgetid).html(designhtml);
- }
- }
- if (response.result.ReportId == 0 || response.result.ReportId == null) {
- $(detailcontainer).find("#showreport_" + portletwidgetid).addClass("hidden");
- }
- if (post.LinkReportId != 0 && post.LinkReportId != null) {
- }
- else {
- $(detailcontainer).find("#showreport_" + portletwidgetid).addClass('hidden');
- }
- }
- $(detailcontainer).siblings('.line-loader').remove();
- $(detailcontainer).removeClass('hidden');
- }
- linkReport(widgetid, portletwidgetid, containerid) {
- var instance = this;
- Unibase.Platform.Widgets.Managers.WidgetManager.Instance().getKPIWidget(widgetid).then(function (response) {
- var res = response.result;
- if (res != null) {
- let containerid = "div_kpireport_" + portletwidgetid;
- var rv_obj = Unibase.Platform.Analytics.Components.ReportViewer.Instance();
- instance.navigationHelper.popup(res.LinkReportId, containerid, rv_obj, null, Unibase.Platform.Helpers.Size.ExtraLarge);
- }
- });
- }
- static Instance() {
- if (this.instance === null || this.instance === undefined)
- this.instance = new TwoValue();
- return this.instance;
- }
- }
- KpiWidgets.TwoValue = TwoValue;
- })(KpiWidgets = Compact.KpiWidgets || (Compact.KpiWidgets = {}));
- })(Compact = Themes.Compact || (Themes.Compact = {}));
- })(Themes = Unibase.Themes || (Unibase.Themes = {}));
- })(Unibase || (Unibase = {}));
|