From 240b9650cd53e2a5484289570746a27f82ac48d4 Mon Sep 17 00:00:00 2001 From: Andrew Collington Date: Wed, 16 Dec 2020 11:10:48 +0000 Subject: [PATCH] Release/3.2.1 (#68) * Fixed spaceship operator regression * Remove 'empty' get parameter (#66) * Improved layout of arrays in directive list (eg, optimisation values) (#67) * Added optimisation value to the list alongside text equivalent. * Bumping version and updating readme --- README.md | 6 ++++++ build/_frontend/interface.jsx | 22 +++++++++++++++------- build/_frontend/interface.scss | 15 ++++++++++++++- build/build.php | 2 +- build/template.phps | 2 +- index.php | 34 ++++++++++++++++++++-------------- package.json | 2 +- src/Opcache/Service.php | 6 +++--- 8 files changed, 61 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 24d3b84..84a3c51 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,12 @@ When the real-time updates are active the interface will automatically update al ## Releases +**Version 3.2.1**\ +Minor maintenance release to: +* Put back "spaceship operator" so PHP8 doesn't give deprecation warnings (must have been accidentally removed in a previous commit) +* More refined axios usage when it comes to parameters +* A little extra formatting on the opcache optimization levels + **Version 3.2.0**\ Updated ReactJS to latest and used minified versions and made slight improvement to sort option when no pagination is present. diff --git a/build/_frontend/interface.jsx b/build/_frontend/interface.jsx index 43f66c9..6a74eed 100644 --- a/build/_frontend/interface.jsx +++ b/build/_frontend/interface.jsx @@ -17,7 +17,7 @@ class Interface extends React.Component { this.setState({realtime: true}) this.polling = setInterval(() => { this.setState({fetching: true, resetting: false}); - axios.get('?', {time: Date.now()}) + axios.get(window.location.pathname, {time: Date.now()}) .then((response) => { this.setState({opstate: response.data}); }); @@ -43,7 +43,7 @@ class Interface extends React.Component { resetHandler = () => { if (this.state.realtime) { this.setState({resetting: true}); - axios.get('?', {params: {reset: 1}}) + axios.get(window.location.pathname, {params: {reset: 1}}) .then((response) => { console.log('success: ', response.data); }); @@ -329,6 +329,16 @@ function GeneralInfo(props) { function Directives(props) { + let directiveList = (directive) => { + return ( + + ); + }; + let directiveNodes = props.directives.map(function(directive) { let map = { 'opcache.':'', '_':' ' }; let dShow = directive.k.replace(/opcache\.|_/gi, function(matched){ @@ -341,9 +351,7 @@ function Directives(props) { vShow = React.createElement('i', {}, 'no value'); } else { if (Array.isArray(directive.v)) { - vShow = directive.v.map((item, key) => { - return {item}
- }); + vShow = directiveList(directive); } else { vShow = directive.v; } @@ -677,7 +685,7 @@ class CachedFiles extends React.Component { handleInvalidate = e => { e.preventDefault(); if (this.props.realtime) { - axios.get('?', {params: { invalidate_searched: this.state.searchTerm }}) + axios.get(window.location.pathname, {params: { invalidate_searched: this.state.searchTerm }}) .then((response) => { console.log('success: ' , response.data); }); @@ -799,7 +807,7 @@ class CachedFile extends React.Component { handleInvalidate = e => { e.preventDefault(); if (this.props.realtime) { - axios.get('?', {params: { invalidate: e.currentTarget.getAttribute('data-file') }}) + axios.get(window.location.pathname, {params: { invalidate: e.currentTarget.getAttribute('data-file') }}) .then((response) => { console.log('success: ' , response.data); }); diff --git a/build/_frontend/interface.scss b/build/_frontend/interface.scss index d9cb112..bc64e52 100644 --- a/build/_frontend/interface.scss +++ b/build/_frontend/interface.scss @@ -249,6 +249,20 @@ $footer-border-color: #CCC; } } + .directive-list { + list-style-type: none; + padding: 0; + margin: 0; + + li { + margin-bottom: 0.5em; + + &:last-child { + margin-bottom: 0; + } + } + } + .file-filter { width: 520px; } @@ -324,7 +338,6 @@ $footer-border-color: #CCC; display: inline-block; a { - display: inline-block; display: inline-flex; align-items: center; white-space: nowrap; diff --git a/build/build.php b/build/build.php index 6edcd41..89bf412 100644 --- a/build/build.php +++ b/build/build.php @@ -4,7 +4,7 @@ * OPcache GUI - build script * * @author Andrew Collington, andy@amnuts.com - * @version 3.2.0 + * @version 3.2.1 * @link https://github.com/amnuts/opcache-gui * @license MIT, http://acollington.mit-license.org/ */ diff --git a/build/template.phps b/build/template.phps index 78bb106..3367549 100644 --- a/build/template.phps +++ b/build/template.phps @@ -8,7 +8,7 @@ namespace Amnuts\Opcache; * A simple but effective single-file GUI for the OPcache PHP extension. * * @author Andrew Collington, andy@amnuts.com - * @version 3.2.0 + * @version 3.2.1 * @link https://github.com/amnuts/opcache-gui * @license MIT, http://acollington.mit-license.org/ */ diff --git a/index.php b/index.php index 8bec619..366bf19 100644 --- a/index.php +++ b/index.php @@ -8,7 +8,7 @@ * A simple but effective single-file GUI for the OPcache PHP extension. * * @author Andrew Collington, andy@amnuts.com - * @version 3.2.0 + * @version 3.2.1 * @link https://github.com/amnuts/opcache-gui * @license MIT, http://acollington.mit-license.org/ */ @@ -57,7 +57,7 @@ class Service { - const VERSION = '3.2.0'; + const VERSION = '3.2.1'; protected $data; protected $options; @@ -263,7 +263,7 @@ protected function compileState(): array $files = []; if (!empty($status['scripts']) && $this->getOption('allow_filelist')) { uasort($status['scripts'], function ($a, $b) { - return $a['hits'] < $b['hits']; + return $a['hits'] <=> $b['hits']; }); foreach ($status['scripts'] as &$file) { $file['full_path'] = str_replace('\\', '/', $file['full_path']); @@ -340,7 +340,7 @@ protected function compileState(): array $levels = []; foreach ($this->optimizationLevels as $level => $info) { if ($level & $v) { - $levels[] = $info; + $levels[] = "{$info} [{$level}]"; } } $v = $levels ?: 'none'; @@ -394,7 +394,7 @@ protected function compileState(): array @@ -421,7 +421,7 @@ class Interface extends React.Component { fetching: true, resetting: false }); - axios.get('?', { + axios.get(window.location.pathname, { time: Date.now() }).then(response => { this.setState({ @@ -456,7 +456,7 @@ class Interface extends React.Component { this.setState({ resetting: true }); - axios.get('?', { + axios.get(window.location.pathname, { params: { reset: 1 } @@ -757,6 +757,16 @@ className: "tables general-info-table" } function Directives(props) { + let directiveList = directive => { + return /*#__PURE__*/React.createElement("ul", { + className: "directive-list" + }, directive.v.map((item, key) => { + return /*#__PURE__*/React.createElement("li", { + key: key + }, item); + })); + }; + let directiveNodes = props.directives.map(function (directive) { let map = { 'opcache.': '', @@ -773,11 +783,7 @@ function Directives(props) { vShow = React.createElement('i', {}, 'no value'); } else { if (Array.isArray(directive.v)) { - vShow = directive.v.map((item, key) => { - return /*#__PURE__*/React.createElement("span", { - key: key - }, item, /*#__PURE__*/React.createElement("br", null)); - }); + vShow = directiveList(directive); } else { vShow = directive.v; } @@ -1083,7 +1089,7 @@ class CachedFiles extends React.Component { e.preventDefault(); if (this.props.realtime) { - axios.get('?', { + axios.get(window.location.pathname, { params: { invalidate_searched: this.state.searchTerm } @@ -1219,7 +1225,7 @@ class CachedFile extends React.Component { e.preventDefault(); if (this.props.realtime) { - axios.get('?', { + axios.get(window.location.pathname, { params: { invalidate: e.currentTarget.getAttribute('data-file') } diff --git a/package.json b/package.json index a1a11de..0ddb442 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "opcache-gui", "description": "A clean and responsive interface for Zend OPcache information, showing statistics, settings and cached files, and providing a real-time update for the information (using jQuery and React).", - "version": "3.2.0", + "version": "3.2.1", "main": "index.js", "devDependencies": { "@babel/cli": "^7.12.8", diff --git a/src/Opcache/Service.php b/src/Opcache/Service.php index f4ff657..1774924 100644 --- a/src/Opcache/Service.php +++ b/src/Opcache/Service.php @@ -4,7 +4,7 @@ class Service { - const VERSION = '3.2.0'; + const VERSION = '3.2.1'; protected $data; protected $options; @@ -210,7 +210,7 @@ protected function compileState(): array $files = []; if (!empty($status['scripts']) && $this->getOption('allow_filelist')) { uasort($status['scripts'], function ($a, $b) { - return $a['hits'] < $b['hits']; + return $a['hits'] <=> $b['hits']; }); foreach ($status['scripts'] as &$file) { $file['full_path'] = str_replace('\\', '/', $file['full_path']); @@ -287,7 +287,7 @@ protected function compileState(): array $levels = []; foreach ($this->optimizationLevels as $level => $info) { if ($level & $v) { - $levels[] = $info; + $levels[] = "{$info} [{$level}]"; } } $v = $levels ?: 'none';