Skip to content

Commit

Permalink
docs: Update README with badges
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Bentley authored and Tony Bentley committed Jan 2, 2024
1 parent 33c3e86 commit f313e97
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 36 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)

# signalk-multiplex-viewer
A plugin for tracing multiplexing routes and events
A plugin for tracing NMEA 0183 and 2000 multiplexed events from Signalk server

- Select from one or more event emitters
- Choose from a list of associated events
- Filter and search for targeted NMEA sentences/pgns
- Find duplicates or missing values and validate that Signalk is providing the correct values for your NMEA connections

NOTE: Depends on signalk-server branch [ws-events](https://github.com/SignalK/signalk-server/tree/ws-events) until merged.

[![npm version](https://img.shields.io/npm/v/signalk-multiplex-viewer/latest.svg?logo=npm)](https://badge.fury.io/js/signalk-multiplex-viewer) ![github actions](https://github.com/tonybentley/signalk-multiplex-viewer/actions/workflows/actions.yaml/badge.svg?branch=main) [![signalk](https://img.shields.io/badge/signalk--node--server--plugin-blue?logo=nodedotjs)](https://www.npmjs.com/search?q=keywords:signalk-node-server-plugin) [![semantic-release: nodejs](https://img.shields.io/badge/semantic--release-nodejs-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) [![mui](https://img.shields.io/badge/MUI-v.5.15.2-e10079?logo=mui)](https://mui.com/material-ui/) [![React](https://img.shields.io/badge/React-v.18.2.0-e10079?logo=react)](https://mui.com/material-ui/)
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"name": "signalk-multiplex-viewer",
"author": "Tony Bentley",
"description": "View multiplexed data from Signal K data sources",
"version": "1.0.4",
"private": false,
"repository": "https://github.com/tonybentley/signalk-multiplex-viewer",
Expand Down
69 changes: 36 additions & 33 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const CustomToolbar = () => {

function App() {

const [data] = useState(Array<Event>());
const [events, setEvents] = useState(Array<EEListItem> ());
const [emitters, setEmitters] = useState(Array<EListItem> ());
const [eventItems, setEventItems] = useState(Array<EventItem> ());
Expand All @@ -54,6 +53,38 @@ function App() {
{ field: 'data', headerName: 'Data', description:'NMEA 0183 string, or NMEA 2000 JSON', width: 650 },
];

const initData = (eventData: Data) => {
let eventList: Array<EEListItem> = []
let emittersList: Array<EListItem> = []
eventData.events.forEach((event: Event) => {
const hasEventListItem = eventList.filter((e: EEListItem) => e.value === event.event);
const boundEmitters = Object.keys(event.emitters).filter(key=> key !== 'NO_EMITTER_ID')
//add event to eventsList
if(hasEventListItem.length === 0 && boundEmitters.length > 0){
eventList.push({
id: uuid(),
value: event.event,
emitters: boundEmitters,
checked: false,
visible: false
})
}
//add emitters to emittersList
Object.keys(event.emitters).forEach((emitter: string) => {
const hasEmitterListItem = emittersList.filter((e: EListItem) => e.value === emitter);
if(hasEmitterListItem.length === 0 && emitter !== 'NO_EMITTER_ID'){
emittersList.push({
id: uuid(),
value: emitter,
checked: false
})
}
})
});
setEmitters([...emittersList]);
setEvents([ ...eventList]);
}

const updateEventsChecked = (event: React.ChangeEvent<HTMLInputElement>) => {
const { value, checked } = event.target;
setEvents((prev: Array<EEListItem>) => {
Expand Down Expand Up @@ -132,42 +163,14 @@ function App() {
}
}, [events])

// on page load get data
useEffect(() => {
getData()
.then((eventData: Data) => {
let eventList: Array<EEListItem> = []
let emittersList: Array<EListItem> = []
eventData.events.forEach((event: Event) => {
const hasEventListItem = eventList.filter((e: EEListItem) => e.value === event.event);
const boundEmitters = Object.keys(event.emitters).filter(key=> key !== 'NO_EMITTER_ID')
//add event to eventsList
if(hasEventListItem.length === 0 && boundEmitters.length > 0){
eventList.push({
id: uuid(),
value: event.event,
emitters: boundEmitters,
checked: false,
visible: false
})
}
//add emitters to emittersList
Object.keys(event.emitters).forEach((emitter: string) => {
const hasEmitterListItem = emittersList.filter((e: EListItem) => e.value === emitter);
if(hasEmitterListItem.length === 0 && emitter !== 'NO_EMITTER_ID'){
emittersList.push({
id: uuid(),
value: emitter,
checked: false
})
}
})
});
setEmitters([...emittersList]);
setEvents([ ...eventList]);
}).catch((err) => {
.then(initData)
.catch((err) => {
throw err;
})
}, [data]);
}, []);


useEffect(() => {
Expand Down

0 comments on commit f313e97

Please sign in to comment.