From 915307cce15a0d8e9b2f343711ba4ca6f49626ba Mon Sep 17 00:00:00 2001 From: Luligu <132135057+Luligu@users.noreply.github.com> Date: Thu, 17 Oct 2024 20:19:43 +0200 Subject: [PATCH] Release 1.0.4 --- rock-s0/INSTALL.md | 2 +- rock-s0/cockpit/index.html | 9 +++- rock-s0/cockpit/manifest.json | 20 ++++---- rock-s0/cockpit/matterbridge.css | 22 +++++---- rock-s0/cockpit/matterbridge.js | 80 ++++++++++++++++++++++++++++++- src/shellyDevice.realgen1.test.ts | 1 - 6 files changed, 109 insertions(+), 25 deletions(-) diff --git a/rock-s0/INSTALL.md b/rock-s0/INSTALL.md index 5f0a734..5327168 100644 --- a/rock-s0/INSTALL.md +++ b/rock-s0/INSTALL.md @@ -53,7 +53,7 @@ set the hostname of the device (change rock-s0 with the new hostname you set bef 127.0.1.1 rock-s0 -# Samba without password +# Samba without password (optional) Copy the file smb.conf to /etc/samba/smb.conf diff --git a/rock-s0/cockpit/index.html b/rock-s0/cockpit/index.html index e610cc6..3baa0ae 100644 --- a/rock-s0/cockpit/index.html +++ b/rock-s0/cockpit/index.html @@ -14,8 +14,13 @@

Matterbridge Dashboard

-

System logs:

-
Fetching logs...
+
Loading Matterbridge status...
+
Loading Matterbridge current version...
+
Loading Matterbridge latest version...
+
Loading Shelly plugin current version...
+
Loading Shelly plugin latest version...
+

System logs:

+
Fetching logs...
diff --git a/rock-s0/cockpit/manifest.json b/rock-s0/cockpit/manifest.json index ebfd3ea..c8b1545 100644 --- a/rock-s0/cockpit/manifest.json +++ b/rock-s0/cockpit/manifest.json @@ -1,13 +1,11 @@ { - "tools": { - "index": { - "label": "Matterbridge", - "keywords": [ - { - "matches": ["plugin", "apps", "addon", "add-on", "install", "extension"] + "name": "matterbridge", + "title": "Matterbridge Management", + "version": "1.0", + "menu": { + "index": { + "label": "Matterbridge" } - ] - } - }, - "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self';" -} + }, + "content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self';" +} \ No newline at end of file diff --git a/rock-s0/cockpit/matterbridge.css b/rock-s0/cockpit/matterbridge.css index d23ffde..e67bb56 100644 --- a/rock-s0/cockpit/matterbridge.css +++ b/rock-s0/cockpit/matterbridge.css @@ -1,14 +1,18 @@ #content { - font-family: Arial, sans-serif; - padding: 20px; -} - -#status, -#logs { - margin: 10px 0; + font-family: Arial, sans-serif; + padding: 20px; } button { - padding: 5px 10px; - margin: 10px 0; + padding: 5px 10px; + margin: 10px 0; } + +#status, +#matterbridge-current, +#matterbridge-latest, +#shelly-current, +#shelly-latest, +#logs { + margin: 10px 0; +} \ No newline at end of file diff --git a/rock-s0/cockpit/matterbridge.js b/rock-s0/cockpit/matterbridge.js index 0c6338d..7396280 100644 --- a/rock-s0/cockpit/matterbridge.js +++ b/rock-s0/cockpit/matterbridge.js @@ -1,15 +1,88 @@ +/* eslint-disable no-control-regex */ /* eslint-disable no-console */ // Wait for Cockpit to fully initialize cockpit.transport.wait(function () { console.log('Matterbridge Cockpit extension loaded'); + // Fetch and display the Matterbridge status + function fetchStatus() { + cockpit + .spawn(['systemctl', 'is-active', 'matterbridge']) + .then(function (status) { + document.getElementById('status').innerText = `Status: ${status.trim().replace('\n', '')}`; + }) + .catch(function (error) { + console.error('Error fetching Matterbridge status:', error); + document.getElementById('status').innerText = 'Error fetching status.'; + }); + } + + // Fetch and display the Matterbridge current version + function fetchMatterbridgeCurrent() { + cockpit + .spawn(['npm', 'list', '-g', 'matterbridge']) + .then(function (status) { + // Extract the version number using a regular expression + const versionMatch = status.match(/matterbridge@(\d+\.\d+\.\d+)/); + const version = versionMatch ? versionMatch[1] : 'Unknown'; + document.getElementById('matterbridge-current').innerText = `Current version: ${version}`; + }) + .catch(function (error) { + console.error('Error fetching Matterbridge current version:', error); + document.getElementById('matterbridge-current').innerText = 'Error fetching Matterbridge current version.'; + }); + } + + // Fetch and display the Matterbridge latest version + function fetchMatterbridgeLatest() { + cockpit + .spawn(['npm', 'show', 'matterbridge', 'version']) + // cockpit.spawn(["whoami"]) + .then(function (status) { + document.getElementById('matterbridge-latest').innerText = `Latest version: ${status.trim()}`; + }) + .catch(function (error) { + console.error('Error fetching Matterbridge latest version:', error); + document.getElementById('matterbridge-latest').innerText = 'Error fetching Matterbridge latest version.'; + }); + } + + // Fetch and display the Shelly plugin current version + function fetchShellyCurrent() { + cockpit + .spawn(['npm', 'list', '-g', 'matterbridge-shelly']) + .then(function (status) { + // Extract the version number using a regular expression + const versionMatch = status.match(/matterbridge-shelly@(\d+\.\d+\.\d+)/); + const version = versionMatch ? versionMatch[1] : 'Unknown'; + document.getElementById('shelly-current').innerText = `Shelly plugin current version: ${version}`; + }) + .catch(function (error) { + console.error('Error fetching Shelly plugin current version:', error); + document.getElementById('shelly-current').innerText = 'Error fetching Shelly plugin current version.'; + }); + } + + // Fetch and display the Shelly plugin latest version + function fetchShellyLatest() { + cockpit + .spawn(['npm', 'show', 'matterbridge-shelly', 'version']) + // cockpit.spawn(["whoami"]) + .then(function (status) { + document.getElementById('shelly-latest').innerText = `Shelly plugin latest version: ${status.trim()}`; + }) + .catch(function (error) { + console.error('Error fetching Shelly plugin latest version:', error); + document.getElementById('shelly-latest').innerText = 'Error fetching Shelly plugin latest version.'; + }); + } + // Fetch logs function fetchLogs() { cockpit .spawn(['journalctl', '-u', 'matterbridge', '--no-pager', '-n', '20', '-o', 'cat']) .then(function (logs) { // const filteredLogs = logs.split('\n').filter(line => !line.includes('matterbridge.service')).join('\n'); - // eslint-disable-next-line no-control-regex logs = logs.replace(/\x1B\[[0-9;]*[m|s|u|K]/g, ''); document.getElementById('logs').innerText = logs; }) @@ -27,5 +100,10 @@ cockpit.transport.wait(function () { }); // Initial fetch of status and logs + fetchStatus(); + fetchMatterbridgeCurrent(); + fetchMatterbridgeLatest(); + fetchShellyCurrent(); + fetchShellyLatest(); fetchLogs(); }); diff --git a/src/shellyDevice.realgen1.test.ts b/src/shellyDevice.realgen1.test.ts index 28ca3c5..8ffca06 100644 --- a/src/shellyDevice.realgen1.test.ts +++ b/src/shellyDevice.realgen1.test.ts @@ -16,7 +16,6 @@ describe('Shellies', () => { let device: ShellyDevice | undefined; const firmwareGen1 = 'v1.14.0-gcb84623'; - const firmwareGen2 = '1.4.2-gc2639da'; const address = '30:f6:ef:69:2b:c5'; beforeAll(async () => {