mirror of
https://github.com/opnsense/plugins.git
synced 2026-05-28 04:34:15 -04:00
sysutils/smart: style and directory change
This commit is contained in:
parent
50d6842989
commit
57a98384f1
6 changed files with 65 additions and 58 deletions
|
|
@ -34,36 +34,39 @@ use \OPNsense\Core\Backend;
|
|||
|
||||
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 @@ class ServiceController extends ApiControllerBase
|
|||
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 @@ class ServiceController extends ApiControllerBase
|
|||
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 @@ class ServiceController extends ApiControllerBase
|
|||
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();
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
*/
|
||||
|
||||
namespace OPNsense\Smart;
|
||||
|
||||
class IndexController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
public function indexAction()
|
||||
|
|
|
|||
|
|
@ -1,33 +1,31 @@
|
|||
{#
|
||||
|
||||
Copyright (C) 2018 Smart-Soft
|
||||
Copyright (C) 2014 Deciso B.V.
|
||||
Copyright (C) 2010 Jim Pingle <jimp@pfsense.org>
|
||||
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 <jimp@pfsense.org>
|
||||
# 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.
|
||||
#}
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
|
@ -229,7 +227,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<pre class="hidden" id="logsMsg">
|
||||
<pre class="hidden" id="logsMsg">
|
||||
</pre>
|
||||
</section>
|
||||
|
||||
|
|
@ -254,7 +252,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<pre class="hidden" id="abortTestMsg">
|
||||
<pre class="hidden" id="abortTestMsg">
|
||||
</pre>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ message:list installed devices
|
|||
description:Get all IDE and SCSI devices currently installed
|
||||
|
||||
[detailed.list]
|
||||
command:/usr/local/opnsense/scripts/OPNsense/smart/detailed_list.sh
|
||||
command:/usr/local/opnsense/scripts/OPNsense/Smart/detailed_list.sh
|
||||
parameters:
|
||||
type:script_output
|
||||
message:list installed devices
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
//set variable for custom title
|
||||
$smart_status_title = "SMART Status";
|
||||
$smart_status_title_link = "ui/smart";
|
||||
|
||||
$smart_status_title = gettext('SMART Status');
|
||||
$smart_status_title_link = 'ui/smart';
|
||||
|
|
|
|||
Loading…
Reference in a new issue