Built files from Bizgaze WebServer
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.apiintegrator.min.js 20KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. var __awaiter=this&&this.__awaiter||function(n,t,i,r){function u(n){return n instanceof i?n:new i(function(t){t(n)})}return new(i||(i=Promise))(function(i,f){function o(n){try{e(r.next(n))}catch(t){f(t)}}function s(n){try{e(r["throw"](n))}catch(t){f(t)}}function e(n){n.done?i(n.value):u(n.value).then(o,s)}e((r=r.apply(n,t||[])).next())})},Unibase;(function(n){let t;(function(t){let i;(function(i){let r;(function(r){class u extends t.Core.BaseComponent{constructor(){super(...arguments);this.RowIndex=0;this.RuleProviderId=0;this.AutomationMode=0;this.RuleInstance=n.Platform.Automation.Components.Rule.Instance()}jsFiles(){return["platform/automation/managers/rulemanager.js","platform/automation/enums/automationmode.js","platform/automation/components/conditions.js","platform/automation/components/contactselection.js","platform/automation/requests/ruleaction.js","platform/automation/requests/rulecondition.js","platform/forms/components/formviewer/formviewer.js","libs/parsley/parsley.min.js","libs/querybuilder/query-builder.min.js","libs/querybuilder/query-builder.standalone.min.js","libs/querybuilder/query-builder.standalone.js","libs/querybuilder/sql-parser.min.js","libs/notificationbuilder/notificationbuilder.js","platform/apps/managers/stagemanager.js","platform/automation/components/rulebuilder/rulebuilder.rule.js","platform/automation/components/rulebuilder/notificationgroup.js","platform/automation/managers/notificationgroupmanager.js"]}cssFiles(){return[]}html(){return`<form id="frmUnibase_ApiIntegrator" data-validate="parsley"data-isdynamic="false">
  2. <div class="card bg-light">
  3. <div class="b-b bg-white card-header header">
  4. <strong class="text-dark title" id="Spn_ApiIntegrator">Create Api Integrator</strong></div>
  5. <div class="card-body scrollable" style="overflow-y: scroll;">
  6. <div class="bg-white card" id="divApiIntegrator">
  7. <div id="Validate_ApiAction" class="clear"></div>
  8. <div class="card-body">
  9. <div class="row">
  10. <div class="col-sm-12">
  11. <div class="floating-label-form-group">
  12. <label for="lbl" id="lbl_RuleActionName">Action<span class="text-danger required" id="spnIsRequired_RuleActionName"> *</span></label>
  13. <input type="text" id="txtApiIntegrator_RuleActionName" class="form-control value-control required floating-label-control" placeholder="Action *" data-placeholder="Enter Action" data-label="Action *">
  14. <input type="hidden" id="hf_RuleActionName" />
  15. </div></div></div>
  16. <div class="row">
  17. <div class="col-sm-12">
  18. <div id="div_Subject" class="floating-label-form-group">
  19. <label for="lbl_ApiParameter" id="lbl_ApiParameter">Api Parameter</label>
  20. <div class="input-group">
  21. <input type="text" id="txtApiIntegrator_ApiParameter" class="col-sm-9 form-control value-control floating-label-control" data-placeholder="Enter ApiParameter" placeholder="ApiParameter" data-label="ApiParameter">
  22. <select id="ddl_ApiParameters" class="col-sm-3 form-control value-control">
  23. <option value="0">Select Token</option>
  24. </select></div></div></div></div>
  25. <div class="row">
  26. <div id="div_NotificationGrp" class="floating-label-form-group col-sm-6 floating-label-form-group-with-value">
  27. <label for="lbl_NotificationGrp" id="lbl_NotificationGroup">Notification Group<span class="text-danger"> *</span></label>
  28. <select id="ddl_NotificationGrp" class="form-control"><option value="0">Select Group</option></select>
  29. </div><div class="col-sm-6 createbtn_grp"><button class="badge badge-primary mt-30 ml-15" id="creategrp_btn">Create Group</button></div></div>
  30. <div class="row">
  31. <div class="col-sm-6">
  32. <div class="input-group">
  33. <label for="Doctype" class="font-bold">Services <span class="text-danger">*</span></label>
  34. <select id="txtAutoComplete_Services" class="form-control text-control required" style="width:100%;" placeholder="Services" data-placeholder="Services" data-label="" data-istagselect="true"></select>
  35. <input type="hidden" id="hf_Autocomplete_Services" class="form-control value-control" data-isdynamic="true"/></div></div>
  36. <div class="ResultActions col-sm-6 hidden">
  37. <div id="div_ResultAction" class=" floating-label-form-group floating-label-form-group-with-value">
  38. <label for="lbl" id="lbl_ResultAction">Result Action</label>
  39. <select id="ddl_ResultAction" class="form-control">
  40. <option value="0">Select</option></select>
  41. <label for="Validation" id="lblValidation_ResultAction"></label><input type="hidden" id="hfFormPropertyId" value="0"/></div></div></div>
  42. </div></div>
  43. <div class="bg-white card Advanced_optionsdata">
  44. <div class="card-header"><i class="fa fa-angle-down arrowicon mr-1" onclick="Unibase.Platform.Automation.Components.ApiIntegrator.Instance().Toggleadvancedoptions()"></i>Advanced Options</div>
  45. <div class="card-body Advanced_options hidden">
  46. <div class="row">
  47. <div class="col-sm-6 floating-label-form-group floating-label-form-group-with-value">
  48. <label class="Message_type">Message Type</label>
  49. <select class="form-control" id="message_result">
  50. <option value="0">Success</option>
  51. <option value="1">Warning</option>
  52. <option value="2">Error</option>
  53. </select>
  54. </div>
  55. <div class="col-sm-6">
  56. <input type="checkbox" class="test_data mt-50" id="chkAutoApprovedApiIntegrator" checked>Perform this Action
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="bg-white card" id="ActionConditionsDivdata">
  62. <div class="card-header"><i class="fa fa-angle-down conditionicon mr-1" style="font-size:20px" onclick="Unibase.Platform.Automation.Components.ApiIntegrator.Instance().ToggleApiIntegratorConditions();"></i>Condition Details</div>
  63. <div class="card-body hidden" id="ActionConditionsDiv">
  64. <div class="ActionConditions">
  65. <!--For Action Conditions-->
  66. </div>
  67. </div>
  68. </div>
  69. <div class="bg-white card" id="SelectstagesDiv">
  70. <div class="card-header">Stage Event</div>
  71. <div class="card-body">
  72. <div class="stages_drp row"><div class="col-sm-6"><label class="from_label">From Stage</label><select class="from_stage_apiintegrator form-control"></select></div><div class="col-sm-6"><label class="_label">To Stage</label><select class="to_stage_apiintegrator form-control"></select></div></div>
  73. </div></div>
  74. </div>
  75. <div class="bg-white card-footer footer" id="CreateApiIntegratorFooter">
  76. <a href="javascript:;" id="btnCloseApiIntegrator" class="btn btn-light btn-sm mr-auto ">Close</a>
  77. <a href="javascript:;" id="btnSaveApiIntegrator" class="btn btn-primary btn-sm"> Save</a>
  78. </div>
  79. </div>
  80. </form>`}load(t,i){return __awaiter(this,void 0,void 0,function*(){var r=this,e;n.Platform.Automation.Components.ApiIntegrator.Instance().ActionId=r.ActionId;n.Platform.Automation.Components.ApiIntegrator.Instance().RuleActionData=r.RuleActionData;n.Platform.Automation.Components.ApiIntegrator.Instance().RowIndex=r.RowIndex;n.Platform.Automation.Components.ApiIntegrator.Instance().AutomationMode=r.AutomationMode;n.Platform.Automation.Components.ApiIntegrator.Instance().RuleProviderId=r.RuleProviderId;n.Platform.Automation.Components.ApiIntegrator.Instance().ParentActionId=r.ParentActionId;n.Platform.Automation.Components.ApiIntegrator.Instance().IsAutomationMode=r.IsAutomationMode;yield n.Platform.Automation.Components.NotificationGroup.Instance().LoadNotificationGroups();r.AutomationMode==n.Platform.Automation.Enums.AutomationMode.AdvancedMode&&eval('bizgaze_automation_flow_main.getcontainerid("'+i+'")');$("#creategrp_btn").click(function(){n.Platform.Automation.Components.NotificationGroup.Instance().init(0,null,!0)});$("#btnCloseApiIntegrator").click(function(){$("#"+i).modal("hide");$("#"+i).remove();n.Platform.Automation.Components.ApiIntegrator.Instance().AutomationMode==n.Platform.Automation.Enums.AutomationMode.NormalMode?n.Platform.Automation.Components.ApiIntegrator.Instance().AutomationMode&&n.Platform.Automation.Components.ApiIntegrator.Instance().IsAutomationMode&&n.Platform.Automation.Components.Rule.Instance().ChangeAction(r.RowIndex,t):eval("bizgaze_automation_flow_main.getpopupclosed()");n.Platform.Automation.Components.Conditions.conditionArray=[]});$("#btnSaveApiIntegrator").click(function(){let r=n.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation("frmUnibase_ApiIntegrator");if(r==!1)return MessageHelper.Instance().showError("Mandatory fields are missing","Validate_ApiAction"),!1;n.Platform.Automation.Components.ApiIntegrator.Instance().SaveApiIntegrator(t,i)});$("#ddl_ApiParameters").change(function(){var n=$("#txtApiIntegrator_ApiParameter").val().toString(),t="{{"+$("#ddl_ApiParameters option:selected").text()+"}}",i=n.slice(0,u.Instance().tokenposition),r=n.slice(u.Instance().tokenposition,n.length);$("#txtApiIntegrator_ApiParameter").val(i+t+r);$("#ddl_ApiParameters").val(0)});$("#txtApiIntegrator_ApiParameter").focusout(function(n){u.Instance().tokenposition=n.target.selectionStart});r.RuleInstance.IsStageChangeEvent()?($("#SelectstagesDiv").removeClass("d-none"),yield n.Platform.Automation.Components.ApiIntegrator.Instance().LoadAppStages()):$("#SelectstagesDiv").addClass("d-none");r.ParentActionId!=0&&(yield n.Platform.Automation.Components.ContactSelection.Instance().getResultActions(r.ParentActionId),yield n.Platform.Automation.Components.ApiIntegrator.Instance().GetRuleActionInfo(Number(r.ParentActionId)),$("#ddl_NotificationGrp").prop("disabled",!0),$("#creategrp_btn").addClass("d-none"));t!=""&&setTimeout(function(){n.Platform.Automation.Components.ApiIntegrator.Instance().EditApiIntegrator(t)},10);let f=r.RuleProviderId;f!=0&&(n.Platform.Automation.Components.ApiIntegrator.Instance().LoadApiParameters(f),n.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(f,null));r.RuleActionData.length!=0&&n.Platform.Automation.Components.ApiIntegrator.Instance().LoadApiIntegratorData(r.RuleActionData);e=_appsettings.server_url()+"/apis/v4/unibase/integrations/integrator/servicintegratorautocomplete/integratorid/0";AutoCompleteHelper.getHelper().Create("#txtAutoComplete_Services","#hf_Autocomplete_Services",e,function(n){var t=n})})}ToggleApiIntegratorConditions(){$("#ActionConditionsDiv").toggleClass("hidden");$(".conditionicon").hasClass("fa-angle-down")?($(".conditionicon").removeClass("fa-angle-down").addClass("fa-angle-up"),n.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(n.Platform.Automation.Components.ApiIntegrator.Instance().RuleProviderId,null)):$(".conditionicon").removeClass("fa-angle-up").addClass("fa-angle-down")}Toggleadvancedoptions(){$(".arrowicon").hasClass("fa-angle-down")?$(".arrowicon").removeClass("fa-angle-down").addClass("fa-angle-up"):$(".arrowicon").removeClass("fa-angle-up").addClass("fa-angle-down");$(".Advanced_options").toggleClass("hidden")}LoadAppStages(){return __awaiter(this,void 0,void 0,function*(){var t="",i='<option value="0">Select FromStage<\/option>',r='<option value="0">Select ToStage<\/option>',u=n.Platform.Automation.Components.Rule.Instance().RuleInstalledAppId;yield n.Platform.Apps.Managers.StageManager.Instance().getStages(u).then(function(n){if(n.result!=null)for(let i=0;i<n.result.length;i++){var u=n.result[i];t+="<option value="+u.StageId+">"+u.StageName+"<\/option>"}$(".from_stage_apiintegrator").html(i+t);$(".to_stage_apiintegrator").html(r+t)})})}EditApiIntegrator(t){let i=Number(t);$("#Spn_ApiIntegrator").text("Edit Api Integrator");n.Platform.Automation.Managers.RuleManager.Instance().getRuleAction(i).then(function(t){$("#txtApiIntegrator_RuleActionName").val(t.RuleActionName);$("#txtApiIntegrator_ApiParameter").val(t.BString2);$("#ddl_NotificationGrp option[value="+t.NotificationGroupId+"]").prop("selected",!0);t.ResultActionId!=null&&$("#ddl_ResultAction").val(t.ResultActionId);n.Platform.Automation.Components.ApiIntegrator.Instance().IsAutomationMode||(n.Platform.Automation.Components.ApiIntegrator.Instance().RuleId=t.RuleId,n.Platform.Automation.Components.ApiIntegrator.Instance().RuleEventId=t.RuleEventId,n.Platform.Automation.Components.ApiIntegrator.Instance().EventGroupId=t.EventGroupId,n.Platform.Automation.Components.ApiIntegrator.Instance().ActionId=t.ActionId,n.Platform.Automation.Components.ApiIntegrator.Instance().ParentActionId=t.ParentActionId);t.ExecuteStatusId!=Number(n.Platform.Automation.Enums.ExecuteActionStatus.Approved)?$("#chkAutoApprovedApiIntegrator").prop("checked",!1):$("#chkAutoApprovedApiIntegrator").prop("checked",!0);let i=Number(t.BString4);n.Platform.Integrations.Managers.IntegrationManager.Instance().getServiceIntegratorById(i).then(function(n){var t=new Option(n.result.ServiceIntegratorName,n.result.ServiceIntegratorId.toString(),!0);$("#txtAutoComplete_Services").append(t)});n.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(t.RuleProviderId,t.SqlWhere);t.SqlWhere!=null&&t.SqlWhere!=""&&($("#ActionConditionsDiv").removeClass("hidden"),$(".conditionicon").removeClass("fa-angle-down").addClass("fa-angle-up"));t.FromStage!=null&&t.ToStage!=null&&($(".from_stage_apiintegrator option[value="+t.FromStage+" ]").prop("selected",!0),$("to_stage_apiintegrator option[value="+t.ToStage+"]").prop("selected",!0));$("#message_result").val(Number(t.BString5));eval("_floatingLabelHelper.init();")})}LoadApiIntegratorData(t){for(var i=0;i<t.length;i++){$("#txtApiIntegrator_RuleActionName").val(t[i].RuleActionName);$("#txtApiIntegrator_ApiParameter").val(t[i].BString1);let r=Number(t[i].BString4);n.Platform.Integrations.Managers.IntegrationManager.Instance().getServiceIntegratorById(r).then(function(n){var t=new Option(n.result.ServiceIntegratorName,n.result.ServiceIntegratorId.toString(),!0);$("#txtAutoComplete_Services").append(t)});t[i].AutoApproved?$("#chkAutoApprovedApiIntegrator").prop("checked",!0):$("#chkAutoApprovedApiIntegrator").prop("checked",!1);t[i].SqlWhere!=""&&t[i].SqlWhere!=null&&(n.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(n.Platform.Automation.Components.ApiIntegrator.Instance().RuleProviderId,t[i].SqlWhere),$(".conditionicon").removeClass("fa-angle-down").addClass("fa-angle-up"),$("#ActionConditionsDiv").removeClass("hidden"));eval("_floatingLabelHelper.init();")}}SaveApiIntegrator(t,r){var e=this;let o=Number(t),f=$("#builder"),u=new n.Platform.Automation.Requests.RuleAction;if(u.RuleActionId=o,u.RuleActionName=$("#txtApiIntegrator_RuleActionName").val().toString(),u.BString1=$("#txtApiIntegrator_ApiParameter").val().toString(),u.BString2=$("#txtApiIntegrator_ApiParameter").val().toString(),u.BString4=$("#txtAutoComplete_Services").val().toString(),u.BString5=$("#message_result option:selected").val().toString(),u.ActionId=n.Platform.Automation.Components.ApiIntegrator.Instance().ActionId,u.RuleId=0,u.Users="",u.NotificationGroupId=$("#ddl_NotificationGrp").val()==undefined?0:Number($("#ddl_NotificationGrp").val()),u.NotificationGroupId==0){MessageHelper.Instance().showError("Please Select Notification Group","Validate_ApiAction");return}e.RuleInstance.IsStageChangeEvent()&&(u.FromStage=$(".from_stage_apiintegrator option:selected").val()!="0"?Number($(".from_stage_apiintegrator option:selected").val()):0,u.ToStage=$(".to_stage_apiintegrator option:selected").val()!="0"?Number($(".to_stage_apiintegrator option:selected").val()):0);let s=f.queryBuilder("getSQL",!1,!0);s!=null?(u.SqlWhere=f.queryBuilder("getSQL",!1,!0).sql.replace(/\n/g," ").replace(/LIKE/g,"ILIKE"),u.SqlWhereJson=JSON.stringify(f.queryBuilder("getSQL",!1,!0))):(u.SqlWhere="",u.SqlWhereJson="");u.ResultActionId=Number($("#ddl_ResultAction option:selected").val());u.ResultActionName=u.ResultActionId!=0?$("#ddl_ResultAction option:selected").text():"";u.DelayTime=0;u.ParentActionId=n.Platform.Automation.Components.ApiIntegrator.Instance().ParentActionId;u.AutoApproved=$("#chkAutoApprovedApiIntegrator").is(":checked");u.RowIndex=n.Platform.Automation.Components.ApiIntegrator.Instance().RowIndex;n.Platform.Automation.Components.ApiIntegrator.Instance().IsAutomationMode?n.Platform.Automation.Components.ApiIntegrator.Instance().AutomationMode==n.Platform.Automation.Enums.AutomationMode.NormalMode?(n.Platform.Automation.Components.Rule.Instance().RuleActionsArray(u),$("#"+r).modal("hide"),$("#"+r).remove(),n.Platform.Automation.Components.Conditions.conditionArray=[]):(u.RuleId=eval("bizgaze_automation_flow_main.getruleid()"),i.Managers.RuleManager.Instance().saveRuleAction(u).then(function(t){if(t.status==n.Data.Status.Error)MessageHelper.Instance().showError(t.message,"Validate_ApiAction");else{MessageHelper.Instance().showSuccess(t.message,"Validate_ApiAction");$("#"+r).modal("hide");$("#"+r).remove();n.Platform.Automation.Components.Conditions.conditionArray=[];var i=t.result.RuleActionName;eval("bizgaze_automation_flow_main.saveApiIntegratorblock('"+t.result.RuleActionId+"','"+i+"')")}})):(u.RuleId=n.Platform.Automation.Components.ApiIntegrator.Instance().RuleId,u.EventGroupId=n.Platform.Automation.Components.ApiIntegrator.Instance().EventGroupId,u.RuleEventId=n.Platform.Automation.Components.ApiIntegrator.Instance().RuleEventId,u.ActionId=n.Platform.Automation.Components.ApiIntegrator.Instance().ActionId,u.ParentActionId=n.Platform.Automation.Components.ApiIntegrator.Instance().ParentActionId,i.Managers.RuleManager.Instance().saveRuleAction(u).then(function(t){t.status==n.Data.Status.Error?MessageHelper.Instance().showError(t.message,"Validate_ApiAction"):(MessageHelper.Instance().showSuccess(t.message,"Validate_ApiAction"),$("#"+r).modal("hide"),$("#"+r).remove(),n.Platform.Automation.Components.Conditions.conditionArray=[])}))}LoadApiParameters(t){n.Platform.Automation.Managers.RuleManager.Instance().getTokens(t).then(function(n){var t,i;let r=document.getElementById("ddl_ApiParameters");$("#ddl_ApiParameters").empty();t=document.createElement("option");t.text="Select Token";t.value="0";r.appendChild(t);for(let t=0;t<=n.length-1;t++)i=document.createElement("option"),i.text=n[t],i.value=(t+1).toString(),r.appendChild(i)})}GetRuleActionInfo(t){return __awaiter(this,void 0,void 0,function*(){yield n.Platform.Automation.Managers.RuleManager.Instance().getRuleAction(t).then(function(n){if(n!=null){var t="<option value="+n.NotificationGroupId+" selected>"+n.NotificationGroupName+"<\/option>";$("#ddl_NotificationGrp").html("").html(t)}})})}static Instance(){return this.instance===undefined&&(this.instance=new u),this.instance}}r.ApiIntegrator=u})(r=i.Components||(i.Components={}))})(i=t.Automation||(t.Automation={}))})(t=n.Platform||(n.Platform={}))})(Unibase||(Unibase={}));