mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-12 08:47:40 -05:00
return SHortnames in events
This commit is contained in:
@@ -23,7 +23,7 @@ exports.getEvent = async function (req, res, next) {
|
||||
|
||||
exports.getEvents = async function (req, res, next) {
|
||||
try {
|
||||
let events = await Event.find({},["title", "description", "startTime", "endTime", "expireTime", "numCalls", "createdAt"]).exec();
|
||||
let events = await Event.find({},["title", "description", "startTime", "endTime", "expireTime", "numCalls", "createdAt", "shortNames"]).exec();
|
||||
res.contentType('json');
|
||||
res.send(JSON.stringify(events));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { Component } from "react";
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
|
||||
import {
|
||||
Container,
|
||||
@@ -10,55 +10,55 @@ import {
|
||||
Divider,
|
||||
Table
|
||||
} from "semantic-ui-react";
|
||||
import NavBar from "../Common/NavBar"
|
||||
import NavBar from "../Common/NavBar"
|
||||
import { useGetEventsQuery } from "../features/api/apiSlice";
|
||||
|
||||
// ----------------------------------------------------
|
||||
|
||||
const ListEvents = (props) => {
|
||||
|
||||
const dateRange = (start, end) => {
|
||||
if (start.getYear() != end.getYear()) {
|
||||
return start.toLocaleDateString('en-us', { weekday:"short", year:"numeric", month:"short", day:"numeric"}) + " " + start.toLocaleTimeString() + " - " + end.toLocaleDateString('en-us', { weekday:"short", year:"numeric", month:"short", day:"numeric"}) + " " + end.toLocaleTimeString();
|
||||
} else if (start.getMonth() != end.getMonth()) {
|
||||
return start.toLocaleDateString('en-us', { weekday:"short", month:"short", day:"numeric"}) + " " + start.toLocaleTimeString() + " - " + end.toLocaleDateString('en-us', { weekday:"short", month:"short", day:"numeric"}) + " " + end.toLocaleTimeString();
|
||||
|
||||
} else if (start.getDay() != end.getDay()) {
|
||||
return start.toLocaleDateString('en-us', { weekday:"short", month:"short", day:"numeric"}) + " " + start.toLocaleTimeString() + " - " + end.toLocaleDateString('en-us', { weekday:"short", day:"numeric"}) + " " + end.toLocaleTimeString();
|
||||
|
||||
} else {
|
||||
return start.toLocaleDateString('en-us', { weekday:"short", month:"short", day:"numeric"}) + " " + start.toLocaleTimeString() + " - " + end.toLocaleTimeString();
|
||||
|
||||
}
|
||||
const dateRange = (start, end) => {
|
||||
if (start.getYear() != end.getYear()) {
|
||||
return start.toLocaleDateString('en-us', { weekday: "short", year: "numeric", month: "short", day: "numeric" }) + " " + start.toLocaleTimeString() + " - " + end.toLocaleDateString('en-us', { weekday: "short", year: "numeric", month: "short", day: "numeric" }) + " " + end.toLocaleTimeString();
|
||||
} else if (start.getMonth() != end.getMonth()) {
|
||||
return start.toLocaleDateString('en-us', { weekday: "short", month: "short", day: "numeric" }) + " " + start.toLocaleTimeString() + " - " + end.toLocaleDateString('en-us', { weekday: "short", month: "short", day: "numeric" }) + " " + end.toLocaleTimeString();
|
||||
|
||||
} else if (start.getDay() != end.getDay()) {
|
||||
return start.toLocaleDateString('en-us', { weekday: "short", month: "short", day: "numeric" }) + " " + start.toLocaleTimeString() + " - " + end.toLocaleDateString('en-us', { weekday: "short", day: "numeric" }) + " " + end.toLocaleTimeString();
|
||||
|
||||
} else {
|
||||
return start.toLocaleDateString('en-us', { weekday: "short", month: "short", day: "numeric" }) + " " + start.toLocaleTimeString() + " - " + end.toLocaleTimeString();
|
||||
|
||||
}
|
||||
|
||||
const {data:events, isSuccess} = useGetEventsQuery();
|
||||
|
||||
|
||||
}
|
||||
|
||||
const { data: events, isSuccess } = useGetEventsQuery();
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<div>
|
||||
<NavBar/>
|
||||
<Container >
|
||||
<Divider horizontal style={{paddingTop:"5em", paddingBottom:"2em"}}><Header as="h1">Events<Icon name='rss' /></Header></Divider>
|
||||
<Table basic="very">
|
||||
//<Table.Cell>{event.shortNames.map( shortName => <Link to={"/system/"+shortName}>{shortName}</Link> )}</Table.Cell>}
|
||||
return (
|
||||
<div>
|
||||
<NavBar />
|
||||
<Container >
|
||||
<Divider horizontal style={{ paddingTop: "5em", paddingBottom: "2em" }}><Header as="h1">Events<Icon name='rss' /></Header></Divider>
|
||||
<Table basic="very">
|
||||
<Table.Body>
|
||||
|
||||
{isSuccess&&events.map((event, index) =>
|
||||
<Table.Row key={index}>
|
||||
<Table.Cell><Link to={"/events/"+event._id}><Header as='h3'>{event.title}</Header></Link></Table.Cell>
|
||||
{isSuccess && events.map((event, index) =>
|
||||
<Table.Row key={index}>
|
||||
<Table.Cell><Link to={"/events/" + event._id}><Header as='h3'>{event.title}</Header></Link></Table.Cell>
|
||||
<Table.Cell>{event.description}</Table.Cell>
|
||||
<Table.Cell>{event.numCalls} Calls</Table.Cell>
|
||||
<Table.Cell>{dateRange(new Date(event.startTime),new Date(event.endTime))}</Table.Cell>
|
||||
</Table.Row>
|
||||
)}
|
||||
<Table.Cell>{dateRange(new Date(event.startTime), new Date(event.endTime))}</Table.Cell>
|
||||
</Table.Row>
|
||||
)}
|
||||
</Table.Body>
|
||||
</Table>
|
||||
</Container>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
</Table>
|
||||
</Container>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export default ListEvents;
|
||||
|
||||
Reference in New Issue
Block a user