Skip to content

Commit

Permalink
Further work on the conference widgets.
Browse files Browse the repository at this point in the history
  • Loading branch information
robol committed Nov 22, 2023
1 parent 4ec02fe commit 6b4d732
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 8 deletions.
20 changes: 20 additions & 0 deletions server/controllers/processes/seminars.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const InstitutionController = require('../InstitutionController')
const EventSeminarController = require('../EventSeminarController')
const GrantController = require('../GrantController')

const Person = require('../../models/Person')

const controller = new EventSeminarController()

router.get('/', async (req, res) => {
Expand Down Expand Up @@ -89,6 +91,24 @@ router.get('/add/person/search', async (req, res) => {
await controller.search(req, res)
})

router.get('/add/person/by-email', async (req, res) => {
const email = req.query.email
if (email) {
const p = await Person.aggregate([
{ $match: { email } },
{ $project: {
_id: 1,
firstName: 1,
lastName: 1,
email: 1
}}])
res.json({ data: p })
}
else {
res.status(404).json({ error: "Missing email field"})
}
})

router.put('/add/person', async (req, res) => {
const controller = new PersonController()
await controller.put(req, res)
Expand Down
5 changes: 3 additions & 2 deletions server/controllers/public/conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ async function conferenceQuery(req) {
_id: 1,
name: 1
},
notes: 1,
description: 1,
conferenceRoom: {
_id: 1,
name: 1
}
},
url: 1
}}
]

Expand Down
7 changes: 6 additions & 1 deletion server/controllers/public/conferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ async function conferencesQuery(req) {
match["grant"] = ObjectId(req.query.grant)
}

if (req.query.SSD) {
match["SSD"] = req.query.SSD
}

const pipeline = [
{ $match: match },
{ $lookup: {
Expand All @@ -44,7 +48,8 @@ async function conferencesQuery(req) {
SSD: 1,
url: 1,
conferenceRoom: 1,
notes: 1
description: 1,
url: 1
}}
]

Expand Down
12 changes: 10 additions & 2 deletions widgets/src/components/Conference.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { getManageURL } from '../utils';
import { getManageURL, getSSDLink } from '../utils';
import axios from 'axios'
import { Loading } from './Loading'

Expand Down Expand Up @@ -32,10 +32,12 @@ export function Conference({ id }) {
</div>
}

console.log(data)

return <div>
<ConferenceTitle conference={data}></ConferenceTitle>
<Markdown remarkPlugins={[remarkMath]} rehypePlugins={[rehypeKatex]}>
{truncateText(data.notes, 300)}
{data.description}
</Markdown>
</div>
}
Expand All @@ -48,6 +50,8 @@ export function ConferenceTitle({ conference, href }) {
</a>
}

// FIXME: tradurre gli SSD nei nomi dei settori.

return <>
{title_block}
<p>
Expand All @@ -57,6 +61,10 @@ export function ConferenceTitle({ conference, href }) {
<span className="far fa-clock"></span> {formatTime(conference.endDate)}
<span className="mx-1"></span>
<span className="fas fa-map-marker-alt"></span> {conference.conferenceRoom?.name}
<span className="mx-1"></span>
<span className="fas fa-university"></span> {conference.SSD.map(x => <span className="mr-1">{getSSDLink(x)}</span>)}
{ conference.url && <><span className="mx-1"></span>
<span className="fas fa-link"></span> <a href={conference.url}>Web</a></> }
</small>
</p></>
}
Expand Down
6 changes: 3 additions & 3 deletions widgets/src/components/ConferenceList.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import rehypeKatex from 'rehype-katex'
import remarkMath from 'remark-math'
import { useQuery } from 'react-query'

export function ConferenceList({ from, to, grant }) {
const filter = { from, to, grant }
export function ConferenceList({ from, to, grant, SSD }) {
const filter = { from, to, grant, SSD }

const { isLoading, error, data } = useQuery([ 'conferences' ], async () => {
const res = await axios.get(getManageURL("public/conferences"), { params: filter })
Expand All @@ -33,7 +33,7 @@ export function ConferenceList({ from, to, grant }) {
events_block.push(
<div key={e._id}>
<ConferenceTitle conference={e} href={link}></ConferenceTitle>
<Markdown remarkPlugins={[remarkMath]} rehypePlugins={[rehypeKatex]}>{truncateText(e.notes, 200)}</Markdown>
<Markdown remarkPlugins={[remarkMath]} rehypePlugins={[rehypeKatex]}>{truncateText(e.description, 200)}</Markdown>
<hr className="my-4"></hr>
</div>
)
Expand Down
42 changes: 42 additions & 0 deletions widgets/src/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import React from 'react'

export function formatPersonName(person) {
return person.firstName + " " + person.lastName +
" " + formatAffiliations(person.affiliations)
Expand Down Expand Up @@ -93,4 +95,44 @@ export function getDMURL(path) {
else {
return "https://www.dm.unipi.it" + path
}
}

export function getSSDLink(SSD) {
var label = ""

switch (SSD) {
case "MAT/01":
label = "Mathematical Logic"
break;
case "MAT/02":
label = "Algebra"
break;
case "MAT/03":
label = "Geometry"
break;
case "MAT/04":
label = "Mathematics Education and History of Mathematics"
break;
case "MAT/05":
label = "Mathematical Analysis"
break;
case "MAT/06":
label = "Probability and Mathematical Statistics"
break;
case "MAT/07":
label = "Mathematical Physics"
break;
case "MAT/08":
label = "Numerical Analysis"
break;
case "MAT/09":
label = "Operation Research"
break;
}

if (label != "") {
return <a key={"SSD-link-" + SSD} href={"https://www.dm.unipi.it/conferenze?SSD=" + SSD.replace("/", "%2F")}>{SSD}</a>
}

return ""
}

0 comments on commit 6b4d732

Please sign in to comment.