import{a as H}from"./chunk-D4RZOGGF.js";import{a as M}from"./chunk-WFZJP5WR.js";import"./chunk-F6KLNSUK.js";import{b as P,c as j,d as q}from"./chunk-YOJ4KGSB.js";import"./chunk-CO3X7TQN.js";import{a as N}from"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{Ib as A,Mb as R,Ob as k,T as L,U as y,V as _,W as I,h as C,i as J,k as x,wb as z}from"./chunk-YSQLW2JA.js";import"./chunk-NVJ2ZZFT.js";import{Nc as r,Ng as B,Qd as f,Qf as O,Rd as v,Te as E,Vc as b,Ve as h,Ye as D,Yg as w,ab as p,af as T,bb as S,dd as g,eh as U,hd as c,of as d,ya as m,zc as u}from"./chunk-SKPDQO4E.js";var V=`<div class="h-100">
  <side-navigation>
    <ng-template side-navigation-nav>
      <div class="row">
        <div class="col-12">
          <label class="report-form-label">{{'SCHEDULEDJOBS.JOB_TYPE'|translate}}</label>
          <nz-select class="w-100" nzSize="small" nzPlaceHolder="{{'COMMON.ALL'|translate}}"
            [(ngModel)]="request.filter.types" nzMode="'multiple'">
            <nz-option *ngFor="let scheduleJobType of scheduledJobService.scheduleJobTypes"
              [nzValue]="scheduleJobType.type" [nzLabel]="(scheduleJobType.title | translate)"></nz-option>
          </nz-select>
        </div>
        <div class="col-12 pos-relative">
          <label class="report-form-label">{{'SCHEDULEDJOBS.JOB_EXECUTION_RANGE' | translate}}</label>
          <input placeholder="{{'COMMON.ALL'|translate}}" type="text" readonly owlinput
            class="form-control form-control-sm bg-white" [(ngModel)]="filterDateRange" [selectMode]="'range'"
            [owlDateTimeTrigger]="dtRange1" [owlDateTime]="dtRange1">
          <owl-date-time [firstDayOfWeek]="1" #dtRange1 [pickerType]="'calendar'"></owl-date-time>
          <cds-icon shape="times-circle" solif class="cds-icon-18 report-form-icon" *ngIf="filterDateRange!=null"
            title="{{'BUTTON.CLEAR'|translate}}" click-stop-propagation (click)="filterDateRange=null;"></cds-icon>
        </div>
        <div class="col-12">
          <label class="report-form-label">{{'SCHEDULEDJOBS.JOB_ACTIVE_STATE'|translate}}</label>
          <nz-select class="w-100" nzSize="small" nzPlaceHolder="{{'COMMON.ALL'|translate}}" [nzAllowClear]="true"
            [(ngModel)]="request.filter.enabled">
            <nz-option *ngFor="let enabledState of enabledStates" [nzValue]="enabledState.value"
              [nzLabel]="(enabledState.title | translate)"></nz-option>
          </nz-select>
        </div>
        <div class="col-12">
          <label class="report-form-label">{{'SCHEDULEDJOBS.JOB_EDITABLE_STATE'|translate}}</label>
          <nz-select class="w-100" nzSize="small" nzPlaceHolder="{{'COMMON.ALL'|translate}}" [nzAllowClear]="true"
            [(ngModel)]="request.filter.editable">
            <nz-option *ngFor="let editableState of editableStates" [nzValue]="editableState.value"
              [nzLabel]="(editableState.title | translate)"></nz-option>
          </nz-select>
        </div>
        <div class="col-12">
          <label class="report-form-label">{{'SCHEDULEDJOBS.JOB_CREATED_BY'|translate}}</label>
          <nz-select class="w-100" nzSize="small" nzPlaceHolder="{{'COMMON.ALL'|translate}}" [nzAllowClear]="true"
            [(ngModel)]="request.filter.createdBySystem" (ngModelChange)="onCreatedBySystemChanged($event)">
            <nz-option *ngFor="let creationState of creationStates" [nzValue]="creationState.value"
              [nzLabel]="(creationState.title | translate:languageService.userTranslate)"></nz-option>
          </nz-select>
        </div>
        <div class="col-12" *ngIf="permissionSearchIdentity && request.filter.createdBySystem!=true">
          <label class="report-form-label">{{'SCHEDULEDJOBS.JOB_CREATED_USER_BY' | translate :
            languageService.userTranslate}}</label>
          <armon-select-search query="identity" [allowMulti]="false" [allowClear]="true"
            [(ngModel)]="request.filter.createdByUserId">
          </armon-select-search>
        </div>
        <div class="col-12 mt-4 d-flex justify-content-center">
          <button class="btn btn-primary btn-sm" (click)="onListClicked($event)">{{'COMMON.FILTER' |translate}}</button>
        </div>
      </div>
    </ng-template>
    <ng-template side-navigation-content>
      <div class="report-data-container">
        <div class="row report-filter-container">
          <div class="col-12 mb-2" *ngIf="permissionScheduledJobsWrite">
            <button class="btn btn-primary btn-sm me-2" (click)="onAddJobClicked($event)">
              {{'SCHEDULEDJOBS.ADD_JOB'|translate}}
            </button>
          </div>
          <div class="col-12">
            <armon-sorting-picker [data]="sortingPickerData" (selectionChanged)="onSortingSelectionChanged($event)">
            </armon-sorting-picker>
          </div>
        </div>
        <div class="row report-data-table-container" id="report-data-table-container">
          <div class="col-12">
            <ng-container *ngIf="items && items.length>0">
              <div class="row my-2" [@listAnimation]="items.length">
                <div class="col-12" *ngFor="let item of items">
                  <div class="card mb-3">
                    <div class="card-body p-4">
                      <div class="d-flex flex-grow-1">
                        <div class="d-flex flex-column align-items-center pe-2 b-r-1">
                          <cds-icon shape="scheduled_job" size="lg" class="text-primary opacity-25 mb-3"></cds-icon>
                          <span class="text-sm fw-medium text-center text-success"
                            *ngIf="item.enabled == true">{{'SCHEDULEDJOBS.JOB_ACTIVE'|translate}}</span>
                          <span class="text-sm fw-medium text-center color-gray"
                            *ngIf="item.enabled == false">{{'SCHEDULEDJOBS.JOB_PASSIVE'|translate}}</span>
                        </div>
                        <div class="row flex-grow-1">
                          <div class="col-12 mb-4">
                            <div class="d-flex flex-column flex-grow-1 px-3">
                              <span
                                class="text-md fw-medium text-primary">{{item.jobType.title|translate}}</span>
                              <span class="text-sm">{{item.jobInterval.title|translate}}</span>
                            </div>
                          </div>
                          <div class="col-md-6 col-12">
                            <div class="d-flex flex-column flex-grow-1 px-3">
                              <span class="text-xs">{{'SCHEDULEDJOBS.JOB_FIRST_EXECUTION_DATE'|translate}} :
                                {{item.firstExectionDateText}}</span>
                              <span class="text-xs mb-3">{{'SCHEDULEDJOBS.JOB_NEXT_EXECUTION_DATE'|translate}} :
                                {{item.nextExecutionDateText}}</span>
                              <ng-container *ngIf="item.settings.reportTypeDefinition">
                                <div>
                                  <span nz-tooltip nzTooltipTitle="{{'REPORT.TEMPLATE_GOTO_REPORT' | translate}}"
                                    class="text-sm cursor-pointer"
                                    (click)="onReportTemplateClicked($event, item)">{{item.settings.reportTypeDefinition.description|translate:languageService.userTranslate}}
                                    -
                                    {{(item.settings.reportName)?item.settings.reportName:item.settings.templateName}}</span>
                                </div>
                              </ng-container>
                              <span class="text-xs text-italic mt-2" *ngIf="item.note">{{item.note}}</span>
                            </div>
                          </div>
                          <div class="col-md-6 col-12" *ngIf="item.createdBy">
                            <div class="d-flex flex-column flex-grow-1 px-3">
                              <span class="text-xs">{{'SCHEDULEDJOBS.JOB_CREATED_BY'|translate}}</span>
                              <armon-captionlines [showBorder]="false" [captionlines]="item.createdBy.caption">
                              </armon-captionlines>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="card-footer" *ngIf="item.jobType.editable || item.jobType.activatable">
                      <button class="btn btn-sm btn-link"
                        *ngIf="item.jobType.editable && item.isEditable && permissionScheduledJobsWrite"
                        (click)="onEditJobClicked($event, item)">{{'BUTTON.EDIT'|translate}}</button>
                      <button class="btn btn-sm btn-link"
                        *ngIf="item.jobType.editable && item.isEditable && permissionScheduledJobsWrite"
                        (click)="onDeleteJobClicked($event, item)">{{'BUTTON.DELETE'|translate}}</button>
                      <button class="btn btn-sm btn-link"
                        *ngIf="item.jobType.activatable && item.isEditable && permissionScheduledJobsWrite"
                        (click)="onActivationClicked($event, item)">{{(item.enabled?'BUTTON.PASSIVE':'BUTTON.ACTIVE')|translate}}</button>
                    </div>
                  </div>
                </div>
              </div>
            </ng-container>
          </div>
          <div class="col-12 my-2">
            <armon-pagination [paginationResponse]="paginationResponse" (pageChanged)="pageChanged($event)"
              [scrollDomId]="'report-data-table-container'">
            </armon-pagination>
          </div>
        </div>
      </div>
    </ng-template>
  </side-navigation>
