Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
Merge origin/main into the-final-countdown
Browse files Browse the repository at this point in the history
* origin/main:
  Bump node-fetch from 2.6.0 to 2.6.1 (#179)
  Bump http-proxy from 1.17.0 to 1.18.1 (#178)
  Graceful fail: hoursForDate() w/ invalid location (#177)
  Fail gracefully for dropped LibCal hours locations (#176)
  Heroku staging autodeploys from main branch (#175)
  Bump to node-sass v4.14.1 & sass-loader v7.3.1 (#174)
  Bump nuxt to latest release v2.14.0 (#173)
  Quick fix: fail gracefully now that R25 is no more (#172)
  Bump elliptic from 6.5.0 to 6.5.3 (#171)
  Bump lodash from 4.17.15 to 4.17.19 (#170)
  Bump acorn from 6.2.1 to 6.4.1 (#169)
  Specify today as date for LibCal API hours request (#166)
  Changed the VUE file to format the new location
  Added the new location to the config file
  • Loading branch information
cappadona committed Sep 22, 2020
2 parents 21dd01f + de03a29 commit 478db2d
Show file tree
Hide file tree
Showing 8 changed files with 3,179 additions and 2,394 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Automatic review apps spun up for all PRs. Just click the **View Deployment** bu
> Stale review apps are destroyed after 5 days of inactivity
### Staging
Automatic deploy to staging instance on every PR merge to `master` branch.
Automatic deploy to staging instance on every PR merge to `main` branch.

### Production
Production instance must be manually deployed via [Heroku dashboard](https://dashboard.heroku.com).
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@nuxtjs/axios": "^5.1.1",
"body-parser": "^1.18.3",
"dotenv": "^7.0.0",
"lodash": "^4.17.13",
"lodash": "^4.17.19",
"nanoid": "^2.0.1",
"nuxt": "^2.5.1"
},
Expand Down
6 changes: 6 additions & 0 deletions pages/_location/consult/_desk.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ export default {
font-size: 25.6vh;
letter-spacing: -1vw;
}
&.copyright {
padding: .05em 0 0;
font-size: 25.6vh;
letter-spacing: -1vw;
}
}
.knockout {
Expand Down
30 changes: 23 additions & 7 deletions store/hours.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { assign, isEmpty } from 'lodash'
import schema from '~/utils/schema'
import libCal from '~/utils/libcal'
import moment from 'moment'

export const state = () => ({
})
Expand All @@ -24,20 +25,35 @@ export const actions = {
const isCirc = typeof payload.circ === 'undefined' ? false : payload.circ
const feed = await libCal.getHours(this.$axios, payload.location, category, undefined, isDesk, isCirc)

const libCalStatus = feed.locations[0].times.status
// Account for locations open 24 hours
if (libCalStatus === '24hours') {
var allHours = libCalStatus
// Account for locations that were removed from LibCal hours
// -- but signage config has not yet been updated/synced
if (feed.locations.length) {
// If location exists in LibCal hours, proceed as usual...
const libCalStatus = feed.locations[0].times.status
var locationName = feed.locations[0].name

// Account for locations open 24 hours
if (libCalStatus === '24hours') {
var allHours = libCalStatus
} else {
allHours = typeof feed.locations[0].times.hours === 'undefined' ? null : feed.locations[0].times.hours
}
var status = await libCal.openNow(this.$axios, payload.location, category, libCalStatus, allHours, isDesk, isCirc)
} else {
allHours = typeof feed.locations[0].times.hours === 'undefined' ? null : feed.locations[0].times.hours
// Otherwise, set some fallbacks (aka fail gracefully)...
locationName = 'undefined'
status = {
'change': null,
'current': 'closed',
'timestamp': moment()
}
}
const status = await libCal.openNow(this.$axios, payload.location, category, libCalStatus, allHours, isDesk, isCirc)

// Relabel status under certain circumstances
let statusLabel = libCal.statusLabel(payload.location, status.current)

const hoursData = {
'name': feed.locations[0].name,
'name': locationName,
'hours': allHours,
'status': statusLabel,
'statusChange': status.change,
Expand Down
4 changes: 2 additions & 2 deletions utils/libcal.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const libCal = {
api: {
endpoints: {
auth: 'libcal/1.1/oauth/token',
hours: 'libcal-hours/api_hours_date.php?iid=973&format=json&nocache=1&lid=',
hours: 'libcal-hours/api_hours_date.php?iid=973&format=json&nocache=1&date=today&lid=',
spaces: {
bookings: 'libcal/1.1/space/bookings?limit=100&',
get bookingsWithDetails () {
Expand Down Expand Up @@ -305,7 +305,7 @@ const libCal = {
// -- such as when requesting hours for a date in the past beyond the current week
// -- (LibCal weeks start on Sunday)
// TODO: Reach out to Springshare support and request they increase this limit to past 2 weeks
if (feed.length === 0) return null
if (feed.length === 0 || feed.locations.length === 0) return null

const times = feed.locations[0].times

Expand Down
7 changes: 6 additions & 1 deletion utils/r25.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ const r25 = {
const response = await axios.$get(url)

// All we care about is the array of reservations
return response.space_reservations.space_reservation
// REVIEW: quick fix to fail gracefully now that R25 has been decommissioned
if (typeof response === 'object') {
return response.space_reservations.space_reservation
} else {
return false
}
},
isR25: function (location, category) {
return schema.locations[location].categories[category].r25
Expand Down
6 changes: 6 additions & 0 deletions utils/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ export default {
'statistical consulting'
]
},
copyright: {
hoursId: 12244,
description: [
'copyright info center'
]
},
elso: {
hoursId: 7701,
description: [
Expand Down
Loading

0 comments on commit 478db2d

Please sign in to comment.