.gitignore000066400000000000000000000003441520013332200130360ustar00rootroot00000000000000/build /node_modules /*.log /*.iws .idea/workspace.xml .idea/tasks.xml .idea/profiles_settings.xml .idea/inspectionProfiles/Project_Default.xml .idea/inspectionProfiles/profiles_settings.xml node_modules/.yarn-integrity /dist.npmignore000066400000000000000000000002441520013332200130440ustar00rootroot00000000000000/.idea /artifacts /build /test /node_modules /*.iml /*.ipr /*.iws /.travis.yml /.scrutinizer.yml /Gruntfile.js /*.lock *.log /corifeus-boot.json /secure /src/**/*.*.travis.yml000066400000000000000000000014301520013332200131540ustar00rootroot00000000000000language: node_js node_js: - node before_script: - npm install -g grunt-cli npm env: global: secure: ndPY/yENX+jrLScJBSsu+GV93TZcnmFyPirG19UBvu2ZdUyh+jUnDfvsqtz9VCoYgArDoXaE2cn+O7ymlhzo3FaiTn4uhZFwWkNDvB/o4yVUY8JfqUJiKM1Ed/1FCwsKNQ5ClH9EyTKlsecu68f3Tl36C+YRI2n0ar2ILD9Fz4SzcFUS1sxAa1zAk20P5JKeEL/sEzHHYT/ex2p/TEltN/6SaV4ITV6z94FH5dxIuwgz7WQeteNx3dPG6H/b+mkpE6Lyzgb5fRhYSdoSiynWK6/Z4gswftXLG12YIue8NVR8Fa2RMAESA2Nzeu0SDfZl/jRJqw0DWKlNq+8Wzme81TPJw0S8aQDYVNWJAnbIXI2qGibXidy7+WHhM8AhoK/e+1VAKuD61H2W75YERGkktiN9oldcoGiyO/ODkxQ6gGZ6URsxC57SbtQdsTDWCAOGjkZOrcXE4qT30ItrfkVif0BpHtHhgCd8iAsnVDKcuTzj995gI/gNDitAKJjnMgIVlS3nLTYBATy7xJh90BMfDBG0MDvnonA7Co5Qrz04MotgQZ5abXckaNPkBAe9WTFeQ51pHcWSoWcuK/InTPIZCB6Hb6i/q5y8SOlGzTpr2v6vxPw9h83X2AxJLabxB6WgXCwr/DbehgnATK09O7s7QvwmG4PzfqqllcfCC6r4QRs= Gruntfile.js000066400000000000000000000100001520013332200133310ustar00rootroot00000000000000const utils = require('corifeus-utils'); module.exports = (grunt) => { const builder = require(`corifeus-builder`); const gruntUtil = builder.utils; const loader = new builder.loader(grunt); loader.js({ jit: { injector: 'grunt-injector', }, config: { injector: { options: {}, jsAngular: { options: { transform: function (filePath) { const relative = gruntUtil.injectorRelativePathGenerator({ srcDir: 'src/angular/', filePath: filePath, }) return `require('./${relative}');`; }, starttag: '//injector-angular-start', endtag: '//injector-angular-end' }, files: { 'src/angular/injector.js': [ 'src/angular/**/*.js', '!src/angular/injector.js', '!src/angular/boot.js', '!src/angular/routes.js', ], } }, sass: { options: { transform: function (filePath) { const relative = gruntUtil.injectorRelativePathGenerator({ srcDir: 'src/', filePath: filePath, }) return `@import "./${relative}";`; }, starttag: '//injector-sass-start', endtag: '//injector-sass-end', }, files: { 'src/injector.scss': [ 'src/**/*.scss', '!src/scss/index.scss', '!src/injector.scss', ] } }, }, watch: { options: { atBegin: true }, js: { files: [ 'src/angular/**/*.js', '!src/angular/injector.js', '!src/angular/boot.js', '!src/angular/routes.js', ], tasks: [ 'injector:jsAngular', ], }, sass: { files: [ 'src/**/*.scss', '!src/scss/index.scss', '!src/injector.scss', ], tasks: [ 'injector:sass' ], }, }, } }); grunt.registerTask('default', ['cory-npm', 'clean', 'cory-replace', 'cory:license']); grunt.registerTask('inject', ['watch:js', 'watch:sass']); grunt.registerTask('build', ['injector']); grunt.registerTask('publish', async function() { const done = this.async() const cwd = process.cwd() try { await gruntUtil.spawn({ grunt: grunt, gruntThis: this, }, { cmd: `${cwd}/node_modules/.bin/grunt${gruntUtil.commandAddon}`, args: [ 'injector' ] }); await gruntUtil.spawn({ grunt: grunt, gruntThis: this, }, { cmd: `${cwd}/node_modules/.bin/webpack${gruntUtil.commandAddon}`, args: [ '--config', './src/builder/webpack.config.js', '--production' ] }); done() } catch(e) { done(e) } }) } LICENSE000066400000000000000000000024251520013332200120550ustar00rootroot00000000000000 @license p3x-redis-ui-material v2018.9.16-3 💿 The p3x-redis-ui-material web interface that connects to the p3x-redis-ui-server via https. https://pages.corifeus.com/redis-ui-material Copyright (c) 2018 Patrik Laszlo / P3X / Corifeus and contributors. MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. README.md000066400000000000000000000056261520013332200123350ustar00rootroot00000000000000# This is a development package For the full-blown package, please follow: https://github.com/patrikx3/redis-ui https://www.npmjs.com/package/p3x-redis-ui https://pages.corifeus.com/redis-ui [//]: #@corifeus-header [![Build Status](https://travis-ci.org/patrikx3/redis-ui-material.svg?branch=master)](https://travis-ci.org/patrikx3/redis-ui-material) [![Uptime Robot ratio (30 days)](https://img.shields.io/uptimerobot/ratio/m780749701-41bcade28c1ea8154eda7cca.svg)](https://uptimerobot.patrikx3.com/) --- # 💿 The p3x-redis-ui-material web interface that connects to the p3x-redis-ui-server via https. v2018.9.21-0 This is an open-source project. Star this repository, if you like it, or even donate! Thank you so much! :) I run my own server with dynamic IP address, so, it may happen, that the server can not be reachable for about max 15 minutes, due to nature of the dynamic DNS. The server may also be unreachable, when I backup the SSD with Clonzilla (very rarely) or an electrical issue (but this should not happen again). When the server is down, please hang on for 15-30 minutes and the server will be back up. All my domains (patrikx3.com and corifeus.com) could have errors, since I am developing in my free time. However, it is usually stable. **Bugs are evident™ - MATRIX️** ### Node Version Requirement ``` >=8.11.4 ``` ### Built on Node ``` v10.11.0 ``` The ```async``` and ```await``` keywords are required. Install NodeJs: https://nodejs.org/en/download/package-manager/ # Description [//]: #@corifeus-header:end The is the `p3x-redis-ui-material` web gui, that uses the `p3x-redis-ui-server`. It is based on Socket.IO and AngularJs Material, uses themes light/dark schema and internationalization (English is implemented by default). # For development standalone I just spawn 3 terminals. ```bash # terminal 1 npm run run-webpack # terminal 2 grunt watch:js # terminal 3 grunt watch:sass ``` [//]: #@corifeus-footer --- [**P3X-REDIS-UI-MATERIAL**](https://pages.corifeus.com/redis-ui-material) Build v2018.9.21-0 [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) [![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) ## P3X Sponsors [IntelliJ - The most intelligent Java IDE](https://www.jetbrains.com) [![JetBrains](https://cdn.corifeus.com/assets/svg/jetbrains-logo.svg)](https://www.jetbrains.com/) [![NoSQLBooster](https://cdn.corifeus.com/assets/png/nosqlbooster-70x70.png)](https://www.nosqlbooster.com/) [The Smartest IDE for MongoDB](https://www.nosqlbooster.com) [//]: #@corifeus-footer:endpackage.json000066400000000000000000000055111520013332200133350ustar00rootroot00000000000000{ "name": "p3x-redis-ui-material", "version": "2018.9.21-0", "description": "💿 The p3x-redis-ui-material web interface that connects to the p3x-redis-ui-server via https.", "corifeus": { "icon": "fas fa-database", "code": "Fireball", "opencollective": false, "build": true, "nodejs": "v10.11.0", "reponame": "redis-ui-material", "publish": true, "prefix": "p3x-", "type": "p3x" }, "main": "src/index.js", "scripts": { "test": "grunt", "run": "concurrently \"grunt watch:js\" \"grunt watch:sass\" \"webpack-dev-server --hot --inline --config ./src/builder/webpack.config.js\"", "run-webpack": "webpack-dev-server --hot --inline --config ./src/builder/webpack.config.js", "build": "grunt build && webpack --config ./src/builder/webpack.config.js --production" }, "repository": { "type": "git", "url": "https://github.com/patrikx3/redis-ui-material.git" }, "keywords": [ "redis", "ui", "gui", "web", "electron", "desktop", "server", "angularjs", "javascript", "material", "dark", "light" ], "author": "Patrik Laszlo ", "license": "MIT", "devDependencies": { "@fortawesome/fontawesome-free": "^5.3.1", "@uirouter/angularjs": "^1.0.20", "angular": "^1.7.4", "angular-animate": "^1.7.4", "angular-aria": "^1.7.4", "angular-cookies": "^1.7.4", "angular-json-tree": "^1.0.1", "parse-ms": "^2.0.0", "angular-material": "^1.1.10", "angular-messages": "^1.7.4", "angular-tree-control": "^0.2.30", "clean-webpack-plugin": "^0.1.19", "concurrently": "^4.0.1", "corifeus-builder": "^2018.9.16-3", "css-loader": "^1.0.0", "extract-text-webpack-plugin": "^4.0.0-beta.0", "file-loader": "^2.0.0", "grunt-injector": "^1.1.0", "html-loader": "^0.5.5", "html-webpack-plugin": "^3.2.0", "jquery": "^3.3.1", "js-htmlencode": "^0.3.0", "lodash": "^4.17.11", "material-design-icons-iconfont": "^3.0.3", "moment": "^2.22.2", "node-sass": "^4.9.3", "optimize-css-assets-webpack-plugin": "^5.0.1", "pretty-bytes": "^5.1.0", "raw-loader": "^0.5.1", "sass-loader": "^7.1.0", "socket.io-client": "^2.1.1", "style-loader": "^0.23.0", "terser-webpack-plugin": "^1.1.0", "typeface-roboto": "0.0.54", "webpack": "^4.19.1", "webpack-cli": "^3.1.0", "webpack-dev-server": "^3.1.8" }, "engines": { "node": ">=8.11.4" }, "homepage": "https://pages.corifeus.com/redis-ui-material", "dependencies": {} } redis-ui-material.iml000066400000000000000000000005171520013332200150700ustar00rootroot00000000000000 src/000077500000000000000000000000001520013332200116345ustar00rootroot00000000000000src/angular/000077500000000000000000000000001520013332200132655ustar00rootroot00000000000000src/angular/boot.js000066400000000000000000000200621520013332200145660ustar00rootroot00000000000000// angular global.angular = require('angular'); require('angular-aria'); require('angular-messages'); require('angular-animate'); require('angular-cookies'); require('@uirouter/angularjs') require('angular-material'); require('angular-tree-control') require('angular-tree-control/context-menu') require('angular-json-tree') p3xr.ng = angular.module('p3xr-redis-ui', [ 'ngCookies', 'ngAnimate', 'ngAria', 'ngMessages', 'ngMaterial', 'ui.router', 'treeControl', 'angular-json-tree', ] ); require('./injector') p3xr.ng.config(($qProvider, $locationProvider, $urlRouterProvider, $stateProvider, p3xrThemeProvider) => { $qProvider.errorOnUnhandledRejections(false); $locationProvider.html5Mode(true); // $urlRouterProvider.otherwise('/'); // $httpProvider.interceptors.push('ngivrHttpInterceptor'); p3xrThemeProvider.start(); const routes = require('./routes') $urlRouterProvider.otherwise('/main'); routes($stateProvider); }) p3xr.ng.run(($rootScope, p3xrSocket, p3xrTheme, $mdMedia, $state, $timeout, $cookies, p3xrRedisParser) => { $rootScope.p3xr = p3xr; $rootScope.$mdMedia = $mdMedia; $rootScope.hasConnected = () => { if (Object.keys(p3xr.state.redisConnections).length === 0) { return false } return true; } $rootScope.locationReload = () => { $state.go('main') location.reload() } let treeDivider Object.defineProperty($rootScope.p3xr.settings, 'redisTreeDivider', { get: () => { treeDivider = $cookies.get(p3xr.settings.tree.cookieName) if (treeDivider === undefined) { treeDivider = p3xr.settings.tree.defaultDivider } return treeDivider }, set: (value) => { treeDivider = value treeDivider = $cookies.put(p3xr.settings.tree.cookieName, value, { expires: p3xr.settings.cookieExpiry, }) } }) let keysSort Object.defineProperty($rootScope.p3xr.settings, 'keysSort', { get: () => { keysSort = $cookies.get(p3xr.settings.keySortInfo.cookieName) if (keysSort === undefined) { keysSort = p3xr.settings.keySortInfo.default } else if (keysSort === 'true') { keysSort = true } else if (keysSort === 'false') { keysSort = false } return keysSort }, set: (value) => { keysSort = value keysSort = $cookies.put(p3xr.settings.keySortInfo.cookieName, value, { expires: p3xr.settings.cookieExpiry, }) } }) let searchClientSide Object.defineProperty($rootScope.p3xr.settings, 'searchClientSide', { get: () => { searchClientSide = $cookies.get(p3xr.settings.searchInfoClientSide.cookieName) if (searchClientSide === undefined) { searchClientSide = p3xr.settings.searchInfoClientSide.default } else if (searchClientSide === 'true') { searchClientSide = true } else if (searchClientSide === 'false') { searchClientSide = false } return searchClientSide }, set: (value) => { searchClientSide = value searchClientSide = $cookies.put(p3xr.settings.searchInfoClientSide.cookieName, value, { expires: p3xr.settings.cookieExpiry, }) } }) let searchStartsWith Object.defineProperty($rootScope.p3xr.settings, 'searchStartsWith', { get: () => { searchStartsWith = $cookies.get(p3xr.settings.searchInfoStartsWith.cookieName) if (searchStartsWith === undefined) { searchStartsWith = p3xr.settings.searchInfoStartsWith.default } else if (searchStartsWith === 'true') { searchStartsWith = true } else if (searchStartsWith === 'false') { searchStartsWith = false } return searchStartsWith }, set: (value) => { searchStartsWith = value searchStartsWith = $cookies.put(p3xr.settings.searchInfoStartsWith.cookieName, value, { expires: p3xr.settings.cookieExpiry, }) } }) $rootScope.keysTreeRendered = [] let keysTree Object.defineProperty($rootScope, 'keysTree', { get: () => { if (JSON.stringify(keysTree) !== JSON.stringify(p3xr.state.keys) || $rootScope.p3xr.state.redisChanged === true ) { $rootScope.p3xr.state.redisChanged = false $rootScope.keysTreeRendered = p3xrRedisParser.keysToTreeControl({ keys: p3xr.state.keys, }) keysTree = p3xr.state.keys } return $rootScope.keysTreeRendered }, set: (value) => { keysTree = value } }) let expandedNodes = [] Object.defineProperty($rootScope, 'expandedNodes', { get: () => { //console.warn('expandedNodes get', expandedNodes) return expandedNodes }, set: (value) => { //console.warn('expandedNodes set', expandedNodes) expandedNodes = value } }) $rootScope.savedExpandedNodes = [] let page = 1 Object.defineProperty($rootScope.p3xr.state, 'page', { get: () => { return page }, set: (value) => { page = parseInt(value) } }) Object.defineProperty($rootScope.p3xr.state, 'keys', { get: () => { let keysRaw = $rootScope.p3xr.state.keysRaw.slice() if ($rootScope.p3xr.settings.searchClientSide && typeof ($rootScope.p3xr.state.search) === 'string' && $rootScope.p3xr.state.search.length > 0) { //console.log($rootScope.p3xr.settings.searchStartsWith) if ($rootScope.p3xr.settings.searchStartsWith) { //console.log('startswith') keysRaw = keysRaw.filter(keyRaw => { return keyRaw.startsWith($rootScope.p3xr.state.search) }) } else { //console.log('includes') keysRaw = keysRaw.filter(keyRaw => { return keyRaw.includes($rootScope.p3xr.state.search) }) } } if (keysRaw <= $rootScope.p3xr.settings.pageCount) { return keysRaw } else { //console.log('new scope change', ($rootScope.p3xr.state.page -1) * $rootScope.p3xr.settings.pageCount, $rootScope.p3xr.settings.pageCount) const start = ($rootScope.p3xr.state.page -1) * $rootScope.p3xr.settings.pageCount const keys = keysRaw.slice(start, start + $rootScope.p3xr.settings.pageCount) return keys } } }) Object.defineProperty($rootScope.p3xr.state, 'pages', { get: () => { const pages = Math.ceil($rootScope.p3xr.state.keysRaw.length / $rootScope.p3xr.settings.pageCount) return pages } }) let pageCount Object.defineProperty($rootScope.p3xr.settings, 'pageCount', { get: () => { pageCount = $cookies.get(p3xr.settings.paging.cookieName) if (pageCount === undefined) { pageCount = p3xr.settings.paging.default } else { pageCount = parseInt(pageCount) } return pageCount }, set: (value) => { pageCount = value pageCount = $cookies.put(p3xr.settings.paging.cookieName, value, { expires: p3xr.settings.cookieExpiry, }) } }) //console.warn('p3xrTheme', p3xrTheme) p3xrTheme.start() console.info('P3X Redis UI ran') }) angular.element(document).ready(() => { const bootstrapElement = document.getElementById('p3xr-redis-ui-bootstrap'); angular.bootstrap(bootstrapElement, ['p3xr-redis-ui']); }) src/angular/dialog/000077500000000000000000000000001520013332200145245ustar00rootroot00000000000000src/angular/dialog/p3xr-dialog-connection.html000066400000000000000000000077401520013332200217100ustar00rootroot00000000000000

