Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
865b51da
Commit
865b51da
authored
May 03, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(dashboard, widgets) refactor services_status.widget.php
parent
85149c0e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
45 deletions
+54
-45
services_status.widget.php
src/www/widgets/widgets/services_status.widget.php
+54
-45
No files found.
src/www/widgets/widgets/services_status.widget.php
View file @
865b51da
...
...
@@ -29,73 +29,82 @@
POSSIBILITY OF SUCH DAMAGE.
*/
$nocsrf
=
true
;
require_once
(
"guiconfig.inc"
);
require_once
(
"services.inc"
);
require_once
(
"system.inc"
);
require_once
(
'plugins.inc'
);
require_once
(
"ipsec.inc"
);
require_once
(
"interfaces.inc"
);
require_once
(
"widgets/include/services_status.inc"
);
$services
=
services_get
();
if
(
isset
(
$_POST
[
'servicestatusfilter'
]))
{
$config
[
'widgets'
][
'servicestatusfilter'
]
=
htmlspecialchars
(
$_POST
[
'servicestatusfilter'
],
ENT_QUOTES
|
ENT_HTML401
);
write_config
(
"Saved Service Status Filter via Dashboard"
);
header
(
"Location:
../..
/index.php"
);
header
(
"Location: /index.php"
);
}
?>
<input
type=
"hidden"
id=
"services_status-config"
name=
"services_status-config"
value=
""
/>
<div
id=
"services_status-settings"
class=
"widgetconfigdiv"
style=
"display:none;"
>
<form
action=
"/widgets/widgets/services_status.widget.php"
method=
"post"
name=
"iformd"
>
<?=
gettext
(
'Comma separated list of services to NOT display in the widget'
)
?>
<br
/>
<input
type=
"text"
size=
"30"
name=
"servicestatusfilter"
class=
"formfld unknown"
id=
"servicestatusfilter"
value=
"
<?=
$config
[
'widgets'
][
'servicestatusfilter'
]
?>
"
/>
<input
id=
"submitd"
name=
"submitd"
type=
"submit"
class=
"btn btn-primary"
value=
"Save"
/>
</form>
<form
action=
"/widgets/widgets/services_status.widget.php"
method=
"post"
name=
"iformd"
>
<table
class=
"table table-condensed"
>
<thead>
<tr>
<th>
<?=
gettext
(
'Comma separated list of services to NOT display in the widget'
)
?>
</th>
</tr>
</thead>
<tbody>
<tr>
<td><input
type=
"text"
name=
"servicestatusfilter"
id=
"servicestatusfilter"
value=
"
<?=
$config
[
'widgets'
][
'servicestatusfilter'
]
?>
"
/></td>
</tr>
<tr>
<td>
<input
id=
"submitd"
name=
"submitd"
type=
"submit"
class=
"btn btn-primary"
value=
"Save"
/>
</td>
</tr>
</tbody>
</table>
</form>
</div>
<table
class=
"table table-striped"
width=
"100%"
border=
"0"
cellpadding=
"0"
cellspacing=
"0"
summary=
"services"
>
<tr>
<td
class=
"widgetsubheader"
align=
"center"
><b>
<?=
gettext
(
'Service'
)
?>
</b></td>
<td
class=
"widgetsubheader"
align=
"center"
><b>
<?=
gettext
(
'Description'
)
?>
</b></td>
<td
class=
"widgetsubheader"
align=
"center"
><b>
<?=
gettext
(
'Status'
)
?>
</b></td>
<td
class=
"widgetsubheader"
>
</td>
</tr>
<table
class=
"table table-striped table-condensed"
>
<thead>
<tr>
<th>
<?=
gettext
(
'Service'
)
?>
</th>
<th>
<?=
gettext
(
'Description'
)
?>
</th>
<th>
<?=
gettext
(
'Status'
)
?>
</th>
</tr>
</thead>
<tbody>
<?php
$skipservices
=
explode
(
","
,
$config
[
'widgets'
][
'servicestatusfilter'
]);
if
(
count
(
$services
)
>
0
)
{
uasort
(
$services
,
"service_name_compare"
);
foreach
(
$services
as
$service
)
{
if
(
!
$service
[
'name'
]
||
in_array
(
$service
[
'name'
],
$skipservices
))
{
continue
;
}
$service_desc
=
explode
(
"."
,
$service
[
'description'
]);
echo
"<tr><td class=
\"
listlr
\"
>"
.
$service
[
'name'
]
.
"</td>
\n
"
;
echo
"<td class=
\"
listr
\"
>"
.
$service_desc
[
0
]
.
"</td>
\n
"
;
// if service is running then listr else listbg
$bgclass
=
null
;
if
(
get_service_status
(
$service
))
{
$bgclass
=
"listr"
;
}
else
{
$bgclass
=
"listbg"
;
}
echo
"<td class=
\"
"
.
$bgclass
.
"
\"
align=
\"
center
\"
>"
.
str_replace
(
'btn '
,
'btn btn-xs '
,
get_service_status_icon
(
$service
,
false
,
true
))
.
"</td>
\n
"
;
echo
"<td valign=
\"
middle
\"
class=
\"
list nowrap
\"
>"
.
str_replace
(
'btn '
,
'btn btn-xs '
,
get_service_control_links
(
$service
))
.
"</td></tr>
\n
"
;
}
}
else
{
echo
"<tr><td colspan=
\"
3
\"
align=
\"
center
\"
>"
.
gettext
(
"No services found"
)
.
" . </td></tr>
\n
"
;
}
?>
$skipservices
=
explode
(
","
,
$config
[
'widgets'
][
'servicestatusfilter'
]);
if
(
count
(
$services
)
>
0
)
:
uasort
(
$services
,
"service_name_compare"
);
foreach
(
$services
as
$service
)
:
if
(
!
$service
[
'name'
]
||
in_array
(
$service
[
'name'
],
$skipservices
))
{
continue
;
}
$service_desc
=
explode
(
"."
,
$service
[
'description'
]);
?>
<tr>
<td>
<?=
$service
[
'name'
];
?>
</td>
<td>
<?=
$service_desc
[
0
];
?>
</td>
<td>
<?=
str_replace
(
'btn '
,
'btn btn-xs '
,
get_service_status_icon
(
$service
,
false
,
true
));
?>
<?=
str_replace
(
'btn '
,
'btn btn-xs '
,
get_service_control_links
(
$service
));
?>
</td>
</tr>
<?php
endforeach
;
else
:?>
<
tr
><
td
colspan
=
"3"
><?=
gettext
(
"No services found"
);
?>
</td></tr>
<?php
endif
;
?>
</tbody>
</table>
<!-- needed to display the widget settings menu -->
<script
type=
"text/javascript"
>
//
<!
[
CDATA
[
selectIntLink
=
"
services_status-configure
"
;
textlink
=
document
.
getElementById
(
selectIntLink
);
textlink
.
style
.
display
=
"
inline
"
;
selectIntLink
=
"
services_status-configure
"
;
textlink
=
document
.
getElementById
(
selectIntLink
);
textlink
.
style
.
display
=
"
inline
"
;
//]]>
</script>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment