Built files from Bizgaze WebServer
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

reportgroup.js 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. var Unibase;
  2. (function (Unibase) {
  3. let Platform;
  4. (function (Platform) {
  5. let Analytics;
  6. (function (Analytics) {
  7. let Reports;
  8. (function (Reports) {
  9. class ReportGroup extends Platform.Core.BaseComponent {
  10. constructor() {
  11. super();
  12. this.parentGroupId = 0;
  13. this.groupId = 0;
  14. this.groupName = '';
  15. this._reportManager = Analytics.Managers.ReportManager.Instance();
  16. }
  17. cssFiles() {
  18. return [];
  19. }
  20. jsFiles() {
  21. var jsFiles = ['platform/analytics/requests/reportgroup.js', 'platform/core/infos/status.js'];
  22. return jsFiles;
  23. }
  24. html(id, containerid) {
  25. 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">
  26. <div class="row">
  27. <div class="col-sm-6">
  28. <div>
  29. <label for="lbl" id="lbl_GroupName">Report Group Name
  30. <span class="text-danger" id="spnIsRequired_reportgroup"> *</span>
  31. </label>
  32. <input type="text" id="txt_GroupName" class="type-control form-control type-control value-control required"
  33. data-regularexp="" data-validatemsg="" placeholder="Enter Report Group Name *">
  34. </div>
  35. <label for="Validation" id="lblValidation_GroupName"></label>
  36. </div>
  37. <div class="col-sm-6">
  38. <label for="lbl" id="lbl_displayname">Display Name</label>
  39. <input type="text" id="txt_displayname" class="type-control form-control type-control value-control required"
  40. data-regularexp="" data-validatemsg="" placeholder="Enter Display Name ">
  41. <label for="Validation" id="lblValidation_displayname"></label>
  42. </div>
  43. <div class="IsInternalGroupDiv col-sm-6 flex-between-center">
  44. <span>IsInternalGroup</span>
  45. <label class="switch mb-0" for="reportGroup_IsInternalGroup">
  46. <input type="checkbox" id="reportGroup_IsInternalGroup"><span></span>
  47. <input type="hidden" id="hf_IsInternalGroup"> <input type="hidden" class="value-control"
  48. id="hf_IsInternalGroupid">
  49. </label>
  50. </div>
  51. <div id="" class="form-group col-sm-6">
  52. <label for="lbl" id="lbl_reportgroupindex">Report Group Index
  53. <span class="text-danger " id="spnIsRequired_reportgroupindex"></span>
  54. </label>
  55. <input type="text" id="txt_reportgroupindex"
  56. class="type-control form-control type-control value-control required"
  57. data-regularexp="" data-validatemsg="" placeholder="Enter Report Group Index *">
  58. </div>
  59. <div class="form-group col-sm-6">
  60. <label for="parentgroupid">
  61. Parent Group
  62. </label>
  63. <select class="form-control" id="parentgroupid" >
  64. </select>
  65. </div>
  66. <div class="IsEnableFolder col-sm-6 flex-between-center">
  67. <span>EnableFolder</span>
  68. <label class="switch mb-0" for="reportGroup_IsEnableFolder">
  69. <input type="checkbox" id="reportGroup_IsEnableFolder"><span></span>
  70. <input type="hidden" id="hf_IsEnableFolder"> <input type="hidden" class="value-control" id="hf_IsEnableFolder">
  71. </label>
  72. </div>
  73. <label for="Validation" id="lblValidation_GroupName"></label>
  74. </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>`;
  75. return html;
  76. }
  77. load(id, containerid, callback) {
  78. var instance = this;
  79. instance.parentGroupId = 0;
  80. $("#" + containerid).find(".modal-body").css('height', $(window).outerHeight() - $("#" + containerid).find(".modal-header").outerHeight() - $("#" + containerid).find(".modal-footer").outerHeight() + 'px');
  81. if (id != 0)
  82. instance.loadReportGroup(id);
  83. $("#btn_SaveReportGrp").click(function () {
  84. let isInternal = $("#reportGroup_IsInternalGroup").prop("checked");
  85. let isEnableFolder = $("#reportGroup_IsEnableFolder").prop("checked");
  86. let groupIndex = $("#txt_reportgroupindex").val();
  87. if ($("#txt_GroupName").val() == "")
  88. return MessageHelper.Instance().showError("Please select ReportGroup", 'divReportGroup_ErrorMessage');
  89. let model = new Unibase.Platform.Analytics.Reports.Requests.ReportGroup();
  90. model.GroupName = String($("#txt_GroupName").val());
  91. model.ReportGroupId = id;
  92. model.IsInternalGroup = isInternal;
  93. model.EnableFolder = isEnableFolder;
  94. model.ReportGroupIndex = !parseInt(groupIndex) ? 0 : parseInt(groupIndex);
  95. model.ParentGroupId = instance.parentGroupId;
  96. model.DisplayName = String($("#txt_displayname").val());
  97. instance._reportManager.saveReportGroup(model).then(function (response) {
  98. let res = JSON.parse(response.result);
  99. if (response.status == Unibase.Data.Status.Error) {
  100. MessageHelper.Instance().showError(response.message, 'divReportGroup_ErrorMessage');
  101. }
  102. else {
  103. $("#RptGroup_AutoComplete").append("<option selected value=" + res.ReportGroupId + ">" + res.GroupName + "</option>");
  104. MessageHelper.Instance().showSuccess(response.message, '');
  105. $('#' + containerid).modal('hide');
  106. $('#' + containerid).remove();
  107. }
  108. });
  109. });
  110. $("#btn_CloseForm").click(function () {
  111. $('#' + containerid).modal('hide');
  112. $('#' + containerid).remove();
  113. $("#RptGroup_AutoComplete").remove();
  114. });
  115. instance.loadReportGroups();
  116. $("#parentgroupid").change(function (e) {
  117. instance.parentGroupId = Number(e.currentTarget.value);
  118. var parentGroupName = e.currentTarget.textContent.trim();
  119. if (instance.groupId == instance.parentGroupId) {
  120. e.currentTarget.value = "0";
  121. e.currentTarget.textContent = "";
  122. MessageHelper.Instance().showError(`Cannot select same report group as parent group`, 'divReportGroup_ErrorMessage');
  123. return false;
  124. }
  125. if (instance.groupId && instance.parentGroupId) {
  126. instance._reportManager.checkReportGroupDependency(instance.groupId, instance.parentGroupId).then((response) => {
  127. if (response.status == Unibase.Data.Status.Success && response.result) {
  128. e.currentTarget.value = "0";
  129. e.currentTarget.textContent = "";
  130. 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');
  131. return false;
  132. }
  133. });
  134. }
  135. });
  136. }
  137. loadForm(FormId, Pk_Value, AppConfigurationId, Callback, ElementId) {
  138. var instance = this;
  139. instance.navigationHelper.popup(0, '', instance, null, Platform.Helpers.Size.Large);
  140. }
  141. loadReportGroupForm(iscreate) {
  142. var Pk_Value = 0;
  143. var instance = this;
  144. if (!iscreate) {
  145. Pk_Value = Unibase.Themes.Providers.DetailHelper.recordId;
  146. }
  147. instance.navigationHelper.popup(Pk_Value, '', instance, null, Platform.Helpers.Size.Large);
  148. }
  149. editReportGroup() {
  150. var instance = this;
  151. var reportGroupId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key.endsWith("reportgroupid")).Value);
  152. instance.navigationHelper.popup(reportGroupId, "", instance, null, Unibase.Platform.Helpers.Size.Large);
  153. }
  154. loadReportGroup(id) {
  155. var instance = this;
  156. instance._reportManager.getReportGroupById(id).then(function (response) {
  157. if (response.status == Unibase.Data.Status.Success) {
  158. var res = response.result;
  159. instance.groupId = response.result.ReportGroupId;
  160. instance.groupName = response.result.GroupName;
  161. instance.displayName = response.result.DisplayName;
  162. $("#txt_GroupName").val(res.GroupName).attr("disabled", "disabled");
  163. $("#reportGroup_IsInternalGroup").prop("checked", res.IsInternalGroup);
  164. $("#reportGroup_IsEnableFolder").prop("checked", res.EnableFolder);
  165. $("#txt_reportgroupindex").val(res.ReportGroupIndex);
  166. $("#txt_displayname").val(res.DisplayName);
  167. if (res.ParentGroupId) {
  168. instance.parentGroupId = res.ParentGroupId;
  169. instance._reportManager.getReportGroupById(res.ParentGroupId).then(res => {
  170. if (res.status == Unibase.Data.Status.Success) {
  171. var option = new Option(res.result.RecursiveParentName, res.result.ReportGroupId.toString(), true, true);
  172. $("#parentgroupid").append(option);
  173. }
  174. });
  175. }
  176. }
  177. else {
  178. return MessageHelper.Instance().showError(response.message, "divReportGroup_ErrorMessage");
  179. }
  180. });
  181. }
  182. exportGroupReports(reportgroupid) {
  183. var instance = this;
  184. var ReportGroupId = 0;
  185. if (reportgroupid == 0)
  186. ReportGroupId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key.endsWith("reportgroupid")).Value);
  187. else
  188. ReportGroupId = reportgroupid;
  189. if (ReportGroupId != 0) {
  190. instance.navigationHelper.showLoading();
  191. instance._reportManager.getReportGroupById(ReportGroupId).then(function (response) {
  192. let groupname = response.result.GroupName;
  193. instance._reportManager.exportGroupreports(ReportGroupId).then(function (rptgrpresponse) {
  194. var filename = groupname + ".xml";
  195. var xmltext = rptgrpresponse.result;
  196. var pom = document.createElement('a');
  197. var bb = new Blob([xmltext], { type: 'text/plain' });
  198. pom.setAttribute('href', window.URL.createObjectURL(bb));
  199. pom.setAttribute('download', filename);
  200. pom.dataset.downloadurl = ['text/plain', pom.download, pom.href].join(':');
  201. pom.draggable = true;
  202. pom.classList.add('dragout');
  203. pom.click();
  204. instance.navigationHelper.hideLoading();
  205. });
  206. });
  207. }
  208. }
  209. deleteReportGroup() {
  210. const reportGroupId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key.endsWith("reportgroupid")).Value);
  211. const reportCount = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key.endsWith("reportcount")).Value);
  212. if (!reportCount) {
  213. bootbox.confirm("Are you sure to delete this group?", (result) => {
  214. if (result) {
  215. this._reportManager.deleteReportGroup(reportGroupId).then((response) => {
  216. if (response.status == Unibase.Data.Status.Success) {
  217. MessageHelper.Instance().showSuccess("Report group has been sucessfully deleted", 'divReportGroup_ErrorMessage');
  218. Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallAppId("Unibase_Platform_Analytics_Reports_App_ReportsGroup").then((response) => {
  219. if (response.status == Unibase.Data.Status.Success)
  220. Unibase.Themes.Compact.Components.Nav.Instance().loadList(response.result.InstalledAppId);
  221. });
  222. }
  223. else
  224. MessageHelper.Instance().showError(response.message, 'divReportGroup_ErrorMessage');
  225. });
  226. }
  227. });
  228. }
  229. else
  230. bootbox.confirm("One or more reports are associated with this group, Please ensure to delete all reports associated with this group before deleting", () => { });
  231. }
  232. loadReportGroups() {
  233. var url = _appsettings.server_url() + '/apis/v4/unibase/platform/analytics/reportgroups_autocompleterecursive';
  234. AutoCompleteHelper.getHelper().Create("#parentgroupid", "#hfAutoComplete_ReportGroup", url, null);
  235. }
  236. updateStatus() {
  237. var instance = this;
  238. let reportidGroupId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key.endsWith("reportgroupid")).Value);
  239. let statusId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key.endsWith("statusid")).Value);
  240. let installedappId = Number(Unibase.Themes.Providers.DetailHelper.installedAppId);
  241. $("#DetailSetting_" + installedappId + "_Active").removeClass("btn-outline-primary");
  242. if (statusId == Unibase.Platform.Core.Enums.RowStatus.Active) {
  243. $("#DetailSetting_" + installedappId + "_Active").addClass("btn-success");
  244. $("#DetailSetting_" + installedappId + "_Active").removeClass("btn-red");
  245. }
  246. else {
  247. $("#DetailSetting_" + installedappId + "_Active").removeClass("btn-success");
  248. $("#DetailSetting_" + installedappId + "_Active").addClass("btn-red");
  249. }
  250. $("#DetailSetting_" + installedappId + "_Active").text((statusId == Unibase.Platform.Core.Enums.RowStatus.Active) ? "Active" : "InActive");
  251. $("#DetailSetting_" + installedappId + "_Active").click(function () {
  252. let id = Unibase.Platform.Core.Enums.RowStatus.Active;
  253. if ($("#DetailSetting_" + installedappId + "_Active").text() == "Active")
  254. id = Unibase.Platform.Core.Enums.RowStatus.InActive;
  255. instance._reportManager.updateReportGroupStatus(reportidGroupId, id).then(function (statusres) {
  256. if (statusres.status == Unibase.Data.Status.Success) {
  257. }
  258. });
  259. });
  260. }
  261. static Instance() {
  262. if (this.instance === undefined) {
  263. this.instance = new ReportGroup();
  264. }
  265. return this.instance;
  266. }
  267. }
  268. Reports.ReportGroup = ReportGroup;
  269. })(Reports = Analytics.Reports || (Analytics.Reports = {}));
  270. })(Analytics = Platform.Analytics || (Platform.Analytics = {}));
  271. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  272. })(Unibase || (Unibase = {}));