Skip to content

Commit

Permalink
Merge pull request #28 from ITPNYU/feature/github_workflow
Browse files Browse the repository at this point in the history
github workflow
  • Loading branch information
rlho authored Oct 14, 2023
2 parents 4c7ad3d + 7035dae commit a1d2f31
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 26 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Deploy to Google Apps Script

on: push

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "14"

- name: Install dependencies
run: |
cd media_commons_booking_app
npm ci
- name: Deploy to Google Apps Script
run: |
cd media_commons_booking_app
npx clasp push
6 changes: 5 additions & 1 deletion media_commons_booking_app/.clasp.json
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{"scriptId":"1ITR1lqORogMlvmr_QZtjOrfX_qQadgdGqhEl7ickqaNFXHGd_ZS8R3vf","rootDir":"./dist","parentId":["12owkz3UxzEjyj8vNnsQXq_o0exBquvg4A6D_MMoE3g8"]}
{
"scriptId": "1ohzyuJgn89_Ovj1-DT5JrN-T8uuRAyxdCl3OECDuXtx4BrX4CsyHi61C",
"rootDir": "./dist",
"parentId": ["12owkz3UxzEjyj8vNnsQXq_o0exBquvg4A6D_MMoE3g8"]
}
3 changes: 3 additions & 0 deletions media_commons_booking_app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ dist/
.env

.vscode

.clasprc.json

6 changes: 5 additions & 1 deletion media_commons_booking_app/appsscript.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/script.external_request"
],
"runtimeVersion": "V8"
"runtimeVersion": "V8",
"webapp": {
"executeAs": "USER_DEPLOYING",
"access": "DOMAIN"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import { AdminUsers } from './AdminUsers';
import { Liaisons } from './Liaisons';
import { formatDate } from '../../utils/date';

const ACTIVE_SHEET_ID = '1VZ-DY6o0GM5DL-v9AKkpCbF0w-xm-_T-vVUSPZph06Q';
const BOOKING_SHEET_NAME = 'bookings';
const BOOKING_STATUS_SHEET_NAME = 'bookingStatus';
const SAFTY_TRAINING_SHEET_NAME = 'safety_training_users';

type Booking = Inputs & {
calendarEventId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ <h2>Room Reservation Request</h2>
</p>
<p>
<a
href="https://docs.google.com/spreadsheets/d/1VZ-DY6o0GM5DL-v9AKkpCbF0w-xm-_T-vVUSPZph06Q/edit#gid=1210315332"
href="https://sites.google.com/nyu.edu/370j-booking/admin"
target="_blank"
>Details</a
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const Calendars = ({
// only enrolledThesis user can book over 4 hours
if (
!enrolledThisis &&
selectInfo.end.getTime() / 1000 - selectInfo.start.getTime() / 1000 >=
selectInfo.end.getTime() / 1000 - selectInfo.start.getTime() / 1000 >
60 * 60 * 4
) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ export const MultipleCalendars = ({ apiKey, allRooms, handleSetDate }) => {
checkedRoomIds.includes(room.roomId)
);
setCheckedRooms(checked);
if (
checkedRoomIds.includes('221') ||
(checkedRoomIds.includes('222') && !showMotionCaptureModal)
) {
setShowMotionCaptureModal(true);
setHasModalBeenShown(true);
}
}, [checkedRoomIds]);

if (loading) {
Expand All @@ -42,6 +35,15 @@ export const MultipleCalendars = ({ apiKey, allRooms, handleSetDate }) => {
const { value, checked } = event.target;

const valuesArray = value.split(',');
console.log('value', value);

if (
!hasModalBeenShown &&
(valuesArray.includes('221') || valuesArray.includes('222'))
) {
setShowMotionCaptureModal(true);
setHasModalBeenShown(true);
}

if (checked) {
setCheckedRoomIds((prev) => [...prev, ...valuesArray]);
Expand Down
20 changes: 8 additions & 12 deletions media_commons_booking_app/src/server/sheets.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
const getSheets = () => SpreadsheetApp.getActive().getSheets();

const getActiveSheetName = () => SpreadsheetApp.getActive().getSheetName();

const ACTIVE_SHEET_ID = '1VZ-DY6o0GM5DL-v9AKkpCbF0w-xm-_T-vVUSPZph06Q';
const ACTIVE_SHEET_ID = '1MnWbn6bvNyMiawddtYYx0tRW4NMgvugl0I8zBO3sy68';

export const fetchRows_ = (sheetName) => {
return SpreadsheetApp.openById(ACTIVE_SHEET_ID)
Expand All @@ -22,7 +18,7 @@ export const fetchRows = (sheetName) => {

function fetchById(sheetName, id) {
const row = fetchRows_(sheetName).find((row) => row[0] === id);
if (!row) throw 'Invalid conversation ID: ' + id;
if (!row) throw `Invalid conversation ID: ${id}`;
const messages = fetchRows_(sheetName)
.filter((row) => row[0] === id)
.flatMap((row) => {
Expand Down Expand Up @@ -76,7 +72,7 @@ export const addEventToCalendar = (
new Date(startTime),
new Date(endTime),
{
description: description,
description,
}
);
event.setColor(CalendarApp.EventColor.GRAY);
Expand Down Expand Up @@ -127,13 +123,13 @@ export const sendHTMLEmail = (
body
) => {
console.log('contents', contents);
var htmlTemplate = HtmlService.createTemplateFromFile(templateName);
for (var key in contents) {
const htmlTemplate = HtmlService.createTemplateFromFile(templateName);
for (const key in contents) {
htmlTemplate[key] = contents[key] || '';
}
var htmlBody = htmlTemplate.evaluate().getContent();
var options = {
htmlBody: htmlBody,
const htmlBody = htmlTemplate.evaluate().getContent();
const options = {
htmlBody,
};
GmailApp.sendEmail(targetEmail, title, body, options);
};
Expand Down

0 comments on commit a1d2f31

Please sign in to comment.