123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- var Unibase;
- (function (Unibase) {
- let Platform;
- (function (Platform) {
- let Automation;
- (function (Automation) {
- let Components;
- (function (Components) {
- class RuleBuilder extends Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.RuleFlow = [];
- }
- jsFiles() {
- var jsfiles = ["platform/automation/managers/rulemanager.js",
- "libs/notificationbuilder/notificationbuilder.js", "platform/automation/components/eventtemplate.js"];
- return jsfiles;
- }
- cssFiles() {
- var cssfiles = ["libs/flowy/styles.css", "libs/notificationbuilder/notificationbuilder.css"];
- return cssfiles;
- }
- html(id, containerid) {
- let html = `<div class="flowchart_new" onclick="eval('closemenu()')" style="background-color:white"><div id="Validate_RuleBuilder" class="col-sm-12 clear"></div><div class=" col-md-12 create_rule" style="margin-top:15px"><div class="row"><div class="col-sm-6 d-flex"><span class="rule_name" style="margin-right:10px;margin-left:10px;"><input type="text" class="form-control border-0" placeholder="Rule Name" id="txt_Rule" style="height:38px;width:200px" class="Rulename_text"></span><span class="Installed_app" style="width:200px"><select id="installedapp_dropdown" class="form-control text-control required" style="width:100%;" onchange="eval('ruleproviders()')" placeholder="Select InstalledApp" data-placeholder="InstalledApp" data-label="" data-istagselect="true"></select></span><span class="rule_providerdropdown ml-5"><select id="ddl_RuleProvider" onchange="eval('ruleprovideridinfo()')" class="form-control text-control"style="margin-right:10px;height:38px;width:200px"><option value='0'>Select RuleProvider</option></select><input type="hidden" id="hf_RuleProvider" value="" /></span></div><div class="col-md-6"><span class="buttons pull-right"><span id="discard">Discard</span><span id="publish">Save Flow</span></span></div></div></div><hr><div class="treeContainer">
- <div class="treebody"></div></div></div>`;
- return html;
- }
- load(id, containerid, callback) {
- var instance = this;
- $("#discard").click(function () {
- let ruleid = eval("bizgaze_automation_flow_main.getruleid()");
- if (ruleid != 0) {
- bootbox.confirm("All items will be deleted, Do You Want To Continue?", function (result) {
- if (result) {
- $('.treebody').html('');
- eval("bizgaze_automation_flow_main.getcloseadvmode()");
- $('#' + containerid).modal('hide');
- $('#' + containerid).remove();
- }
- else {
- return;
- }
- });
- }
- else {
- $('.treebody').html('');
- eval("bizgaze_automation_flow_main.getcloseadvmode()");
- $('#' + containerid).modal('hide');
- $('#' + containerid).remove();
- }
- });
- $("#publish").click(function () {
- instance.SaveRuleFlow(containerid);
- });
- Unibase.Platform.Automation.Components.RuleBuilder.Instance().loadinstalledappsfordrpdown();
- if (id != 0) {
- Unibase.Platform.Automation.Components.RuleBuilder.Instance().EditRuleFlow(id);
- }
- else {
- eval("load()");
- }
- }
- loadScript(url, callback) {
- let script = document.createElement("script");
- script.type = "text/javascript";
- if (script.readyState) {
- script.onreadystatechange = function () {
- if (script.readyState == "loaded" ||
- script.readyState == "complete") {
- script.onreadystatechange = null;
- callback();
- }
- };
- }
- else {
- script.onload = function () {
- callback();
- };
- }
- script.src = url;
- document.getElementsByTagName("head")[0].appendChild(script);
- }
- removejscssfile(filename, filetype) {
- var targetelement = (filetype == "js") ? "script" : (filetype == "css") ? "link" : "none";
- var targetattr = (filetype == "js") ? "src" : (filetype == "css") ? "href" : "none";
- var allsuspects = document.getElementsByTagName(targetelement);
- for (var i = allsuspects.length; i >= 0; i--) {
- if (allsuspects[i] && allsuspects[i].getAttribute(targetattr) != null && allsuspects[i].outerHTML.includes(filename)) {
- allsuspects[i].parentNode.removeChild(allsuspects[i]);
- }
- }
- }
- loadinstalledappsfordrpdown() {
- var url = _appsettings.server_url() + '/apis/v4/unibase/platform/apps/installedappautocomplete';
- AutoCompleteHelper.getHelper().Create("#installedapp_dropdown", "#hf_Autocomplete_InstalledApp", url, function (response) {
- var data = response;
- });
- }
- SearchBlocks() {
- var input, filter, div, subdiv, a, i;
- input = document.getElementById("SearchBlocks");
- filter = input.value.toUpperCase();
- div = document.getElementById("blocklist");
- subdiv = div.getElementsByClassName("blockelem create-flowy noselect");
- for (i = 0; i < subdiv.length; i++) {
- if (subdiv[i].firstElementChild.value.toUpperCase() == filter) {
- a = subdiv[i];
- if (a.innerHTML.indexOf(filter) > -1) {
- subdiv[i].style.display = "";
- }
- }
- else {
- a = subdiv[i];
- if (a.firstElementChild.value.toUpperCase().indexOf(filter) > -1) {
- subdiv[i].style.display = "";
- }
- else {
- subdiv[i].style.display = "none";
- }
- }
- }
- }
- render(id, callback) {
- this.navigationHelper.popup(id, '', Unibase.Platform.Automation.Components.RuleBuilder.Instance(), null, Platform.Helpers.Size.ExtraLarge);
- }
- SaveRuleFlow(containerid) {
- let ruleid = eval("bizgaze_automation_flow_main.getruleid()");
- let output = eval("bizgaze_automation_flow_main.output()");
- let ruleflow = JSON.stringify(output);
- let model = new Unibase.Platform.Automation.Requests.Rule();
- model.RuleId = eval("bizgaze_automation_flow_main.getruleid()");
- model.RuleFlow = ruleflow;
- if (ruleflow != undefined && ruleid != 0) {
- Automation.Managers.RuleManager.Instance().saveRuleFlow(model).then(function (response) {
- if (response.status == Unibase.Data.Status.Error) {
- MessageHelper.Instance().showError(response.message, "Validate_RuleBuilder");
- }
- else {
- MessageHelper.Instance().showSuccess(response.message, "Validate_RuleBuilder");
- eval("bizgaze_automation_flow_main.getcloseadvmode()");
- $('#' + containerid).modal('hide');
- $('#' + containerid).remove();
- Unibase.Platform.Helpers.NavigationHelper.Instance().loadDetail(ruleid, Unibase.Platform.Automation.Components.Rule.installedappid, null);
- }
- });
- }
- else {
- MessageHelper.Instance().showError("Please Create Rule", "Validate_RuleBuilder");
- }
- }
- EditRuleFlow(id) {
- Unibase.Platform.Automation.Managers.RuleManager.Instance().getRule(id).then(function (response) {
- eval("bizgaze_automation_flow_main.appendruleid('" + response.RuleId + "')");
- eval("bizgaze_automation_flow_main.appendruleproviderid('" + response.RuleProviderId + "')");
- Unibase.Platform.Automation.Components.RuleBuilder.Instance().RuleFlow = response.RuleFlow;
- eval(" bizgaze_automation_flow_main.import(" + response.RuleFlow + ")");
- eval("load()");
- });
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new RuleBuilder();
- }
- return this.instance;
- }
- }
- Components.RuleBuilder = RuleBuilder;
- })(Components = Automation.Components || (Automation.Components = {}));
- })(Automation = Platform.Automation || (Platform.Automation = {}));
- })(Platform = Unibase.Platform || (Unibase.Platform = {}));
- })(Unibase || (Unibase = {}));
|