diff options
author | Stephen Beaver <sbeaver@netgate.com> | 2016-09-14 15:32:20 -0400 |
---|---|---|
committer | Stephen Beaver <sbeaver@netgate.com> | 2016-09-14 15:32:20 -0400 |
commit | 1c402413913bab1938b967283b315adca364a23b (patch) | |
tree | b775363283a51c9f6811709a0e8004180301c5bc /src/etc/inc/service-utils.inc | |
parent | 1c1f08f92e8841f7282280caeed7613edd810453 (diff) | |
parent | 9979487e0e2b24a3fa5daebc96902f78185cc64d (diff) | |
download | pfsense-1c402413913bab1938b967283b315adca364a23b.zip pfsense-1c402413913bab1938b967283b315adca364a23b.tar.gz |
Merge pull request #2975 from NOYB/Services_Status
Diffstat (limited to 'src/etc/inc/service-utils.inc')
-rw-r--r-- | src/etc/inc/service-utils.inc | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/src/etc/inc/service-utils.inc b/src/etc/inc/service-utils.inc index 654d4c8..d053b24 100644 --- a/src/etc/inc/service-utils.inc +++ b/src/etc/inc/service-utils.inc @@ -454,27 +454,50 @@ function get_service_status($service) { return $running; } -function get_service_status_icon($service, $withtext = true, $smallicon = false) { - global $g; +function get_service_status_icon($service, $withtext = true, $smallicon = false, $withthumbs = false, $title = "service_state") { $output = ""; + if (get_service_status($service)) { $statustext = gettext("Running"); - $output .= "<a title=\"" . sprintf(gettext("%s Service is"), $service["name"]) . " {$statustext}\" ><i class=\""; - $output .= ($smallicon) ? "fa fa-play" : "fa fa-lg fa-play"; - $output .= "\" ></i></a>"; - if ($withtext) { - $output .= " " . $statustext; - } + $text_class = "text-success"; + $fa_class = "fa fa-play"; + $fa_class_thumbs = "fa fa-thumbs-o-up"; + $Thumbs_UpDown = "Thumbs up"; } else { - $service_enabled = is_service_enabled($service['name']); - $statustext = ($service_enabled) ? gettext("Stopped") : gettext("Disabled"); - $output .= "<a title=\"" . sprintf(gettext("%s Service is"), $service["name"]) . " {$statustext}\" ><i class=\""; - $output .= ($smallicon) ? "fa fa-times" : "fa fa-lg fa-times"; - $output .= "\" ></i></a>"; - if ($withtext) { - $output .= " " . $statustext; + if (is_service_enabled($service['name'])) { + $statustext = gettext("Stopped"); + $text_class = "text-danger"; + $fa_class = "fa fa-stop"; + } else { + $statustext = gettext("Disabled"); + $text_class = "text-warning"; + $fa_class = "fa fa-ban"; } + $fa_class_thumbs = "fa fa-thumbs-o-down"; + $Thumbs_UpDown = "Thumbs down"; + } + $fa_size = ($smallicon) ? "fa-1x" : "fa-lg"; + + $spacer = ($withthumbs || $withtext) ? " " : ""; + if ($title == "state") { + $output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"{$statustext}\"></i>{$spacer}"; + } elseif ($title == "service_state") { + $output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"" . sprintf(gettext("%s Service is %s"), $service["name"], $statustext) . "\"></i>{$spacer}"; + } elseif ($title == "description_state") { + $output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"" . sprintf(gettext("%s, %s Service is %s"), $service["description"], $statustext) . "\"></i>{$spacer}"; + } elseif ($title == "description_service_state") { + $output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"" . sprintf(gettext("%s, %s Service is %s"), $service["description"], $service["name"], $statustext) . "\"></i>{$spacer}"; } + + $spacer = ($withtext) ? " " : ""; + if ($withthumbs) { + $output .= "<i class=\"{$text_class} {$fa_class_thumbs} {$fa_size}\" title=\"{$Thumbs_UpDown}\"></i>{$spacer}"; + } + + if ($withtext) { + $output .= "<span class=\"" . $text_class . "\">" . $statustext . "</span>"; + } + return $output; } |