Skip to content

Commit

Permalink
r0b08x [chore] 1/19/2025, 7:53:49 PM
Browse files Browse the repository at this point in the history
  • Loading branch information
p3x-robot committed Jan 19, 2025
1 parent 0238e4c commit 380c1ed
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 23 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ https://corifeus.com/redis-ui


---
# 💿 The p3x-redis-ui-material web interface that connects to the p3x-redis-ui-server via http and socket.io v2025.4.126
# 💿 The p3x-redis-ui-material web interface that connects to the p3x-redis-ui-server via http and socket.io v2025.4.127



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


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

[![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)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "p3x-redis-ui-material",
"version": "2025.4.126",
"version": "2025.4.127",
"description": "💿 The p3x-redis-ui-material web interface that connects to the p3x-redis-ui-server via http and socket.io",
"corifeus": {
"icon": "fas fa-database",
Expand Down
109 changes: 89 additions & 20 deletions src/angular/pages/main/p3xr-main-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,44 @@ p3xr.ng.component('p3xrMainKey', {

this.loading = false
const loadKey = async (options = {}) => {
const { withoutParent = false } = options;

$interval.cancel(interval)
let {withoutParent} = options
if (withoutParent === undefined) {
withoutParent = false
}


let hadError = undefined
try {
this.loading = true;


// it can throw an error, when we switch the database
//p3xr.ui.overlay.show({
// message: p3xr.strings.intention.getKey
//})
this.loading = true

setTimeout(() => {
$scope.$digest();
})

//const type = p3xr.state.keysInfo[$stateParams.key].type
//console.warn('$stateParams.key', $stateParams.key)
const response = await p3xrSocket.request({
action: 'key-get',
payload: { key: $stateParams.key },
});

payload: {
key: $stateParams.key,
//type: type,
}
})
this.response = response

//const type = response.type
if (response.ttl === -2) {
checkTtl();
checkTtl()
return;
}

response.size = 0

const { type, valueBuffer } = response;

switch (type) {
Expand Down Expand Up @@ -170,23 +193,69 @@ p3xr.ng.component('p3xrMainKey', {
response.value = valueBuffer.map((entry) => decodeStreamEntry(entry));
break;
}

//console.log('response', response);

this.response = response;
loadTtl();
if (response.type !== 'stream') {
if (typeof response.valueBuffer === 'object' && response.length > 0) {
for (let keys of Object.keys(response.valueBuffer)) {
response.size += response.valueBuffer[keys].byteLength
}
} else if (Array.isArray(response.valueBuffer)) {
for (let i = 0; i < response.valueBuffer.length; i++) {
response.size += response.valueBuffer[i].byteLength
}
} else {
response.size = response.valueBuffer.byteLength
}
} else {
//console.log('response', response)
function sumMaxByteLength(arr) {
let total = 0;

function processElement(element) {
if (ArrayBuffer.isView(element) || element instanceof ArrayBuffer) {
total += element.byteLength;
} else if (Array.isArray(element)) {
element.forEach(processElement);
}
}

arr.forEach(processElement);
return total;
}
response.size = sumMaxByteLength(response.valueBuffer)
}

if (response.ttl > -1) {
wasExpiring = true
}
loadTtl()
$scope.$digest()

} catch (e) {
console.error(e);
hadError = e
console.error(e)
if (!p3xr.settings.handleConnectionIsClosed(e, $rootScope)) {
p3xrCommon.alert(p3xr.strings.label.unableToLoadKey({ key: $stateParams.key }));
} else {
p3xrCommon.alert(e.message);
p3xrCommon.alert(p3xr.strings.label.unableToLoadKey({ key: $stateParams.key }))
} else{
p3xrCommon.alert(e.message)
}
//p3xrCommon.generalHandleError(e)
} finally {
this.loading = false;
//p3xr.ui.overlay.hide()
if (hadError !== undefined) {
$state.go('main.statistics');
} else if (!withoutParent && $stateParams.resize !== null) {
$stateParams.resize()
}

$timeout(() => {
this.loading = false
$scope.$digest()
}, p3xr.settings.debounce)

}
};


}

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

0 comments on commit 380c1ed

Please sign in to comment.