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
9896d2e3
Commit
9896d2e3
authored
Apr 17, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
services: control button rework
Suggested by: @adschellevis
parent
b3b5bd30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
27 deletions
+26
-27
services.inc
src/etc/inc/services.inc
+4
-21
foot.inc
src/www/foot.inc
+22
-6
No files found.
src/etc/inc/services.inc
View file @
9896d2e3
...
...
@@ -2785,30 +2785,13 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false)
function
get_service_control_links
(
$service
,
$addname
=
false
)
{
$service_id
=
isset
(
$service
[
'id'
])
?
$service
[
'id'
]
:
''
;
$service_act
=
sprintf
(
'srv_status_act_%s%s'
,
$service
[
'name'
],
$service_id
);
$service_title
=
$addname
?
$service
[
'name'
]
.
' '
:
''
;
$template
=
'<span data-service_id="%s" data-service_action="%s" data-service="%s" '
;
$template
.=
'data-toggle="tooltip" data-placement="bottom" title="%s" '
;
$template
.=
'class="btn btn-default %s %s"></span>'
.
PHP_EOL
;
$output
=
"
<script type='text/javascript'>
$( document ).ready(function() {
$('.
{
$service_act
}
').click(function(event){
event.preventDefault();
params = {};
params['action'] = $(this).data('service_action');
params['service'] = $(this).data('service');
params['id'] = $(this).data('service_id');
$.post('/status_services.php',params, function(data) {
// refresh page after service action via server
location.reload(true);
});
});
});
</script>
"
;
$output
=
''
;
if
(
get_service_status
(
$service
))
{
$output
.=
sprintf
(
...
...
@@ -2817,7 +2800,7 @@ function get_service_control_links($service, $addname = false)
'restart'
,
$service
[
'name'
],
sprintf
(
gettext
(
'Restart %sService'
),
$service_title
),
$service_act
,
'srv_status_act'
,
'glyphicon glyphicon-refresh'
);
...
...
@@ -2827,7 +2810,7 @@ function get_service_control_links($service, $addname = false)
'stop'
,
$service
[
'name'
],
sprintf
(
gettext
(
'Stop %sService'
),
$service_title
),
$service_act
,
'srv_status_act'
,
'glyphicon glyphicon-stop'
);
}
else
{
...
...
@@ -2837,7 +2820,7 @@ function get_service_control_links($service, $addname = false)
'start'
,
$service
[
'name'
],
sprintf
(
gettext
(
'Start %sService'
),
$service_title
),
$service_act
,
'srv_status_act'
,
'glyphicon glyphicon-play'
);
}
...
...
src/www/foot.inc
View file @
9896d2e3
...
...
@@ -63,11 +63,27 @@
<?php
endif
;
?>
<!-- bootstrap script -->
<script
type=
"text/javascript"
src=
"/ui/js/bootstrap.min.js"
></script>
<!-- Fancy select with search options -->
<script
type=
"text/javascript"
src=
"/ui/js/bootstrap-select.min.js"
></script>
<!-- bootstrap dialog -->
<script
src=
"/ui/js/bootstrap-dialog.min.js"
></script>
<!-- bootstrap script -->
<script
type=
"text/javascript"
src=
"/ui/js/bootstrap.min.js"
></script>
<!-- Fancy select with search options -->
<script
type=
"text/javascript"
src=
"/ui/js/bootstrap-select.min.js"
></script>
<!-- bootstrap dialog -->
<script
type=
"text/javascript"
src=
"/ui/js/bootstrap-dialog.min.js"
></script>
<!-- service control hook -->
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
'
.srv_status_act
'
).
click
(
function
(
event
){
event
.
preventDefault
();
params
=
{};
params
[
'
action
'
]
=
$
(
this
).
data
(
'
service_action
'
);
params
[
'
service
'
]
=
$
(
this
).
data
(
'
service
'
);
params
[
'
id
'
]
=
$
(
this
).
data
(
'
service_id
'
);
$
.
post
(
'
/status_services.php
'
,
params
,
function
(
data
)
{
// refresh page after service action via server
location
.
reload
(
true
);
});
});
});
</script>
</body>
</html>
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