Skip to content

Commit 0238e4c

Browse files
committed
r0b08x [chore] 1/19/2025, 7:41:27 PM
1 parent 3391115 commit 0238e4c

File tree

3 files changed

+71
-87
lines changed

3 files changed

+71
-87
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ https://corifeus.com/redis-ui
1212

1313

1414
---
15-
# 💿 The p3x-redis-ui-material web interface that connects to the p3x-redis-ui-server via http and socket.io v2025.4.125
15+
# 💿 The p3x-redis-ui-material web interface that connects to the p3x-redis-ui-server via http and socket.io v2025.4.126
1616

1717

1818

@@ -109,7 +109,7 @@ All my domains, including [patrikx3.com](https://patrikx3.com), [corifeus.eu](ht
109109
---
110110

111111

112-
[**P3X-REDIS-UI-MATERIAL**](https://corifeus.com/redis-ui-material) Build v2025.4.125
112+
[**P3X-REDIS-UI-MATERIAL**](https://corifeus.com/redis-ui-material) Build v2025.4.126
113113

114114
[![NPM](https://img.shields.io/npm/v/p3x-redis-ui-material.svg)](https://www.npmjs.com/package/p3x-redis-ui-material) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software)
115115

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "p3x-redis-ui-material",
3-
"version": "2025.4.125",
3+
"version": "2025.4.126",
44
"description": "💿 The p3x-redis-ui-material web interface that connects to the p3x-redis-ui-server via http and socket.io",
55
"corifeus": {
66
"icon": "fas fa-database",

src/angular/pages/main/p3xr-main-key.js

+68-84
Original file line numberDiff line numberDiff line change
@@ -103,106 +103,90 @@ p3xr.ng.component('p3xrMainKey', {
103103

104104
this.loading = false
105105
const loadKey = async (options = {}) => {
106-
$interval.cancel(interval)
107-
let {withoutParent} = options
108-
if (withoutParent === undefined) {
109-
withoutParent = false
110-
}
111-
112-
113-
let hadError = undefined
106+
const { withoutParent = false } = options;
107+
114108
try {
115-
116-
// it can throw an error, when we switch the database
117-
//p3xr.ui.overlay.show({
118-
// message: p3xr.strings.intention.getKey
119-
//})
120-
this.loading = true
121-
122-
setTimeout(() => {
123-
$scope.$digest();
124-
})
125-
126-
//const type = p3xr.state.keysInfo[$stateParams.key].type
127-
//console.warn('$stateParams.key', $stateParams.key)
109+
this.loading = true;
110+
128111
const response = await p3xrSocket.request({
129112
action: 'key-get',
130-
payload: {
131-
key: $stateParams.key,
132-
//type: type,
133-
}
134-
})
135-
this.response = response
136-
137-
//const type = response.type
113+
payload: { key: $stateParams.key },
114+
});
115+
138116
if (response.ttl === -2) {
139-
checkTtl()
117+
checkTtl();
140118
return;
141119
}
142-
response.size = 0
143-
144-
if (response.type !== 'stream') {
145-
if (typeof response.valueBuffer === 'object' && response.length > 0) {
146-
for (let keys of Object.keys(response.valueBuffer)) {
147-
response.size += response.valueBuffer[keys].byteLength
148-
}
149-
} else if (Array.isArray(response.valueBuffer)) {
150-
for (let i = 0; i < response.valueBuffer.length; i++) {
151-
response.size += response.valueBuffer[i].byteLength
152-
}
153-
} else {
154-
response.size = response.valueBuffer.byteLength
155-
}
156-
} else {
157-
//console.log('response', response)
158-
function sumMaxByteLength(arr) {
159-
let total = 0;
120+
121+
const { type, valueBuffer } = response;
122+
123+
switch (type) {
124+
case 'string':
125+
response.value = new TextDecoder().decode(valueBuffer);
126+
break;
127+
128+
case 'list':
129+
case 'set':
130+
response.value = valueBuffer.map((buf) => new TextDecoder().decode(buf));
131+
break;
132+
133+
case 'hash':
134+
response.value = {};
135+
Object.entries(valueBuffer).forEach(([key, buf]) => {
136+
response.value[key] = new TextDecoder().decode(buf);
137+
});
138+
break;
139+
140+
case 'zset':
141+
response.value = [];
142+
for (let i = 0; i < valueBuffer.length; i += 2) {
143+
// Ensure proper decoding of score and value
144+
const value = new TextDecoder().decode(valueBuffer[i]);
145+
const score = new TextDecoder().decode(valueBuffer[i + 1]);
160146

161-
function processElement(element) {
162-
if (ArrayBuffer.isView(element) || element instanceof ArrayBuffer) {
163-
total += element.byteLength;
164-
} else if (Array.isArray(element)) {
165-
element.forEach(processElement);
166-
}
147+
response.value.push(value);
148+
response.value.push(score);
149+
}
150+
break;
151+
152+
case 'stream':
153+
function decodeStreamEntry(entry) {
154+
// Recursively decode stream entry
155+
return entry.map((item) => {
156+
if (Array.isArray(item)) {
157+
// If the item is an array, recursively process it
158+
return decodeStreamEntry(item);
159+
} else if (ArrayBuffer.isView(item) || item instanceof ArrayBuffer) {
160+
// Decode binary data if it's an ArrayBuffer
161+
return new TextDecoder().decode(item);
162+
} else {
163+
// Return strings or any other values as-is
164+
return item;
165+
}
166+
});
167167
}
168168

169-
arr.forEach(processElement);
170-
return total;
171-
}
172-
response.size = sumMaxByteLength(response.valueBuffer)
169+
// Process the valueBuffer
170+
response.value = valueBuffer.map((entry) => decodeStreamEntry(entry));
171+
break;
173172
}
173+
174+
//console.log('response', response);
174175

175-
if (response.ttl > -1) {
176-
wasExpiring = true
177-
}
178-
loadTtl()
179-
$scope.$digest()
180-
176+
this.response = response;
177+
loadTtl();
181178
} catch (e) {
182-
hadError = e
183-
console.error(e)
179+
console.error(e);
184180
if (!p3xr.settings.handleConnectionIsClosed(e, $rootScope)) {
185-
p3xrCommon.alert(p3xr.strings.label.unableToLoadKey({ key: $stateParams.key }))
186-
} else{
187-
p3xrCommon.alert(e.message)
181+
p3xrCommon.alert(p3xr.strings.label.unableToLoadKey({ key: $stateParams.key }));
182+
} else {
183+
p3xrCommon.alert(e.message);
188184
}
189-
//p3xrCommon.generalHandleError(e)
190185
} finally {
191-
//p3xr.ui.overlay.hide()
192-
if (hadError !== undefined) {
193-
$state.go('main.statistics');
194-
} else if (!withoutParent && $stateParams.resize !== null) {
195-
$stateParams.resize()
196-
}
197-
198-
$timeout(() => {
199-
this.loading = false
200-
$scope.$digest()
201-
}, p3xr.settings.debounce)
202-
186+
this.loading = false;
203187
}
204-
205-
}
188+
};
189+
206190

207191
const generateHighlight = () => {
208192
$('#p3xr-theme-styles-tree-key').remove()

0 commit comments

Comments
 (0)