LCOV - code coverage report
Current view: top level - pkg/playground - service.js Coverage Total Hit
Test: cockpit Lines: 93.3 % 30 28
Test Date: 2026-07-17 07:33:01

            Line data    Source code
       1              : // SPDX-License-Identifier: LGPL-2.1-or-later
       2            1 : import cockpit from "cockpit";
       3              : 
       4              : import '../lib/patternfly/patternfly-6-cockpit.scss';
       5              : 
       6              : import * as service from "service";
       7              : 
       8            1 : document.addEventListener("DOMContentLoaded", () => {
       9            1 :     let proxy;
      10              : 
      11            1 :     function navigate() {
      12            0 :         proxy = service.proxy(cockpit.location.path[0] || "");
      13              : 
      14            1 :         function show() {
      15            1 :             function s(t) {
      16            1 :                 document.getElementById(t).textContent = JSON.stringify(proxy[t]);
      17            1 :             }
      18            1 :             s('exists');
      19            1 :             s('state');
      20            1 :             s('enabled');
      21            1 :         }
      22              : 
      23            1 :         proxy.addEventListener("changed", show);
      24            1 :         show();
      25              : 
      26            1 :         document.body.removeAttribute("hidden");
      27            1 :     }
      28              : 
      29            1 :     function b(t) {
      30            1 :         document.getElementById(t).addEventListener("click", () => {
      31            1 :             proxy[t]()
      32            0 :                     .catch(error => console.error("action", t, "failed:", JSON.stringify(error)));
      33            1 :         });
      34            1 :     }
      35              : 
      36            1 :     b('start');
      37            1 :     b('stop');
      38            1 :     b('enable');
      39            1 :     b('disable');
      40              : 
      41            1 :     cockpit.addEventListener("locationchanged", navigate);
      42            1 :     navigate();
      43            1 : });
        

Generated by: LCOV version 2.0-1