diff --git a/pkg/systemd/init.js b/pkg/systemd/init.js index 90aa7aa70a71..7bb085f7e3ef 100644 --- a/pkg/systemd/init.js +++ b/pkg/systemd/init.js @@ -205,10 +205,14 @@ $(function() { unit.CombinedState = active_state; unit.AutomaticStartup = _("Static"); - if (unit.UnitFileState && startsWith(unit.UnitFileState, 'enabled')) + unit.AutomaticStartupIndex = 3; + if (unit.UnitFileState && startsWith(unit.UnitFileState, 'enabled')) { unit.AutomaticStartup = _("Enabled"); - else if (unit.UnitFileState && startsWith(unit.UnitFileState, 'disabled')) + unit.AutomaticStartupIndex = 1; + } else if (unit.UnitFileState && startsWith(unit.UnitFileState, 'disabled')) { unit.AutomaticStartup = _("Disabled"); + unit.AutomaticStartupIndex = 2; + } if (unit.Id.slice(-5) == "timer") { unit.is_timer = true; @@ -266,6 +270,7 @@ $(function() { var pattern = $('#services-filter button.active').attr('data-pattern'); var current_text_filter = $('#services-text-filter').val() .toLowerCase(); + var current_type_filter = parseInt($('#current-service-type').attr("data-num")); function cmp_path(a, b) { return units_by_path[a].Id.localeCompare(units_by_path[b].Id) } var sorted_keys = Object.keys(units_by_path).sort(cmp_path); @@ -292,6 +297,8 @@ $(function() { if (current_text_filter && unit.Description.toLowerCase().indexOf(current_text_filter) == -1 && unit.Id.indexOf(current_text_filter) == -1) return; + if (current_type_filter !== 0 && current_type_filter !== unit.AutomaticStartupIndex) + return; units.push(unit); }); @@ -328,6 +335,8 @@ $(function() { function clear_filters() { $("#services-text-filter").val(""); + $('#current-service-type').attr("data-num", 0); + $('#current-service-type').text(_("All")); render(); } @@ -490,6 +499,13 @@ $(function() { render(); }); + $('#services-dropdown .dropdown-menu li').on('click', function() { + var selected = $(this).children(":first"); + $("#current-service-type").text(selected.text()); + $("#current-service-type").attr("data-num", selected.attr("data-num")); + render(); + }); + update_all(); } diff --git a/pkg/systemd/services.css b/pkg/systemd/services.css index ad704b423351..684220181562 100644 --- a/pkg/systemd/services.css +++ b/pkg/systemd/services.css @@ -33,3 +33,21 @@ table.systemd-unit-relationship-table td:first-child { background-color: initial; border: initial; } + +#services-dropdown { + display: inline; +} + +#service-type { + min-width: 10rem; +} + +#services-dropdown .dropdown-menu { + margin-top: 4px; + left: auto; + right: 0; +} + +.caret { + margin-top: 6px; +} diff --git a/pkg/systemd/services.html b/pkg/systemd/services.html index 327b4fdedbff..f891f2390dbf 100644 --- a/pkg/systemd/services.html +++ b/pkg/systemd/services.html @@ -62,6 +62,19 @@
+
diff --git a/test/verify/check-services b/test/verify/check-services index e658b6d2c6f5..25c6f6317bac 100755 --- a/test/verify/check-services +++ b/test/verify/check-services @@ -211,6 +211,15 @@ Unit=test.service if m.image == "rhel-7-6-distropkg": # Introduced in #11241 return + def select_from_dropdown(value): + button_text_selector = "#services-dropdown button span:nth-of-type(1)" + item_selector = "#services-dropdown ul li a:contains({0})".format(value) + b.click("#services-dropdown button") + b.wait_present(item_selector) + b.wait_visible(item_selector) + b.click(item_selector) + b.wait_in_text(button_text_selector, value) + def wait_service_present(service): b.wait_present(svc_sel(service)) b.wait_visible(svc_sel(service)) @@ -222,6 +231,7 @@ Unit=test.service b.set_input_text("#services-text-filter", "") wait_service_present("test.service") wait_service_present("test-fail.service") + select_from_dropdown("All") b.go("#/") @@ -237,6 +247,32 @@ Unit=test.service wait_service_not_present("test.service") wait_service_present("test-fail.service") + # Select only static services + init_filter_state() + select_from_dropdown("Static") + wait_service_not_present("test.service") + wait_service_present("test-fail.service") + + # Select only disabled services + select_from_dropdown("Disabled") + wait_service_present("test.service") + wait_service_not_present("test-fail.service") + + # Check filtering and selecting together - empty state + b.set_input_text("#services-text-filter", "failing") + wait_service_not_present("test.service") + b.wait_present("#empty-search") + b.wait_visible("#empty-search") + + # Check resetting filter + b.wait_present("#clear-all-filters") + b.wait_visible("#clear-all-filters") + b.click("#clear-all-filters") + wait_service_present("test.service") + wait_service_present("test-fail.service") + self.assertEqual(b.val("#services-text-filter"), "") + self.assertEqual(b.text("#services-dropdown button span:nth-of-type(1)"), "All") + def testApi(self): m = self.machine b = self.browser