Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions packages/server-admin-ui/src/views/Dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ const Dashboard = (props) => {
numberOfAvailablePaths,
wsClients,
providerStatistics,
uptime
uptime,
devices
} = props.serverStatistics || {
deltaRate: 0,
numberOfAvailablePaths: 0,
wsClients: 0,
providerStatistics: {},
uptime: ''
uptime: '',
devices: []
}
const providerStatus = props.providerStatus || []
const errorCount = providerStatus.filter((s) => s.type === 'error').length
Expand Down Expand Up @@ -66,6 +68,11 @@ const Dashboard = (props) => {
}

const renderActivity = (providerId, providerStats, linkType) => {
let device = providerId
if (providerId.startsWith('ws.')) {
const found = devices.find((d) => d.clientId === providerId.slice(3))
device = found && found.description ? found.description : providerId
}
return (
<li key={providerId} onClick={() => props.history.push(`/dashboard`)}>
<i
Expand All @@ -84,7 +91,7 @@ const Dashboard = (props) => {
<span className="title">
{linkType === 'plugin'
? pluginNameLink(providerId)
: providerIdLink(providerId)}
: providerIdLink(providerId, device)}
</span>
{providerStats.writeRate > 0 && (
<span className="value">
Expand Down Expand Up @@ -285,11 +292,11 @@ function pluginNameLink(id) {
return <a href={'#/serverConfiguration/plugins/' + id}>{id}</a>
}

function providerIdLink(id) {
function providerIdLink(id, name) {
if (id === 'defaults') {
return <a href={'#/serverConfiguration/settings'}>{id}</a>
} else if (id.startsWith('ws.')) {
return <a href={'#/security/devices'}>{id}</a>
return <a href={'#/security/devices'}>{name}</a>
} else {
return <a href={'#/serverConfiguration/connections/' + id}>{id}</a>
}
Expand Down
14 changes: 12 additions & 2 deletions src/deltastats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import { isUndefined, values } from 'lodash'
import { EventEmitter } from 'node:events'

import { getSecurityConfig } from './security'
const STATS_UPDATE_INTERVAL_SECONDS = 5
export const CONNECTION_WRITE_EVENT_NAME = 'connectionwrite'

Expand Down Expand Up @@ -73,6 +73,15 @@ export function startDeltaStatistics(
return setInterval(() => {
updateProviderPeriodStats(app)
const anyApp = app as any
const config = getSecurityConfig(anyApp)
let devices = []
if (
anyApp &&
anyApp.securityStrategy &&
typeof anyApp.securityStrategy.getDevices === 'function'
) {
devices = anyApp.securityStrategy.getDevices(config)
}
app.emit('serverevent', {
type: 'SERVERSTATISTICS',
from: 'signalk-server',
Expand All @@ -83,7 +92,8 @@ export function startDeltaStatistics(
numberOfAvailablePaths: anyApp.streambundle.getAvailablePaths().length,
wsClients: anyApp.interfaces.ws ? anyApp.interfaces.ws.numClients() : 0,
providerStatistics: app.providerStatistics,
uptime: process.uptime()
uptime: process.uptime(),
devices: devices
}
})
app.lastIntervalDeltaCount = app.deltaCount
Expand Down
Loading