-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from Luligu/dev
Release 1.0.4
- Loading branch information
Showing
25 changed files
with
1,016 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Matterbridge Management</title> | ||
<link rel="stylesheet" href="matterbridge.css" type="text/css"> | ||
<script type="text/javascript" src="../base1/cockpit.js"></script> | ||
<script type="text/javascript" src="../manifests.js"></script> | ||
<script type="text/javascript" src="matterbridge.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div id="content"> | ||
<h1>Matterbridge Dashboard</h1> | ||
<button id="frontend-button">Open the frontend</button> | ||
<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> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "matterbridge", | ||
"title": "Matterbridge Management", | ||
"version": "1.0", | ||
"menu": { | ||
"index": { | ||
"label": "Matterbridge" | ||
} | ||
}, | ||
"content-security-policy": "default-src 'self'; script-src 'self'; style-src 'self';" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#content { | ||
font-family: Arial, sans-serif; | ||
padding: 20px; | ||
} | ||
|
||
button { | ||
padding: 5px 10px; | ||
margin: 10px 0; | ||
} | ||
|
||
#status, | ||
#matterbridge-current, | ||
#matterbridge-latest, | ||
#shelly-current, | ||
#shelly-latest, | ||
#logs { | ||
margin: 10px 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* 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'); | ||
logs = logs.replace(/\x1B\[[0-9;]*[m|s|u|K]/g, ''); | ||
document.getElementById('logs').innerText = logs; | ||
}) | ||
.catch(function (error) { | ||
console.error('Error fetching logs:', error); | ||
document.getElementById('logs').innerText = 'Error fetching logs.'; | ||
}); | ||
} | ||
|
||
// Reload the Matterbridge configuration | ||
document.getElementById('frontend-button').addEventListener('click', function () { | ||
const hostname = window.location.hostname; | ||
const newUrl = `http://${hostname}:8283`; | ||
window.open(newUrl, '_blank'); | ||
}); | ||
|
||
// Initial fetch of status and logs | ||
fetchStatus(); | ||
fetchMatterbridgeCurrent(); | ||
fetchMatterbridgeLatest(); | ||
fetchShellyCurrent(); | ||
fetchShellyLatest(); | ||
fetchLogs(); | ||
}); |
Oops, something went wrong.