Skip to content

Commit

Permalink
sysutils/smart: style and directory change
Browse files Browse the repository at this point in the history
  • Loading branch information
fichtner committed Jan 13, 2019
1 parent 50d6842 commit 57a9838
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*/

namespace OPNsense\Smart;

class IndexController extends \OPNsense\Base\IndexController
{
public function indexAction()
Expand Down
60 changes: 29 additions & 31 deletions sysutils/smart/src/opnsense/mvc/app/views/OPNsense/Smart/index.volt
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
{#

Copyright (C) 2018 Smart-Soft
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2010 Jim Pingle <[email protected]>
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 <[email protected]>
# 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">

Expand Down Expand Up @@ -229,7 +227,7 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</table>
</div>
<pre class="hidden" id="logsMsg">
<pre class="hidden" id="logsMsg">
</pre>
</section>

Expand All @@ -254,7 +252,7 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</table>
</div>
<pre class="hidden" id="abortTestMsg">
<pre class="hidden" id="abortTestMsg">
</pre>
</section>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions sysutils/smart/src/www/widgets/include/smart_status.inc
Original file line number Diff line number Diff line change
@@ -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';

0 comments on commit 57a9838

Please sign in to comment.