import{k as e,ay as a,aQ as s}from"../../../../../vendor-element-plus.js?ver=3.1.10";import{aQ as t,W as i,X as r,ab as n,Z as c,aa as l,a5 as d,a9 as o,Y as h,a8 as m,a6 as f,J as p,az as g}from"../../../../../vendor.js?ver=3.1.10";import{S as u}from"../../../../../SettingsHeader.js?ver=3.1.10";import{_ as v}from"../../../../../fc-bits-ui.js?ver=3.1.10";const b={class:"fcrm_settings fcrm_min_bg fcrm_view"},_={class:"fcrm_body"},y={class:"fcrm_max_w_800"},x={class:"fcrm_report_card"},$={class:"fcrm_report_card_header"},k={class:"fcrm_report_card_title_group"},w={class:"fcrm-db-health-actions"},H={class:"fcrm_report_card_body"},j={class:"fcrm-db-health-intro"},C={key:0,class:"fcrm-db-health-ok"},L={class:"fcrm-cron-jobs"},z={class:"fcrm-cron-job-info"},B={class:"fcrm-cron-job-name"},D={class:"fcrm-cron-job-meta"},I={class:"fcrm-cron-meta-item"},M={class:"fcrm-cron-meta-label"},S={class:"fcrm-cron-meta-value"},R={class:"fcrm-cron-meta-item"},T={class:"fcrm-cron-meta-label"},Z={class:"fcrm-cron-meta-value"};const q=v({name:"DatabaseHealth",components:{SettingsHeader:u},data:()=>({indexes:[],fetching:!1,repairing:!1,loaded:!1}),computed:{hasBroken(){return this.indexes.some(e=>"yes"!==e.status)}},methods:{fetchHealth(e=!0){this.fetching=!0,this.$get("setting/db-index-health",e?{fresh:1}:{}).then(e=>{this.indexes=e.indexes||[],this.loaded=!0}).catch(e=>{this.handleError(e)}).finally(()=>{this.fetching=!1})},repair(){this.repairing=!0,this.$post("setting/db-index-health/repair").then(e=>{this.$notify.success(e.message),this.indexes=e.indexes||this.indexes}).catch(e=>{this.handleError(e)}).finally(()=>{this.repairing=!1})}},mounted(){this.changeTitle(this.$t("Database Health")),this.fetchHealth(!0)}},[["render",function(u,v,q,E,Q,A){const F=t("SettingsHeader"),J=e,N=s,U=a;return i(),r("div",b,[n(F,{title:u.$t("Database Health")},null,8,["title"]),c("div",_,[c("div",y,[c("div",x,[c("div",$,[c("div",k,[c("h4",null,l(u.$t("Critical Database Indexes")),1)]),c("div",w,[n(J,{size:"small",loading:Q.fetching,onClick:v[0]||(v[0]=e=>A.fetchHealth(!0))},{default:d(()=>[o(l(u.$t("Re-check")),1)],void 0),_:1},8,["loading"]),A.hasBroken?(i(),h(J,{key:0,size:"small",type:"primary",loading:Q.repairing,onClick:A.repair},{default:d(()=>[o(l(u.$t("Repair Now")),1)],void 0),_:1},8,["loading","onClick"])):m("",!0)])]),f((i(),r("div",H,[c("p",j,l(u.$t("FluentCRM relies on these indexes for fast campaign sending, automation processing and duplicate protection. If a database upgrade was interrupted, one may be missing — repairing recreates it safely.")),1),Q.loaded&&!A.hasBroken?(i(),r("div",C,[v[1]||(v[1]=c("svg",{width:"20",height:"20",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[c("path",{d:"M8 14C4.6862 14 2 11.3138 2 8C2 4.6862 4.6862 2 8 2C11.3138 2 14 4.6862 14 8C14 11.3138 11.3138 14 8 14ZM7.4018 10.4L11.6438 6.1574L10.7954 5.309L7.4018 8.7032L5.7044 7.0058L4.856 7.8542L7.4018 10.4Z",fill:"var(--fc-success)"})],-1)),c("span",null,l(u.$t("All critical indexes are present and healthy.")),1)])):m("",!0),c("div",L,[(i(!0),r(p,null,g(Q.indexes,e=>(i(),r("div",{class:"fcrm-cron-job",key:e.name},[c("div",z,[c("p",B,l(u.$t(e.title)),1),c("div",D,[c("div",I,[c("p",M,l(u.$t("Table:")),1),c("p",S,l(e.table),1)]),c("div",R,[c("p",T,l(u.$t("Type:")),1),c("p",Z,l("unique"===e.type?u.$t("Unique key"):u.$t("Index")),1)])])]),n(N,{size:"small",type:"yes"===e.status?"success":"danger",effect:"light"},{default:d(()=>[o(l("yes"===e.status?u.$t("Healthy"):u.$t("Missing")),1)],void 0),_:2},1032,["type"])]))),128))])])),[[U,Q.fetching]])])])])])}],["__scopeId","data-v-e46b47fe"]]);export{q as default};