</div>`;var F=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}
`;var G=function(o,e,t,n){var a=arguments.length,i=a<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(o,e,t,n);else for(var s=o.length-1;s>=0;s--)(l=o[s])&&(i=(a<3?l(i):a>3?l(e,t,i):l(e,t))||i);return a>3&&i&&Object.defineProperty(e,t,i),i},Y=class{scheduledJobService;languageService;authService;routingService;interactionService;modalService;items;request;filterDateRange;paginationResponse=new B;enabledStates=[{value:!0,title:"SCHEDULEDJOBS.JOB_ONLY_ACTIVE"},{value:!1,title:"SCHEDULEDJOBS.JOB_ONLY_PASSIVE"}];editableStates=[{value:!0,title:"SCHEDULEDJOBS.JOB_ONLY_EDITABLE"},{value:!1,title:"SCHEDULEDJOBS.JOB_ONLY_NOT_EDITABLE"}];creationStates=[{value:!0,title:"SCHEDULEDJOBS.JOB_ONLY_SYSTEM"},{value:!1,title:"SCHEDULEDJOBS.JOB_ONLY_USER"}];permissionSearchIdentity;permissionScheduledJobsWrite;sortingPickerData;constructor(e,t,n,a,i,l){this.scheduledJobService=e,this.languageService=t,this.authService=n,this.routingService=a,this.interactionService=i,this.modalService=l}ngOnInit(){this.permissionSearchIdentity=this.authService.checkPermission(c.IDENTITY.getReadBasic()),this.permissionScheduledJobsWrite=this.authService.checkPermission(c.SCHEDULEDJOBS.getWrite()),this.request=y.getEmptyModel(),this.request.pagination.take=u.REQUEST_ITEM_LIMIT,this.sortingPickerData={items:[{value:"type",label:"SCHEDULEDJOBS.SORTING_TYPE",showDirection:!0,selected:!0,directionDefault:J.ASC},{value:"nextExecutionDate",label:"SCHEDULEDJOBS.SORTING_EXECUTION_DATE",showDirection:!0},{value:"status",label:"SCHEDULEDJOBS.SORTING_STATUS",showDirection:!0}]},this.setSortingSelection(this.sortingPickerData.items[0].value,b.ASC),this.getData()}setSortingSelection(e,t){this.request.sorting.field=e,this.request.sorting.order=t}getData(){this.scheduledJobService.listScheduledJobs(this.request).subscribe(e=>{this.items=e.items,this.paginationResponse=e.pagination})}pageChanged(e){this.request.pagination=e,this.getData()}onSortingSelectionChanged(e){this.setSortingSelection(e.value,e.direction),this.getData()}updateFilter(){this.filterDateRange?this.request.filter.executionInRange={start:this.filterDateRange[0],end:this.filterDateRange[1]}:this.request.filter.executionInRange=null}onListClicked(e){this.updateFilter(),this.getData()}onCreatedBySystemChanged(e){this.request.filter.createdBySystem==!0&&(this.request.filter.createdByUserId=null)}showScheduledJobModal(e=null){this.modalService.open(A,{settings:{size:"lg",scrollable:!0},props:{scheduledJob:d(e)?null:e,availableTypes:d(e)?L.filter(t=>t.addable==!0):null}}).result.then(t=>{this.getData()}).catch(t=>{})}onAddJobClicked(e){this.showScheduledJobModal()}onDeleteJobClicked(e,t){this.interactionService.showDialog("SCHEDULEDJOBS.DELETE","SCHEDULEDJOBS.DELETE_CONFIRMATION",null,{},!0,"BUTTON.DELETE","",!0,()=>{this.scheduledJobService.deleteScheduledJob(t.id).subscribe(()=>{this.interactionService.showMessage("SCHEDULEDJOBS.DELETE_COMPLETED",null,r.Success),this.getData()})})}onActivationClicked(e,t){this.interactionService.showDialog(t.enabled?"SCHEDULEDJOBS.PASSIVE":"SCHEDULEDJOBS.ACTIVATE",t.enabled?"SCHEDULEDJOBS.PASSIVE_CONFIRMATION":"SCHEDULEDJOBS.ACTIVATE_CONFIRMATION",null,{},!0,"BUTTON.YES","",!1,()=>{let n=new _;n.enabled=!t.enabled,this.scheduledJobService.updateScheduledJob(t.id,n).subscribe(()=>{this.interactionService.showMessage("SCHEDULEDJOBS.UPDATE_COMPLETED",null,r.Success),this.getData()})})}onEditJobClicked(e,t){this.showScheduledJobModal(t.getUpsertModel())}onReportTemplateClicked(e,t){this.routingService.gotoReportTemplate(t.settings.reportTypeDefinition.type,t.settings.templateId,t.settings.customReportId)}static ctorParameters=()=>[{type:I},{type:T},{type:k},{type:R},{type:O},{type:v}]};Y=G([m({selector:"armon-scheduledjobs",template:V,animations:H,standalone:!0,providers:[{provide:h,useClass:x}],imports:[q,P,U,E,p,D,S,f,z,j,C,w,M,N,g],styles:[F]})],Y);export{Y as ScheduledJobsComponent};
