Skip to content

Commit

Permalink
Release 1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligu committed Oct 17, 2024
1 parent bc0ddb5 commit 915307c
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 25 deletions.
2 changes: 1 addition & 1 deletion rock-s0/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions rock-s0/cockpit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
<div id="content">
<h1>Matterbridge Dashboard</h1>
<button id="frontend-button">Open the frontend</button>
<h4>System logs:</h1>
<div id="logs">Fetching logs...</div>
<div id="status">Loading Matterbridge status...</div>
<div id="matterbridge-current">Loading Matterbridge current version...</div>
<div id="matterbridge-latest">Loading Matterbridge latest version...</div>
<div id="shelly-current">Loading Shelly plugin current version...</div>
<div id="shelly-latest">Loading Shelly plugin latest version...</div>
<h4>System logs:</h4>
<div id="logs">Fetching logs...</div>
</div>
</body>

Expand Down
20 changes: 9 additions & 11 deletions rock-s0/cockpit/manifest.json
Original file line number Diff line number Diff line change
@@ -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';"
}
22 changes: 13 additions & 9 deletions rock-s0/cockpit/matterbridge.css
Original file line number Diff line number Diff line change
@@ -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;
}
80 changes: 79 additions & 1 deletion rock-s0/cockpit/matterbridge.js
Original file line number Diff line number Diff line change
@@ -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;
})
Expand All @@ -27,5 +100,10 @@ cockpit.transport.wait(function () {
});

// Initial fetch of status and logs
fetchStatus();
fetchMatterbridgeCurrent();
fetchMatterbridgeLatest();
fetchShellyCurrent();
fetchShellyLatest();
fetchLogs();
});
1 change: 0 additions & 1 deletion src/shellyDevice.realgen1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 915307c

Please sign in to comment.