Viewing File: /usr/local/cpanel/whostmgr/docroot/templates/web-log-retention/main.c855d24149189a1b.min.js
"use strict";(self.webpackChunkweb_log_retention=self.webpackChunkweb_log_retention||[]).push([[792],{7276:(d,b,i)=>{var g=i(345),_=i(177),x=i(9650),E=i(1562),C=i(7901),t=i(3953);const k=[];let F=(()=>{class n{static#t=this.ɵfac=function(s){return new(s||n)};static#e=this.ɵmod=t.$C({type:n});static#n=this.ɵinj=t.G2t({imports:[C.iI.forRoot(k),C.iI]})}return n})();var h=i(6381),m=i(6153),r=i(3373),M=i(2806),v=i(8391);let f=(()=>{class n{constructor(){this._locale=(0,t.WQX)(h.h),this.pageSize=(0,t.vPA)(25),this.selectedPage=(0,t.vPA)(1),this.totalRecords=(0,t.vPA)(0),this.recordsBeforeFilter=(0,t.vPA)(0),this.filters=(0,t.vPA)([]),this.sorts=(0,t.vPA)([]),this.pageSizes=[10,25,50,100],this.loading=(0,t.vPA)(!1),this._reloadNonce=(0,t.vPA)(0),this.metadata=(0,t.EWP)((()=>({pager:{page:this.selectedPage(),pageSize:this.pageSize()},filters:this.filters(),sorts:this.sorts(),nonce:this._reloadNonce()})))}setSort(e,s){this.sorts.set([new m.FU(e,s,"retention_days"===e?m.r3.NumericZeroAsMax:m.r3.Lexicographic)])}updateSearchFilter(e){this.filters.set(e?[new v.d("*",v.t.Contains,e)]:[]),this.selectedPage.set(1)}updatePageSize(e){this.pageSize.set(e),this.selectedPage.set(1)}changePage(e){this.selectedPage.set(e)}updateRecordCounts(e,s){this.totalRecords.set(e),this.recordsBeforeFilter.set(s)}noResultsReason(e){const s=this.recordsBeforeFilter();return e?null:this._locale.maketext(s?"No results match your query.":"No results available.")}triggerReload(){this._reloadNonce.update((e=>e+1))}static#t=this.ɵfac=function(s){return new(s||n)};static#e=this.ɵprov=t.jDH({token:n,factory:n.ɵfac,providedIn:"root"})}return n})();var y=i(9079),j=i(5558),R=i(9437),B=i(980),S=i(7673),p=i(9490),P=i(4355),T=i(2312),I=i(8810),W=i(6354);let A=(()=>{class n{constructor(){this._whmApiClient=(0,t.WQX)(P.gB),this._tableService=(0,t.WQX)(f)}_getErrorMessage(e){return e instanceof Error?e.message:String(e?.message??"An unexpected error occurred")}listAccountsRetention(e){const s=new T.m(T.R.JsonApi,{method:"list_accounts_retention",sorts:e?.sorts,filters:e?.filters,pager:e?.pager});return this._whmApiClient.get(s).pipe((0,W.T)((a=>{if(!a.success)throw new Error(a.errors?.[0]?.message??"API request failed");const o=a.meta?.totalRecords??0,u=a.meta?.recordsBeforeFilter??o;this._tableService.updateRecordCounts(o,u);const l=a.data,Z=Array.isArray(l)?l:l?.accounts??[];return{default_retention:Array.isArray(l)?a.meta?.properties?.default_retention??0:l?.default_retention??0,accounts:Z,meta:{totalRecords:o,recordsBeforeFilter:u}}})),(0,R.W)((a=>(0,I.$)((()=>new Error(this._getErrorMessage(a)))))))}static#t=this.ɵfac=function(s){return new(s||n)};static#e=this.ɵprov=t.jDH({token:n,factory:n.ɵfac,providedIn:"root"})}return n})(),w=(()=>{class n{constructor(){this._locale=(0,t.WQX)(h.h)}descriptionTitle(){return this._locale.maketext("Use this interface to view web server log retention settings.")}descriptionText(e,s,a){return`${this._locale.maketext("View and manage web server log retention settings for all accounts on this server.")} ${e?this._locale.maketext("The system retains logs indefinitely by default."):this._locale.maketext("The system retains logs for [quant,_1,day,days] by default.",s)} ${this._locale.maketext("Use the [output,url,_1,Tweak Settings] interface to change the server default.",a)}`}retentionDefaultLabel(e){return 0===e?this._locale.maketext("Default (indefinite)[comment,label]"):this._locale.maketext("Default ([quant,_1,day,days])[comment,label]",e)}retentionCustomLabel(e){return 0===e?this._locale.maketext("Indefinite[comment,label]"):this._locale.maketext("[quant,_1,day,days][comment,label]",e)}static#t=this.ɵfac=function(s){return new(s||n)};static#e=this.ɵprov=t.jDH({token:n,factory:n.ɵfac,providedIn:"root"})}return n})(),D=(()=>{class n{constructor(){this._api=(0,t.WQX)(A),this._table=(0,t.WQX)(f),this._alerts=(0,t.WQX)(p.uE),this._text=(0,t.WQX)(w),this._response=(0,y.ot)((0,y.br)(this._table.metadata).pipe((0,j.n)((e=>e?(this._table.loading.set(!0),this._api.listAccountsRetention(e).pipe((0,R.W)((s=>(this._alerts.error(this._getErrorMessage(s)),(0,S.of)({default_retention:0,accounts:[],meta:{totalRecords:0,recordsBeforeFilter:0}})))),(0,B.j)((()=>this._table.loading.set(!1))))):(0,S.of)(null)))),{initialValue:null}),this._accounts=(0,t.EWP)((()=>this._response()?.accounts??[])),this.defaultRetention=(0,t.EWP)((()=>this._response()?.default_retention??0)),this.isDefaultRetentionIndefinite=(0,t.EWP)((()=>0===Number(this.defaultRetention()))),this.loading=(0,t.EWP)((()=>this._table.loading())),this.totalItems=(0,t.EWP)((()=>this._response()?.meta?.totalRecords??0)),this.paginatedAccounts=(0,t.EWP)((()=>this._accounts().map((e=>({...e,retention_cell:{display:this._getRetentionDisplay(e),using_default:e.using_default},actions:{user:e.user}}))))),this.noResultsReason=(0,t.EWP)((()=>this._table.noResultsReason(this._accounts().length)))}refresh(){this._table.triggerReload()}_getRetentionDisplay(e){if(e.using_default){const a=Number(this.defaultRetention());return this._text.retentionDefaultLabel(a)}const s=Number(e.retention_days);return this._text.retentionCustomLabel(s)}_getErrorMessage(e){if(e instanceof Error)return e.message;if("string"==typeof e)return e;const s=e;return String(s?.message??s?.error??"An unexpected error occurred")}static#t=this.ɵfac=function(s){return new(s||n)};static#e=this.ɵprov=t.jDH({token:n,factory:n.ɵfac,providedIn:"root"})}return n})(),G=(()=>{class n{constructor(){this.retention=null,this.locale=(0,t.WQX)(h.h)}static#t=this.ɵfac=function(s){return new(s||n)};static#e=this.ɵcmp=t.VBU({type:n,selectors:[["cp-web-log-retention-retention-cell"]],inputs:{retention:"retention"},decls:2,vars:3,consts:[["data-testid","retentionDisplay"]],template:function(s,a){1&s&&(t.j41(0,"span",0),t.EFF(1),t.k0s()),2&s&&(t.AVh("text-muted",null==a.retention?null:a.retention.using_default),t.R7$(),t.SpI(" ",null==a.retention?null:a.retention.display,"\n"))},encapsulation:2})}return n})(),V=(()=>{class n{constructor(){this.user="",this.locale=(0,t.WQX)(h.h),this.ButtonState=r.w,this.ButtonVariant=r.Ak,this._securityToken=window.PAGE?.securityToken??""}openManageLogs(){const e=document.createElement("form");e.method="POST",e.action="/xfercpanel",e.target="_blank",[{name:"token",value:this._securityToken},{name:"user",value:this.user},{name:"goto_uri",value:"frontend/jupiter/raw/index.html"}].forEach((a=>{const o=document.createElement("input");o.type="hidden",o.name=a.name,o.value=a.value,e.appendChild(o)})),document.body.appendChild(e),e.submit(),document.body.removeChild(e)}static#t=this.ɵfac=function(s){return new(s||n)};static#e=this.ɵcmp=t.VBU({type:n,selectors:[["cp-web-log-retention-manage-logs-button"]],inputs:{user:"user"},decls:3,vars:5,consts:[["cssClass","btn-sm manage-logs-btn",3,"btnClick","id","buttonVariant","buttonState"],["src","/images/cpanel.png","alt","","aria-hidden","true",1,"cpanel-logo","me-1"]],template:function(s,a){1&s&&(t.j41(0,"cp-button",0),t.bIt("btnClick",(function(){return a.openManageLogs()})),t.nrm(1,"img",1),t.EFF(2),t.k0s()),2&s&&(t.Y8G("id","manageLogs_"+a.user)("buttonVariant",a.ButtonVariant.secondary)("buttonState",a.ButtonState.enabled),t.BMQ("data-testid","manageLogs_"+a.user),t.R7$(2),t.SpI(" ",a.locale.maketext("Manage Logs"),"\n"))},dependencies:[r.Qp],styles:["[_nghost-%COMP%] .manage-logs-btn{min-height:32px;padding-top:.375rem;padding-bottom:.375rem}.cpanel-logo[_ngcontent-%COMP%]{height:16px}"]})}return n})();const $=["retentionCell"],O=["actionsCell"],z=["expandTemplate"];function L(n,c){1&n&&t.nrm(0,"cp-web-log-retention-retention-cell",11),2&n&&t.Y8G("retention",c.$implicit)}function Q(n,c){if(1&n&&t.nrm(0,"cp-web-log-retention-manage-logs-button",12),2&n){const e=c.$implicit;t.Y8G("user",null==e?null:e.user)}}function N(n,c){if(1&n&&(t.j41(0,"dl",13)(1,"dt"),t.EFF(2),t.k0s(),t.j41(3,"dd"),t.EFF(4),t.k0s(),t.j41(5,"dt"),t.EFF(6),t.k0s(),t.j41(7,"dd"),t.nrm(8,"cp-web-log-retention-retention-cell",11),t.k0s()()),2&n){const e=c.$implicit,s=t.XpG();t.R7$(2),t.JRh(s.locale.maketext("Domain")),t.R7$(2),t.JRh(e.domain),t.R7$(2),t.JRh(s.locale.maketext("Retention Setting")),t.R7$(2),t.Y8G("retention",e.retention_cell)}}function X(n,c){if(1&n&&t.EFF(0),2&n){let e;const s=t.XpG();t.SpI(" ",null!==(e=s.noResultsReason)&&void 0!==e?e:s.locale.maketext("No accounts found on this server.")," ")}}function U(n,c){if(1&n&&t.EFF(0),2&n){const e=t.XpG();t.SpI(" ",e.locale.maketext("No accounts match your search criteria.")," ")}}let Y=(()=>{class n{constructor(){this.locale=(0,t.WQX)(h.h),this.tableService=(0,t.WQX)(f),this._facade=(0,t.WQX)(D),this._text=(0,t.WQX)(w),this.defaultRetention=this._facade.defaultRetention,this.isDefaultRetentionIndefinite=this._facade.isDefaultRetentionIndefinite,this.descriptionTitle=(0,t.EWP)((()=>this._text.descriptionTitle())),this.descriptionText=(0,t.EWP)((()=>this._text.descriptionText(this.isDefaultRetentionIndefinite(),this.defaultRetention(),this.getTweakSettingsUrl()))),this._securityToken=window.PAGE?.securityToken??"",this.paginatedAccounts=this._facade.paginatedAccounts,this.totalItems=this._facade.totalItems,this.loading=this._facade.loading,this.accountTableColumns=[],(0,M.Yl)("bs5")}ngOnInit(){this.tableService.setSort("user",m.UE.Ascending),this.accountTableColumns=[new r.VP("user",{displayValue:this.locale.maketext("User"),isSortable:!0,isResponsive:!0}),new r.VP("domain",{displayValue:this.locale.maketext("Domain"),isSortable:!0}),new r.VP("retention_cell",{displayValue:this.locale.maketext("Retention Setting"),isSortable:!0,customCellTemplate:this.retentionCellTemplate}),new r.VP("actions",{displayValue:this.locale.maketext("Actions"),isSortable:!1,isResponsive:!0,customCellTemplate:this.actionsCellTemplate})]}applyFilter(e){this.tableService.updateSearchFilter(e)}onSortChanged(e){const s=e.sorts?.[0];s&&this.tableService.setSort("retention_cell"===s.column?"retention_days":s.column,s.direction)}onPaginatorChange(e){e.pageSize!==this.tableService.pageSize()&&this.tableService.updatePageSize(e.pageSize),e.currentPage!==this.tableService.selectedPage()&&this.tableService.changePage(e.currentPage)}getTweakSettingsUrl(){return`${this._securityToken}/scripts2/tweaksettings?find=web_log_retention`}refresh(){this._facade.refresh()}get noResultsReason(){return this._facade.noResultsReason()}static#t=this.ɵfac=function(s){return new(s||n)};static#e=this.ɵcmp=t.VBU({type:n,selectors:[["cp-web-log-retention-root"]],viewQuery:function(s,a){if(1&s&&(t.GBs($,7),t.GBs(O,7),t.GBs(z,7)),2&s){let o;t.mGM(o=t.lsd())&&(a.retentionCellTemplate=o.first),t.mGM(o=t.lsd())&&(a.actionsCellTemplate=o.first),t.mGM(o=t.lsd())&&(a.expandTemplate=o.first)}},decls:18,vars:19,consts:[["retentionCell",""],["actionsCell",""],["expandTemplate",""],["position","top-right"],[1,"list-container"],[1,"description",3,"innerHTML"],["id","accountSearch","search-component","","role","search",3,"valueChange","label","placeholder","debounce","autofocus"],["data-testid","accountsTable","table-component","",3,"sortChanged","dataColumns","dataList","isLoading","hasExpandContent","expandContentTemplate"],["empty-table-message",""],["empty-search-results-message",""],["id","tablePagination","paginator-component","",3,"paginatorChange","currentPage","currentPageSize","pageSizeOptions","paginationDisabled","showPageSize","totalItems"],[3,"retention"],[3,"user"],[1,"expanded-row-content"]],template:function(s,a){if(1&s){const o=t.RV6();t.nrm(0,"cp-alert-list",3),t.j41(1,"div",4),t.DNE(2,L,1,1,"ng-template",null,0,t.C5r)(4,Q,1,1,"ng-template",null,1,t.C5r)(6,N,9,4,"ng-template",null,2,t.C5r),t.j41(8,"section"),t.nrm(9,"p",5),t.k0s(),t.j41(10,"cp-table-layout")(11,"cp-search",6),t.bIt("valueChange",(function(l){return t.eBV(o),t.Njj(a.applyFilter(l))})),t.k0s(),t.j41(12,"cp-table",7),t.bIt("sortChanged",(function(l){return t.eBV(o),t.Njj(a.onSortChanged(l))})),t.j41(13,"span",8),t.DNE(14,X,1,1),t.k0s(),t.j41(15,"span",9),t.DNE(16,U,1,1),t.k0s()(),t.j41(17,"cp-paginator",10),t.bIt("paginatorChange",(function(l){return t.eBV(o),t.Njj(a.onPaginatorChange(l))})),t.k0s()()()}if(2&s){const o=t.sdS(7);t.R7$(8),t.BMQ("title",a.descriptionTitle()),t.R7$(),t.Y8G("innerHTML",a.descriptionText(),t.npT),t.R7$(2),t.Y8G("label",a.locale.maketext("Search"))("placeholder",a.locale.maketext("Filter by User or Domain"))("debounce",300)("autofocus",!0),t.R7$(),t.Y8G("dataColumns",a.accountTableColumns)("dataList",a.paginatedAccounts())("isLoading",a.loading())("hasExpandContent",!0)("expandContentTemplate",o),t.R7$(2),t.vxM(a.loading()?-1:14),t.R7$(2),t.vxM(a.loading()?-1:16),t.R7$(),t.Y8G("currentPage",a.tableService.selectedPage())("currentPageSize",a.tableService.pageSize())("pageSizeOptions",a.tableService.pageSizes)("paginationDisabled",a.loading())("showPageSize",!0)("totalItems",a.totalItems())}},dependencies:[p.Ab,r.h5,p.Sy,r.Or,r.kj,G,V],styles:["[_nghost-%COMP%] .empty-table-svg{display:none}[_nghost-%COMP%] cp-search input:focus{border-color:#86b7fe;outline:0;box-shadow:0 0 0 .25rem #0d6efd40}[_nghost-%COMP%] cp-table-layout div:first-of-type>div:first-of-type{padding:0}[_nghost-%COMP%] cp-table table thead th{font-weight:700}[_nghost-%COMP%] .table>thead>tr>th{border-top:none!important}@media (min-width: 576px){[_nghost-%COMP%] .table-expandable thead tr th:first-child{display:none}[_nghost-%COMP%] .table-expandable td.table-cell-expand{display:none}[_nghost-%COMP%] .table-expandable tr.expand-content{display:none!important}}"]})}return n})();var H=i(8658);let J=(()=>{class n{static#t=this.ɵfac=function(s){return new(s||n)};static#e=this.ɵmod=t.$C({type:n,bootstrap:[Y]});static#n=this.ɵinj=t.G2t({providers:[{provide:_.kB,useValue:window.PAGE?.base??"/"},p.uE,A],imports:[p.sb,H.B,F,x.wb,g.Bb,_.MD,E.q1,r.IP,p.tq,r.tm,r.bG,P.fg]})}return n})();g.sG().bootstrapModule(J,{ngZoneEventCoalescing:!0}).catch((n=>console.error(n)))}},d=>{d.O(0,[262,128,996,538],(()=>d(d.s=7276))),d.O()}]);
Back to Directory
File Manager