123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var Unibase;
- (function (Unibase) {
- let Platform;
- (function (Platform) {
- let Automation;
- (function (Automation) {
- let Components;
- (function (Components) {
- class ActiveRules extends Platform.Core.BaseComponent {
- cssFiles() {
- return [];
- }
- jsFiles() {
- return ["platform/automation/managers/rulemanager.js", "platform/core/enums/rowstatus.js", "platform/automation/enums/schedulertype.js", "platform/automation/enums/ruletype.js"];
- }
- html(id, containerid) {
- let html = `<form id="frmUnibase_RuleScheduler" data-validate="parsley" data-isdynamic="false">
- <div id="Validate_RuleScheduler" class="clear"></div>
- <div class="card bg-light m-0">
- <div class="b-b bg-white card-header header">
- <strong class="text-dark title" id="Form_RuleScheduler">Schedule Rule</strong>
- </div>
- <div class="card-body scrollable" style="height:100%;overflow-y:hidden scroll;">
- <div class="bg-white card" id="divEventDetails">
- <div class="card-body">
- <div class="row" id="div_Scheduler">
- <div class="col-sm-6">
- <div class="floating-label-form-group floating-label-form-group-with-value">
- <label for="lblSchedulerType" id="lbl_SchedulerType" class="font-bold">Scheduler Type<span class="text-danger">*</span></label>
- <select id="ddl_SchedulerType" class="form-control value-control" data-isdynamic="true" placeholder="Select" data-placeholder="Select" data-label="Select">
- <option value="">Select</option>
- <option value="2">Daily</option>
- <option value="3">FifteenMinute</option>
- <option value="4">FiveMinute</option>
- <option value="5">FortyFiveMinute</option>
- <option value="6">HalfYearly</option>
- <option value="7">Monthly</option>
- <option value="8">NineHour</option>
- <option value="9">OneHour</option>
- <option value="10">OneMinute</option>
- <option value="11">Quarterly</option>
- <option value="12">SixHour</option>
- <option value="13">ThirtyMinute</option>
- <option value="14">ThreeHour</option>
- <option value="15">ThreeMinute</option>
- <option value="16">TwelveHour</option>
- <option value="17">TwoHour</option>
- <option value="18">TwoMinute</option>
- <option value="19">Yearly</option>
- </select>
- <input type="hidden" id="hf_SchedulerType" />
- </div>
- </div>
- <div class="col-sm-6">
- <div class="input-group">
- <label for="User" class="font-bold">User</label>
- <select id="txtAutoComplete_Users" class="form-control text-control" style="width:100%;" placeholder="User" data-placeholder="User" data-label="" data-istagselect="true"></select>
- <input type="hidden" id="hf_Autocomplete_Users" class="form-control value-control" data-isdynamic="true" />
- </div>
- </div>
- </div>
- <div class="row" id="div_Dates">
- <div id="" class="col-sm-6">
- <div class="floating-label-form-group" id="div_StartDate">
- <label for="lbl" id="lbl_StartDate">Start Date<span class="text-danger" id="spnIsRequired_StartDate"> *</span></label>
- <div class="input-group">
- <input type="text" id="date_StartDate" class="form-control type-control datepicker-input hasDatepicker value-control floating-label-control" placeholder="Start Date *" data-placeholder="dd/mm/yyyy hh:mm" data-label="Start Date *">
- <span class="input-group-addon mt-10"><i class="fa fa-calendar"></i></span>
- <input type="hidden" id="hf_StartDate" />
- </div>
- </div>
- </div>
-
- <div id="" class="col-sm-6">
- <div class="floating-label-form-group" id="div_EndDate">
- <label for="lbl" id="lbl_EndDate">End Date<span class="text-danger" id="spnIsRequired_EndDate"> *</span></label>
- <div class="input-group">
- <input type="text" id="date_EndDate" class="form-control type-control datepicker-input hasDatepicker value-control floating-label-control" placeholder="End Date *" data-placeholder="dd/mm/yyyy hh:mm" data-label="End Date *">
- <span class="input-group-addon mt-10"><i class="fa fa-calendar"></i></span>
- <input type="hidden" id="hf_EndDate" />
- </div>
- </div>
- </div>
- </div>
-
- </div>
- </div>
- </div>
- <div class="bg-white card-footer footer" id="FooterRuleScheduler">
- <a href="javascript:;" id="btnCloseRuleScheduler" class="btn btn-light btn-sm mr-auto "> Close</a>
- <a href="javascript:;" id="btnSaveRuleScheduler" class="btn btn-primary btn-sm"> Save</a>
- </div>
- </div>
- </form>`;
- return html;
- }
- load(id, containerid, callback) {
- var instance = this;
- $("#btnCloseRuleScheduler").click(function () {
- $('#' + containerid).modal('hide');
- $('#' + containerid).remove();
- });
- $("#btnSaveRuleScheduler").click(function () {
- let appcontrolid = "frmUnibase_RuleScheduler";
- let result = Unibase.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation(appcontrolid);
- if (result == false) {
- MessageHelper.Instance().showError("Mandatory fields are missing", "Validate_RuleScheduler");
- return false;
- }
- else {
- ActiveRules.Instance().SaveRuleScheduler(id, containerid);
- }
- });
- var url = _appsettings.server_url() + '/apis/v4/unibase/platform/followers/reports_followersauto';
- AutoCompleteHelper.getHelper().Create("#txtAutoComplete_Users", "#hf_Autocomplete_Users", url, function (response) {
- var data = response;
- });
- $("#date_StartDate").daterangepicker({
- autoUpdateInput: false,
- timePicker: true,
- timePicker24Hour: true,
- locale: {
- format: 'DD/MM/YYYY HH:mm',
- },
- singleDatePicker: true,
- showDropdowns: true,
- minYear: 1901,
- maxDate: new Date(2050, 11, 31)
- });
- $("#date_EndDate").daterangepicker({
- autoUpdateInput: false,
- timePicker: true,
- timePicker24Hour: true,
- locale: {
- format: 'DD/MM/YYYY HH:mm',
- },
- singleDatePicker: true,
- showDropdowns: true,
- minYear: 1901,
- maxDate: new Date(2050, 11, 31)
- });
- $('#date_StartDate').on('apply.daterangepicker', function (ev, picker) {
- $('#div_StartDate').addClass('floating-label-form-group-with-value');
- });
- $('#date_EndDate').on('apply.daterangepicker', function (ev, picker) {
- $('#div_EndDate').addClass('floating-label-form-group-with-value');
- });
- if (id != "") {
- Unibase.Platform.Automation.Components.ActiveRules.Instance().EditRuleScheduler(id);
- }
- }
- init(containerid) {
- this.render(containerid);
- this.loadJsFiles();
- }
- render(containerid) {
- return __awaiter(this, void 0, void 0, function* () {
- $("." + containerid).empty();
- let html = `<form id="frmUnibase_ActiveRules" data-validate="parsley" data-isdynamic="false">
- <div class="card bg-light m-0">
- <div class="b-b bg-white card-header">
- <strong class="biz-highlight-bg-color title" id="">Active Rules</strong>
- <span class="badge badge-light badge-pill badge-outline span_activerules_count">0</span>
- </div>
- <div class="card-body scrollable p-0" style="overflow-y: scroll;">
- <table class="table m-0">
- <thead style="background: #EAECEE !important;">
- <tr >
- <th class="biz-list-header">Rule Name</th>
- <th class="biz-list-header">Sceduler Type</th>
- <th class="biz-list-header">From Date</th>
- <th class="biz-list-header">To Date</th>
- <th class="biz-list-header">NextSceduled Date</th>
- <th></th>
- </tr>
- </thead>
- <tbody class="ActiveRuleslist_body bg-white text-dark font-14"></tbody>
- </table>
- </div>
- <div class="bg-white card-footer footer" id="ActiveRulesFooter">
-
- </div>
- </div>
- </form>`;
- return yield $("." + containerid).append(html);
- });
- }
- loadJsFiles() {
- var jsfiles = Unibase.Platform.Automation.Components.ActiveRules.Instance().jsFiles();
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(jsfiles, function () {
- let RuleId = "";
- if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length > 0) {
- for (let obj of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) {
- if (obj.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_ruleid") {
- RuleId = obj.Value.toString();
- }
- }
- }
- if (Number(RuleId) != 0) {
- Unibase.Platform.Automation.Components.ActiveRules.Instance().GetActiveRules(Number(RuleId));
- }
- });
- }
- GetActiveRules(RuleId) {
- Unibase.Platform.Automation.Managers.RuleManager.Instance().getActiveRules(RuleId).then(function (response) {
- if (response.length > 0) {
- $('.ActiveRuleslist_body').html('<tr class="ActiveRuleslist hidden"></tr>');
- var html = "";
- let ActiveRules = response;
- let Status = ActiveRules[0].StatusId;
- let StatusName = "";
- let ChangeStatusName = "";
- let statusbadge = "";
- let SchedulerType = Unibase.Platform.Automation.Enums.SchedulerType[ActiveRules[0].SchedulerId];
- let NewStatus;
- if (Status == Number(Unibase.Platform.Core.Enums.RowStatus.Active)) {
- StatusName = "Active";
- ChangeStatusName = "DeActivate";
- NewStatus = Unibase.Platform.Core.Enums.RowStatus.InActive;
- statusbadge = "#fff";
- }
- else {
- StatusName = "InActive";
- ChangeStatusName = "Activate";
- NewStatus = Unibase.Platform.Core.Enums.RowStatus.Active;
- statusbadge = "#FFF1F1";
- }
- html = '<tr style="background:' + statusbadge + '"><td class="widget-list-item-main-title">' + ActiveRules[0].RuleName + '</td><td>' + SchedulerType + '</td><td>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().FormatDateTimeWithoutSeconds(ActiveRules[0].StartDate) + '</td><td>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().FormatDateTimeWithoutSeconds(ActiveRules[0].EndDate) + '</td><td>' + Unibase.Platform.Helpers.DateTimeHelper.Instance().FormatDateTimeWithoutSeconds(ActiveRules[0].NextScheduleDate) + '</td><td><div><a href="javascript:;" data-toggle="dropdown" class="no-caret dropdown-toggle pull-right biz-transparent-text-color" id="" aria-expanded="false"><i class="fa fa-ellipsis-h mr-20"></i></a><ul class="dropdown-menu pull-right clearfix"><li class="dropdown-menu-item hidden"></li><li id=""><a class="dropdown-item biz-transparent-text-color" href="javascript:;" id="" onclick="Unibase.Platform.Automation.Components.ActiveRules.Instance().ChangeActiveRuleStatus(' + ActiveRules[0].ActiveRuleId + ',' + ActiveRules[0].RuleId + ',' + NewStatus + ');">' + ChangeStatusName + '</a></li></ul></div></td></tr>';
- $(".ActiveRuleslist:last").before(html);
- $(".span_activerules_count").text(1);
- }
- else {
- $(".ActiveRuleslist_body").html('<div class="alert alert-primary text-center mb-0 border-0 rounded-0 w-100 ">No Records Found</div>');
- $(".span_activerules_count").text(0);
- }
- });
- }
- ChangeActiveRuleStatus(ActiveRuleId, RuleId, Status) {
- if (Status == Unibase.Platform.Core.Enums.RowStatus.Active) {
- Unibase.Platform.Helpers.NavigationHelper.Instance().popup(RuleId, "", Unibase.Platform.Automation.Components.ActiveRules.Instance(), null, Platform.Helpers.Size.DockLeft);
- }
- else {
- Unibase.Platform.Automation.Managers.RuleManager.Instance().UpdateActiveRuleStatus(ActiveRuleId, Status).then(function (response) {
- if (response.status == Unibase.Data.Status.Success) {
- MessageHelper.Instance().showSuccess(response.message, " ");
- Unibase.Platform.Automation.Components.ActiveRules.Instance().GetActiveRules(response.result.RuleId);
- }
- });
- }
- }
- EditRuleScheduler(id) {
- let response;
- Unibase.Platform.Automation.Managers.RuleManager.Instance().getRule(id).then(function (res) {
- response = res;
- $("#hf_SchedulerType").val(response.SchedulerId);
- $("#divEventDetails").removeClass("hidden");
- $("#EventColumnsdiv").addClass("hidden");
- $("#select2_EventColumns").removeClass("required");
- $("#date_StartDate").val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateTimeWithoutSeconds(response.StartDate));
- $("#date_EndDate").val(Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocalDateTimeWithoutSeconds(response.EndDate));
- $("#ddl_SchedulerType").val($("#hf_SchedulerType").val());
- $("input[type=radio]").attr('disabled', 1);
- var useroption = new Option(response.UserName, response.IdentityUserId.toString(), true, true);
- $("#txtAutoComplete_Users").append(useroption);
- $("#div_StartDate").addClass('floating-label-form-group-with-value');
- $("#div_EndDate").addClass('floating-label-form-group-with-value');
- eval('_floatingLabelHelper.init();');
- });
- }
- SaveRuleScheduler(id, containerid) {
- let ruleobj = {};
- ruleobj.RuleId = id;
- ruleobj.SchedulerId = Number($("#ddl_SchedulerType").val());
- ruleobj.RuleType = Unibase.Platform.Automation.Enums.RuleType.Scheduler;
- let StartDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDateTime($("#date_StartDate").val());
- ruleobj.StartDate = new Date(StartDate);
- let EndDate = Unibase.Platform.Helpers.DateTimeHelper.Instance().formatServerDateTime($("#date_EndDate").val());
- ruleobj.EndDate = new Date(EndDate);
- ruleobj.IdentityUserId = Number($("#txtAutoComplete_Users option:selected").val());
- Unibase.Platform.Automation.Managers.RuleManager.Instance().UpdateRuleScheduler(ruleobj).then(function (response) {
- if (response.status == Unibase.Data.Status.Error) {
- MessageHelper.Instance().showError(response.message, "Validate_RuleScheduler");
- }
- else {
- $('#' + containerid).modal('hide');
- $('#' + containerid).remove();
- Unibase.Platform.Automation.Components.ActiveRules.Instance().GetActiveRules(response.result.RuleId);
- }
- });
- }
- static Instance() {
- if (this.instance === undefined) {
- this.instance = new ActiveRules();
- }
- return this.instance;
- }
- }
- Components.ActiveRules = ActiveRules;
- })(Components = Automation.Components || (Automation.Components = {}));
- })(Automation = Platform.Automation || (Platform.Automation = {}));
- })(Platform = Unibase.Platform || (Unibase.Platform = {}));
- })(Unibase || (Unibase = {}));
|