123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- var Unibase;
- (function (Unibase) {
- let Platform;
- (function (Platform) {
- let Analytics;
- (function (Analytics) {
- let Reports;
- (function (Reports) {
- class ReportGroup extends Platform.Core.BaseComponent {
- constructor() {
- super();
- this.parentGroupId = 0;
- this.groupId = 0;
- this.groupName = '';
- this._reportManager = Analytics.Managers.ReportManager.Instance();
- }
- cssFiles() {
- return [];
- }
- jsFiles() {
- var jsFiles = ['platform/analytics/requests/reportgroup.js', 'platform/core/infos/status.js'];
- return jsFiles;
- }
- html(id, containerid) {
- let html = `<form id="" method="post" class="" data-formuniquekey="" data-validate="parsley"><header class="b-b bg-white modal-header"><strong class="text-dark Title" id="div_FormName">Create Report Group</strong></header><div class="bg-light control-sorting modal-body bg-white" style="overflow-y:auto; height:475px;"><div id="" class="clear bizgaze_FormErrorMessages"></div><div id="divReportGroup_ErrorMessage"></div><div class="section_ReportGroup card"><div class="card-body">
- <div class="row">
- <div class="col-sm-6">
- <div>
- <label for="lbl" id="lbl_GroupName">Report Group Name
- <span class="text-danger" id="spnIsRequired_reportgroup"> *</span>
- </label>
- <input type="text" id="txt_GroupName" class="type-control form-control type-control value-control required"
- data-regularexp="" data-validatemsg="" placeholder="Enter Report Group Name *">
- </div>
- <label for="Validation" id="lblValidation_GroupName"></label>
- </div>
- <div class="col-sm-6">
- <label for="lbl" id="lbl_displayname">Display Name</label>
- <input type="text" id="txt_displayname" class="type-control form-control type-control value-control required"
- data-regularexp="" data-validatemsg="" placeholder="Enter Display Name ">
- <label for="Validation" id="lblValidation_displayname"></label>
- </div>
-
- <div class="IsInternalGroupDiv col-sm-6 flex-between-center">
- <span>IsInternalGroup</span>
- <label class="switch mb-0" for="reportGroup_IsInternalGroup">
- <input type="checkbox" id="reportGroup_IsInternalGroup"><span></span>
- <input type="hidden" id="hf_IsInternalGroup"> <input type="hidden" class="value-control"
- id="hf_IsInternalGroupid">
- </label>
- </div>
-
- <div id="" class="form-group col-sm-6">
- <label for="lbl" id="lbl_reportgroupindex">Report Group Index
- <span class="text-danger " id="spnIsRequired_reportgroupindex"></span>
- </label>
- <input type="text" id="txt_reportgroupindex"
- class="type-control form-control type-control value-control required"
- data-regularexp="" data-validatemsg="" placeholder="Enter Report Group Index *">
- </div>
- <div class="form-group col-sm-6">
- <label for="parentgroupid">
- Parent Group
- </label>
- <select class="form-control" id="parentgroupid" >
- </select>
- </div>
- <div class="IsEnableFolder col-sm-6 flex-between-center">
- <span>EnableFolder</span>
- <label class="switch mb-0" for="reportGroup_IsEnableFolder">
- <input type="checkbox" id="reportGroup_IsEnableFolder"><span></span>
- <input type="hidden" id="hf_IsEnableFolder"> <input type="hidden" class="value-control" id="hf_IsEnableFolder">
- </label>
- </div>
- <label for="Validation" id="lblValidation_GroupName"></label>
- </div></div></div></div></div><footer class="bg-white modal-footer" id="formFooter"><a href="javascript:;" id="btn_CloseForm" class="btn btn-light btn-sm mr-auto" onclick=""> Close</a><a href="javascript:;" id="btn_SaveReportGrp" class="btn btn-primary btn-sm" > Save</a></footer></form>`;
- return html;
- }
- load(id, containerid, callback) {
- var instance = this;
- instance.parentGroupId = 0;
- $("#" + containerid).find(".modal-body").css('height', $(window).outerHeight() - $("#" + containerid).find(".modal-header").outerHeight() - $("#" + containerid).find(".modal-footer").outerHeight() + 'px');
- if (id != 0)
- instance.loadReportGroup(id);
- $("#btn_SaveReportGrp").click(function () {
- let isInternal = $("#reportGroup_IsInternalGroup").prop("checked");
- let isEnableFolder = $("#reportGroup_IsEnableFolder").prop("checked");
- let groupIndex = $("#txt_reportgroupindex").val();
- if ($("#txt_GroupName").val() == "")
- return MessageHelper.Instance().showError("Please select ReportGroup", 'divReportGroup_ErrorMessage');
- let model = new Unibase.Platform.Analytics.Reports.Requests.ReportGroup();
- model.GroupName = String($("#txt_GroupName").val());
- model.ReportGroupId = id;
- model.IsInternalGroup = isInternal;
- model.EnableFolder = isEnableFolder;
- model.ReportGroupIndex = !parseInt(groupIndex) ? 0 : parseInt(groupIndex);
- model.ParentGroupId = instance.parentGroupId;
- model.DisplayName = String($("#txt_displayname").val());
- instance._reportManager.saveReportGroup(model).then(function (response) {
- let res = JSON.parse(response.result);
- if (response.status == Unibase.Data.Status.Error) {
- MessageHelper.Instance().showError(response.message, 'divReportGroup_ErrorMessage');
- }
- else {
- $("#RptGroup_AutoComplete").append("<option selected value=" + res.ReportGroupId + ">" + res.GroupName + "</option>");
- MessageHelper.Instance().showSuccess(response.message, '');
- $('#' + containerid).modal('hide');
- $('#' + containerid).remove();
- }
- });
- });
- $("#btn_CloseForm").click(function () {
- $('#' + containerid).modal('hide');
- $('#' + containerid).remove();
- $("#RptGroup_AutoComplete").remove();
- });
- instance.loadReportGroups();
- $("#parentgroupid").change(function (e) {
- instance.parentGroupId = Number(e.currentTarget.value);
- var parentGroupName = e.currentTarget.textContent.trim();
- if (instance.groupId == instance.parentGroupId) {
- e.currentTarget.value = "0";
- e.currentTarget.textContent = "";
- MessageHelper.Instance().showError(`Cannot select same report group as parent group`, 'divReportGroup_ErrorMessage');
- return false;
- }
- if (instance.groupId && instance.parentGroupId) {
- instance._reportManager.checkReportGroupDependency(instance.groupId, instance.parentGroupId).then((response) => {
- if (response.status == Unibase.Data.Status.Success && response.result) {
- e.currentTarget.value = "0";
- e.currentTarget.textContent = "";
- MessageHelper.Instance().showError(`Parent group ${parentGroupName} has the current report group ${instance.groupName} as parent group, change the parent report group and try again`, 'divReportGroup_ErrorMessage');
- return false;
- }
- });
- }
- });
- }
- loadForm(FormId, Pk_Value, AppConfigurationId, Callback, ElementId) {
- var instance = this;
- instance.navigationHelper.popup(0, '', instance, null, Platform.Helpers.Size.Large);
- }
- loadReportGroupForm(iscreate) {
- var Pk_Value = 0;
- var instance = this;
- if (!iscreate) {
- Pk_Value = Unibase.Themes.Providers.DetailHelper.recordId;
- }
- instance.navigationHelper.popup(Pk_Value, '', instance, null, Platform.Helpers.Size.Large);
- }
- editReportGroup() {
- var instance = this;
- var reportGroupId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key.endsWith("reportgroupid")).Value);
- instance.navigationHelper.popup(reportGroupId, "", instance, null, Unibase.Platform.Helpers.Size.Large);
- }
- loadReportGroup(id) {
- var instance = this;
- instance._reportManager.getReportGroupById(id).then(function (response) {
- if (response.status == Unibase.Data.Status.Success) {
- var res = response.result;
- instance.groupId = response.result.ReportGroupId;
- instance.groupName = response.result.GroupName;
- instance.displayName = response.result.DisplayName;
- $("#txt_GroupName").val(res.GroupName).attr("disabled", "disabled");
- $("#reportGroup_IsInternalGroup").prop("checked", res.IsInternalGroup);
- $("#reportGroup_IsEnableFolder").prop("checked", res.EnableFolder);
- $("#txt_reportgroupindex").val(res.ReportGroupIndex);
- $("#txt_displayname").val(res.DisplayName);
- if (res.ParentGroupId) {
- instance.parentGroupId = res.ParentGroupId;
- instance._reportManager.getReportGroupById(res.ParentGroupId).then(res => {
- if (res.status == Unibase.Data.Status.Success) {
- var option = new Option(res.result.RecursiveParentName, res.result.ReportGroupId.toString(), true, true);
- $("#parentgroupid").append(option);
- }
- });
- }
- }
- else {
- return MessageHelper.Instance().showError(response.message, "divReportGroup_ErrorMessage");
- }
- });
- }
- exportGroupReports(reportgroupid) {
- var instance = this;
- var ReportGroupId = 0;
- if (reportgroupid == 0)
- ReportGroupId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key.endsWith("reportgroupid")).Value);
- else
- ReportGroupId = reportgroupid;
- if (ReportGroupId != 0) {
- instance.navigationHelper.showLoading();
- instance._reportManager.getReportGroupById(ReportGroupId).then(function (response) {
- let groupname = response.result.GroupName;
- instance._reportManager.exportGroupreports(ReportGroupId).then(function (rptgrpresponse) {
- var filename = groupname + ".xml";
- var xmltext = rptgrpresponse.result;
- var pom = document.createElement('a');
- var bb = new Blob([xmltext], { type: 'text/plain' });
- pom.setAttribute('href', window.URL.createObjectURL(bb));
- pom.setAttribute('download', filename);
- pom.dataset.downloadurl = ['text/plain', pom.download, pom.href].join(':');
- pom.draggable = true;
- pom.classList.add('dragout');
- pom.click();
- instance.navigationHelper.hideLoading();
- });
- });
- }
- }
- deleteReportGroup() {
- const reportGroupId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key.endsWith("reportgroupid")).Value);
- const reportCount = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key.endsWith("reportcount")).Value);
- if (!reportCount) {
- bootbox.confirm("Are you sure to delete this group?", (result) => {
- if (result) {
- this._reportManager.deleteReportGroup(reportGroupId).then((response) => {
- if (response.status == Unibase.Data.Status.Success) {
- MessageHelper.Instance().showSuccess("Report group has been sucessfully deleted", 'divReportGroup_ErrorMessage');
- Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallAppId("Unibase_Platform_Analytics_Reports_App_ReportsGroup").then((response) => {
- if (response.status == Unibase.Data.Status.Success)
- Unibase.Themes.Compact.Components.Nav.Instance().loadList(response.result.InstalledAppId);
- });
- }
- else
- MessageHelper.Instance().showError(response.message, 'divReportGroup_ErrorMessage');
- });
- }
- });
- }
- else
- bootbox.confirm("One or more reports are associated with this group, Please ensure to delete all reports associated with this group before deleting", () => { });
- }
- loadReportGroups() {
- var url = _appsettings.server_url() + '/apis/v4/unibase/platform/analytics/reportgroups_autocompleterecursive';
- AutoCompleteHelper.getHelper().Create("#parentgroupid", "#hfAutoComplete_ReportGroup", url, null);
- }
- updateStatus() {
- var instance = this;
- let reportidGroupId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key.endsWith("reportgroupid")).Value);
- let statusId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key.endsWith("statusid")).Value);
- let installedappId = Number(Unibase.Themes.Providers.DetailHelper.installedAppId);
- $("#DetailSetting_" + installedappId + "_Active").removeClass("btn-outline-primary");
- if (statusId == Unibase.Platform.Core.Enums.RowStatus.Active) {
- $("#DetailSetting_" + installedappId + "_Active").addClass("btn-success");
- $("#DetailSetting_" + installedappId + "_Active").removeClass("btn-red");
- }
- else {
- $("#DetailSetting_" + installedappId + "_Active").removeClass("btn-success");
- $("#DetailSetting_" + installedappId + "_Active").addClass("btn-red");
- }
- $("#DetailSetting_" + installedappId + "_Active").text((statusId == Unibase.Platform.Core.Enums.RowStatus.Active) ? "Active" : "InActive");
- $("#DetailSetting_" + installedappId + "_Active").click(function () {
- let id = Unibase.Platform.Core.Enums.RowStatus.Active;
- if ($("#DetailSetting_" + installedappId + "_Active").text() == "Active")
- id = Unibase.Platform.Core.Enums.RowStatus.InActive;
- instance._reportManager.updateReportGroupStatus(reportidGroupId, id).then(function (statusres) {
- if (statusres.status == Unibase.Data.Status.Success) {
- }
- });
- });
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new ReportGroup();
- }
- return this.instance;
- }
- }
- Reports.ReportGroup = ReportGroup;
- })(Reports = Analytics.Reports || (Analytics.Reports = {}));
- })(Analytics = Platform.Analytics || (Platform.Analytics = {}));
- })(Platform = Unibase.Platform || (Unibase.Platform = {}));
- })(Unibase || (Unibase = {}));
|