UNPKG

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

2 lines (1 loc) • 11.4 kB
import{Rd as D,Tb as g,U as u,Y as l,fa as b,na as a,oa as i}from"./chunk-MHKTEXY5.js";import{a as m,b as y,h as S}from"./chunk-O7S4L63H.js";var C=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],T=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],P=["b","kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],K=["b","kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],M=(t,n,e)=>{let r=t;return typeof n=="string"||Array.isArray(n)?r=t.toLocaleString(n,e):(n===!0||e!==void 0)&&(r=t.toLocaleString(void 0,e)),r},N=t=>{if(typeof t=="number")return Math.log10(t);let n=t.toString(10);return n.length+Math.log10(`0.${n.slice(0,15)}`)},L=t=>typeof t=="number"?Math.log(t):N(t)*Math.log(10),z=(t,n)=>{if(typeof t=="number")return t/n;let e=t/BigInt(n),r=t%BigInt(n);return Number(e)+Number(r)/n},v=(t,n)=>{if(n===void 0)return t;if(typeof n!="number"||!Number.isSafeInteger(n)||n<0)throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof n}: ${n}`);return n===0?t:t.length<n?t.padStart(n," "):t},j=t=>{let{minimumFractionDigits:n,maximumFractionDigits:e}=t;if(!(n===void 0&&e===void 0))return y(m(m({},n!==void 0&&{minimumFractionDigits:n}),e!==void 0&&{maximumFractionDigits:e}),{roundingMode:"trunc"})};function p(t,n){if(typeof t!="bigint"&&!Number.isFinite(t))throw new TypeError(`Expected a finite number, got ${typeof t}: ${t}`);n=m({bits:!1,binary:!1,space:!0,nonBreakingSpace:!1},n);let e=n.bits?n.binary?K:P:n.binary?T:C,r=n.space?n.nonBreakingSpace?"\xA0":" ":"",o=typeof t=="number"?t===0:t===0n;if(n.signed&&o){let d=` 0${r}${e[0]}`;return v(d,n.fixedWidth)}let s=t<0,c=s?"-":n.signed?"+":"";s&&(t=-t);let h=j(n),f;if(t<1){let d=M(t,n.locale,h);f=c+d+r+e[0]}else{let d=Math.min(Math.floor(n.binary?L(t)/Math.log(1024):N(t)/3),e.length-1);if(t=z(t,(n.binary?1024:1e3)**d),!h){let B=Math.max(3,Math.floor(t).toString().length);t=t.toPrecision(B)}let k=M(Number(t),n.locale,h),I=e[d];f=c+k+r+I}return v(f,n.fixedWidth)}var x=(()=>{class t{injector;redisTreeDivider=a(this.getStorage("p3xr-main-treecontrol-divider",":"));jsonFormat=a(this.getStorageInt("p3xr-json-format",4));animation=a(this.getStorageInt("p3xr-animation-settings",0)===1);maxValueDisplay=a(this.getStorageInt("p3xr-main-treecontrol-max-value-display",1024));maxKeys=a(this.clampMaxKeys(this.getStorageInt("p3xr-max-keys",1e3)));keysSort=a(this.getStorageBool("p3xr-main-treecontrol-key-sort",!0));searchClientSide=a(this.getStorageBool("p3xr-main-treecontrol-search-client-mode",!1));searchStartsWith=a(this.getStorageBool("p3xr-main-treecontrol-search-starts-with",!1));pageCount=a(this.getStorageInt("p3xr-main-treecontrol-page-size",250));keyPageCount=a(this.getStorageInt("p3xr-main-key-page-size",5));language=a(this.getStorage("p3xr-language","en"));undoEnabled=a(this.getStorageBool("p3xr-undo-enabled",!0));showDiffBeforeSave=a(this.getStorageBool("p3xr-show-diff-before-save",!1));maxKeysMax=1e5;maxLightKeysCount=11e4;resizeMinWidth=315;debounce=100;debounceSearch=2e3;googleAnalytics="G-8M2CK7993T";maxValueAsBuffer=1e3*256;socketTimeout=3e5;connectInfoStorageKey="p3xr-connect-info";currentDatabaseStorageKeyPrefix="p3xr-main-current-database";prettyBytes(e){let r=this.resolveAutoLang();return p(e,{locale:r})}getStorageKeyCurrentDatabase(e){return this.currentDatabaseStorageKeyPrefix+"-"+e}generateId(){return Date.now().toString(36)+"-"+Math.random().toString(36).substring(2,10)}clipboard(e){return S(this,null,function*(){try{return yield navigator.clipboard.writeText(e),!0}catch(r){return!1}})}humanizeDurationCustomLanguages={az:{y:()=>"il",mo:()=>"ay",w:()=>"h\u0259ft\u0259",d:()=>"g\xFCn",h:()=>"saat",m:()=>"d\u0259qiq\u0259",s:()=>"saniy\u0259",ms:()=>"millisaniy\u0259"},be:{y:e=>e===1?"\u0433\u043E\u0434":"\u0433\u0430\u0434\u043E\u045E",mo:e=>e===1?"\u043C\u0435\u0441\u044F\u0446":"\u043C\u0435\u0441\u044F\u0446\u0430\u045E",w:e=>e===1?"\u0442\u044B\u0434\u0437\u0435\u043D\u044C":"\u0442\u044B\u0434\u043D\u044F\u045E",d:e=>e===1?"\u0434\u0437\u0435\u043D\u044C":"\u0434\u0437\u0451\u043D",h:e=>e===1?"\u0433\u0430\u0434\u0437\u0456\u043D\u0430":"\u0433\u0430\u0434\u0437\u0456\u043D",m:e=>e===1?"\u0445\u0432\u0456\u043B\u0456\u043D\u0430":"\u0445\u0432\u0456\u043B\u0456\u043D",s:e=>e===1?"\u0441\u0435\u043A\u0443\u043D\u0434\u0430":"\u0441\u0435\u043A\u0443\u043D\u0434",ms:e=>e===1?"\u043C\u0456\u043B\u0456\u0441\u0435\u043A\u0443\u043D\u0434\u0430":"\u043C\u0456\u043B\u0456\u0441\u0435\u043A\u0443\u043D\u0434"},bs:{y:()=>"godina",mo:()=>"mjeseci",w:()=>"sedmica",d:()=>"dana",h:()=>"sati",m:()=>"minuta",s:()=>"sekundi",ms:()=>"milisekundi"},fil:{y:()=>"taon",mo:()=>"buwan",w:()=>"linggo",d:()=>"araw",h:()=>"oras",m:()=>"minuto",s:()=>"segundo",ms:()=>"millisegundo"},hy:{y:()=>"\u057F\u0561\u0580\u056B",mo:()=>" delays",w:()=>"\u0577\u0561\u0562delays",d:()=>"\u0585delays",h:()=>"\u056Adelays",m:()=>"delays",s:()=>"delays",ms:()=>"delays"},ka:{y:()=>"\u10EC\u10D4\u10DA\u10D8",mo:()=>"\u10D7\u10D5\u10D4",w:()=>"\u10D9\u10D5\u10D8\u10E0\u10D0",d:()=>"\u10D3\u10E6\u10D4",h:()=>"\u10E1\u10D0\u10D0\u10D7\u10D8",m:()=>"\u10EC\u10E3\u10D7\u10D8",s:()=>"\u10EC\u10D0\u10DB\u10D8",ms:()=>"\u10DB\u10D8\u10DA\u10D8\u10EC\u10D0\u10DB\u10D8"},kk:{y:()=>"\u0436\u044B\u043B",mo:()=>"\u0430\u0439",w:()=>"\u0430\u043F\u0442\u0430",d:()=>"\u043A\u04AF\u043D",h:()=>"\u0441\u0430\u0493\u0430\u0442",m:()=>"\u043C\u0438\u043D\u0443\u0442",s:()=>"\u0441\u0435\u043A\u0443\u043D\u0434",ms:()=>"\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434"},ky:{y:()=>"\u0436\u044B\u043B",mo:()=>"\u0430\u0439",w:()=>"\u0430\u043F\u0442\u0430",d:()=>"\u043A\u04AF\u043D",h:()=>"\u0441\u0430\u0430\u0442",m:()=>"\u043C\u04AF\u043D\u04E9\u0442",s:()=>"\u0441\u0435\u043A\u0443\u043D\u0434",ms:()=>"\u043C\u0438\u043B\u043B\u0438\u0441\u0435\u043A\u0443\u043D\u0434"},ne:{y:()=>"\u0935\u0930\u094D\u0937",mo:()=>"\u092E\u0939\u093F\u0928\u093E",w:()=>"\u0939\u092A\u094D\u0924\u093E",d:()=>"\u0926\u093F\u0928",h:()=>"\u0918\u0923\u094D\u091F\u093E",m:()=>"\u092E\u093F\u0928\u0947\u091F",s:()=>"\u0938\u0947\u0915\u0947\u0928\u094D\u0921",ms:()=>"\u092E\u093F\u0932\u093F\u0938\u0947\u0915\u0947\u0928\u094D\u0921"},si:{y:()=>"\u0DC0\u0DC3\u0DBB",mo:()=>"\u0DB8\u0DCF\u0DC3",w:()=>"\u0DC3\u0DAD\u0DD2",d:()=>"\u0DAF\u0DD2\u0DB1",h:()=>"\u0DB4\u0DD0\u0DBA",m:()=>"\u0DB8\u0DD2\u0DB1\u0DD2\u0DAD\u0DCA\u0DAD\u0DD4",s:()=>"\u0DAD\u0DAD\u0DCA\u0DB4\u0DBB",ms:()=>"\u0DB8\u0DD2\u0DBD\u0DD2 \u0DAD\u0DAD\u0DCA\u0DB4\u0DBB"},tg:{y:()=>"\u0441\u043E\u043B",mo:()=>"\u043C\u043E\u04B3",w:()=>"\u04B3\u0430\u0444\u0442\u0430",d:()=>"\u0440\u04EF\u0437",h:()=>"\u0441\u043E\u0430\u0442",m:()=>"\u0434\u0430\u049B\u0438\u049B\u0430",s:()=>"\u0441\u043E\u043D\u0438\u044F",ms:()=>"\u043C\u0438\u043B\u043B\u0438\u0441\u043E\u043D\u0438\u044F"},nb:{y:e=>"\xE5r",mo:e=>e===1?"m\xE5ned":"m\xE5neder",w:e=>e===1?"uke":"uker",d:e=>e===1?"dag":"dager",h:e=>e===1?"time":"timer",m:e=>e===1?"minutt":"minutter",s:e=>e===1?"sekund":"sekunder",ms:()=>"millisekund"}};humanizeDurationLanguageMap={"pt-BR":"pt",zn:"zh_CN","zh-HK":"zh_TW","zh-TW":"zh_TW","pt-PT":"pt"};resolveAutoLang(){return this.injector.get(D).currentLang()||"en"}getHumanizeDurationOptions(){let e=this.resolveAutoLang();return{language:this.humanizeDurationLanguageMap[e]||e||"en",languages:this.humanizeDurationCustomLanguages}}constructor(e){this.injector=e,i(()=>{this.setStorage("p3xr-main-treecontrol-divider",this.redisTreeDivider())}),i(()=>{this.setStorage("p3xr-json-format",String(this.jsonFormat()))}),i(()=>{this.setStorage("p3xr-animation-settings",this.animation()?"1":"0")}),i(()=>{this.applyAnimationClass(this.animation())}),i(()=>{this.setStorage("p3xr-main-treecontrol-max-value-display",String(this.maxValueDisplay()))}),i(()=>{this.setStorage("p3xr-max-keys",String(this.maxKeys()))}),i(()=>{this.setStorage("p3xr-main-treecontrol-key-sort",String(this.keysSort()))}),i(()=>{this.setStorage("p3xr-main-treecontrol-search-client-mode",String(this.searchClientSide()))}),i(()=>{this.setStorage("p3xr-main-treecontrol-search-starts-with",String(this.searchStartsWith()))}),i(()=>{this.setStorage("p3xr-main-treecontrol-page-size",String(this.pageCount()))}),i(()=>{this.setStorage("p3xr-main-key-page-size",String(this.keyPageCount()))}),i(()=>{this.setStorage("p3xr-language",this.language())}),i(()=>{this.setStorage("p3xr-undo-enabled",String(this.undoEnabled()))}),i(()=>{this.setStorage("p3xr-show-diff-before-save",String(this.showDiffBeforeSave()))})}getStorage(e,r){try{let o=localStorage.getItem(e);return o!==null?o:r}catch(o){return r}}getStorageInt(e,r){let o=this.getStorage(e,"");if(!o)return r;let s=parseInt(o,10);return isNaN(s)?r:s}getStorageBool(e,r){let o=this.getStorage(e,"");return o?o==="true"?!0:o==="false"?!1:r:r}clampMaxKeys(e){return isNaN(e)||e<5||e>this.maxKeysMax?1e3:e}setStorage(e,r){try{localStorage.setItem(e,r)}catch(o){}}applyAnimationClass(e){typeof document>"u"||(document.body.classList.toggle("p3xr-animation",e),document.body.classList.toggle("p3xr-no-animation",!e))}static \u0275fac=function(r){return new(r||t)(l(b))};static \u0275prov=u({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();var R={major:0,minor:0,patch:0,isAtLeast:()=>!1,raw:""};function w(t){if(!t)return R;let n=t.split(".").map(Number),e=n[0]||0,r=n[1]||0,o=n[2]||0;return{major:e,minor:r,patch:o,isAtLeast:(s,c)=>e>s||e===s&&r>=c,raw:t}}var Q=(()=>{class t{settings;theme=a(void 0);connection=a(void 0);currentDatabase=a(void 0);databaseIndexes=a([0]);connections=a({list:[]});redisConnections=a({});keysRaw=a([]);keysInfo=a(void 0);search=a(this.getStoredSearch());page=a(1);info=a(void 0);dbsize=a(void 0);redisChanged=a(!1);failed=a(!1);monitor=a(!1);monitorPattern=a("*");commands=a([]);commandsMeta=a({});cfg=a(void 0);version=a(void 0);modules=a([]);hasRediSearch=a(!1);hasReJSON=a(!1);hasTimeSeries=a(!1);hasBloom=a(!1);reducedFunctions=a(!1);keysInfoFetchedAt=a(Date.now());connectionState=a("none");currentPage=a("unknown");consoleDrawerOpen=a(this.getStoredDrawerOpen());setConsoleDrawerOpen(e){this.consoleDrawerOpen.set(e);try{localStorage.setItem("p3xr-console-drawer-open",String(e))}catch(r){}}toggleConsoleDrawer(){this.setConsoleDrawerOpen(!this.consoleDrawerOpen())}getStoredDrawerOpen(){try{return localStorage.getItem("p3xr-console-drawer-open")==="true"}catch(e){return!1}}redisVersion=g(()=>w(this.info()?.server?.redis_version));themeLayout=g(()=>{let e=this.theme();return e?e+"Layout":void 0});themeCommon=g(()=>{let e=this.theme();return e?e+"Common":void 0});filteredKeys=g(()=>{let e=this.keysRaw().slice(),r=this.search(),o=this.settings;return o.searchClientSide()&&typeof r=="string"&&r.length>0&&(o.searchStartsWith()?e=e.filter(s=>s.startsWith(r)):e=e.filter(s=>s.includes(r))),e});paginatedKeys=g(()=>{let e=this.filteredKeys(),r=this.settings.pageCount();if(e.length<=r)return e;let o=(this.page()-1)*r;return e.slice(o,o+r)});pages=g(()=>Math.ceil(this.filteredKeys().length/this.settings.pageCount()));apiHost=(()=>{let e=new URL(location.toString());return`${e.protocol}//${e.host}`})();constructor(e){this.settings=e}resetConnections(){this.connections.set({list:[]})}getStoredSearch(){try{return localStorage.getItem("p3xr-state-search")??""}catch(e){return""}}static \u0275fac=function(r){return new(r||t)(l(x))};static \u0275prov=u({token:t,factory:t.\u0275fac,providedIn:"root"})}return t})();export{x as a,Q as b};