From 7035daef181ba78b0c4f70f9f5156b97be27ae1c Mon Sep 17 00:00:00 2001 From: "riho.takagi" Date: Sat, 14 Oct 2023 15:46:54 -0400 Subject: [PATCH] update --- .github/workflows/deploy.yml | 26 +++++++++++++++++++ media_commons_booking_app/.clasp.json | 6 ++++- media_commons_booking_app/.gitignore | 3 +++ media_commons_booking_app/appsscript.json | 6 ++++- .../client/admin-page/components/Admin.tsx | 3 --- .../src/client/booking/approval_email.html | 2 +- .../client/booking/components/Calendars.tsx | 2 +- .../booking/components/MultipleCalendars.tsx | 16 +++++++----- .../src/server/sheets.js | 20 ++++++-------- 9 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..bf88ff48 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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 diff --git a/media_commons_booking_app/.clasp.json b/media_commons_booking_app/.clasp.json index 97195e46..b61136bf 100644 --- a/media_commons_booking_app/.clasp.json +++ b/media_commons_booking_app/.clasp.json @@ -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"] +} diff --git a/media_commons_booking_app/.gitignore b/media_commons_booking_app/.gitignore index 4f65133b..919dfbb7 100644 --- a/media_commons_booking_app/.gitignore +++ b/media_commons_booking_app/.gitignore @@ -18,3 +18,6 @@ dist/ .env .vscode + +.clasprc.json + diff --git a/media_commons_booking_app/appsscript.json b/media_commons_booking_app/appsscript.json index 77b14bf5..2c8b26c6 100644 --- a/media_commons_booking_app/appsscript.json +++ b/media_commons_booking_app/appsscript.json @@ -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" + } } diff --git a/media_commons_booking_app/src/client/admin-page/components/Admin.tsx b/media_commons_booking_app/src/client/admin-page/components/Admin.tsx index 7a14a5da..37900733 100644 --- a/media_commons_booking_app/src/client/admin-page/components/Admin.tsx +++ b/media_commons_booking_app/src/client/admin-page/components/Admin.tsx @@ -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; diff --git a/media_commons_booking_app/src/client/booking/approval_email.html b/media_commons_booking_app/src/client/booking/approval_email.html index 391b7716..be72d49f 100644 --- a/media_commons_booking_app/src/client/booking/approval_email.html +++ b/media_commons_booking_app/src/client/booking/approval_email.html @@ -159,7 +159,7 @@

Room Reservation Request

Details diff --git a/media_commons_booking_app/src/client/booking/components/Calendars.tsx b/media_commons_booking_app/src/client/booking/components/Calendars.tsx index 4aefb955..59f66621 100644 --- a/media_commons_booking_app/src/client/booking/components/Calendars.tsx +++ b/media_commons_booking_app/src/client/booking/components/Calendars.tsx @@ -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; diff --git a/media_commons_booking_app/src/client/booking/components/MultipleCalendars.tsx b/media_commons_booking_app/src/client/booking/components/MultipleCalendars.tsx index 4f3c03ea..cca5e93e 100644 --- a/media_commons_booking_app/src/client/booking/components/MultipleCalendars.tsx +++ b/media_commons_booking_app/src/client/booking/components/MultipleCalendars.tsx @@ -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) { @@ -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]); diff --git a/media_commons_booking_app/src/server/sheets.js b/media_commons_booking_app/src/server/sheets.js index d17df7c3..d8232b27 100644 --- a/media_commons_booking_app/src/server/sheets.js +++ b/media_commons_booking_app/src/server/sheets.js @@ -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) @@ -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) => { @@ -76,7 +72,7 @@ export const addEventToCalendar = ( new Date(startTime), new Date(endTime), { - description: description, + description, } ); event.setColor(CalendarApp.EventColor.GRAY); @@ -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); };