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