1import{u as C}from"./CwC7nI8P.js";import{u as g}from"./B6QNAOp5.js";import{_ as S,a as F}from"./C6T2KIVj.js";import{c as M,_ as N,a as W}from"./D_-igjt9.js";import{r as u,t as j,o as I,c as z,w as d,a as o,f as w,g as G,_ as B,W as H,p as J,d as K,b as R,F as O,i as Q,h as T}from"./RMfq9duL.js";import{_ as X}from"./C_avYXow.js";import{_ as Y}from"./DXbPTSmL.js";import{_ as Z}from"./D06AUDt-.js";import{_ as ee}from"./DQVo-qnh.js";import{_ as te}from"./BZ1fT2Bq.js";import{_ as oe}from"./DAPq6DuQ.js";import"./DdEMei-N.js";import"./BawCpwxd.js";const ne={__name:"RedirectsEditUpdateDialog",setup(E,{expose:A}){const a=u(!1),v=u(null),i=u({}),e=u({}),s=u(!1),_=u(null);j(async()=>{const{data:n}=await C("getAllRedirects",()=>g().getAllRedirects());_.value=n});const b=n=>{try{if(n.includes(" "))throw new Error;return new URL(n),!0}catch{return!1}},x=n=>{a.value=!0,i.value={source:"",destination:"",isActive:!0,...n},e.value={...i.value}},$=()=>{a.value=!1},f=async()=>{if(await v.value.validate()){if(s.value=!0,e.value._id){try{await g().updateRedirect({id:e.value._id,data:{source:e.value.source,destination:e.value.destination,isActive:e.value.isActive}})}catch{s.value=!1}i.value.source=e.value.source,i.value.destination=e.value.destination,i.value.isActive=e.value.isActive}else try{await g().createRedirect({data:{source:e.value.source,destination:e.value.destination,isActive:e.value.isActive}})}catch{s.value=!1}s.value=!1,$()}await C("getAllRedirects",()=>g().getAllRedirects())};return A({openDialog:x}),(n,l)=>{const m=S,D=M,y=N,r=B,p=X,k=Y,q=W,V=F,U=Z;return I(),z(V,{modelValue:a.value,"onUpdate:modelValue":l[3]||(l[3]=t=>a.value=t),persistent:""},{default:d(()=>[o(q,{class:"tw-w-9/12"},{default:d(()=>[o(k,{ref_key:"form",ref:v,onSubmit:f},{default:d(()=>[o(y,null,{default:d(()=>[o(m,{outlined:"",modelValue:e.value.source,"onUpdate:modelValue":l[0]||(l[0]=t=>e.value.source=t),modelModifiers:{trim:!0},label:"Source Link",rules:[t=>!!t||"Required",t=>b(t)||"Invalid URL",t=>_.value.value?!_.value.value.find(h=>{const c=h.source.split("?")[0];return c!==i.value.source.split("?")[0]&&t.split("?")[0]===c})||"Source link is already present":!0]},null,8,["modelValue","rules"]),o(m,{outlined:"",modelValue:e.value.destination,"onUpdate:modelValue":l[1]||(l[1]=t=>e.value.destination=t),label:"Destination Link",rules:[t=>!!t||"Required",t=>b(t)||"Invalid URL"]},null,8,["modelValue","rules"]),w("div",null,[o(D,{modelValue:e.value.isActive,"onUpdate:modelValue":l[2]||(l[2]=t=>e.value.isActive=t),"left-label":"",label:"Is Active"},null,8,["modelValue"])])]),_:1}),o(p,{align:"right"},{default:d(()=>[G(o(r,{flat:"",label:"Cancel",color:"primary"},null,512),[[U]]),o(r,{type:"submit",label:"Save",color:"blue-10",loading:s.value},null,8,["loading"])]),_:1})]),_:1},512)]),_:1})]),_:1},8,["modelValue"])}}},le={class:"q-pa-md mt-6"},ae={class:"flex"},ie={class:"my-table-details"},we={__name:"index",async setup(E,{expose:A}){let a,v;const i=u(null),e=u(null),s=u(""),_=g(),{data:b,pending:x,error:$,refresh:f}=([a,v]=H(()=>C("getAllRedirects",()=>_.getAllRedirects())),a=await a,v(),a),n=[{name:"_id",label:"ID",align:"center",field:"_id",sortable:!0},{name:"source",label:"Source Link",align:"center",field:"source",sortable:!0},{name:"destination",label:"Destination Link",align:"center",field:"destination",sortable:!0},{name:"isActive",label:"Is Active",align:"center",field:"isActive",sortable:!0},{name:"actions",align:"center",label:"Actions"}],l=J(()=>b.value||[]),m=r=>{i.value.openDialog(r,f)},D=async r=>{await _.deleteRedirect(r),await f()},y=async r=>{e.value.openDialog(r,D)};return A({openDialog:m}),(r,p)=>{const k=ne,q=ee,V=T,U=S,t=B,L=oe,h=te;return I(),K(O,null,[o(k,{"onPage:actionDone":R(f),ref_key:"editUpdateDialogRef",ref:i},null,8,["onPage:actionDone"]),o(q,{ref_key:"deleteDialogRef",ref:e},null,512),w("div",le,[o(h,{key:"_id",title:"Redirects",separator:"cell",loading:R(x),rows:R(l),columns:n,"row-key":"name"},{"top-right":d(()=>[w("div",ae,[o(U,{outlined:"",borderless:"",dense:"",debounce:"300",modelValue:R(s),"onUpdate:modelValue":p[0]||(p[0]=c=>Q(s)?s.value=c:null),placeholder:"Search"},{append:d(()=>[o(V,{name:"search"})]),_:1},8,["modelValue"]),o(t,{class:"q-ml-md",label:"Create Redirect",color:"blue-10",onClick:p[1]||(p[1]=c=>m(null))})])]),"body-cell-actions":d(c=>[o(L,{props:c},{default:d(()=>[w("div",ie,[o(t,{onClick:P=>m(c.row),flat:"",icon:"edit",color:"blue-10"},null,8,["onClick"]),o(t,{onClick:P=>y(c.row._id),icon:"delete",flat:"",label:"Delete",color:"negative"},null,8,["onClick"])])]),_:2},1032,["props"])]),_:1},8,["loading","rows"])])],64)}}};export{we as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.