D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
psa
/
admin
/
cp
/
public
/
javascript
/
components
/
pages
/
Filename :
ActionLogPage.js
back
Copy
(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/ActionLogPage"],{2412:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>v,getTimestampFromDateSelector:()=>h});var a=t(286),i=t(596),o=t(89),s=t(285);const r=o.Locale.getSection("smb.components.months"),l=(e,n)=>new Date(e,n,0).getDate(),d=(e,n,t)=>Math.min(e,l(t,n)),c=e=>/^\d+$/.test(e),u=new Date,m=u.getDate(),g=u.getMonth()+1,p=u.getFullYear(),f=({years:e,...n})=>(0,s.jsx)(a.FormField,{...n,children:({getId:n,getValue:t,getName:i,setValue:o,isDisabled:u})=>{const{day:f,month:v,year:h}=t(),y=()=>{if(!f||!v||!h){const e=v||g,n=h||p;o({day:d(f||m,e,n),month:e,year:n})}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a.Input,{id:`${n()}Day`,name:`${i()}[day]`,value:f,onChange:({target:{value:e}})=>{""===e?o({day:e,month:v,year:h}):c(e)&&e>0&&e<=l(h,v)&&o({day:Number(e),month:v,year:h})},onBlur:y,disabled:u(),size:"sm"})," - ",(0,s.jsxs)(a.Select,{id:`${n()}Month`,name:`${i()}[month]`,value:v,onChange:e=>o({day:d(f,e,h),month:e,year:h}),disabled:u(),size:"sm",children:[(0,s.jsx)(a.SelectOption,{value:1,children:r.lmsg("1")}),(0,s.jsx)(a.SelectOption,{value:2,children:r.lmsg("2")}),(0,s.jsx)(a.SelectOption,{value:3,children:r.lmsg("3")}),(0,s.jsx)(a.SelectOption,{value:4,children:r.lmsg("4")}),(0,s.jsx)(a.SelectOption,{value:5,children:r.lmsg("5")}),(0,s.jsx)(a.SelectOption,{value:6,children:r.lmsg("6")}),(0,s.jsx)(a.SelectOption,{value:7,children:r.lmsg("7")}),(0,s.jsx)(a.SelectOption,{value:8,children:r.lmsg("8")}),(0,s.jsx)(a.SelectOption,{value:9,children:r.lmsg("9")}),(0,s.jsx)(a.SelectOption,{value:10,children:r.lmsg("10")}),(0,s.jsx)(a.SelectOption,{value:11,children:r.lmsg("11")}),(0,s.jsx)(a.SelectOption,{value:12,children:r.lmsg("12")})]})," - ",e?(0,s.jsx)(a.Select,{id:`${n()}Year`,name:`${i()}[year]`,value:h,onChange:e=>o({day:d(f,v,e),month:v,year:e}),disabled:u(),size:"sm",children:e.map((e=>(0,s.jsx)(a.SelectOption,{value:e,children:String(e)},e)))}):(0,s.jsx)(a.Input,{id:`${n()}Year`,name:`${i()}[year]`,value:h,onChange:({target:{value:e}})=>{""===e?o({day:f,month:v,year:e}):c(e)&&e>0&&e<=2100&&o({day:d(f,v,e),month:v,year:Number(e)})},onBlur:y,disabled:u(),size:"sm"})]})}});f.propTypes={years:i.PropTypes.arrayOf(i.PropTypes.number)};const v=f,h=({day:e,month:n,year:t})=>{const a=new Date;return a.setDate(e),a.setMonth(n-1),a.setFullYear(t),a.getTime()}},2564:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>d});var a=t(285),i=t(596),o=t.n(i),s=t(286);const r=t(89).Locale.getTranslate("components.forms.action-log"),l=({onConfirm:e,disabled:n=!1,state:t})=>{const[i,o]=(0,a.useState)(!1),l=()=>o(!1);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.Button,{"data-id":"actionLogClearButton",state:t,onClick:()=>o(!0),disabled:n,children:(0,a.jsx)(r,{content:"clearLog"})})," ",(0,a.jsx)(s.Dialog,{isOpen:i,size:"xs",cancelButton:!1,children:(0,a.jsxs)(s.Media,{image:(0,a.jsx)(s.Icon,{name:"cross-mark-circle-filled",intent:"danger",size:"48"}),children:[(0,a.jsx)(s.MediaSection,{children:(0,a.jsx)(r,{content:"confirmCleanLog"})}),(0,a.jsxs)(s.MediaSection,{children:[(0,a.jsx)(s.Button,{"data-id":"actionLogClearYesButton",size:"lg",intent:"danger",onClick:()=>{e(),l()},children:(0,a.jsx)(r,{content:"yes"})})," ",(0,a.jsx)(s.Button,{size:"lg",onClick:l,children:(0,a.jsx)(r,{content:"no"})})]})]})})]})};l.propTypes={onConfirm:o().func.isRequired,disabled:o().bool,state:o().string};const d=l},2562:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>p});var a=t(596),i=t.n(a),o=t(286),s=t(89),r=t(646),l=t(2412),d=t(2563),c=t(2564),u=t(285);const m=s.Locale.getTranslate("components.forms.action-log"),g=({objects:e,isAdminAlias:n,years:t,onClearLog:a,onDownloadLog:i,errors:s,state:g,...p})=>{const f=!(!Object.keys(s).length&&!g);return(0,u.jsxs)(o.Form,{errors:s,state:g,applyButton:!1,cancelButton:!n&&{id:"btn-cancel",component:r.default,to:"/admin/server/tools"},submitButton:!n&&{id:"btn-submit",disabled:f},...p,children:[(0,u.jsxs)(o.Section,{title:(0,u.jsx)(m,{content:"logFiles"}),children:[(0,u.jsx)(l.default,{name:"fromDate",label:(0,u.jsx)(m,{content:"fromDate"}),years:t}),(0,u.jsx)(l.default,{name:"toDate",label:(0,u.jsx)(m,{content:"toDate"}),years:t}),(0,u.jsxs)(o.SectionItem,{title:"",children:[n?null:(0,u.jsx)(c.default,{onConfirm:a,disabled:f,state:"clear"===g?"loading":void 0}),(0,u.jsx)(o.Button,{"data-id":"actionLogDownloadButton",onClick:i,disabled:f,children:(0,u.jsx)(m,{content:"downloadLog"})})]})]}),n?null:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(o.Section,{"data-id":"actionLogObjects",title:(0,u.jsx)(m,{content:"loggedActions"}),children:e.map((({name:e,displayName:n,actions:t,mixed:a})=>(0,u.jsx)(o.SectionItem,{title:n,children:(0,u.jsx)(o.FormFieldCheckbox,{name:`objects[${e}]`,label:[t,a?(0,u.jsxs)("em",{children:[" ",(0,u.jsx)(m,{content:"mixed"})]}):null]})},e)))}),(0,u.jsx)(o.FormFieldRadioButtons,{label:(0,u.jsx)(m,{content:"storeLogsInDb"}),name:"rotate[type]",options:[{value:"by_period",label:(0,u.jsx)(m,{content:"period"}),indentFields:[(0,u.jsx)(d.default,{name:"rotate[period]",label:null},"rotate[period]")]},{value:"by_number",label:(0,u.jsx)(m,{content:"storeNumber"}),indentFields:[(0,u.jsx)(o.FormField,{name:"rotate[records]",label:null,children:({getValue:e,setValue:n,isDisabled:t})=>(0,u.jsx)(o.InputNumber,{value:e(),onChange:n,min:1,max:999999,disabled:t()})},"rotate[records]")]},{value:"forever",label:(0,u.jsx)(m,{content:"dontRemoveRecs"})}]})]})]})};g.propTypes={objects:i().arrayOf(i().shape({actions:i().string,displayName:i().string,mixed:i().bool,name:i().string})).isRequired,isAdminAlias:i().bool.isRequired,years:i().arrayOf(i().number).isRequired,onClearLog:i().func.isRequired,onDownloadLog:i().func.isRequired,errors:i().object.isRequired,state:i().string};const p=g},2561:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>S});var a=t(285),i=t(580),o=t(586),s=t(628),r=t(286),l=t(89),d=t(536),c=t(2562),u=t(2565),m=t.n(u),g=t(2566),p=t.n(g),f=t(1282),v=t.n(f);const h=l.Locale.getSection("components.forms.action-log"),y=l.Locale.getTranslate("components.forms.action-log"),b=e=>Object.fromEntries(e.map((({name:e,enabled:n})=>[e,n]))),j=e=>Object.keys(e).filter((n=>e[n])),x={fromDate:{errorDate:h.lmsg("invalidDatePeriod")},toDate:{errorDate:h.lmsg("invalidDatePeriod")}},S=()=>{const e=(0,i.useNavigate)(),{data:{actionLog:{objects:n,rotate:t,minDate:u},viewer:{isAdminAlias:g}}}=(0,o.useQuery)(v()),[f]=(0,s.useMutation)(m(),{refetchQueries:[{query:v()}]}),[h]=(0,s.useMutation)(p()),[S,k]=(0,a.useState)({}),[D,L]=(0,a.useState)(),[w,N]=(0,a.useState)((()=>{const{period:{unit:e,value:a},records:i,type:o}=t,s=new Date,r=s.getFullYear(),l=s.getMonth()+1,d=s.getDate();return{fromDate:{day:1,month:l,year:u.year},toDate:{day:d,month:l,year:r},rotate:{period:{unit:e,value:a},records:i,type:o},objects:b(n)}})),C=(0,a.useMemo)((()=>{return e=u.year,n=(new Date).getFullYear(),[...Array(n-e+1).keys()].map(((n,t)=>e+t));var e,n}),[u]),F=(0,a.useMemo)((()=>n.map((e=>{const{displayName:n,name:t,actions:a}=e;return{actions:[...new Set(a.map((({displayName:e})=>e)))].join("/"),displayName:n,mixed:new Set(a.map((({enabled:e})=>e))).size>1,name:t}}))),[n]),O=async(n,t,i)=>{L(t);try{await n(),(0,d.addToast)({intent:"success",message:(0,a.jsx)(y,{content:i})}),"submit"===t&&e("/admin/server/tools")}catch({graphQLErrors:e}){e.forEach((({message:e})=>(0,d.addToast)({intent:"danger",message:e})))}finally{L(null)}};return(0,a.jsx)(c.default,{values:w,errors:S,state:D,objects:F,isAdminAlias:g,years:C,onClearLog:()=>O((async()=>{const{fromDate:e,toDate:n}=w;await h({variables:{input:{fromDate:e,toDate:n}}})}),"clear","clearDone"),onDownloadLog:()=>{const{fromDate:e,toDate:n}=w;(0,l.redirectPost)("/cp/download-action-log",{fromDate:e,toDate:n})},onSubmit:()=>O((async()=>{const{objects:e,rotate:n}=w;await f({variables:{input:{objects:j(e),rotate:n}}})}),"submit","submitDone"),onFieldChange:(e,n)=>{const t=(0,r.setIn)(w,e,n);k((e=>{const{fromDate:{year:n,month:t,day:a},toDate:{year:i,month:o,day:s}}=e;if(a&&s)return new Date(n,t-1,a)<=new Date(i,o-1,s);return!0})(t)?{}:x),N(t)}})}},2563:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>r});var a=t(286),i=t(89),o=t(285);const s=i.Locale.getSection("components.forms.action-log"),r=({...e})=>(0,o.jsx)(a.FormField,{...e,children:({getId:e,getName:n,getValue:t,setValue:i,isDisabled:r})=>{const{value:l,unit:d}=t();return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(a.InputNumber,{id:`${e()}Value`,name:`${n()}[value]`,value:l,onChange:e=>i({value:e,unit:d}),disabled:r(),min:1,max:999999})," ",(0,o.jsxs)(a.Select,{id:`${e()}Unit`,name:`${n()}[unit]`,value:d,disabled:r(),onChange:e=>i({value:l,unit:e}),size:"sm",children:[(0,o.jsx)(a.SelectOption,{value:"day",children:s.lmsg("periodDay")}),(0,o.jsx)(a.SelectOption,{value:"week",children:s.lmsg("periodWeek")}),(0,o.jsx)(a.SelectOption,{value:"month",children:s.lmsg("periodMonth")})]})]})}})},2560:(e,n,t)=>{"use strict";t.r(n),t.d(n,{default:()=>a.default});var a=t(2561)},2566:e=>{var n={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ClearActionLog"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ClearActionLogInput"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"clearActionLog"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"result"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:115}};n.loc.source={body:"mutation ClearActionLog($input: ClearActionLogInput!) {\n clearActionLog(input: $input) {\n result\n }\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function t(e,n){if("FragmentSpread"===e.kind)n.add(e.name.value);else if("VariableDefinition"===e.kind){var a=e.type;"NamedType"===a.kind&&n.add(a.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){t(e,n)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){t(e,n)})),e.definitions&&e.definitions.forEach((function(e){t(e,n)}))}var a={};function i(e,n){for(var t=0;t<e.definitions.length;t++){var a=e.definitions[t];if(a.name&&a.name.value==n)return a}}n.definitions.forEach((function(e){if(e.name){var n=new Set;t(e,n),a[e.name.value]=n}})),e.exports=n,e.exports.ClearActionLog=function(e,n){var t={kind:e.kind,definitions:[i(e,n)]};e.hasOwnProperty("loc")&&(t.loc=e.loc);var o=a[n]||new Set,s=new Set,r=new Set;for(o.forEach((function(e){r.add(e)}));r.size>0;){var l=r;r=new Set,l.forEach((function(e){s.has(e)||(s.add(e),(a[e]||new Set).forEach((function(e){r.add(e)})))}))}return s.forEach((function(n){var a=i(e,n);a&&t.definitions.push(a)})),t}(n,"ClearActionLog")},2565:e=>{var n={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"UpdateActionLogSettings"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UpdateActionLogSettingsInput"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"updateActionLogSettings"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"result"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:142}};n.loc.source={body:"mutation UpdateActionLogSettings($input: UpdateActionLogSettingsInput!) {\n updateActionLogSettings(input: $input) {\n result\n }\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function t(e,n){if("FragmentSpread"===e.kind)n.add(e.name.value);else if("VariableDefinition"===e.kind){var a=e.type;"NamedType"===a.kind&&n.add(a.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){t(e,n)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){t(e,n)})),e.definitions&&e.definitions.forEach((function(e){t(e,n)}))}var a={};function i(e,n){for(var t=0;t<e.definitions.length;t++){var a=e.definitions[t];if(a.name&&a.name.value==n)return a}}n.definitions.forEach((function(e){if(e.name){var n=new Set;t(e,n),a[e.name.value]=n}})),e.exports=n,e.exports.UpdateActionLogSettings=function(e,n){var t={kind:e.kind,definitions:[i(e,n)]};e.hasOwnProperty("loc")&&(t.loc=e.loc);var o=a[n]||new Set,s=new Set,r=new Set;for(o.forEach((function(e){r.add(e)}));r.size>0;){var l=r;r=new Set,l.forEach((function(e){s.has(e)||(s.add(e),(a[e]||new Set).forEach((function(e){r.add(e)})))}))}return s.forEach((function(n){var a=i(e,n);a&&t.definitions.push(a)})),t}(n,"UpdateActionLogSettings")}}]); //# sourceMappingURL=ActionLogPage.js.map?a10473031bf286635da3