Built files from Bizgaze WebServer
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

integration.setting.js 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. var Unibase;
  2. (function (Unibase) {
  3. let Platform;
  4. (function (Platform) {
  5. let Integrations;
  6. (function (Integrations) {
  7. let Components;
  8. (function (Components) {
  9. class Setting extends Platform.Core.BaseComponent {
  10. jsFiles() {
  11. return ["platform/integrations/enums/methodtype.js",
  12. "platform/integrations/enums/encryptdecrypttype.js",
  13. "platform/integrations/enums/responsetype.js",
  14. "platform/integrations/managers/integrationmanager.js"];
  15. }
  16. cssFiles() {
  17. return [];
  18. }
  19. html(id, containerid) {
  20. return '<div id="Unibase_integrationSettings" default="" data-validate="parsley" data-isdynamic="false"><div class="b-b bg-white header integrationSettingHeader" ><strong class="text-dark">Edit</strong><a class="btn btn-sm ml-auto" id="resetsettings" data-toggle="tooltip" title="Reset"><i class="fa fa-refresh"></i></a><a class="btn btn-sm"><i class="ti-help-alt" title="help" href="javascript:;" target="_blank"></i></a></div><div data-simplebar class="simple-scroll-bar scrollable integration-setting-body"><div id="Unibase_ValidationSummary" class="clear mt-10"></div><div class="card hidden"><div class="card-body"><div class="row"><div class="col-sm-6"><div class="floating-label-form-group" ><label for= "txtLastUpdatedDate">StartDate</label><input type= "text" id = "txtLastUpdatedDate" class="form-control value-control datepicker-input hasDatepicker txtLastUpdatedDate floating-label-control" /><span class="input-group-addon mt-10" > <i class="fa fa-calendar"> </i></span></div></div> <div class="col-sm-6" id="timeint"> <div class="floating-label-form-group-with-value" for="cmbSttxtLastSyncDateartHours" id="div_StartHours"><label for="cmbStartHours" id="lbl_StartHours">Time Interval(min)</label><select id="cmbTimeInterval" style="background-color:white" class="form-control mb-10" data-isdynamic="false"><option value="0">-- Select --</option><option value="20">20</option><option value="30">30</option><option value="45">45</option><option value="60">60</option><option value="90">1.30hr</option><option value="120">2.00hr</option><option value="150">2.30hr</option><option value="180">3.00hr</option> <option value="210">3.30hr</option> <option value="240">4.00hr</option><option value="270">4.30hr</option><option value="300">5.00hr</option><option value="330">5.30hr</option><option value="360">6.00hr</option></select></div></div></div></div></div>' +
  21. '<div class="card card-body" id="updatedisplaytext"><div class="row mx-0 mb-15"><div class="col-6"><label for="displayText" id="lbl_displayText" class="font-18"><strong>Display text</strong></label></div><div class="col-6"><input type="textbox" class="form-control required" id="displayText" value=""></div></div><div class="row mx-0 mb-15"><div class="col-6"><label for="LastSyncDate" id="lbl_syncDate" class="font-18"><strong>LastSyncDate/FromDate</strong></label></div><div class="col-6 d-flex align-item-center"><input type="text" id="txtLastSyncDate" class="lastSyncDate datepicker-input form-control required" placeholder="yyyy/mm/dd hh:mm" data-placeholder="yyyy/mm/dd hh:mm" data-label="LastSyncDate"><span class="input-group-addon"><i class="fa fa-calendar ml-20 font-18 required"></i></span></div></div><div class="row mx-0 mb-15"><div class="col-7"><label for="chkIsToDate" class="font-18"><strong>Is ToDate</strong></label><label id="lblIsToDate" class="switch form-inline pull-right"><input id="chkIsToDate" data-group="chkIsToDate" type="checkbox" data-isdynamic="false" onchange=""><span></span></label></div></div><div class="row mx-0 mb-15 todate"><div class="col-6"><label for="ToDate" id="lbl_ToDate" class="font-18"><strong>ToDate</strong></label></div><div class="col-6 d-flex align-item-center"><input type="text" id="txtToDate" class="toDate datepicker-input form-control required" placeholder="yyyy/mm/dd hh:mm" data-placeholder="yyyy/mm/dd hh:mm" data-label="ToDate"><span class="input-group-addon"><i class="fa fa-calendar ml-20 font-18 required"></i></span></div></div><div class="row mx-0"><div class="col-7"><label for="frmchkIsUpdate" class="font-18"><strong>Is Update</strong></label><label id="lblIsUpdate" class="switch form-inline pull-right"><input id="chkIsUpdate" data-group="chkIsUpdate" type="checkbox" data-isdynamic="false" onchange=""><span></span></label></div></div></div>' +
  22. '<div class="SettingValue Service-summary edit-SettingName" id="UpdateSettingsValues" style="min-height:200px;overflow-x:hidden;"><ul class="list-group no-border" id = "ulSettingValueDetails" ></ul></div></div><div id="div_integrationSettingFooter" class="bg-white footer"><a class="btn btn-light btn-sm btn-center mr-auto btn-close" id="btnClose">Close</a><a class="btn btn-primary btn-center btn-sm text-white" id="btn_updateSetting">Save</a></div></div>';
  23. }
  24. init(serviceIntegratorId, serviceId, update) {
  25. Unibase.Platform.Integrations.Components.Setting.serviceIntegratorId = serviceIntegratorId;
  26. Unibase.Platform.Integrations.Components.Setting.serviceId = serviceId;
  27. Unibase.Platform.Integrations.Components.Setting.update = update;
  28. this.navigationHelper.popup(0, '', Unibase.Platform.Integrations.Components.Setting.Instance(), null, Platform.Helpers.Size.Large);
  29. this.getServiceIntegrator();
  30. }
  31. load(id, containerid, callback) {
  32. $("#resetsettings").hide();
  33. $("#btn_updateSetting").click(function () {
  34. Setting.Instance().updateSetting(containerid);
  35. });
  36. $("#chkIsToDate").click(function () {
  37. Unibase.Platform.Integrations.Components.Setting.Instance().istodate();
  38. });
  39. $("#txtLastSyncDate").daterangepicker({
  40. autoUpdateInput: false,
  41. timePicker: true,
  42. timePicker24Hour: true,
  43. locale: {
  44. format: 'YYYY/MM/DD HH:mm:ss'
  45. },
  46. singleDatePicker: true,
  47. showDropdowns: true,
  48. minYear: 1901,
  49. maxDate: new Date(2050, 11, 31)
  50. });
  51. $("#txtToDate").daterangepicker({
  52. autoUpdateInput: false,
  53. timePicker: true,
  54. timePicker24Hour: true,
  55. locale: {
  56. format: 'YYYY/MM/DD HH:mm:ss'
  57. },
  58. singleDatePicker: true,
  59. showDropdowns: true,
  60. minYear: 1901,
  61. maxDate: new Date(2050, 11, 31)
  62. });
  63. }
  64. istodate() {
  65. if (($("#chkIsToDate").prop("checked") == false)) {
  66. $(".todate").addClass("hidden");
  67. }
  68. else {
  69. $(".todate").removeClass("hidden");
  70. var date = new Date().toUTCString();
  71. var olderDate = moment(date).subtract(5, 'hours').toDate();
  72. var olderDate1 = moment(olderDate).subtract(30, 'minutes').toDate();
  73. var tdate = moment(olderDate1).format();
  74. var d = this.formatDateTime(tdate);
  75. $("#txtToDate").val(d);
  76. $("#txtToDate").daterangepicker({
  77. autoUpdateInput: false,
  78. timePicker: true,
  79. timePicker24Hour: true,
  80. locale: {
  81. format: 'YYYY/MM/DD HH:mm:ss'
  82. },
  83. singleDatePicker: true,
  84. showDropdowns: true,
  85. minYear: 1901,
  86. maxDate: new Date(2050, 11, 31)
  87. });
  88. }
  89. }
  90. loadForm(FormId, Pk_Value, AppConfigurationId, Callback, ElementId) {
  91. }
  92. formatDateTime(dateTime) {
  93. if (dateTime.toString().indexOf("T") > -1) {
  94. dateTime = dateTime.toString().replace("T", " ");
  95. dateTime = moment(dateTime).format("YYYY/MM/DD HH:mm:ss");
  96. }
  97. dateTime = dateTime + " +00:00";
  98. var date = moment.utc(dateTime).local();
  99. return date.format("YYYY/MM/DD HH:mm:ss");
  100. }
  101. getServiceIntegrator() {
  102. var serviceIntegratorId = Setting.serviceIntegratorId;
  103. Unibase.Platform.Integrations.Managers.IntegrationManager.Instance().getServiceIntegratorById(serviceIntegratorId).then(function (response) {
  104. $("#chkIsUpdate").prop("checked", response.result.IsUpdate);
  105. $("#chkIsToDate").prop("checked", response.result.IsTodate);
  106. $("#displayText").val(response.result.DisplayText);
  107. $("#displayText").prop("disabled", true);
  108. var ToDate = response.result.ToDate;
  109. var LastSyncDate = response.result.LastSyncDate;
  110. if (LastSyncDate == "0001-01-01T00:00:00") {
  111. date = moment(LastSyncDate).format("YYYY/MM/DD HH:mm:ss");
  112. $("#txtLastSyncDate").val(date);
  113. $("#txtLastSyncDate").daterangepicker({
  114. autoUpdateInput: false,
  115. timePicker: true,
  116. timePicker24Hour: true,
  117. locale: {
  118. format: 'YYYY/MM/DD HH:mm:ss'
  119. },
  120. singleDatePicker: true,
  121. showDropdowns: true,
  122. minYear: 1901,
  123. maxDate: new Date(2050, 11, 31)
  124. });
  125. }
  126. else {
  127. var date = Unibase.Platform.Integrations.Components.Setting.Instance().formatDateTime(response.result.LastSyncDate);
  128. $("#txtLastSyncDate").val(date);
  129. $("#txtLastSyncDate").daterangepicker({
  130. autoUpdateInput: false,
  131. timePicker: true,
  132. timePicker24Hour: true,
  133. locale: {
  134. format: 'YYYY/MM/DD HH:mm:ss'
  135. },
  136. singleDatePicker: true,
  137. showDropdowns: true,
  138. minYear: 1901,
  139. maxDate: new Date(2050, 11, 31)
  140. });
  141. }
  142. if (!$("#chkIsToDate").prop("checked")) {
  143. var tdate = moment(ToDate).format("YYYY/MM/DD HH:mm:ss");
  144. $("#txtToDate").val(tdate);
  145. $("#chkIsToDate").prop("checked", false);
  146. if (($("#chkIsToDate").prop("checked") == false)) {
  147. $(".todate").addClass("hidden");
  148. }
  149. $("#txtToDate").daterangepicker({
  150. autoUpdateInput: false,
  151. timePicker: true,
  152. timePicker24Hour: true,
  153. locale: {
  154. format: 'YYYY/MM/DD HH:mm:ss'
  155. },
  156. singleDatePicker: true,
  157. showDropdowns: true,
  158. minYear: 1901,
  159. maxDate: new Date(2050, 11, 31)
  160. });
  161. }
  162. else {
  163. var tdate = Unibase.Platform.Integrations.Components.Setting.Instance().formatDateTime(response.result.ToDate);
  164. $("#txtToDate").val(tdate);
  165. $("#chkIsToDate").prop("checked", true);
  166. $("#txtToDate").daterangepicker({
  167. autoUpdateInput: false,
  168. timePicker: true,
  169. timePicker24Hour: true,
  170. locale: {
  171. format: 'YYYY/MM/DD HH:mm:ss'
  172. },
  173. singleDatePicker: true,
  174. showDropdowns: true,
  175. minYear: 1901,
  176. maxDate: new Date(2050, 11, 31)
  177. });
  178. }
  179. });
  180. }
  181. changeUpdateStatus() {
  182. var isUpdate = $("#chkIsUpdate").prop("checked");
  183. var serviceIntegratorId = Setting.serviceIntegratorId;
  184. Unibase.Platform.Integrations.Managers.IntegrationManager.Instance().changeServiceIntegratorStatus(serviceIntegratorId, isUpdate).then(function (response) {
  185. if (response.status == 0) {
  186. MessageHelper.Instance().showSuccess(response.message, "");
  187. }
  188. else {
  189. MessageHelper.Instance().showError(response.message, "Unibase_ValidationSummary");
  190. return false;
  191. }
  192. });
  193. }
  194. updateSetting(containerid) {
  195. var isUpdate = $("#chkIsUpdate").prop("checked");
  196. var isTodate = $("#chkIsToDate").prop("checked");
  197. var displayText = $("#displayText").val();
  198. var lastsdate = $("#txtLastSyncDate").val();
  199. var olderDate = moment(lastsdate).subtract(5, 'hours').toDate();
  200. var olderDate1 = moment(olderDate).subtract(30, 'minutes').toDate();
  201. var lastsyncdate = moment(olderDate1).format("YYYY-MM-DD HH:mm:ss");
  202. var todate = $("#txtToDate").val();
  203. if ($("#chkIsToDate").prop("checked")) {
  204. var tolderDate = moment(todate).subtract(5, 'hours').toDate();
  205. var tolderDate1 = moment(tolderDate).subtract(30, 'minutes').toDate();
  206. todate = moment(tolderDate1).format("YYYY-MM-DD HH:mm:ss");
  207. }
  208. var serviceIntegratorId = Setting.serviceIntegratorId;
  209. var postData = {
  210. IsUpdate: isUpdate,
  211. isTodate: isTodate,
  212. DisplayText: displayText,
  213. LastSyncDate: lastsyncdate,
  214. ToDate: todate,
  215. ServiceIntegratorId: serviceIntegratorId
  216. };
  217. let appcontrolid = "Unibase_integrationSettings";
  218. let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
  219. if (result == false) {
  220. MessageHelper.Instance().showError("Mandatory fields are missing", "Unibase_ValidationSummary");
  221. return false;
  222. }
  223. else if ($("#displayText").val() == "") {
  224. MessageHelper.Instance().showError("DisplayText should not be empty", "Unibase_ValidationSummary");
  225. }
  226. else if ($("#chkIsToDate").prop("checked") && lastsyncdate > todate) {
  227. MessageHelper.Instance().showError("ToDate is lessthan FromDate", "Unibase_ValidationSummary");
  228. }
  229. else {
  230. Unibase.Platform.Integrations.Managers.IntegrationManager.Instance().UpdateServiceIntegrator(postData).then(function (response) {
  231. if (response.status == 0) {
  232. $('#' + containerid).modal('hide');
  233. $('#' + containerid).remove();
  234. MessageHelper.Instance().showSuccess(response.message, "");
  235. }
  236. else {
  237. MessageHelper.Instance().showError(response.message, "Unibase_ValidationSummary");
  238. return false;
  239. }
  240. });
  241. }
  242. }
  243. static Instance() {
  244. return new Setting();
  245. }
  246. }
  247. Setting.serviceId = 0;
  248. Setting.serviceIntegratorId = 0;
  249. Setting.update = "";
  250. Components.Setting = Setting;
  251. })(Components = Integrations.Components || (Integrations.Components = {}));
  252. })(Integrations = Platform.Integrations || (Platform.Integrations = {}));
  253. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  254. })(Unibase || (Unibase = {}));