Skip to content

Commit

Permalink
r0b08x [chore] 3/9/2024, 8:47:41 AM
Browse files Browse the repository at this point in the history
  • Loading branch information
p3x-robot committed Mar 9, 2024
1 parent 013358c commit 46f750c
Show file tree
Hide file tree
Showing 7 changed files with 916 additions and 800 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 v2024.4.134
# 💿 The p3x-redis-ui-material web interface that connects to the p3x-redis-ui-server via http and socket.io v2024.4.135



Expand Down Expand Up @@ -77,7 +77,7 @@ All my domains ([patrikx3.com](https://patrikx3.com) and [corifeus.com](https://

---

[**P3X-REDIS-UI-MATERIAL**](https://corifeus.com/redis-ui-material) Build v2024.4.134
[**P3X-REDIS-UI-MATERIAL**](https://corifeus.com/redis-ui-material) Build v2024.4.135

[![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": "2024.4.134",
"version": "2024.4.135",
"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
18 changes: 18 additions & 0 deletions src/angular/pages/main/key/p3xr-main-key-string.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@
</md-button>


<input type="file" id="p3xr-main-key-string-upload-buffer" style="display: none" onchange="angular.element(this).scope().readFileAsBuffer(event)"/>
<md-button class="md-button md-raised md-primary" ng-click="$ctrl.setBufferUpload({ $event: $event})">
<md-icon>upload</md-icon>
<span hide-sm hide-xs>{{ $root.p3xr.strings.intention.setBuffer }}</span>
<md-tooltip ng-if="$root.$mdMedia('sm') || $root.$mdMedia('xs')" md-direction="bottom">{{
$root.p3xr.strings.intention.setBuffer }}
</md-tooltip>
</md-button>


<md-button class="md-button md-raised md-accent" ng-click="$ctrl.downloadBuffer({ $event: $event})">
<md-icon>download</md-icon>
<span hide-sm hide-xs>{{ $root.p3xr.strings.intention.downloadBuffer }}</span>
<md-tooltip ng-if="$root.$mdMedia('sm') || $root.$mdMedia('xs')" md-direction="bottom">{{
$root.p3xr.strings.intention.downloadBuffer }}
</md-tooltip>
</md-button>


<md-button class="md-button md-raised md-primary" ng-click="$ctrl.formatJson({ $event: $event})" ng-if="$root.p3xr.state.connection.readonly !== true">
<md-icon>format_line_spacing</md-icon>
Expand Down
68 changes: 67 additions & 1 deletion src/angular/pages/main/key/p3xr-main-key-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,48 @@ p3xr.ng.component('p3xrMainKeyString', {
p3xrKey: '<',
p3xrResponse: '<',
},
controller: function (p3xrSocket, p3xrCommon, $rootScope, p3xrDialogJsonView, p3xrDialogJsonEditor) {
controller: function (p3xrSocket, p3xrCommon, $rootScope, p3xrDialogJsonView, p3xrDialogJsonEditor, $scope) {

this.setBufferUpload = () => {
document.getElementById('p3xr-main-key-string-upload-buffer').click()
}

$scope.readFileAsBuffer = async (event) => {
const file = event.target.files[0];
if (!file) {
return;
}
const reader = new FileReader();
reader.onload = async (loadEvent) => {
const arrayBuffer = loadEvent.target.result;
// Process the buffer here
//console.log(arrayBuffer);

try {
const response = await p3xrSocket.request({
action: 'key-set',
payload: {
type: this.p3xrResponse.type,
value: arrayBuffer,
key: this.p3xrKey,
}
})

window['gtag']('config', p3xr.settings.googleAnalytics,
{
'page_path': '/key-set'
}
);

} catch (e) {
p3xrCommon.generalHandleError(e)
} finally {
$rootScope.$broadcast('p3xr-refresh-key');
}

};
reader.readAsArrayBuffer(file);
}


this.copy = () => {
Expand All @@ -15,6 +56,31 @@ p3xr.ng.component('p3xrMainKeyString', {
p3xrCommon.toast(p3xr.strings.status.dataCopied)
}

this.downloadBuffer = async () => {
try {
const response = await p3xrSocket.request({
action: 'key-get-string-buffer',
payload: {
key: this.p3xrKey,
}
})
//console.log('response', response)

const blob = new Blob([response.bufferValue]);
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `${this.p3xrKey}.bin`;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
} catch (e) {
p3xrCommon.generalHandleError(e)
} finally {
}
}

this.editable = false;
let originalValue
this.edit = () => {
Expand Down
2 changes: 2 additions & 0 deletions src/strings/en/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ const strings = {
},
intention: {
copy: 'Copy',
downloadBuffer: 'Download buffer',
setBuffer: 'Set buffer',
saveWithFormatJson: 'Save with format',
formatJson: 'Format Json',
pubsubMonitor: 'PubSub Monitor',
Expand Down
Loading

0 comments on commit 46f750c

Please sign in to comment.