{{ $root.p3xr.state.cfg.readonlyConnections ? $root.p3xr.strings.label.connectiondView : options.type === 'new' ? $root.p3xr.strings.label.connectiondAdd : $root.p3xr.strings.label.connectiondEdit }}

close
{{ $root.p3xr.strings.form.error.required }}
{{ $root.p3xr.strings.form.error.port }}
{{ $root.p3xr.strings.label.passwordSecure }}
{{ $root.p3xr.strings.intention.testConnection }} cancel {{ $root.p3xr.strings.intention.cancel }} {{ options.type === 'new' ? 'add' : 'save' }} {{ options.type === 'new' ? $root.p3xr.strings.intention.add : $root.p3xr.strings.intention.save }}
src/angular/dialog/p3xr-dialog-connection.js000066400000000000000000000116731520013332200213600ustar00rootroot00000000000000p3xr.ng.factory('p3xrDialogConnection', function (p3xrCommon, $mdDialog, p3xrSocket) { return new function () { this.show = async(options) => { try { const result = await $mdDialog.show({ controller: function ($scope, $mdDialog) { $scope.options = options if (options.model !== undefined) { $scope.model = options.model $scope.model.password = options.model.id } else { $scope.model = { name: undefined, host: undefined, port: undefined, password: undefined, id: undefined, } } // Promise reject $scope.cancel = function () { p3xrCommon.toast({ message: p3xr.strings.status.cancelled }) $mdDialog.cancel(); }; /* // Promise resolve $scope.hide = function () { $mdDialog.hide(); }; // Promise resolve - with result $scope.answer = function (answer) { $mdDialog.hide(answer); }; */ const handleInvalidForm = () => { if ($scope.p3xrConnectionForm.$invalid) { p3xrCommon.toast({ message: p3xr.strings.form.error.invalid }) return false } return true } $scope.testConnection = async() => { $scope.p3xrConnectionForm.$setSubmitted(); if (!handleInvalidForm()) { return; } try { const response = await p3xrSocket.request({ action: 'redis-test-connection', payload: { model: $scope.model }, }) p3xrCommon.toast({ message: p3xr.strings.status.redisConnected }) } catch(e) { p3xrCommon.generalHandleError(e) } } $scope.submit = async () => { if (!handleInvalidForm()) { return; } if ($scope.model.host === undefined) { $scope.model.host = 'localhost' } if ($scope.model.port === undefined) { $scope.model.port = 6379 } if (options.type === 'new') { $scope.model.id = p3xr.nextId() } try { const response = await p3xrSocket.request({ action: 'connection-save', payload: { model: angular.copy($scope.model) }, }) p3xrCommon.toast({ message: $scope.options.type === 'new' ? p3xr.strings.status.added : p3xr.strings.status.saved }) //$scope.options.type = 'edit'; $mdDialog.cancel(); } catch(e) { p3xrCommon.generalHandleError(e) } } }, template: require('./p3xr-dialog-connection.html'), parent: angular.element(document.body), targetEvent: options.$event, clickOutsideToClose: true, fullscreen: true // Only for -xs, -sm breakpoints. }) // console.warn(result) } catch(error) { p3xrCommon.generalHandleError(error) } } } }); src/angular/dialog/p3xr-dialog-json-view.html000066400000000000000000000023131520013332200214610ustar00rootroot00000000000000
table_chart   {{ $root.p3xr.strings.intention.jsonViewShow }} close
{{ $root.p3xr.strings.label.jsonViewNotParsable}}
close {{ $root.p3xr.strings.intention.close }}
src/angular/dialog/p3xr-dialog-json-view.js000066400000000000000000000043641520013332200211410ustar00rootroot00000000000000p3xr.ng.factory('p3xrDialogJsonView', function (p3xrCommon, $mdDialog) { return new function () { this.show = async(options) => { try { const result = await $mdDialog.show({ controller: function ($scope, $mdDialog) { let lastResult Object.defineProperty($scope, 'isJson', { get: () => { try { const obj = JSON.parse(options.value) if (lastResult !== true) { $scope.obj = obj } lastResult = true return true } catch(e) { if (lastResult !== false) { $scope.obj = undefined } lastResult = false return false } } }) // Promise reject $scope.ok = function () { $mdDialog.cancel(); }; /* // Promise resolve $scope.hide = function () { $mdDialog.hide(); }; // Promise resolve - with result $scope.answer = function (answer) { $mdDialog.hide(answer); }; */ }, template: require('./p3xr-dialog-json-view.html'), parent: angular.element(document.body), targetEvent: options.$event, clickOutsideToClose: true, fullscreen: true // Only for -xs, -sm breakpoints. }) // console.warn(result) } catch(error) { p3xrCommon.generalHandleError(error) } } } }); src/angular/dialog/p3xr-dialog-key-new.html000066400000000000000000000107441520013332200211260ustar00rootroot00000000000000

{{$root.p3xr.strings.form.key.label.formName}}

close
{{ $root.p3xr.strings.form.key.error.key }}
{{ $root.p3xr.strings.redisTypes[type] }}
{{ $root.p3xr.strings.form.key.error.hashKey }}
{{ $root.p3xr.strings.form.key.error.score }}
{{ $root.p3xr.strings.form.key.error.value }}
close {{ $root.p3xr.strings.intention.cancel }} add {{ $root.p3xr.strings.intention.add }}
src/angular/dialog/p3xr-dialog-key-new.js000066400000000000000000000100241520013332200205650ustar00rootroot00000000000000p3xr.ng.factory('p3xrDialogKeyNew', function (p3xrCommon, $mdDialog, p3xrSocket) { return new function () { this.show = (options) => { return new Promise(async (resolve, reject) => { try { const result = await $mdDialog.show({ controller: function ($scope, $mdDialog) { $scope.types = [ 'string', 'list', 'hash', 'set', 'zset', ] $scope.model = { type: 'string', key: options.node !== undefined ? options.node.key : '', value: undefined, score: undefined, hashKey: undefined, index: undefined, } // Promise reject $scope.cancel = function () { p3xrCommon.toast({ message: p3xr.strings.status.cancelled }) $mdDialog.cancel(); reject() }; /* // Promise resolve $scope.hide = function () { $mdDialog.hide(); }; // Promise resolve - with result $scope.answer = function (answer) { $mdDialog.hide(answer); }; */ const handleInvalidForm = () => { if ($scope.p3xrKeyNewForm.$invalid) { p3xrCommon.toast({ message: p3xr.strings.form.error.invalid }) return false } return true } $scope.submit = async () => { if (!handleInvalidForm()) { return; } try { const response = await p3xrSocket.request({ action: 'key-new', payload: { model: angular.copy($scope.model) }, }) resolve(response) p3xrCommon.toast({ message:p3xr.strings.status.set }) //$scope.options.type = 'edit'; $mdDialog.cancel(); } catch(e) { reject(e) p3xrCommon.generalHandleError(e) } } }, template: require('./p3xr-dialog-key-new.html'), parent: angular.element(document.body), targetEvent: options.$event, clickOutsideToClose: true, fullscreen: true // Only for -xs, -sm breakpoints. }) // console.warn(result) } catch(error) { reject(error) p3xrCommon.generalHandleError(error) } }) } } }); src/angular/dialog/p3xr-dialog-treecontrol-settings.html000066400000000000000000000076531520013332200237520ustar00rootroot00000000000000

{{$root.p3xr.strings.form.treeSettings.label.formName}}

close
{{ $root.p3xr.strings.label.treeSeparatorEmpty }}
{{ $root.p3xr.strings.form.treeSettings.error.page }}
{{ model.keysSort ? $root.p3xr.strings.label.keysSort.on : $root.p3xr.strings.label.keysSort.off }} {{ model.searchClientSide ? $root.p3xr.strings.form.treeSettings.label.searchModeClient : $root.p3xr.strings.form.treeSettings.label.searchModeServer }}
{{ $root.p3xr.strings.page.treeControls.search.info }}
{{ model.searchStartsWith ? $root.p3xr.strings.form.treeSettings.label.searchModeStartsWith : $root.p3xr.strings.form.treeSettings.label.searchModeIncludes }}
cancel {{ $root.p3xr.strings.intention.cancel }} save {{ $root.p3xr.strings.intention.save }}
src/angular/dialog/p3xr-dialog-treecontrol-settings.js000066400000000000000000000075301520013332200234140ustar00rootroot00000000000000p3xr.ng.factory('p3xrDialogTreecontrolSettings', function (p3xrCommon, $mdDialog, $timeout) { return new function () { this.show = async(options) => { try { await $mdDialog.show({ controller: function ($scope, $rootScope) { $scope.model = { treeSeparator: $rootScope.p3xr.settings.redisTreeDivider, pageCount: $rootScope.p3xr.settings.pageCount, keysSort: $rootScope.p3xr.settings.keysSort, searchClientSide: $rootScope.p3xr.settings.searchClientSide, searchStartsWith: $rootScope.p3xr.settings.searchStartsWith, } // Promise reject $scope.cancel = function () { p3xrCommon.toast({ message: p3xr.strings.status.cancelled }) $mdDialog.cancel(); }; /* // Promise resolve $scope.hide = function () { $mdDialog.hide(); }; // Promise resolve - with result $scope.answer = function (answer) { $mdDialog.hide(answer); }; */ const handleInvalidForm = () => { if ($scope.p3xrDialogTreecontrolSettingsForm.$invalid) { p3xrCommon.toast({ message: p3xr.strings.form.error.invalid }) return false } return true } $scope.submit = async () => { if (!handleInvalidForm()) { return; } try { $rootScope.p3xr.settings.redisTreeDivider = $scope.model.treeSeparator $rootScope.p3xr.settings.pageCount = $scope.model.pageCount $rootScope.p3xr.settings.keysSort = $scope.model.keysSort $rootScope.p3xr.settings.searchClientSide = $scope.model.searchClientSide $rootScope.p3xr.settings.searchStartsWith = $scope.model.searchStartsWith $rootScope.p3xr.state.page = 1 $rootScope.p3xr.state.redisChanged = true; $timeout(() => { $rootScope.$digest() }) if ( !$rootScope.p3xr.settings.searchClientSide ) { options.p3xrMainRef.refresh() } //$scope.options.type = 'edit'; $mdDialog.cancel(); } catch(e) { p3xrCommon.generalHandleError(e) } } }, template: require('./p3xr-dialog-treecontrol-settings.html'), parent: angular.element(document.body), targetEvent: options.$event, clickOutsideToClose: true, fullscreen: true // Only for -xs, -sm breakpoints. }) // console.warn(result) } catch(error) { p3xrCommon.generalHandleError(error) } } } }); src/angular/factory/000077500000000000000000000000001520013332200147345ustar00rootroot00000000000000src/angular/factory/p3xr-common.js000066400000000000000000000051311520013332200174540ustar00rootroot00000000000000p3xr.ng.factory('p3xrCommon', function ($mdToast, $mdDialog, $rootScope, p3xrRedisParser) { const generalHandleError = (dataOrError) => { if (dataOrError === undefined) { return; } if (! (dataOrError instanceof Error || dataOrError instanceof Object)) { dataOrError = new Error(dataOrError) } if (dataOrError instanceof Error || dataOrError.status === 'error') { let error if (dataOrError instanceof Error) { error = dataOrError } else { error = dataOrError.error } console.error(error) if (error.hasOwnProperty('code') && p3xr.strings.code.hasOwnProperty(error.code)) { error.message = p3xr.strings.code[error.code] } $mdToast.show( $mdToast.simple() .textContent(error.hasOwnProperty('message') ? error.message : error) .position(p3xr.settings.toast.position) .theme(p3xr.state.themeLayout) .hideDelay(p3xr.settings.toast.timeout) // .capsule(true) ); return false } return true } const toast = (options) => { $mdToast.show( $mdToast.simple() .textContent(options.message) .position(p3xr.settings.toast.position) .theme(p3xr.state.themeLayout) .hideDelay(p3xr.settings.toast.timeout) // .capsule(true) ); } const confirm = (options) => { const confirm = $mdDialog.confirm() .title(p3xr.strings.confirm.title) .textContent(options.message) .targetEvent(options.event) .ok(p3xr.strings.intention.sure) if (!options.hasOwnProperty('disableCancel')) { confirm.cancel(p3xr.strings.intention.cancel); } return $mdDialog.show(confirm) } const loadRedisInfoResponse = (options) => { const { response } = options $rootScope.p3xr.state.info = p3xrRedisParser.info(response.info) if ($rootScope.p3xr.settings.sort) { $rootScope.p3xr.state.keysRaw = response.keys.sort() } else { $rootScope.p3xr.state.keysRaw = response.keys } $rootScope.p3xr.state.keysInfo = response.keysInfo $rootScope.$digest() } return { generalHandleError: generalHandleError, toast: toast, confirm: confirm, loadRedisInfoResponse: loadRedisInfoResponse }; }); src/angular/factory/p3xr-redis-parser.js000066400000000000000000000140331520013332200205650ustar00rootroot00000000000000p3xr.ng.factory('p3xrRedisParser', function ($rootScope) { return new function() { const selfMain = this; this.array = (options) => { const { line } = options let { divider, fieldDivider } = options if (divider === undefined) { divider = ',' } if (fieldDivider === undefined) { fieldDivider = '=' } const rows = line.split(divider) const obj = {} for(let row of rows) { const rowLine = row.split(fieldDivider) obj[rowLine[0]] = rowLine[1].trim() } return obj } this.info = (str) => { const lines = str.split('\n') const obj = {} let section let currentSectionObj for(let line of lines) { if (line.startsWith('#')) { if (section !== undefined) { obj[section] = currentSectionObj } section = line.substring(1).toLowerCase().trim() currentSectionObj = {} } else if (line.length > 2) { const lineArray = line.split(':') currentSectionObj[lineArray[0]] = lineArray[1].includes(',') ? selfMain.array({ line: lineArray[1].trim() }) : lineArray[1].trim() } } if (section !== undefined) { obj[section] = currentSectionObj } if (obj.hasOwnProperty('keyspace')) { obj.keyspaceDatabases = {} Object.keys(obj.keyspace).forEach(key => { key = parseInt(key.substring(2)) obj.keyspaceDatabases[key] = true }) } return obj } // const moment = require('moment') this.keysToTreeControl = (options) => { // const start = Date.now() const { keys } = options let { divider } = options if (divider === undefined) { divider = p3xr.settings.redisTreeDivider } //console.warn(keys) const mainNodes = [] $rootScope.expandedNodes = [] const recursiveNodes = (splitKey, level = 0, nodes = mainNodes) => { let foundNode = false if (level + 1 < splitKey.length) { for(let nodeIndex in nodes) { const node = nodes[nodeIndex] if (node.label === splitKey[level] && node.type === 'folder') { foundNode = node } } } if (foundNode === false) { const defaultFoundNode = { label: splitKey[level], key: splitKey.slice(0, level + 1).join(divider), children: [], childCount: 0, } if (level + 1 === splitKey.length) { //console.warn(splitKey.length - 1 === level)t foundNode = Object.assign(defaultFoundNode, { type: 'element', keysInfo: p3xr.state.keysInfo[defaultFoundNode.key] }) } else { foundNode = Object.assign(defaultFoundNode, { type: 'folder', }) } nodes.push(foundNode) } for(let saveExpandedNode of $rootScope.savedExpandedNodes) { if (saveExpandedNode.key === foundNode.key) { $rootScope.expandedNodes.push(foundNode) } } if (level + 1 < splitKey.length) { recursiveNodes(splitKey, level + 1, foundNode.children) } } for(let key of keys) { let splitkey; if (divider === ''){ splitkey = [key] } else { splitkey = key.split(divider) } recursiveNodes(splitkey) } const generatedKeys = {} const recursiveKeyCount = (node) => { generatedKeys[node.key] = node.children.length; for(let child of node.children) { recursiveKeyCount(child) } } for(let node of mainNodes) { recursiveKeyCount(node) } const recursiveCounterKeys = (node) => { for(let generatedKey of Object.keys(generatedKeys)) { if (generatedKey.startsWith(`${node.key}:`) || generatedKey === node.key ) { node.childCount += generatedKeys[generatedKey] } } for(let child of node.children) { recursiveCounterKeys(child) } } for(let node of mainNodes) { recursiveCounterKeys(node) } //console.warn('key calculate', (Date.now() - start), 'ms' ) $rootScope.savedExpandedNodes = [] return mainNodes } this.console = new function() { const selfConsole = this; selfConsole.parse = (responseResult) => { if (typeof responseResult === 'object') { let result = '' Object.keys(responseResult).forEach(key => { if (result !== '') { result += "\n" } result += responseResult[key] }) return result } else { return responseResult } } } }; }); src/angular/factory/p3xr-socket.js000066400000000000000000000113121520013332200174520ustar00rootroot00000000000000p3xr.ng.factory('p3xrSocket', function ($rootScope, p3xrCommon, $state) { // socket.io now auto-configures its connection when we ommit a connection url const ioOptions = { rejectUnauthorized: false, path: '/socket.io', transports: ['websocket'], secure: true, } const ioClient = io.connect(p3xr.api.host, ioOptions); let reconnect = false; ioClient.on('connect', async function () { if (reconnect) { console.log('p3xr-socket (socket) RE-connected', ioClient.id) //return; } else { console.log('p3xr-socket (socket) connected', ioClient.id) } reconnect = true; }) ioClient.on('disconnect', function () { location.reload() }) let connectErrorWas = false const socketError = async function (error) { if (!connectErrorWas) { connectErrorWas = true; try { p3xrCommon.generalHandleError(error) $state.go('socketio-error', { error: error }) await p3xrCommon.confirm({ disableCancel: false, message: p3xr.strings.confirm.socketioConnectError }) location.reload() } catch(e) { p3xrCommon.generalHandleError(e) } } } ioClient.on('error', socketError) ioClient.on('connect_error', socketError) ioClient.on('connections', (data) => { //console.log(data) if (!p3xrCommon.generalHandleError(data)) { p3xr.connectionsReset() return; } p3xr.state.connections = data.connections $rootScope.$digest() }) ioClient.on('redis-disconnected', async(data) => { if ($rootScope.p3xr.state.connection !== undefined && $rootScope.p3xr.state.connection.id === data.connectionId) { $rootScope.p3xr.state.connection = undefined; if (data.status === 'error') { p3xrCommon.toast({ message: p3xr.strings.status.redisDisconnected(data) }) } else if (data.status === 'code') { if (!p3xr.strings.code.hasOwnProperty(data.code)) { p3xrCommon.toast({ message: `unknown redis disconnect code: ${data.code}` }) } else { p3xrCommon.toast({ message: p3xr.strings.code[data.code] }) } } $state.go('main') try { await request({ action: 'trigger-redis-disconnect', enableResponse: false, }) } catch(e) { p3xrCommon.generalHandleError(e) } //$rootScope.$digest(); } }) ioClient.on('redis-status', (data) => { $rootScope.p3xr.state.redisConnections = data.redisConnections //console.warn(data.redisConnections) $rootScope.$digest(); }) ioClient.on('configuration', (data) => { $rootScope.p3xr.state.cfg = data; $rootScope.$digest(); }) ioClient.on('error', p3xrCommon.generalHandleError) const request = (options) => { let { enableResponse } = options if (enableResponse !== false) { enableResponse = true } if (enableResponse) { return new Promise((resolve, reject) => { options.requestId = p3xr.nextId(); const responseEvent = `p3xr-response-${options.requestId}` let timeout const response = (data) => { clearTimeout(timeout) ioClient.off(responseEvent) if (data.status === 'ok') { resolve(data) } else { const error = new Error(data.error.message) error.code = data.error.code reject(error) } $rootScope.$digest() } timeout = setTimeout(() => { ioClient.off(responseEvent, response) reject(new Error(`socket.io request timeout ${p3xr.settings.socket.timeout}ms`)); $rootScope.$digest() }, p3xr.settings.socket.timeout) ioClient.on(responseEvent, response) ioClient.emit('p3xr-request', options) }) } else { ioClient.emit('p3xr-request', options) } } return { ioClient: ioClient, request: request, }; }); src/angular/injector.js000066400000000000000000000023401520013332200154370ustar00rootroot00000000000000//injector-angular-start require('./dialog/p3xr-dialog-connection.js'); require('./dialog/p3xr-dialog-json-view.js'); require('./dialog/p3xr-dialog-key-new.js'); require('./dialog/p3xr-dialog-treecontrol-settings.js'); require('./factory/p3xr-common.js'); require('./factory/p3xr-redis-parser.js'); require('./factory/p3xr-socket.js'); require('./layout/p3xr-layout.js'); require('./pages/main/key/p3xr-main-key-hash.js'); require('./pages/main/key/p3xr-main-key-list.js'); require('./pages/main/key/p3xr-main-key-set.js'); require('./pages/main/key/p3xr-main-key-string.js'); require('./pages/main/key/p3xr-main-key-zset.js'); require('./pages/main/p3xr-main-key.js'); require('./pages/main/p3xr-main-statistics.js'); require('./pages/main/p3xr-main-treecontrol-controls.js'); require('./pages/main/p3xr-main-treecontrol.js'); require('./pages/p3xr-console.js'); require('./pages/p3xr-error.js'); require('./pages/p3xr-main.js'); require('./pages/p3xr-overview.js'); require('./pages/p3xr-settings.js'); require('./provider/p3xr-theme.js'); require('./provider/theme-generator/p3xr-theme-dark.js'); require('./provider/theme-generator/p3xr-theme-light.js'); require('./ui/p3xr-accordion.js'); require('./ui/p3xr-button.js'); //injector-angular-endsrc/angular/layout/000077500000000000000000000000001520013332200146025ustar00rootroot00000000000000src/angular/layout/p3xr-layout.html000066400000000000000000000062351520013332200177050ustar00rootroot00000000000000
v{{ $root.p3xr.pkg.version }}
src/angular/layout/p3xr-layout.js000066400000000000000000000072461520013332200173600ustar00rootroot00000000000000p3xr.ng.component('p3xrLayout', { template: require('./p3xr-layout.html'), controller: function (p3xrTheme, $rootScope, p3xrSocket, p3xrCommon, $state, $cookies) { this.setTheme = (theme) => { p3xrTheme.setTheme(p3xrTheme.generateThemeName(theme)) } this.openLink = { github: () => { window.open(`https://github.com/patrikx3/${p3xr.pkg.corifeus.reponame}`, `github-patrikx3-${p3xr.pkg.corifeus.reponame}`) } } Object.defineProperty(this, 'themeSelectedKey', { get: () => { let key = p3xr.state.theme key = key.slice('p3xrTheme'.length) key = key.toLowerCase() return key } }) this.$onInit = () => { const connection = $cookies.getObject(p3xr.settings.connectInfo.cookieName) if (connection !== undefined) { this.connect(connection) } } this.connect = async (connection) => { connection = angular.copy(connection) try { p3xr.ui.overlay.show({ message: p3xr.strings.title.connectinRedis }) const db = $cookies.get(p3xr.settings.connection.getCookieNameCurrentDatabase(connection.id)) const response = await p3xrSocket.request({ action: 'connection-connect', payload: { connection: connection, db: db }, }) let dbIndex = 0 const databaseIndexes = [] //console.warn(response) while(dbIndex < response.databases) { databaseIndexes.push(dbIndex++) } $rootScope.p3xr.state.databaseIndexes = databaseIndexes $rootScope.p3xr.state.connection = connection p3xrCommon.loadRedisInfoResponse({ response: response }) $cookies.putObject(p3xr.settings.connectInfo.cookieName, connection, { expires: p3xr.settings.cookieExpiry }) } catch(error) { $cookies.remove(p3xr.settings.connectInfo.cookieName) $rootScope.p3xr.state.connection = undefined p3xrCommon.generalHandleError(error) } finally { p3xr.ui.overlay.hide() } // $rootScope.$digest() } this.disconnect = async () => { try { await p3xrSocket.request({ action: 'connection-disconnect', payload: { connectionId: p3xr.state.connection.id, }, }) $rootScope.p3xr.state.connection = undefined } catch(error) { p3xrCommon.generalHandleError(error) } $cookies.remove(p3xr.settings.connectInfo.cookieName) $state.go('main') // $rootScope.$digest() } Object.defineProperty(this, 'connectionName', { get: () => { if ($rootScope.p3xr.state.connection !== undefined) { return $rootScope.p3xr.strings.label.connected({ name: $rootScope.p3xr.state.connection.name }) } else { return $rootScope.p3xr.strings.intention.connect } } }) this.isMain = () => { return $state.current.name.startsWith('main') } } }) src/angular/layout/p3xr-layout.scss000066400000000000000000000012741520013332200177120ustar00rootroot00000000000000@import '~angular-material/modules/scss/angular-material.layout-attributes'; $height: 64px; .p3xr-layout-content { margin-bottom: $height; margin-top: $height; padding: 5px; position: absolute; left: 0px; right: 0px; } #p3xr-layout-header-container { top: 0px; } #p3xr-layout-footer-container { bottom: 0px; } #p3xr-layout-header-version { position: fixed; z-index: 6; top: 42px; left: 128px; font-size: 75%; } #p3xr-layout-header-container, #p3xr-layout-footer-container { position: fixed; z-index: 5; left: 0px; width: 100%; .md-toolbar-tools { height: $height !important; min-height: $height !important; max-height: $height !important; } } src/angular/pages/000077500000000000000000000000001520013332200143645ustar00rootroot00000000000000src/angular/pages/main/000077500000000000000000000000001520013332200153105ustar00rootroot00000000000000src/angular/pages/main/key/000077500000000000000000000000001520013332200161005ustar00rootroot00000000000000src/angular/pages/main/key/p3xr-main-key-hash.html000066400000000000000000000000611520013332200223100ustar00rootroot00000000000000
{{ $ctrl.p3xrValue }}
src/angular/pages/main/key/p3xr-main-key-hash.js000066400000000000000000000003051520013332200217610ustar00rootroot00000000000000p3xr.ng.component('p3xrMainKeyHash', { template: require('./p3xr-main-key-hash.html'), bindings: { p3xrValue: '=', p3xKey: '<' }, controller: function() { } }) src/angular/pages/main/key/p3xr-main-key-list.html000066400000000000000000000046571520013332200223570ustar00rootroot00000000000000
{{ $root.p3xr.strings.page.key.list.table.index }} {{ $root.p3xr.strings.page.key.list.table.value }}
{{ $index }}  
{{ value }}
table_chart delete
src/angular/pages/main/key/p3xr-main-key-list.js000066400000000000000000000045301520013332200220150ustar00rootroot00000000000000p3xr.ng.component('p3xrMainKeyList', { template: require('./p3xr-main-key-list.html'), bindings: { p3xrValue: '=', p3xrKey: '<' }, controller: function($mdColors, p3xrCommon, p3xrSocket, $rootScope, p3xrDialogJsonView) { this.editingValue = { } this.model = { } this.editValue = (options) => { const { $index, value } = options this.editingValue[$index] = true this.model[$index] = { index: $index, value: value } } this.cancelEditValue = (options) => { const { $index } = options this.editingValue[$index] = false } this.saveEditValue = async (options) => { try { const { $index } = options const model = this.model[$index] const response = await p3xrSocket.request({ action: 'key-list-set', payload: { key: this.p3xrKey, model: model, } }) $rootScope.$broadcast('p3x-refresh-key'); this.editingValue[$index] = false } catch(e) { p3xrCommon.generalHandleError(e) } } this.deleteListElement = async (options) => { try { const response = await p3xrSocket.request({ action: 'key-list-delete-index', payload: { key: this.p3xrKey, index: options.index, } }) $rootScope.$broadcast('p3x-refresh-key'); } catch(e) { p3xrCommon.generalHandleError(e) } } this.showJson = (options) => { const { value } = options; p3xrDialogJsonView.show({ value: value }) } this.setTableStyles = (options) => { const { $odd } = options if (!$odd) { return ''; } let style = ''; const bg = $mdColors.getThemeColor(`${p3xr.state.themeLayout}-background-500-0.1`) style += `background-color: ${bg};` return style; } } }) src/angular/pages/main/key/p3xr-main-key-list.scss000066400000000000000000000012261520013332200223530ustar00rootroot00000000000000p3xr-main-key-list { table.p3xr-main-key-list-table { table-layout:fixed; max-width:100%; width: 100%; border-collapse: collapse; td { vertical-align: top; } thead { tr { td:first-child { text-align: center; } td { padding: 5px; } td:last-child { white-space: nowrap; } } } tbody { tr { td:first-child { text-align: right; white-space: nowrap; } td { } td:last-child { text-align: right; white-space: nowrap; } } } } } src/angular/pages/main/key/p3xr-main-key-set.html000066400000000000000000000000631520013332200221620ustar00rootroot00000000000000
{{ $ctrl.p3xrValue }}
src/angular/pages/main/key/p3xr-main-key-set.js000066400000000000000000000003031520013332200216270ustar00rootroot00000000000000p3xr.ng.component('p3xrMainKeySet', { template: require('./p3xr-main-key-set.html'), bindings: { p3xrValue: '=', p3xKey: '<' }, controller: function() { } }) src/angular/pages/main/key/p3xr-main-key-string.html000066400000000000000000000022561520013332200227030ustar00rootroot00000000000000
table_chart {{ $root.p3xr.strings.intention.jsonViewShow }} edit {{ $root.p3xr.strings.intention.edit }} cancel {{ $root.p3xr.strings.intention.cancel }} save {{ $root.p3xr.strings.intention.save }}
{{ $ctrl.p3xrValue }}
src/angular/pages/main/key/p3xr-main-key-string.js000066400000000000000000000024561520013332200223550ustar00rootroot00000000000000p3xr.ng.component('p3xrMainKeyString', { template: require('./p3xr-main-key-string.html'), bindings: { p3xrValue: '=', p3xrKey: '<' }, controller: function(p3xrSocket, p3xrCommon, $rootScope, p3xrDialogJsonView) { this.editable = false; let originalValue this.edit = () => { originalValue = angular.copy(this.p3xrValue) this.editable = true } this.cancelEdit = () => { this.p3xrValue = originalValue this.editable = false } this.save = async () => { try { const response = await p3xrSocket.request({ action: 'key-set', payload: { type: $rootScope.p3xr.state.keysInfo[this.p3xrKey].type, value: this.p3xrValue, key: this.p3xrKey, } }) this.editable = false } catch(e) { p3xrCommon.generalHandleError(e) } } this.jsonViewer = (options) => { p3xrDialogJsonView.show({ event: options.$event, value: this.p3xrValue }) // this.showJson = !this.showJson } } }) src/angular/pages/main/key/p3xr-main-key-string.scss000066400000000000000000000000771520013332200227110ustar00rootroot00000000000000p3xr-main-key-string { textarea { width: 100%; } } src/angular/pages/main/key/p3xr-main-key-zset.html000066400000000000000000000000611520013332200223520ustar00rootroot00000000000000
{{ $ctrl.p3xrValue }}
src/angular/pages/main/key/p3xr-main-key-zset.js000066400000000000000000000003051520013332200220230ustar00rootroot00000000000000p3xr.ng.component('p3xrMainKeyZset', { template: require('./p3xr-main-key-zset.html'), bindings: { p3xrValue: '=', p3xKey: '<' }, controller: function() { } }) src/angular/pages/main/p3xr-main-key.html000066400000000000000000000101311520013332200205760ustar00rootroot00000000000000 refresh {{ $root.p3xr.strings.intention.reloadKey }} delete {{ $root.p3xr.strings.intention.delete }} fingerprint {{ $root.p3xr.strings.intention.rename }} {{ $root.p3xr.strings.label.ttlTitle }} timer {{ $root.p3xr.strings.intention.ttl }}

{{ $root.p3xr.strings.page.key.label.key }}: 

{{ $ctrl.$stateParams.key }}

{{ $root.p3xr.strings.page.key.label.type }}:

{{ $root.p3xr.state.keysInfo[$ctrl.$stateParams.key].type }}

{{ $root.p3xr.strings.page.key.label.encoding }}:

{{ $ctrl.response.encoding }}

{{ $root.p3xr.strings.page.key.label.length }}:

{{ $ctrl.charactersPrettyBytes($root.p3xr.state.keysInfo[$ctrl.$stateParams.key].length) }}   {{ $root.p3xr.state.keysInfo[$ctrl.$stateParams.key].length }}   {{ $root.p3xr.strings.page.key.label.lengthString }} {{ $root.p3xr.strings.page.key.label.lengthItem }}

{{ $root.p3xr.strings.page.key.label.ttl }}:

{{ $root.p3xr.strings.page.key.label.ttlNotExpire }} ({{ $ctrl.ttlParsed }}) {{ $ctrl.response.ttl }}
src/angular/pages/main/p3xr-main-key.js000066400000000000000000000140251520013332200202540ustar00rootroot00000000000000//const debounce = require('lodash/debounce') p3xr.ng.component('p3xrMainKey', { template: require('./p3xr-main-key.html'), bindings: { p3xrResize: '&', }, controller: function(p3xrCommon, p3xrRedisParser, p3xrSocket, $rootScope, $stateParams, $timeout, $scope, $mdDialog, $state) { this.$stateParams = $stateParams; const loadKey = async(options = {}) => { let { withoutParent } = options if (withoutParent === undefined) { withoutParent = false } try { // it can throw an error, when we switch the database p3xr.ui.overlay.show({ message: p3xr.strings.intention.getKey }) const type = p3xr.state.keysInfo[$stateParams.key].type const response = await p3xrSocket.request({ action: 'key-get', payload: { key: $stateParams.key, type: type, } }) if (response.ttl === -2) { p3xrCommon.toast({ message: p3xr.strings.status.keyIsNotExisting }) $rootScope.$broadcast('p3x-refresh') $state.go('main.statistics') return; } if (response.ttl > 0) { const parsedTtl = require('parse-ms')(response.ttl * 1000) // console.log(parsedTtl) let parsedTtlString = '' let hadValue = false for(let timeType of ['days', 'hours', 'minutes', 'seconds']) { if (parsedTtl[timeType] > 0 || hadValue) { hadValue = true parsedTtlString += ' ' + parsedTtl[timeType] + ' ' + p3xr.strings.time[timeType] } } this.ttlParsed = parsedTtlString.trim() } switch(type) { case 'zset': const scores = Object.keys(response.score).sort() const sortedScores = [] for(let score of scores) { sortedScores.push([parseInt(score), response.score[score]]) } break; case 'string': // console.warn(response) p3xr.state.keysInfo[$stateParams.key].length = response.value.length break; } this.response = response } catch(e) { p3xrCommon.generalHandleError(e) } finally { if (!withoutParent) { $stateParams.resize() } $timeout(() => { p3xr.ui.overlay.hide() }, p3xr.settings.debounce) } } this.$onInit = () => loadKey() this.charactersPrettyBytes = (length) => { if (length < 1024 || length === undefined) { return '' } const prettyBytes = require('pretty-bytes'); return '(' + prettyBytes(length) + ')' } this.refresh = (options) => { loadKey(options) } this.rename = async (opts) => { $rootScope.$broadcast('p3xr-key-rename', { key: $stateParams.key, $event: opts.$event, }); } this.delete = async() => { $rootScope.$broadcast('p3xr-key-delete', { key: $stateParams.key }); } this.setTtl = async (options) => { try { const confirm = $mdDialog.prompt() .title(p3xr.strings.confirm.ttl.title) .textContent(p3xr.strings.confirm.ttl.textContent) .placeholder(p3xr.strings.confirm.ttl.placeholder) .ariaLabel(p3xr.strings.confirm.ttl.placeholder) .initialValue(this.response.ttl === -1 ? '' : this.response.ttl) .targetEvent(options.$event) .ok(p3xr.strings.intention.ttl) .cancel(p3xr.strings.intention.cancel); const confirmResponse = await $mdDialog.show(confirm) if (confirmResponse === undefined || confirmResponse.trim() === '') { const response = await p3xrSocket.request({ action: 'persist', payload: { key: $stateParams.key, } }) await this.refresh() p3xrCommon.toast({ message: p3xr.strings.status.persisted }) } else if (!confirmResponse.match(/^-{0,1}\d+$/)) { p3xrCommon.toast({ message: p3xr.strings.status.notInteger }) } else { const response = await p3xrSocket.request({ action: 'expire', payload: { key: $stateParams.key, ttl: parseInt(confirmResponse), } }) await this.refresh() p3xrCommon.toast({ message: p3xr.strings.status.ttlChanged }) } } catch(e) { p3xrCommon.generalHandleError(e) } } // const refreshDebounced = debounce(this.refresh, 1000) $scope.$on('p3x-refresh', () => { this.refresh({ withoutParent: true }) }) $scope.$on('p3x-refresh-key', () => { this.refresh({ withoutParent: true }) }) } }) src/angular/pages/main/p3xr-main-key.scss000066400000000000000000000003761520013332200206170ustar00rootroot00000000000000p3xr-main-key { .p3xr-main-key-label-key-title { border-bottom-style: dotted; border-bottom-width: 1px; border-bottom-color: rgba(128, 128, 128, 0.5); cursor: pointer; } md-list-item { p { font-weight: bold; } } }src/angular/pages/main/p3xr-main-statistics.html000066400000000000000000000024331520013332200222060ustar00rootroot00000000000000

{{ $ctrl.generateKey(itemKey) }}

{{ itemValue }}

{{ $ctrl.generateKey(itemKey) }}

{{ itemValue }}
src/angular/pages/main/p3xr-main-statistics.js000066400000000000000000000017261520013332200216620ustar00rootroot00000000000000p3xr.ng.component('p3xrMainStatistics', { template: require('./p3xr-main-statistics.html'), controller: function(p3xrCommon, p3xrRedisParser, p3xrSocket, $rootScope) { const exclude = ['in', 'run', 'per'] const include = ['sha1', ] const replace = { 'perc': 'percent', 'sec': 'seconds' } this.generateKey = (key) => { const keyElem = key.split('_').map((instance, index) => { if (replace.hasOwnProperty(instance)) { instance = replace[instance] } if (include.includes(instance) || (instance.length < 4 && !exclude.includes(instance))) { return instance.toUpperCase() } else if (index === 0) { return instance[0].toUpperCase() + instance.substring(1) } return instance }) return keyElem.join(' ') } } }) src/angular/pages/main/p3xr-main-treecontrol-controls.html000066400000000000000000000062751520013332200242250ustar00rootroot00000000000000
{{ $root.p3xr.strings.page.treeControls.expandAll}} keyboard_arrow_down {{ $root.p3xr.strings.page.treeControls.collapseAll}} keyboard_arrow_up
{{ $root.p3xr.strings.status.keyCount({keyCount: $root.p3xr.state.keysRaw.length }) }} {{ $root.p3xr.strings.page.treeControls.pager.first}} skip_previous {{ $root.p3xr.strings.page.treeControls.pager.prev}} keyboard_arrow_left / {{ $root.p3xr.state.pages }} {{ $root.p3xr.strings.page.treeControls.pager.next}} keyboard_arrow_right {{ $root.p3xr.strings.page.treeControls.pager.last}} skip_next
{{ $root.p3xr.strings.form.treeSettings.label.formName}} settings
src/angular/pages/main/p3xr-main-treecontrol-controls.js000066400000000000000000000064771520013332200237010ustar00rootroot00000000000000p3xr.ng.component('p3xrMainTreecontrolControls', { template: require('./p3xr-main-treecontrol-controls.html'), bindings: { p3xrMainRef: '<' }, controller: function($cookies, $rootScope, p3xrCommon, $timeout, p3xrDialogTreecontrolSettings) { this.treeExpandAll = () => { try { p3xr.ui.overlay.show({ message: p3xr.strings.status.treeExpandAll }) let expandedNodes = [] const recursiveFolders = (node, level = 0) => { if (node.type === 'folder') { expandedNodes.push(node) for(let childNode of node.children) { recursiveFolders(childNode, level++) } } } for(let node of $rootScope.keysTreeRendered) { recursiveFolders(node) } $rootScope.expandedNodes = expandedNodes } catch(e) { p3xrCommon.generalHandleError(e) } finally { $timeout(() => { p3xr.ui.overlay.hide() }, p3xr.settings.debounce) } } this.treeCollapseAll = () => { $rootScope.expandedNodes = [] } this.page = (options) => { const { page } = options ///console.log(page ) switch(page) { case 'prev': if ($rootScope.p3xr.state.page - 1 >= 1) { $rootScope.p3xr.state.page = $rootScope.p3xr.state.page - 1 } break; case 'next': if ($rootScope.p3xr.state.page + 1 <= $rootScope.p3xr.state.pages) { $rootScope.p3xr.state.page = $rootScope.p3xr.state.page + 1 } break; case 'last': $rootScope.p3xr.state.page = $rootScope.p3xr.state.pages break; case 'first': $rootScope.p3xr.state.page = 1 break; } $timeout(() => { $rootScope.$digest() }) } this.pageChange = () => { if ($rootScope.p3xr.state.page < 1) { $rootScope.p3xr.state.page = 1 } else if ($rootScope.p3xr.state.page > $rootScope.p3xr.state.pages) { $rootScope.p3xr.state.page = $rootScope.p3xr.state.pages } } this.openTreeSettingDialog = (opts) => { opts.p3xrMainRef = this.p3xrMainRef p3xrDialogTreecontrolSettings.show(opts); //console.warn($rootScope.p3xr.state.redisTreeDivider) } const debounce = require('lodash/debounce') const debouncedOnSearchChange = debounce(() => { if ($rootScope.p3xr.settings.searchClientSide) { // $rootScope.p3xr.settings.searchClientSide // $rootScope.p3xr.settings.searchStartsWith $rootScope.p3xr.state.redisChanged = true } else { this.p3xrMainRef.refresh() } }, p3xr.settings.debounceSearch ) this.onSearchChange = debouncedOnSearchChange } }) src/angular/pages/main/p3xr-main-treecontrol-controls.scss000066400000000000000000000011201520013332200242140ustar00rootroot00000000000000p3xr-main-treecontrol-controls { margin-top: 2px; display: block; text-align: center; min-height: 24px; .md-icon-button { height: auto !important; min-height: auto !important;; width: auto !important;; min-width: auto !important;; margin: 0 !important;; padding: 0 !important; } .p3xr-main-treecontrol-controls-search { clear: both; text-align: left; padding: 5px; input { width: calc(100% - 40px) !important; max-width: 300px !important; } } }src/angular/pages/main/p3xr-main-treecontrol.html000066400000000000000000000045761520013332200223660ustar00rootroot00000000000000 {{ $ctrl.extractNodeTooltip(node) }} src/angular/pages/main/p3xr-main-treecontrol.js000066400000000000000000000153751520013332200220350ustar00rootroot00000000000000p3xr.ng.component('p3xrMainTree', { template: require('./p3xr-main-treecontrol.html'), bindings: { p3xrResize: '&', p3xrMainRef: '<' }, controller: function(p3xrCommon, p3xrRedisParser, p3xrSocket, $rootScope, $timeout, $state, $scope, $mdDialog, p3xrDialogKeyNew) { this.$onInit = () => { this.p3xrResize() } this.getTreeTheme = () => { if (p3xr.state.theme.toLowerCase().includes('light')) { return 'tree-classic' } return 'tree-dark' } this.keysTreeOptions = { nodeChildren: "children", dirSelectable: false, multiSelection: false, /* injectClasses: { ul: "a1", li: "a2", liSelected: "a7", iExpanded: "a3", iCollapsed: "a4", iLeaf: "a5", label: "a6", labelSelected: "a8" } */ }; this.selectTreeNode = function(node, selected, $parentNode, $index, $first, $middle, $last, $odd, $even, $path) { //console.warn('selectTreeNode', arguments) $state.go('main.key', { key: node.key, resize: this.p3xrResize, }) } this.showToggle = function(node, expanded, $parentNode, $index, $first, $middle, $last, $odd, $even, $path) { // console.warn('showToggle', arguments, $path()) /* p3xrCommon.toast({ message: 'key ' + node.key }) */ } this.delete = async(options) => { try { await p3xrCommon.confirm({ message: p3xr.strings.confirm.deleteKey }) const expandedNodes = angular.copy($rootScope.expandedNodes); const response = await p3xrSocket.request({ action: 'delete', payload: { key: options.key } }) $timeout(() => { $rootScope.savedExpandedNodes = expandedNodes p3xrCommon.loadRedisInfoResponse({ response: response}) }) $state.go('main.statistics') p3xrCommon.toast({ message: p3xr.strings.status.deletedKey({ key: options.key }) }) } catch(e) { p3xrCommon.generalHandleError(e) } } this.rename = async(options) => { try { const confirm = $mdDialog.prompt() .title(p3xr.strings.confirm.rename.title) .textContent(p3xr.strings.confirm.rename.textContent) .placeholder(p3xr.strings.confirm.rename.placeholder) .ariaLabel(p3xr.strings.confirm.rename.placeholder) .initialValue(options.key) .targetEvent(options.$event) .required(true) .ok(p3xr.strings.intention.rename) .cancel(p3xr.strings.intention.cancel); const confirmResponse = await $mdDialog.show(confirm) const expandedNodes = angular.copy($rootScope.expandedNodes); const response = await p3xrSocket.request({ action: 'rename', payload: { key: options.key, keyNew: confirmResponse, } }) $timeout(() => { $rootScope.savedExpandedNodes = expandedNodes p3xrCommon.loadRedisInfoResponse({ response: response}) $state.go('main.key', { key: confirmResponse, resize: this.p3xrResize, }) }) p3xrCommon.toast({ message: p3xr.strings.status.renamedKey }) } catch(e) { p3xrCommon.generalHandleError(e) } } this.deleteTree = async(options) => { try { const { event, node} = options // event.preventDefault() event.stopPropagation(); const expandedNodes = angular.copy($rootScope.expandedNodes); await p3xrCommon.confirm({ event: event, message: p3xr.strings.confirm.deleteAllKeys({ key: node.key }) }) const response = await p3xrSocket.request({ action: 'key-del-tree', payload: { key: node.key, redisTreeDivider: p3xr.settings.redisTreeDivider } }) $timeout(() => { $rootScope.savedExpandedNodes = expandedNodes p3xrCommon.loadRedisInfoResponse({ response: response}) }) p3xrCommon.toast({ message: p3xr.strings.status.treeDeleted({ key: node.key }) }) } catch(e) { p3xrCommon.generalHandleError(e) } } this.extractNodeTooltip = (node) => { if (node.type !== 'folder') { return p3xr.ui.htmlEncode(node.keysInfo.type + ' - ' + node.key) } return p3xr.ui.htmlEncode(node.key) } this.addKey = async (options) => { const { event, node} = options event.stopPropagation(); const expandedNodes = angular.copy($rootScope.expandedNodes); try { const response = await p3xrDialogKeyNew.show({ $event: event, node: node, }) $timeout(() => { $rootScope.savedExpandedNodes = expandedNodes p3xrCommon.loadRedisInfoResponse({ response: response}) $state.go('main.key', { key: response.key, resize: this.p3xrResize, }) }) } catch(e) { p3xrCommon.generalHandleError(e) } } $scope.$on('p3xr-key-delete', (event, arg) => { this.delete(arg) }); $scope.$on('p3xr-key-rename', (event, arg) => { this.rename(arg) }); $scope.$on('p3xr-key-new', (event, arg) => { this.addKey(arg) }); } }) src/angular/pages/main/p3xr-main-treecontrol.scss000066400000000000000000000010671520013332200223650ustar00rootroot00000000000000p3xr-main { treecontrol { ul { overflow: visible !important; /*# STEP1 #### Override overflow attribute like uncledb said */ } .tree-leaf-head { display: none !important; background-image: none; } } treecontrol > ul > li { padding-left: 0; } .p3xr-main-tree { .p3xr-main-tree-node { line-height: 28px !important; white-space: nowrap; /*# STEP-2 #Set nowrap for node labels ###### THIS DID THE TRICK FOR ME ########*/ .p3xr-main-tree-node-count { opacity: 0.5; } } } }src/angular/pages/p3xr-console.html000066400000000000000000000014021520013332200176030ustar00rootroot00000000000000

{{ $root.p3xr.strings.label.console }}

src/angular/pages/p3xr-console.js000066400000000000000000000161771520013332200172720ustar00rootroot00000000000000let actionHistory = [] let actionHistoryPosition = -1 p3xr.ng.component('p3xrConsole', { template: require('./p3xr-console.html'), controller: function(p3xrCommon, p3xrSocket, $state, $rootScope, p3xrRedisParser, $mdDialog) { // .p3xr-layout-footer-container // .p3xr-layout-header-container // #p3xr-console-header // #p3xr-console-input // $window.height() let $container let $header; let $footer; let $consoleHeader let $input let $output let scrollers if (!$rootScope.hasConnected()) { $state.go('main') } const debounce = require('lodash/debounce') const resize = debounce(() => { let minus = 0 for(let item of [$header, $footer, $consoleHeader, $input]) { minus += item.outerHeight() } const windowHeight = $window.height() //console.log(windowHeight, minus) const outputHeight = Math.max(windowHeight - minus - 50, 100) $container.height(outputHeight) $container.css('max-height', `${outputHeight}px`) }, p3xr.settings.debounce) this.$onInit = () => { $container = $('#p3xr-console-content') $header = $('#p3xr-layout-header-container') $footer = $('#p3xr-layout-footer-container') $consoleHeader = $('#p3xr-console-header') $input = $('#p3xr-console-input') $output = $('#p3xr-console-content-output') $input.focus() scrollers = $container[0] $window.on('resize', resize) resize() this.clearConsole() } this.$onDestroy = function () { $window.off('resize', resize) }; this.inputValue = '' this.actionEnter = async() => { try { const enter = String(this.inputValue).trim() if (enter === '') { return; } $output.append(`
${enter}
`) this.inputValue = '' const actionHistoryIndexOf = actionHistory.indexOf(response.generatedCommand) if (actionHistoryIndexOf > -1) { actionHistory.splice(actionHistoryIndexOf, 1) } actionHistory.push(response.generatedCommand) if (actionHistory.length > 20) { actionHistory = actionHistory.slice(0, 20) } actionHistoryPosition = -1 const response = await p3xrSocket.request({ action: 'console', payload: { command: enter } }) //console.warn(typeof response.result, response.result, response.generatedCommand) const result = p3xrRedisParser.console.parse(response.result) $output.append(`
${result}
`) if (response.hasOwnProperty('database')) { $rootScope.p3xr.state.currentDatabase = response.database $rootScope.p3xr.state.redisChanged = true } } catch(e) { $output.append(`
${e.message}
`) } finally { //console.log(scrollers.scrollHeight, scrollers.scrollTop, scrollers.height) scrollers.scrollTop = scrollers.scrollHeight; //$output.scrollTop($output.prop("scrollHeight")); $input.focus() } } this.action = ($event) => { //console.warn($event.keyCode) switch($event.keyCode) { // enter case 13: return this.actionEnter() // keyup 38 case 38: if (actionHistory.length < 1) { return; } if (actionHistoryPosition === -1) { actionHistoryPosition = actionHistory.length } actionHistoryPosition-- if (actionHistoryPosition > -1) { } else { actionHistoryPosition = actionHistory.length -1 } this.inputValue = actionHistory[actionHistoryPosition] break; // keydown 40 case 40: if (actionHistory.length < 1) { return; } actionHistoryPosition++ if (actionHistoryPosition >= actionHistory.length ) { } else { actionHistoryPosition = 0 } this.inputValue = actionHistory[actionHistoryPosition] break; case 9: $event.stopPropagation(); $event.preventDefault(); break; default: actionHistoryPosition = -1 break; } } this.clearConsole = () => { $output.empty() $output.append('
' + $rootScope.p3xr.strings.label.welcomeConsole + '
') $input.focus() } this.commands = () => { $mdDialog.show({ controller: function ($scope, $mdDialog ) { $scope.ok = function () { $mdDialog.hide(); }; $scope.$watch(function () { const height = $('#p3xr-console-commands').parent().height(); return height; }, (newValue, oldValue) => { $scope.height = newValue; }) }, fullscreen: true, template: `
keyboard   {{ $root.p3xr.strings.intention.commands }} close
close {{ $root.p3xr.strings.intention.close }}
`, }); } } }) src/angular/pages/p3xr-console.scss000066400000000000000000000011321520013332200176120ustar00rootroot00000000000000p3xr-console { #p3xr-console-content { font-family: monospace, monospace !important; $minWidthCalc: 20px; text-align: center; #p3xr-console-content-output { pre { font-family: monospace, monospace !important; white-space: pre-wrap; } min-width: calc(100% - #{$minWidthCalc}); text-align: left; .p3xr-console-content-output-item:before { content: "> "; opacity: 0.5; } } input { min-width: calc(100% - 40px); position: fixed; bottom: 75px; left: 10px; right: 10px; } } }src/angular/pages/p3xr-error.html000066400000000000000000000010021520013332200172660ustar00rootroot00000000000000

{{ $root.p3xr.strings.title.socketioConnectError }}



{{ $ctrl.$stateParams.error.message }}
src/angular/pages/p3xr-error.js000066400000000000000000000003441520013332200167460ustar00rootroot00000000000000p3xr.ng.component('p3xrError', { template: require('./p3xr-error.html'), controller: function($stateParams, $rootScope) { this.$stateParams = $stateParams $rootScope.p3xr.state.failed = true; } }) src/angular/pages/p3xr-main.html000066400000000000000000000100701520013332200170660ustar00rootroot00000000000000

{{ $root.p3xr.strings.intention.main }}

save {{ $root.p3xr.strings.intention.save }} {{ $root.p3xr.strings.form.main.label.database }} radio_button_checked radio_button_unchecked {{ dbIndex }} show_chart {{ $root.p3xr.strings.intention.statistics }} keyboard {{ $root.p3xr.strings.intention.console }} refresh {{ $root.p3xr.strings.intention.refresh }}
{{ $root.p3xr.strings.title.main }}
{{ $root.p3xr.strings.intention.noConnections }}
src/angular/pages/p3xr-main.js000066400000000000000000000206631520013332200165470ustar00rootroot00000000000000p3xr.ng.component('p3xrMain', { template: require('./p3xr-main.html'), controller: function($cookies, p3xrSocket, p3xrCommon, p3xrRedisParser, $rootScope, $state, $timeout, $scope, p3xrDialogKeyNew) { let $container let $header; let $footer; let $consoleHeader let scrollers const debounce = require('lodash/debounce') const resize = debounce(() => { //console.warn('who is resizing non stop') let minus = 0 for(let item of [$header, $footer, $consoleHeader]) { minus += item.outerHeight() } const windowHeight = $window.outerHeight() //console.log(windowHeight, minus) const outputPositionMinus = 28 const outputHeight = Math.max(windowHeight - minus- outputPositionMinus, 100) $container.height(outputHeight) $container.css('max-height', `${outputHeight}px`) const containerPosition = p3xr.dom.getPosition($container[0]) const $treeControl = $('#p3xr-main-treecontrol-container') if ($treeControl) { const $treeControlControls = $('#p3xr-main-treecontrol-controls-container') const treeControlControlsPosition = p3xr.dom.getPosition($treeControlControls[0]) $treeControl.css('top', (containerPosition.top + treeControlControlsPosition.height) + 'px') $treeControl.css('left', containerPosition.left + 'px'); $treeControl.css('height', (containerPosition.height - treeControlControlsPosition.height) + 'px') $treeControl.css('max-height', containerPosition.height + 'px') $treeControl.css('width', '33%') $treeControl.css('min-width', '320px') const treeControlPosition = p3xr.dom.getPosition($treeControl[0]) const $content = $('#p3xr-main-content-container'); $content.css('top', containerPosition.top + 'px') $content.css('left', (containerPosition.left + treeControlPosition.width ) + 'px') $content.css('width', (containerPosition.width - treeControlPosition.width ) + 'px') $content.css('height', containerPosition.height + 'px') $treeControlControls.width(treeControlPosition.width) } }, p3xr.settings.debounce) this.resize = resize this.$onInit = () => { $container = $('#p3xr-main-content') $header = $('#p3xr-layout-header-container') $footer = $('#p3xr-layout-footer-container') $consoleHeader = $('#p3xr-main-header') scrollers = $container[0] resize() $window.on('resize', resize) $state.go('main.statistics') if (p3xr.state.redisChanged) { p3xr.state.redisChanged = false; this.refresh() } } this.$onDestroy = function () { $window.off('resize', resize) }; $rootScope.p3xr.state.page = 1; let selectedDatabase = 0 let currentDatabase Object.defineProperty(this, 'currentDatabase', { get: () => { let currentDatabase = p3xr.state.currentDatabase if (currentDatabase === undefined) { currentDatabase = $cookies.get(p3xr.settings.connection.getCookieNameCurrentDatabase(p3xr.state.connection.id)) } if (currentDatabase === undefined) { currentDatabase = 0; } return currentDatabase; }, set: async(value) => { currentDatabase = value if (selectedDatabase !== currentDatabase) { selectedDatabase = value try { const response = await p3xrSocket.request({ action: 'console', payload: { command: `select ${selectedDatabase}` } }) } catch(e) { p3xrCommon.generalHandleError(e) } } $cookies.put(p3xr.settings.connection.getCookieNameCurrentDatabase(p3xr.state.connection.id), String(value), { expires: p3xr.settings.cookieExpiry, }) } }) this.selectDatabase = async(selectDbIndex) => { this.currentDatabase = selectDbIndex try { $rootScope.p3xr.state.page = 1; const response = await p3xrSocket.request({ action: 'console', payload: { command: `select ${selectDbIndex}` } }) p3xrCommon.toast({ message: p3xr.strings.status.dbChanged({ db: selectDbIndex }) }) await this.statistics() } catch(e) { p3xrCommon.generalHandleError(e) } finally { resize() } } this.save = async () => { try { const response = await p3xrSocket.request({ action: 'save', }) $rootScope.p3xr.state.info = p3xrRedisParser.info(response.info) $rootScope.$digest() p3xrCommon.toast({ message: p3xr.strings.status.savedRedis }) } catch(e) { p3xrCommon.generalHandleError(e) } } this.statistics = async () => { try { await this.refresh() $state.go('main.statistics') } catch(e) { p3xrCommon.generalHandleError(e) } } this.refresh = async (options = {}) => { let { withoutParent } = options if (withoutParent === undefined) { withoutParent = false } try { p3xr.ui.overlay.show({ message: p3xr.strings.status.reloadingDataInfo }) const payload = {} if (!$rootScope.p3xr.settings.searchClientSide && typeof ($rootScope.p3xr.state.search) === 'string' && $rootScope.p3xr.state.search.length > 0) { if ($rootScope.p3xr.settings.searchStartsWith) { payload.match = $rootScope.p3xr.state.search + '*'; } else { payload.match = '*' + $rootScope.p3xr.state.search + '*'; } } const response = await p3xrSocket.request({ action: 'refresh', payload: payload }) p3xrCommon.loadRedisInfoResponse({ response: response }) if (!withoutParent) { $rootScope.$broadcast('p3x-refresh'); } } catch(e) { p3xrCommon.generalHandleError(e) } finally { $timeout(() => { p3xr.ui.overlay.hide() }, p3xr.settings.debounce) } } $scope.$on('p3x-refresh', () => { this.refresh({ withoutParent: true }) }) this.addKey = (options) => { const { event, node} = options // event.preventDefault() event.stopPropagation(); $rootScope.$broadcast('p3xr-key-new', { event: event, node: node, }); } /* redis version = server - redis_version keys = keyspace - dbIndex -> keys memory used -> memory - used_memory_human uptime -> server - uptime_in_days last save - save = 0) { echo format_time(time() - $info[$i]['Persistence']['rdb_last_save_time']) . " ago"; } else { echo format_time(-(time() - $info[$i]['Persistence']['rdb_last_save_time'])) . "in the future"; } } else { echo 'never'; } ?> */ } }) src/angular/pages/p3xr-main.scss000066400000000000000000000005621520013332200171020ustar00rootroot00000000000000p3xr-main { #p3xr-main-treecontrol-container { position: fixed; overflow: auto; } #p3xr-main-treecontrol-container-directive-small { max-height: 320px; overflow: auto; } .p3xr-main-treecontrol-folder-icon { transform: scale(0.75); } #p3xr-main-content-container { position: fixed; overflow: auto; display: block; } }src/angular/pages/p3xr-overview.html000066400000000000000000000016531520013332200200170ustar00rootroot00000000000000 {{ $root.p3xr.strings.page.overview.overviewClients }}

{{ connectionValue.connection.name }}

{{ connectionValue.connection.host }}:{{ connectionValue.connection.port }}

{{ $root.p3xr.strings.page.overview.connectedCount({ length: connectionValue.clients.length }) }}

src/angular/pages/p3xr-overview.js000066400000000000000000000003371520013332200174650ustar00rootroot00000000000000p3xr.ng.component('p3xrOverview', { template: require('./p3xr-overview.html'), controller: function($rootScope, $state) { if (!$rootScope.hasConnected()) { $state.go('main') } } }) src/angular/pages/p3xr-settings.html000066400000000000000000000131671520013332200200140ustar00rootroot00000000000000
{{ $root.p3xr.strings.intention.noConnectionsInSettings }}

{{connection.name}}

{{connection.host}}:{{connection.port}}

edit {{ $root.p3xr.strings.intention.edit }} {{ $root.p3xr.strings.intention.edit }} mode_comment {{ $root.p3xr.strings.intention.view }} {{ $root.p3xr.strings.intention.view }} delete_forever {{ $root.p3xr.strings.intention.delete }} {{ $root.p3xr.strings.intention.delete }}

{{ $root.p3xr.strings.form.treeSettings.field.treeSeparator}}
{{ $root.p3xr.settings.redisTreeDivider}} {{ $root.p3xr.strings.label.treeSeparatorEmptyNote}}
{{ $root.p3xr.strings.form.treeSettings.field.page}}
{{ $root.p3xr.settings.pageCount}}
{{ $root.p3xr.strings.form.treeSettings.field.keysSort}}
{{ $root.p3xr.settings.keysSort ? $root.p3xr.strings.label.keysSort.on : $root.p3xr.strings.label.keysSort.off }}
{{ $root.p3xr.strings.form.treeSettings.field.searchMode}}
{{ $root.p3xr.settings.searchClientSide ? $root.p3xr.strings.form.treeSettings.label.searchModeClient : $root.p3xr.strings.form.treeSettings.label.searchModeServer }}
{{ $root.p3xr.strings.form.treeSettings.field.searchModeStartsWith}}
{{ $root.p3xr.settings.searchStartsWith ? $root.p3xr.strings.form.treeSettings.label.searchModeStartsWith : $root.p3xr.strings.form.treeSettings.label.searchModeIncludes }}
src/angular/pages/p3xr-settings.js000066400000000000000000000026251520013332200174610ustar00rootroot00000000000000p3xr.ng.component('p3xrSettings', { template: require('./p3xr-settings.html'), controller: function(p3xrCommon, p3xrDialogConnection, $mdDialog, p3xrSocket, p3xrDialogTreecontrolSettings) { this.connectionForm = (options) => { p3xrDialogConnection.show(options) } this.openTreeSettingDialog = (opts) => { p3xrDialogTreecontrolSettings.show(opts); //console.warn($rootScope.p3xr.state.redisTreeDivider) } this.deleteConnection = async (options) => { const { model, ev } = options; try { await p3xrCommon.confirm({ event: ev, message: p3xr.strings.confirm.deleteConnectionText }); const response = await p3xrSocket.request({ action: 'connection-delete', payload: { id: model.id }, }) p3xrCommon.toast({ message: p3xr.strings.status.deleted }); } catch(error) { if (error === undefined) { p3xrCommon.toast({ message: p3xr.strings.status.cancelled }); return; } p3xrCommon.generalHandleError(error) } } } }) src/angular/provider/000077500000000000000000000000001520013332200151175ustar00rootroot00000000000000src/angular/provider/p3xr-theme.js000066400000000000000000000062751520013332200174630ustar00rootroot00000000000000p3xr.ng.provider('p3xrTheme', function p3xrThemeProvider($mdThemingProvider, ) { const selfProvider = this; $mdThemingProvider.generateThemesOnDemand(true); $mdThemingProvider.alwaysWatchTheme(true); $mdThemingProvider.setNonce(); const themeCookieName = 'p3xr-theme' const themeDefault = 'p3xrThemeLight'; this.start = () => { // console.warn('ngivrTheme we are in the provider eg: config')( Object.keys(p3xr.theme).forEach(theme => { //console.warn('provider theme: ', theme) p3xr.theme[theme]($mdThemingProvider) }) $mdThemingProvider.setDefaultTheme(themeDefault); } const themeIsGenerated = {}; const themeType = { dark: [ 'p3xrThemeDark' ], light: [ 'p3xrThemeLight' ] } // this is the service eg: ngivrTheme this.$get = ['$mdTheming', '$rootScope' , '$cookies', function p3xxThemeFactory($mdTheming, $rootScope, $cookies ) { // let's assume that the UnicornLauncher constructor was also changed to // accept and use the useTinfoilShielding argument return new function p3xrTheme() { const self = this; this.start = () => { // console.log(selfProvider); // console.log('ngivrTheme we are in the service eg: run or injector') self.setTheme(); } this.setTheme = (themeName) => { if (themeName === undefined) { themeName = $cookies.get(themeCookieName) if (themeName === undefined) { themeName = themeDefault } } //console.warn(`theme will generate theme on the fly: ${theme}`); if (!themeIsGenerated.hasOwnProperty(themeName)) { //console.warn(`theme generating theme on the fly: ${theme}`); $mdTheming.generateTheme(themeName); $mdTheming.generateTheme(`${themeName}Layout`); $mdTheming.generateTheme(`${themeName}Common`); themeIsGenerated[themeName] = true; } //console.warn(themeIsGenerated) //console.warn(`theme registered: ${$mdTheming.registered(theme)}`); $mdThemingProvider.setDefaultTheme(themeName); $rootScope.p3xr.state.theme = themeName; $cookies.put(themeCookieName, themeName, { expires: p3xr.settings.cookieExpiry,}); $body.removeClass('p3xr-theme-light') $body.removeClass('p3xr-theme-dark') if (themeType.dark.includes(themeName)) { $body.addClass('p3xr-theme-dark') } else { $body.addClass('p3xr-theme-light') } } this.getCurrentThemeName = () => { return $cookies.get(themeCookieName); } this.generateThemeName = (themeNameRaw) => { const generateThemeName = 'p3xrTheme' + themeNameRaw[0].toUpperCase() + themeNameRaw.substring(1) return generateThemeName; } }; }]; }); src/angular/provider/theme-generator/000077500000000000000000000000001520013332200202055ustar00rootroot00000000000000src/angular/provider/theme-generator/p3xr-theme-dark.js000066400000000000000000000020351520013332200234560ustar00rootroot00000000000000p3xr.theme.dark = function ($mdThemingProvider) { $mdThemingProvider.theme(`p3xrThemeDarkLayout`) .primaryPalette('grey', { 'default': '800', 'hue-1': '50', 'hue-2': '700', 'hue-3': '900', }) .accentPalette('grey') .warnPalette('blue-grey') .backgroundPalette('grey', { 'default': 'A700', 'hue-1': '800', 'hue-2': '700', 'hue-3': '900', }) ; $mdThemingProvider.theme(`p3xrThemeDarkLayout`).dark() $mdThemingProvider.theme(`p3xrThemeDark`) .primaryPalette('blue-grey') .accentPalette('teal') .warnPalette('red') .backgroundPalette('grey') ; $mdThemingProvider.theme(`p3xrThemeDark`).dark() $mdThemingProvider.theme(`p3xrThemeDarkCommon`) .primaryPalette('light-green') .accentPalette('deep-orange') .warnPalette('lime') .backgroundPalette('grey') ; $mdThemingProvider.theme(`p3xrThemeDarkCommon`).dark() } src/angular/provider/theme-generator/p3xr-theme-light.js000066400000000000000000000016331520013332200236470ustar00rootroot00000000000000p3xr.theme.light = function ($mdThemingProvider, p3xrThemeNameGenerator) { $mdThemingProvider.theme('p3xrThemeLightLayout') .primaryPalette('blue-grey', { 'default': '800', 'hue-1': '50', 'hue-2': '700', 'hue-3': '900', }) .accentPalette('blue-grey') .warnPalette('red') .backgroundPalette('blue-grey', { 'default': 'A100', 'hue-1': '50', 'hue-2': '700', 'hue-3': '900', }) ; $mdThemingProvider.theme(`p3xrThemeLight`) .primaryPalette('deep-purple') .accentPalette('purple') .warnPalette('red') .backgroundPalette('blue-grey') ; $mdThemingProvider.theme(`p3xrThemeLightCommon`) .primaryPalette('green') .accentPalette('orange') .warnPalette('yellow') .backgroundPalette('blue-grey') ; } src/angular/routes.js000066400000000000000000000021611520013332200151440ustar00rootroot00000000000000const routes = ($stateProvider, $urlRouterProvider) => { $stateProvider.state({ name: 'settings', url: '/settings', template: '' }) $stateProvider.state({ name: 'main', url: '/main', template: '' }) $stateProvider.state({ name: 'overview', url: '/overview', template: '' }) $stateProvider.state({ name: 'console', url: '/console', template: '' }) $stateProvider.state('main.statistics', { url: '/statistics', template: '', }); $stateProvider.state('main.key', { url: '/key/:key', template: '', params : { resize: null, } }); $stateProvider.state('socketio-error', { url: '/socketio-error', template: '', params: { error: null } }); } module.exports = routessrc/angular/ui/000077500000000000000000000000001520013332200137025ustar00rootroot00000000000000src/angular/ui/p3xr-accordion.html000066400000000000000000000014121520013332200174210ustar00rootroot00000000000000

{{ $ctrl.p3xrTitle }}

{{ !$ctrl.extended ? 'keyboard_arrow_down' : 'keyboard_arrow_up' }} {{ !$ctrl.extended ? $root.p3xr.strings.intention.extend : $root.p3xr.strings.intention.collapse}}
src/angular/ui/p3xr-accordion.js000066400000000000000000000025001520013332200170700ustar00rootroot00000000000000let accordionKey = 0 p3xr.ng.component('p3xrAccordion', { template: require('./p3xr-accordion.html'), bindings: { p3xrTitle: '<', p3xrAccordionKey: '@', }, transclude: { 'actions': '?p3xrAccordionActions', 'content': 'p3xrAccordionContent', }, controller: function ($transclude, $cookies) { this.transcludePresent = function (slot) { return $transclude.isSlotFilled(slot); }; this.$onInit = function() { //console.log(this.p3xrAccordionKey) if (this.p3xrAccordionKey === undefined || this.p3xrAccordionKey === '') { console.log('wrong') this.p3xAccordionKey = ++accordionKey; } const cookieName = `p3xr-accordion-extended-${this.p3xrAccordionKey}` //console.log(cookieName) Object.defineProperty(this, 'extended', { get: () => { const cookieValue = $cookies.get(cookieName) return cookieValue === undefined ? true : cookieValue === 'true' }, set: (value) => { $cookies.put(cookieName, String(value), { expires: p3xr.settings.cookieExpiry, }) } }) } } }) src/angular/ui/p3xr-button.html000066400000000000000000000006321520013332200167760ustar00rootroot00000000000000 {{ $ctrl.p3xrMdIcon }} {{ $ctrl.p3xrLabel }} {{ $ctrl.p3xrLabel }} src/angular/ui/p3xr-button.js000066400000000000000000000003601520013332200164440ustar00rootroot00000000000000p3xr.ng.component('p3xrButton', { template: require('./p3xr-button.html'), bindings: { p3xrLabel: '<', p3xrMdIcon: '@', p3xrFaIcon: '@', p3xrTooltipDirection: '@', p3xrClasses: '@' }, }) src/builder/000077500000000000000000000000001520013332200132625ustar00rootroot00000000000000src/builder/webpack.config.js000066400000000000000000000142301520013332200165000ustar00rootroot00000000000000const webpack = require('webpack'); const CleanWebpackPlugin = require('clean-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const TerserPlugin = require('terser-webpack-plugin') const fileAsset = `[name].[hash].[ext]`; const minimize = process.argv.includes('--production'); const mode = minimize ? 'development' : 'production'; const filenamePrefix = minimize ? '[name].[hash]' : '[name]' let minimizer = undefined; const top = process.cwd() const buildDir = top + `/dist`; let devtool; const basePath = __dirname; const targetPath = '../..'; const targetFolder = 'dist'; const pkg = require('../../package') const plugins = [ new HtmlWebpackPlugin({ template: `${top}/src/index.html`, inject: 'head', chunksSortMode: 'dependency', chunks: ['bundle'], title: pkg.description, minify: minimize }), new ExtractTextPlugin({ filename: `${filenamePrefix}.css`, disable: false, allChunks: true }), ]; if (minimize) { const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); plugins.unshift( new CleanWebpackPlugin([targetFolder], { root: basePath + '/' + targetPath }) ) plugins.push( new OptimizeCssAssetsPlugin({ assetNameRegExp: /\.css$/g, // cssProcessor: require('cssnano'), // cssProcessorOptions: { safe: true, discardComments: { removeAll: true } }, canPrint: true }) ) devtool = false; const bannerText = require('corifeus-builder').utils.license(); minimizer = [ new TerserPlugin({ sourceMap: true, parallel: true, cache: true, extractComments: { condition: /^\**!|@preserve|@license|@cc_on/, filename: function (fileName) { return `${fileName}.LICENSE.txt`; }, banner: function (webpackBanner) { return ` ${bannerText} For more information about all licenses, please see ${webpackBanner} `; } }, terserOptions: { compress: { warnings: false }, ecma: 8, // todo found out if mangle use or not // mangle: false === keep function names // mangle: true === drop function names mangle: false, sourceMap: true, comments: false, beautify: false }, }), ] plugins.push( new webpack.BannerPlugin({ banner: bannerText, include: /\.css$/, exclude: /\.ts$|\.js$/, // hash:[hash], chunkhash:[chunkhash], name:[name], filebase:[filebase], query:[query], file:[file] }) ) plugins.push( new webpack.SourceMapDevToolPlugin({ filename: 'sourcemaps/[file].map', append: '\n//# sourceMappingURL=./[url]' }) ) } const fileLoader = [ { loader: 'file-loader', options: { name: fileAsset, outputPath: 'assets', context: 'assets', // publicPath: 'webpack/assets', // useRelativePath: true, } } ] module.exports = { // watch: true, devtool: devtool, entry: { bundle: top + "/src/bundle.js", }, output: { path: buildDir, filename: `${filenamePrefix}.js`, chunkFilename: '[id].chunk.js', // publicPath: '{{ app.url_subdir }}/webpack/', publicPath: ``, }, module: { rules: [ { test: /\.(scss|css)$/, // exclude: [`${cwd}/src/assets/ngivr.scss`], use: ExtractTextPlugin.extract({ fallback: 'style-loader', use: [ { loader: 'css-loader', options: { sourceMap: true, minimize: minimize === true } } , 'sass-loader'], }) }, { test: /\.html$/, use: [{ loader: 'html-loader', options: { minimize: mode, caseSensitive: true } }] }, { test: /\.(png|jpe?g|gif|ico)$/, use: fileLoader }, { test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, use: fileLoader }, { test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, use: fileLoader }, { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, use: fileLoader }, { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, use: fileLoader }, { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, use: fileLoader }, { test: /\.css$/, use: ExtractTextPlugin.extract({ // fallback: "style-loader", use: [ { loader: 'css-loader', options: { minimize: minimize, sourceMap: true }, }] }) } ] }, optimization: { minimize: minimize, minimizer: minimizer }, plugins: plugins, mode: mode, devServer: { host: '0.0.0.0', disableHostCheck: true, historyApiFallback: { rewrites: [ {from: /.*\..*/, to: '/index.html'} ] }, hot: true, inline: true, stats: { colors: true }, clientLogLevel: 'none', progress: true, noInfo: false }, } src/bundle.js000066400000000000000000000014461520013332200134500ustar00rootroot00000000000000require('typeface-roboto'); require('./scss/index.scss') // fontawesome require('@fortawesome/fontawesome-free/js/all') // jquery global.$ = require('jquery/dist/jquery.slim') global.jQuery = global.$ global.$window = $(window); $(() => { global.$body = $('body'); }) // socket global.io = require('socket.io-client') require('./decorate/string') global.p3xr = global.p3xr || {} p3xr.pkg = require('../package') p3xr.theme = { dark: undefined, light: undefined, } p3xr.ui = { overlay: undefined, htmlEncode: require('js-htmlencode').htmlEncode } require('./core/strings') require('./core/settings') require('./core/random') require('./core/next-id') require('./core/api') require('./core/state') require('./core/dom') require('./jquery/overlay') require('./angular/boot'); src/core/000077500000000000000000000000001520013332200125645ustar00rootroot00000000000000src/core/api.js000066400000000000000000000003521520013332200136730ustar00rootroot00000000000000global.p3xr.api = { host: undefined, } const apiUrl = new URL(location.toString()) if (apiUrl.port === "8080") { global.p3xr.api.host = 'https://localhost:7843' } else { global.p3xr.api.host = `https://${apiUrl.host}` } src/core/dom.js000066400000000000000000000046121520013332200137040ustar00rootroot00000000000000// https://www.google.hu/search?q=javascript+vanilla+position&oq=javascript+vanilla+position&aqs=chrome..69i57.3908j0j7&sourceid=chrome&ie=UTF-8 // https://www.kirupa.com/html5/get_element_position_using_javascript.htm const dom = {} dom.getPosition = function getPosition(el) { let leftPos = 0; let topPos = 0; if (el === undefined) { return { left: 0, top: 0, width: 0, height: 0, } } const style = el.currentStyle || window.getComputedStyle(el); const width = el.offsetWidth // or use style.width const marginSide = parseFloat(style.marginLeft) + parseFloat(style.marginRight) const paddingSide = parseFloat(style.paddingLeft) + parseFloat(style.paddingRight) const borderSide = parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth) const height = el.offsetHeight // or use style.width const marginHorizontal = parseFloat(style.marginTop) + parseFloat(style.marginBottom) const paddingHorizontal = parseFloat(style.paddingTop) + parseFloat(style.paddingBottom) const borderHorizontal = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth) const result = { width: width + marginSide + paddingSide + borderSide, height: height + marginHorizontal + paddingHorizontal + borderHorizontal } while (el) { if (el.tagName === "BODY") { // deal with browser quirks with body/window/document and page scroll const leftScroll = el.scrollLeft || document.documentElement.scrollLeft; const topScroll = el.scrollTop || document.documentElement.scrollTop; leftPos += (el.offsetLeft - leftScroll + el.clientLeft); topPos += (el.offsetTop - topScroll + el.clientTop); } else { // for all other non-BODY elements leftPos += (el.offsetLeft - el.scrollLeft + el.clientLeft); topPos += (el.offsetTop - el.scrollTop + el.clientTop); } el = el.offsetParent; } result.left = leftPos result.top = topPos return result; } /* // deal with the page getting resized or scrolled window.addEventListener("scroll", updatePosition, false); window.addEventListener("resize", updatePosition, false); function updatePosition() { // add your code to update the position when your browser // is resized or scrolled } */ p3xr.dom = domsrc/core/next-id.js000066400000000000000000000010611520013332200144700ustar00rootroot00000000000000let currentId = 0 let currentIdTime = Date.now() global.p3xr.nextId = () => { const now = Date.now(); if (currentIdTime !== now) { currentId = 0; currentIdTime = now } const comingId = ++currentId; const randomHex = global.p3xr.random().reverse().padStart(15, '0'); const timeHex = currentIdTime.toString(16).padStart(12, '0').reverse() const comingIdHex = comingId.toString(16).padStart(3, '0').reverse(); const newId = `P3Xid${timeHex}${comingIdHex}${randomHex}`; //console.log(newId) return newId } src/core/random.js000066400000000000000000000002211520013332200143750ustar00rootroot00000000000000global.p3xr.random = () => { return (Math.floor(Math.random() * (99999999999999999 - 10000000000000000)) + 10000000000000000).toString(16) } src/core/settings.js000066400000000000000000000023701520013332200147640ustar00rootroot00000000000000const cookieExpiry = new Date() cookieExpiry.setFullYear(cookieExpiry.getFullYear() + 5) p3xr.settings = { socket: { timeout: 3000, }, toast: { timeout: 3000, position: 'bottom right', }, debounce: 250, debounceSearch: 1000, cookieExpiry: cookieExpiry, connection: { cookieNameCurrentDatabase: 'p3xr-main-current-database', getCookieNameCurrentDatabase: (id) => { return p3xr.settings.connection.cookieNameCurrentDatabase + '-' + id } }, tree: { cookieName: 'p3xr-main-treecontrol-divider', defaultDivider: ':', }, redisTreeDivider: ':', paging: { default: 100, cookieName: 'p3xr-main-treecontrol-page-size' }, pageCount: 100, keySortInfo: { default: false, cookieName: 'p3xr-main-treecontrol-key-sort', }, keysSort: false, searchClientSide: true, searchInfoClientSide: { default: true, cookieName: 'p3xr-main-treecontrol-search-client-mode' }, searchStartsWith: false, searchInfoStartsWith: { default: false, cookieName: 'p3xr-main-treecontrol-search-starts-with' }, connectInfo: { cookieName: 'p3xr-layout-connect', } }src/core/state.js000066400000000000000000000012271520013332200142440ustar00rootroot00000000000000p3xr.state = { theme: undefined, connection: undefined, currentDatabase: undefined, redisChanged: false, databaseIndexes: [0], connections: [], redisConnections: {}, keys: [], cfg: undefined, keysInfo: undefined, failed: false, keysRaw: [], search: '', } Object.defineProperty(p3xr.state, 'themeLayout', { get: () => { return p3xr.state.theme + 'Layout' } }) Object.defineProperty(p3xr.state, 'themeCommon', { get: () => { return p3xr.state.theme + 'Common' } }) p3xr.connectionsReset = () => { p3xr.state.connections = { list: [] } } p3xr.connectionsReset()src/core/strings.js000066400000000000000000000001451520013332200146130ustar00rootroot00000000000000p3xr.translations = { en: require('../strings/en/strings') } p3xr.strings = p3xr.translations.en src/decorate/000077500000000000000000000000001520013332200134225ustar00rootroot00000000000000src/decorate/string.js000066400000000000000000000002071520013332200152650ustar00rootroot00000000000000if (!String.prototype.reverse) { String.prototype.reverse = function () { return this.split('').reverse().join('') } } src/index.html000066400000000000000000000006041520013332200136310ustar00rootroot00000000000000 P3X Redis UI src/injector.scss000066400000000000000000000007721520013332200143540ustar00rootroot00000000000000//injector-sass-start @import "./angular/layout/p3xr-layout.scss"; @import "./angular/pages/main/key/p3xr-main-key-list.scss"; @import "./angular/pages/main/key/p3xr-main-key-string.scss"; @import "./angular/pages/main/p3xr-main-key.scss"; @import "./angular/pages/main/p3xr-main-treecontrol-controls.scss"; @import "./angular/pages/main/p3xr-main-treecontrol.scss"; @import "./angular/pages/p3xr-console.scss"; @import "./angular/pages/p3xr-main.scss"; @import "./jquery/overlay.scss"; //injector-sass-endsrc/jquery/000077500000000000000000000000001520013332200131535ustar00rootroot00000000000000src/jquery/overlay.js000066400000000000000000000012031520013332200151660ustar00rootroot00000000000000let counter = 0 p3xr.ui.overlay = new function() { const template = (options = {}) => { return `
${options.hasOwnProperty('message') ? "

" : ''} ${options.hasOwnProperty('message') ? options.message : ''}
` } this.show = (options = {}) => { this.hide() //console.warn('p3xr.ui.overlay show') $body.append(template(options)) } this.hide = () => { //console.warn('p3xr.ui.overlay hide') $body.find('#p3xr-overlay').remove() } }src/jquery/overlay.scss000066400000000000000000000006211520013332200155300ustar00rootroot00000000000000 #p3xr-overlay { i { font-size: 400% !important; } z-index: 999999; font-size: 125%; position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; text-align:center; /*Flexbox*/ display: flex; flex-direction: column; align-items: center; align-content: center; justify-content: center; background-color: rgba(0, 0, 0, 0.9); color: rgba(128, 128, 128, 0.5); } src/scss/000077500000000000000000000000001520013332200126075ustar00rootroot00000000000000src/scss/index.scss000066400000000000000000000030721520013332200146150ustar00rootroot00000000000000@import '~material-design-icons-iconfont/dist/material-design-icons.css'; @import '~angular-material/angular-material.css'; @import '~angular-tree-control/css/tree-control.css'; @import '~angular-json-tree/dist/angular-json-tree.css'; #p3xr-redis-ui-bootstrap { height: 100vh; } .fa, .fas, .fab, far, .svg-inline--fa { transform: scale(1.5) !important; margin-right: 5px !important; margin-left: 5px !important; } [ng-click] { cursor: pointer; } .md-button { min-width: auto; } input:-webkit-autofill { background-color: transparent !important;; } .p3xr-md-menu-item-selected { background-color: rgba(128, 128, 128, 0.5) !important; } .p3xr-md-input-container-no-bottom { margin-bottom: 0px; padding-bottom: 0px; } .p3xr-typography-ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .p3xr-input { padding: 3px; border-style: solid; border-width: 2px } .p3xr-theme-light { .p3xr-input { border-color: rgba(128, 128, 128, 0.5); } json-tree .key { color: black; font-weight: bold; } } .p3xr-theme-dark { json-tree .key { color: rgba(255, 255, 255, 0.6); font-weight: bold; } } .p3xr-theme-dark { ::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */ color: rgba(255, 255, 255, 0.75); } .p3xr-input { background-color: gray; color: white; border-color: rgba(200, 200, 200, 0.5); } } .p3xr-pre { font-family: monospace; font-size: 18px; line-height: 20px; white-space: pre; // white-space: pre-wrap; // word-wrap: break-word; } @import '../injector'; src/strings/000077500000000000000000000000001520013332200133255ustar00rootroot00000000000000src/strings/en/000077500000000000000000000000001520013332200137275ustar00rootroot00000000000000src/strings/en/strings.js000066400000000000000000000227621520013332200157670ustar00rootroot00000000000000const strings = { title: { name: 'P3X Redis UI', main: 'You may choose a REDIS connection to connect from the left bottom menu.', statistics: 'Statistics', connectinRedis: 'Connecting to Redis ...', socketioConnectError: 'Socket.IO Error' /* server: 'Server', clients: 'Clients', memory: 'Memory', persistence: 'Persistance', stats: 'Statastics', replication: 'Replication', cpu: 'CPU', cluster: 'Cluster', keyspace: 'Keyspace', */ }, confirm: { title: 'Confirm', deleteConnection: 'Confirm', deleteConnectionText: 'Are you sure to delete this Redis connection?', deleteAllKeys: (opts) => { return `Delete this tree and all it\'s keys (${opts.key})?` }, socketioConnectError: 'Socket.IO cannot connect to the server, you can reload and you might to resolve the connection error by yourself, the client does not know to solve it by itself.', deleteKey: 'Are you sure to delete this key?', rename: { title: 'Are you to rename this key?', textContent: 'If you click the rename button, it will rename this key forever.', placeholder: 'The Redis key (required)', }, ttl: { title: 'Are you to change this keys\'s TTL?', textContent: 'If you click the change TTL button, it will rename this key\'s time to live, empty will persist this key keep forever.', placeholder: 'The Redis key\'s TTL (integer or empty)', }, }, intention: { addKey: `Add to this key`, addKeyRoot: 'Add a root key', reloadKey: 'Reload key', reload: 'Reload', close: 'Close', commands: 'Commands', view: 'View', statistics: 'Statistics', refresh: 'Refresh', clear: 'Clear', rename: 'Rename', main: 'Home', cancel: 'Cancel', theme: 'Theme', github: 'GitHub', settings: 'Settings', connect: 'Connect', disconnect: 'Disconnect', overview: 'Overview', console: 'Console', noConnections: 'No connections, add a connection in the settings menu.', noConnectionsInSettings: 'No connections, you may add a NEW CONNECTION above.', connectionAdd: 'New connection', extend: 'Extend', collapse: 'Collapse', add: 'Add', edit: 'Edit', save: 'Save', ttl: 'Set TTL', 'delete': 'Delete', remove: 'Remove', 'sure': 'Sure', testConnection: 'Test connection', getKey: 'Loading Redis key and associated data ...', jsonViewShow: 'Display JSON tree', }, label: { jsonViewNotParsable: 'This value is not JSON parsable ', ttlTitle: 'Set the TTL in seconds', passwordSecure: 'The password might will be empty, but still it will show characters, this is a security feature.', treeSeparatorEmpty: 'If the tree separator is empty, the tree wil have no nested nodes, just a pure list', treeSeparatorEmptyNote: 'No nested nodes, just a pure list', welcomeConsole: 'Welcome to the Redis Console', console: 'Console', connectiondAdd: 'Add connection', connectiondEdit: 'Edit connection', connectiondView: 'View connection', connections: 'Connections', keysSort: { on: 'Key sorting on', off: 'Key sorting off' }, theme: { light: 'Light', dark: 'Dark', }, connected: (opts) => { return `Connected: ${opts.name}` }, tree: 'Tree', }, status: { keyIsNotExisting: 'This key could have been deleted or expired.', keyCount: (opts) => { if (opts.keyCount === 0) { return 'No key' } else if (opts.keyCount === 1) { return '1 key' } else { return `${opts.keyCount} keys` } }, treeExpandAll: 'Expand all tree leafs, this has a cost, might take time ...', noRedisKeys: 'There are no keys in this database.', redisConnected: 'Redis connected successful', reloadingDataInfo: 'Reloading Redis data info', added: 'Added', saved: 'Updated', cancelled: 'Cancelled', deleted: 'Deleted', savedRedis: 'Redis data is saved', redisDisconnected: (opts) => { return `The current connection had an error: ${opts.error.message}` }, dbChanged: (opts) => { return `The db index set to ${opts.db}. ` }, treeDeleted: (opts) => { return `The tree key was deleted (${opts.key}).` }, deletedKey: (opts) => { return `The key was deleted (${opts.key}).` }, renamedKey: 'This key has been renamed', ttlChanged: 'This key\'s TTL has been changed', notInteger: 'This input is not an integer', persisted: 'This key is persisted forever', set: 'The key is set/added' }, code: { 'delete-connection': 'This connection was deleted, so you are disconnected to this Redis instance.', 'save-connection': 'This connection was changed, so you are disconnected to this Redis instance. You may re-connect.', 'readonly-connections': 'Connections add/save/delete are readonly only!', }, form: { error: { required: 'Required', port: 'The port is between 1-65535', invalid: 'The form is invalid' }, connection: { label: { name: 'Name', host: 'Hostname', port: 'Port', password: 'Password', }, }, treeSettings: { label: { formName: 'Tree settings', searchModeClient: 'Client search mode', searchModeServer: 'Server search mode', searchModeStartsWith: 'Search with starts with mode', searchModeIncludes: 'Search includes mode', }, field: { treeSeparator: 'Tree separator', page: 'Paging count', keysSort: 'Sort the keys', searchMode: 'Search mode', searchModeStartsWith: 'Search starts with / includes' }, error: { page: 'The page count must be an integer between 10 - 500' }, }, key: { label: { formName: 'Add new Redis key' }, field: { key: 'Key', type: 'Type', index: 'Index', hashKey: 'Hash key', score: 'Score', value: 'Value', }, error: { key: 'The key is, at least, one character', hashKey: 'The hash table key is at least one character', score: 'The sorted set score is required', value: 'The value is required', } }, main: { label: { database: 'DB', } } }, page: { overview: { noConnected: 'There is no connection to Redis.', overviewClients: 'List the connected by the count of clients', connectedCount: (opt) => { if (opt.length === 1) { return '1 client' } return `${opt.length} clients` } }, key: { label: { key: 'Key', encoding: 'Encoding', length: 'Size', ttl: 'TTL', ttlTitle: 'Time To Live', type: 'Type', ttlNotExpire: 'does not expire', lengthString: 'characters', lengthItem: 'items', actions: 'Actions', }, list: { table: { index: 'Index', value: 'Value', action: 'Action', } } }, treeControls: { settings: 'Tree settings', expandAll: 'Expand all', collapseAll: 'Collapse all', search: { clear: 'Clear current search to set empty', placeholderClient: 'Search client side', placeholderServer: 'Search server side', info: 'The client side search means, that it matches the text in the search input. The server side search means, that is it like search in the keys patterns as *{search-text}*. For large search sets, it is better to use server side searching. For smaller search sets, it is better to use client side search mode.', infoDetails: 'To find out how the search works, please check out the settings' }, pager: { next: 'Next', prev: 'Previous', first: 'First', last: 'Last' } } }, time: { days: 'days', hours: 'hours', minutes: 'minutes', seconds: 'seconds', }, redisTypes: { string: 'String', list: 'List', hash: 'Hash table', set: 'Set', zset: 'Sorted set - zset' } } module.exports = strings;