p3x-redis-ui-material
Version:
💿 P3X Redis UI triple frontend — Angular + React/MUI + Vue/Vuetify with 54 languages, 7 themes, Socket.IO, desktop notifications, and full feature parity
1 lines • 13.7 kB
JavaScript
import{A as e,B as t,C as n,D as r,E as i,I as a,Jt as ee,M as te,Nt as o,T as s,Tt as c,Y as l,Zt as u,_t as d,at as f,k as p,lt as m,m as ne,ot as re,rt as h,t as ie,u as g,w as _,y as v,z as y}from"./i18n.store-Bkc9i0ZB.js";import{lt as ae,o as b,t as x,x as S}from"./_plugin-vue_export-helper-BZ1AqotW.js";import{n as oe,t as se}from"./redis-state.store-6nwmGrRG.js";import{t as ce}from"./common.store-yJBdXfWc.js";import{t as le}from"./overlay.store-BBYRGnlo.js";import{i as C}from"./socket.service-CwqYs11N.js";import{d as w,h as ue}from"./index-BNz7Rlxf.js";import{a as de,d as T,f as fe,n as pe,o as me,p as E,s as he}from"./key-type-base-COna9PL5.js";import{t as ge}from"./redis-version-D5h1AGvN.js";import{n as _e,t as ve}from"./JsonEditorDialog-qO_9GIFK.js";import{t as ye}from"./JsonViewDialog-DFmNO6gL.js";import{t as be}from"./HexMonitor-Bg_4eWTr.js";a(),m(),o(),g();var xe={key:0,class:`p3xr-key-type-actions`},Se={key:1,class:`p3xr-key-type-actions`},Ce={class:`p3xr-key-type-content`},we={key:0,class:`p3xr-key-type-editor`},Te={key:0,class:`p3xr-key-type-buffer-info`},Ee={key:0,style:{opacity:`0.5`,"font-style":`italic`}},De={key:2,class:`p3xr-key-string-display`},Oe={key:0,style:{opacity:`0.5`}},D=x(te({__name:`KeyString`,props:{response:{},value:{},valueBuffer:{},keyName:{},valueFormat:{}},emits:[`refresh`],setup(a,{emit:te}){let o=a,m=te,g=ie(),x=se(),D=oe(),O=ce(),k=le(),{width:ke}=ae(),A=n(()=>g.strings),j=n(()=>ke.value>=960),M=n(()=>x.connection?.readonly===!0),N=d(!1),P=d(!1),F=d(!1),I=d(``),L=d(null),R=d(!1),z=d(!1),B=d(!1),V=d(``),H=d(``),U=null,W=d(),Ae=n(()=>E(me(typeof o.value==`string`?o.value:``,o.valueFormat))),je=n(()=>E(typeof o.value==`string`?o.value:``)),Me=n(()=>he(o.value)),Ne=n(()=>ge(x.info?.server?.redis_version).isAtLeast(8,4));function G(){let e=W.value;e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)}h(N,e=>{e&&t(()=>t(G))}),h(I,()=>t(G));function K(){let e=o.value;typeof e==`string`&&e.length>=D.maxValueAsBuffer?(P.value=!0,L.value=structuredClone(o.valueBuffer),I.value=String(o.valueBuffer??``)):(P.value=!1,L.value=structuredClone(e),I.value=String(e??``)),N.value=!0,t(G)}function q(){N.value=!1,P.value=!1,I.value=``}async function Pe(e,t){return!D.showDiffBeforeSave||e===t?!0:(V.value=e,H.value=t,B.value=!0,new Promise(e=>{U=e}))}async function J(){try{if(F.value&&JSON.parse(I.value),L.value!=null&&!await Pe(String(L.value),I.value))return;k.show({message:T(A.value?.intention?.save)}),await C({action:`key/set`,payload:{type:o.response?.type,key:o.keyName,value:I.value}});let e=L.value;N.value=!1,P.value=!1,m(`refresh`),k.hide(),D.undoEnabled&&e!==void 0&&String(e)!==I.value&&await O.toastWithUndo(T(A.value?.status?.saved))&&(k.show({message:`Undo...`}),await C({action:`key/set`,payload:{type:o.response?.type,key:o.keyName,value:String(e)}}),m(`refresh`),k.hide(),O.toast(T(A.value?.status?.reverted)))}catch(e){O.generalHandleError(e),k.hide()}}function Y(){let e=document.createElement(`input`);e.type=`file`,e.onchange=async()=>{let n=e.files?.[0];if(!n)return;let r=new FileReader;r.onerror=e=>O.generalHandleError(e),r.onload=async e=>{let n=e.target.result;try{if(N.value){await O.confirm({message:T(A.value?.confirm?.uploadBuffer)}),I.value=new TextDecoder().decode(n),O.toast(T(A.value?.confirm?.uploadBufferDone)),t(G);return}await O.confirm({message:T(A.value?.confirm?.uploadBuffer)}),k.show(),await C({action:`key/set`,payload:{type:o.response?.type,value:n,key:o.keyName}}),O.toast(T(A.value?.confirm?.uploadBufferDoneAndSave)),m(`refresh`)}catch(e){e!==void 0&&O.generalHandleError(e)}finally{k.hide()}},r.readAsArrayBuffer(n)},e.click()}async function X(){try{let e=JSON.stringify(JSON.parse(o.value),null,D.jsonFormat||2);k.show({message:T(A.value?.intention?.save)}),await C({action:`key/set`,payload:{type:o.response?.type,key:o.keyName,value:e}}),m(`refresh`)}catch{O.toast(T(A.value?.label?.jsonViewNotParsable))}finally{k.hide()}}async function Z(){try{let e=await C({action:`key/string-digest`,payload:{key:o.keyName}});O.toast(e.digest)}catch(e){O.generalHandleError(e)}}function Q(){pe(String(o.value??``))}function $(){de(o.valueBuffer||fe(String(o.value??``)),o.keyName)}function Fe(){return o.valueBuffer?.byteLength===void 0?``:`(`+D.prettyBytes(o.valueBuffer.byteLength)+`)`}async function Ie(e){if(z.value=!1,!e?.obj)return;let t=String(o.value??``);k.show({message:T(A.value?.intention?.save)});try{await C({action:`key/set`,payload:{type:o.response?.type,key:o.keyName,value:e.obj}}),m(`refresh`),k.hide(),D.undoEnabled&&t!==e.obj&&await O.toastWithUndo(T(A.value?.status?.saved))&&(k.show({message:`Undo...`}),await C({action:`key/set`,payload:{type:o.response?.type,key:o.keyName,value:t}}),m(`refresh`),k.hide(),O.toast(T(A.value?.status?.reverted)))}catch(e){O.generalHandleError(e),k.hide()}}return(t,n)=>(l(),r(`div`,null,[N.value?(l(),r(`div`,Se,[M.value?i(``,!0):(l(),s(ue,{key:0,modelValue:F.value,"onUpdate:modelValue":n[16]||=e=>F.value=e,label:c(T)(A.value?.label?.validateJson),color:`secondary`,density:`compact`,"hide-details":``,style:{"margin-right":`8px`}},null,8,[`modelValue`,`label`])),j.value?(l(),s(b,{key:1,variant:`flat`,color:`error`,onClick:n[17]||=e=>q(),style:{gap:`3px`}},{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[46]||=[p(`mdi-close-circle`,-1)]]),_:1}),_(`span`,null,u(c(T)(A.value?.intention?.cancel)),1)]),_:1})):(l(),s(w,{key:2,text:c(T)(A.value?.intention?.cancel),location:`top`},{activator:f(({props:t})=>[e(b,y(t,{variant:`flat`,color:`error`,onClick:n[18]||=e=>q(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[47]||=[p(`mdi-close-circle`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`])),M.value?i(``,!0):(l(),r(v,{key:3},[j.value?(l(),s(b,{key:0,variant:`flat`,color:`primary`,onClick:n[19]||=e=>Y(),style:{gap:`3px`}},{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[48]||=[p(`mdi-upload`,-1)]]),_:1}),_(`span`,null,u(c(T)(A.value?.intention?.setBuffer)),1)]),_:1})):(l(),s(w,{key:1,text:c(T)(A.value?.intention?.setBuffer),location:`top`},{activator:f(({props:t})=>[e(b,y(t,{variant:`flat`,color:`primary`,onClick:n[20]||=e=>Y(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[49]||=[p(`mdi-upload`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`])),j.value?(l(),s(b,{key:2,variant:`flat`,color:`primary`,onClick:n[21]||=e=>J(),style:{gap:`3px`}},{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[50]||=[p(`mdi-check`,-1)]]),_:1}),_(`span`,null,u(c(T)(A.value?.intention?.save)),1)]),_:1})):(l(),s(w,{key:3,text:c(T)(A.value?.intention?.save),location:`top`},{activator:f(({props:t})=>[e(b,y(t,{variant:`flat`,color:`primary`,onClick:n[22]||=e=>J(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[51]||=[p(`mdi-check`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`]))],64))])):(l(),r(`div`,xe,[M.value?i(``,!0):(l(),r(v,{key:0},[j.value?(l(),s(b,{key:0,variant:`flat`,color:`primary`,onClick:n[0]||=e=>Y(),style:{gap:`3px`}},{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[29]||=[p(`mdi-upload`,-1)]]),_:1}),_(`span`,null,u(c(T)(A.value?.intention?.setBuffer)),1)]),_:1})):(l(),s(w,{key:1,text:c(T)(A.value?.intention?.setBuffer),location:`top`},{activator:f(({props:t})=>[e(b,y(t,{variant:`flat`,color:`primary`,onClick:n[1]||=e=>Y(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[30]||=[p(`mdi-upload`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`]))],64)),j.value?(l(),s(b,{key:1,variant:`flat`,color:`secondary`,onClick:n[2]||=e=>$(),style:{gap:`3px`}},{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[31]||=[p(`mdi-download`,-1)]]),_:1}),_(`span`,null,u(c(T)(A.value?.intention?.downloadBuffer)),1)]),_:1})):(l(),s(w,{key:2,text:c(T)(A.value?.intention?.downloadBuffer),location:`top`},{activator:f(({props:t})=>[e(b,y(t,{variant:`flat`,color:`secondary`,onClick:n[3]||=e=>$(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[32]||=[p(`mdi-download`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`])),j.value?(l(),s(b,{key:3,variant:`flat`,color:`secondary`,onClick:n[4]||=e=>R.value=!0,style:{gap:`3px`}},{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[33]||=[p(`mdi-file-tree`,-1)]]),_:1}),_(`span`,null,u(c(T)(A.value?.intention?.jsonViewShow)),1)]),_:1})):(l(),s(w,{key:4,text:c(T)(A.value?.intention?.jsonViewShow),location:`top`},{activator:f(({props:t})=>[e(b,y(t,{variant:`flat`,color:`secondary`,onClick:n[5]||=e=>R.value=!0,style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[34]||=[p(`mdi-file-tree`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`])),j.value?(l(),s(b,{key:5,variant:`flat`,color:`secondary`,onClick:n[6]||=e=>Q(),style:{gap:`3px`}},{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[35]||=[p(`mdi-content-copy`,-1)]]),_:1}),_(`span`,null,u(c(T)(A.value?.intention?.copy)),1)]),_:1})):(l(),s(w,{key:6,text:c(T)(A.value?.intention?.copy),location:`top`},{activator:f(({props:t})=>[e(b,y(t,{variant:`flat`,color:`secondary`,onClick:n[7]||=e=>Q(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[36]||=[p(`mdi-content-copy`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`])),M.value?i(``,!0):(l(),r(v,{key:7},[j.value?(l(),s(b,{key:0,variant:`flat`,color:`primary`,onClick:n[8]||=e=>X(),style:{gap:`3px`}},{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[37]||=[p(`mdi-format-line-spacing`,-1)]]),_:1}),_(`span`,null,u(c(T)(A.value?.intention?.formatJson)),1)]),_:1})):(l(),s(w,{key:1,text:c(T)(A.value?.intention?.formatJson),location:`top`},{activator:f(({props:t})=>[e(b,y(t,{variant:`flat`,color:`primary`,onClick:n[9]||=e=>X(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[38]||=[p(`mdi-format-line-spacing`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`]))],64)),j.value?(l(),s(b,{key:8,variant:`flat`,color:`primary`,onClick:n[10]||=e=>z.value=!0,style:{gap:`3px`}},{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[39]||=[p(`mdi-file-document-outline`,-1)]]),_:1}),_(`span`,null,u(c(T)(A.value?.intention?.jsonViewEditor)),1)]),_:1})):(l(),s(w,{key:9,text:c(T)(A.value?.intention?.jsonViewEditor),location:`top`},{activator:f(({props:t})=>[e(b,y(t,{variant:`flat`,color:`primary`,onClick:n[11]||=e=>z.value=!0,style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[40]||=[p(`mdi-file-document-outline`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`])),Ne.value?(l(),r(v,{key:10},[j.value?(l(),s(b,{key:0,variant:`flat`,color:`secondary`,onClick:n[12]||=e=>Z(),style:{gap:`3px`}},{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[41]||=[p(`mdi-pound`,-1)]]),_:1}),n[42]||=_(`span`,null,`Digest`,-1)]),_:1})):(l(),s(w,{key:1,text:`Digest`,location:`top`},{activator:f(({props:t})=>[e(b,y(t,{variant:`flat`,color:`secondary`,onClick:n[13]||=e=>Z(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[43]||=[p(`mdi-pound`,-1)]]),_:1})]),_:1},16)]),_:1}))],64)):i(``,!0),M.value?i(``,!0):(l(),r(v,{key:11},[j.value?(l(),s(b,{key:0,variant:`flat`,color:`primary`,onClick:n[14]||=e=>K(),style:{gap:`3px`}},{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[44]||=[p(`mdi-pencil`,-1)]]),_:1}),_(`span`,null,u(c(T)(A.value?.intention?.edit)),1)]),_:1})):(l(),s(w,{key:1,text:c(T)(A.value?.intention?.edit),location:`top`},{activator:f(({props:t})=>[e(b,y(t,{variant:`flat`,color:`primary`,onClick:n[15]||=e=>K(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:f(()=>[e(S,{size:`small`},{default:f(()=>[...n[45]||=[p(`mdi-pencil`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`]))],64))])),_(`div`,Ce,[N.value?(l(),r(`div`,we,[P.value||String(a.value)===`[object ArrayBuffer]`?(l(),r(`div`,Te,u(typeof A.value?.label?.isBuffer==`function`?A.value.label.isBuffer({maxValueAsBuffer:c(D).prettyBytes(c(D).maxValueAsBuffer)}):``)+` `+u(Fe()),1)):i(``,!0),re(_(`textarea`,{ref_key:`textareaRef`,ref:W,"onUpdate:modelValue":n[23]||=e=>I.value=e,class:`p3xr-key-string-textarea`,onInput:n[24]||=e=>G()},null,544),[[ne,I.value]])])):(l(),r(`div`,{key:1,class:`p3xr-key-type-display`,style:ee({cursor:M.value?`default`:`pointer`,overflow:a.valueFormat===`hex`?`visible`:`auto`}),onClick:n[25]||=e=>!M.value&&K()},[c(D).maxValueDisplay===-1?(l(),r(`div`,Ee,u(c(T)(A.value?.label?.hiddenUntilEdit)),1)):a.valueFormat===`hex`?(l(),s(be,{key:1,value:je.value},null,8,[`value`])):(l(),r(`span`,De,[p(u(Ae.value),1),Me.value?(l(),r(`span`,Oe,`...`)):i(``,!0)]))],4))]),e(ye,{open:R.value,value:String(a.value??``),onClose:n[26]||=e=>R.value=!1},null,8,[`open`,`value`]),e(ve,{open:z.value,value:String(a.value??``),onClose:Ie},null,8,[`open`,`value`]),e(_e,{open:B.value,"key-name":a.keyName,"old-value":V.value,"new-value":H.value,onConfirm:n[27]||=e=>{B.value=!1,c(U)?.(!0)},onCancel:n[28]||=e=>{B.value=!1,c(U)?.(!1)}},null,8,[`open`,`key-name`,`old-value`,`new-value`])]))}}),[[`__scopeId`,`data-v-7bdffae3`]]);export{D as default};