From 57a98384f1006a6d711b4563e32dfc18ccbcd7ab Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Sun, 13 Jan 2019 16:52:37 +0100 Subject: [PATCH] sysutils/smart: style and directory change --- .../OPNsense/Smart/Api/ServiceController.php | 54 ++++++++++------- .../OPNsense/Smart/IndexController.php | 1 + .../mvc/app/views/OPNsense/Smart/index.volt | 60 +++++++++---------- .../{smart => Smart}/detailed_list.sh | 0 .../service/conf/actions.d/actions_smart.conf | 2 +- .../src/www/widgets/include/smart_status.inc | 6 +- 6 files changed, 65 insertions(+), 58 deletions(-) rename sysutils/smart/src/opnsense/scripts/OPNsense/{smart => Smart}/detailed_list.sh (100%) diff --git a/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/Api/ServiceController.php b/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/Api/ServiceController.php index 451a1f5b35..0af8f67288 100644 --- a/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/Api/ServiceController.php +++ b/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/Api/ServiceController.php @@ -34,36 +34,39 @@ class ServiceController extends ApiControllerBase { - private function getDevices () + private function getDevices() { $backend = new Backend(); - $devices = preg_split ("/[\s]+/", trim($backend->configdRun("smart list"))); + $devices = preg_split("/[\s]+/", trim($backend->configdRun("smart list"))); return $devices; } - public function listAction () + public function listAction() { - if ($this->request->isPost()) - return array("devices" => $this->getDevices ()); + if ($this->request->isPost()) { + return array("devices" => $this->getDevices()); + } return array("message" => "Unable to run list action"); } - public function infoAction () + public function infoAction() { if ($this->request->isPost()) { - $device = $this->request->getPost ('device'); - $type = $this->request->getPost ('type'); + $device = $this->request->getPost('device'); + $type = $this->request->getPost('type'); - if (!in_array ($device, $this->getDevices ())) + if (!in_array($device, $this->getDevices())) { return array("message" => "Invalid device name"); + } $valid_info_types = array("i", "H", "c", "A", "a"); - if (!in_array ($type, $valid_info_types)) + if (!in_array($type, $valid_info_types)) { return array("message" => "Invalid info type"); + } $backend = new Backend(); @@ -75,19 +78,21 @@ public function infoAction () return array("message" => "Unable to run info action"); } - public function logsAction () + public function logsAction() { if ($this->request->isPost()) { - $device = $this->request->getPost ('device'); - $type = $this->request->getPost ('type'); + $device = $this->request->getPost('device'); + $type = $this->request->getPost('type'); - if (!in_array ($device, $this->getDevices ())) + if (!in_array($device, $this->getDevices())) { return array("message" => "Invalid device name"); + } $valid_log_types = array("error", "selftest"); - if (!in_array ($type, $valid_log_types)) + if (!in_array($type, $valid_log_types)) { return array("message" => "Invalid log type"); + } $backend = new Backend(); @@ -99,19 +104,21 @@ public function logsAction () return array("message" => "Unable to run logs action"); } - public function testAction () + public function testAction() { if ($this->request->isPost()) { - $device = $this->request->getPost ('device'); - $type = $this->request->getPost ('type'); + $device = $this->request->getPost('device'); + $type = $this->request->getPost('type'); - if (!in_array ($device, $this->getDevices ())) + if (!in_array($device, $this->getDevices())) { return array("message" => "Invalid device name"); + } $valid_test_types = array("offline", "short", "long", "conveyance"); - if (!in_array ($type, $valid_test_types)) + if (!in_array($type, $valid_test_types)) { return array("message" => "Invalid test type"); + } $backend = new Backend(); @@ -123,13 +130,14 @@ public function testAction () return array("message" => "Unable to run test action"); } - public function abortAction () + public function abortAction() { if ($this->request->isPost()) { - $device = $this->request->getPost ('device'); + $device = $this->request->getPost('device'); - if (!in_array ($device, $this->getDevices ())) + if (!in_array($device, $this->getDevices())) { return array("message" => "Invalid device name"); + } $backend = new Backend(); diff --git a/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/IndexController.php b/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/IndexController.php index b446f5475f..acccc4bd9a 100644 --- a/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/IndexController.php +++ b/sysutils/smart/src/opnsense/mvc/app/controllers/OPNsense/Smart/IndexController.php @@ -28,6 +28,7 @@ */ namespace OPNsense\Smart; + class IndexController extends \OPNsense\Base\IndexController { public function indexAction() diff --git a/sysutils/smart/src/opnsense/mvc/app/views/OPNsense/Smart/index.volt b/sysutils/smart/src/opnsense/mvc/app/views/OPNsense/Smart/index.volt index 96d2d74411..331cab9c42 100644 --- a/sysutils/smart/src/opnsense/mvc/app/views/OPNsense/Smart/index.volt +++ b/sysutils/smart/src/opnsense/mvc/app/views/OPNsense/Smart/index.volt @@ -1,33 +1,31 @@ {# - -Copyright (C) 2018 Smart-Soft -Copyright (C) 2014 Deciso B.V. -Copyright (C) 2010 Jim Pingle -Copyright (C) 2006 Eric Friesen -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, -INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, -OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -#} + # Copyright (C) 2018 Smart-Soft + # Copyright (C) 2014 Deciso B.V. + # Copyright (C) 2010 Jim Pingle + # Copyright (C) 2006 Eric Friesen + # All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided that the following conditions are met: + # + # 1. Redistributions of source code must retain the above copyright notice, + # this list of conditions and the following disclaimer. + # + # 2. Redistributions in binary form must reproduce the above copyright + # notice, this list of conditions and the following disclaimer in the + # documentation and/or other materials provided with the distribution. + # + # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + # POSSIBILITY OF SUCH DAMAGE. + #}