diff --git a/model/services.py b/model/services.py index 54f9cd48..892f51c5 100644 --- a/model/services.py +++ b/model/services.py @@ -123,7 +123,7 @@ def parse_systemctlshow_output(output): def parse_systemctllist_output(output): - """Parses the output of 'systemctl --type=service --no-pager'. + """Parses the output of 'systemctl --type=service --no-pager --all'. Args: output (str): the output of the command. Example format: @@ -186,7 +186,7 @@ def get_services_list(): List[str]: a list of services. """ - cmd = ['systemctl', '--type=service', '--no-pager'] + cmd = ['systemctl', '--type=service', '--no-pager', '--all'] output = run_systemd_command(cmd) return parse_systemctllist_output(output) diff --git a/tests/test_services.py b/tests/test_services.py index d387cb0b..45d86f26 100644 --- a/tests/test_services.py +++ b/tests/test_services.py @@ -121,7 +121,7 @@ def test_services_get_list(self, mock_run_cmd): services_list = ServicesModel().get_list() mock_run_cmd.assert_called_once_with( - ['systemctl', '--type=service', '--no-pager'] + ['systemctl', '--type=service', '--no-pager', '--all'] ) expected_output = [ diff --git a/ui/js/host-system-services.js b/ui/js/host-system-services.js index f14e7278..0c0ae217 100644 --- a/ui/js/host-system-services.js +++ b/ui/js/host-system-services.js @@ -149,6 +149,8 @@ ginger.generateSystemServiceElem = function(value){ var name = '' if (value.name !== undefined) { name = value.name.toLowerCase(); + } else { + return; } var servicename = name.split(".service").join("").replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, ''); var id = 'service-'+servicename; @@ -180,32 +182,28 @@ ginger.generateSystemServiceElem = function(value){ description: description, cgroup: cgroup })); - if(!value.cgroup){ - $('.system-services-cgroup',systemServicesItem).remove(); - $('.column-service-details',systemServicesItem).empty().append('--'); + if((value.cgroup) && (!jQuery.isEmptyObject(value.cgroup.processes))){ + $.each(value.cgroup.processes, function(pid,process){ + var processItem = $.parseHTML(wok.substitute($("#systemServiceProcessItem").html(), { + pid: pid, + process: process + })); + $('.system-service-process-body',systemServicesItem).append(processItem); + }); + }else { + $('.system-services-process',systemServicesItem).remove(); } - else { - if(!jQuery.isEmptyObject(value.cgroup.processes)){ - $.each(value.cgroup.processes, function(pid,process){ - var processItem = $.parseHTML(wok.substitute($("#systemServiceProcessItem").html(), { - pid: pid, - process: process - })); - $('.system-service-process-body',systemServicesItem).append(processItem); - }); - }else { - $('.system-services-process',systemServicesItem).remove(); - } - if(sub === 'running') { - $('.service-start',systemServicesItem).parent().addClass('disabled'); - }else { - $('.service-stop',systemServicesItem).parent().addClass('disabled'); - } - if($('#system-services-body > li#'+id).length){ - $('#system-services-body > li#'+id).replaceWith(systemServicesItem); - }else { - $('#system-services-body').append(systemServicesItem); - } + + if(sub === 'running') { + $('.service-start',systemServicesItem).parent().addClass('disabled'); + }else { + $('.service-stop',systemServicesItem).parent().addClass('disabled'); + } + + if($('#system-services-body > li#'+id).length){ + $('#system-services-body > li#'+id).replaceWith(systemServicesItem); + }else { + $('#system-services-body').append(systemServicesItem); } };