An embeddable attendance calendar for visualising personnel attendance over time.
- Run
bower install && npm install
- Install Docker and run the mongo container
docker run -P --name att-cal-db -d mongo
- Check which host
docker-machine ip default
and portdocker ps -a
the db is running on - Run
DB_HOST=dbhost DB_PORT=dbport node server.js
wheredbhost
anddbport
are the host and port from previeous step
All server api calls are published under the /api
prefix. For example /api/calendars
. The server accepts JSON and responds with JSON.
Single item responses are returned at the root of the response.
{
"_id": "5860ecad5a2e435e02edbe79",
"name": "My calendar",
}
Lists are returned in a wrapper under the data
property. The meta
property contains metadata about the list (for paging etc).
{
"data": [
{
"_id": "5860ecad5a2e435e02edbe79",
"name": "My calendar"
}
],
"meta": {
"totalItems": 1
}
}
CRUD endpoint for calendars. A calendar has a name and a collection of attendees, i.e. people who are participating in the calendar.
name
(String) - the name of the calendarattendees
(Array) - list of the attendees of the calendar. For POST/PUT this is the_id
s of theattendees
, in GET operations it contains the fullattendee
objects. (See Attendees)
{
"name": "My calendar",
"attendees": []
}
- GET /calendars
- GET /calendars/{_id}
- POST /calendars
- PUT /calendars/{_id}
- DELETE /calendars/{_id}
Example request body
{
"name": "Fred's calendar",
"attendees": ["5860ede05a2e435e02edbe7b", "5860edce5a2e435e02edbe7a"]
}
Example response body
{
"_id": "5860ecad5a2e435e02edbe79",
"name": "Fred's calendar",
"__v": 0,
"attendees": [
{
"_id": "5860ede05a2e435e02edbe7b",
"__v": 0,
"attendances": [],
"name": "John Doe"
}
]
}
An attendee is a person who participates in the attendance calendar.
name
(String) - The name of the attendeeattendances
(Array) - A list of attendance statuses (present/absent) based on date for the attendee (see Attendances)
{
"name": "John Doe",
"attendances": []
}
- GET /attendees
- GET /attendees/{_id}
- POST /attendees
- PUT /attendees/{_id}
- DELETE /attendees/{_id}
Example request body
{
"name": "John Doe",
"attendances": []
}
Example response body
{
"data": [
{
"_id": "5860edce5a2e435e02edbe7a",
"__v": 0,
"attendances": [],
"name": "John Doe"
},
],
"meta": {
"totalItems": 1
}
}
A single attendance record, containing date and status along with calendar id and attendee id.
date
(Date) - The date of the attendance recordstatus
(String) - The attendance status (one ofabsent
,present
)calendar
(String) - The id of the calendar this record belongs toattendee
(String) - The id of the attendee this record belongs to
{
"calendar": "5860ecad5a2e435e02edbe79",
"attendee": "5860edce5a2e435e02edbe7a",
"status": "absent",
"date": "2016-12-26T11:03:39.381Z"
}
- GET /attendances
- GET /attendances/{_id}
- POST /attendances
- PUT /attendances/{_id}
- DELETE /attendances/{_id}
- GET /attendances/search?queryKey=queryValue
Example request body
{
"date": "2016-12-26T11:03:39.381Z",
"status": "absent",
"attendee": "5860edce5a2e435e02edbe7a",
"calendar": "5860ecad5a2e435e02edbe79"
}
Example response body
{
"data": [
{
"_id": "586104a34909f56c106bba79",
"calendar": "5860ecad5a2e435e02edbe79",
"attendee": "5860edce5a2e435e02edbe7a",
"status": "absent",
"__v": 0,
"date": "2016-12-26T11:03:39.381Z"
}
],
"meta": {
"totalItems": 1
}
}
Example search operation
Note: All query parameters except those allowed by the API are filtered out. Allowed query parameters are
calendar
(calendarId)attendee
(attendeeId)
GET /api/attendances/search?calendar=5860ecad5a2e435e02edbe79&attendee=5860edce5a2e435e02edbe7a