From 2ca4564e2a2f9f6de122a646ff9002f87637cf73 Mon Sep 17 00:00:00 2001 From: nconrad <1194246+nconrad@users.noreply.github.com> Date: Sun, 5 Nov 2023 21:05:21 -0600 Subject: [PATCH 1/2] add photo gallery components/examples; update international node list; (and merge) --- .eslintrc.js | 1 + docs/reference-guides/dev-quick-reference.md | 5 +- docusaurus.config.js | 16 +- news/2023-10-30-joann-blog-hawaii.md | 6 +- src/components/PhotoGallery.tsx | 44 ++++++ src/components/PhotoIndex.tsx | 148 ++++++++++++++++++ src/components/home/StatusChart.tsx | 13 +- src/pages/Photos.tsx | 38 +++++ .../partners/CustomPartnerSidebar/index.tsx | 2 + 9 files changed, 252 insertions(+), 21 deletions(-) create mode 100644 src/components/PhotoGallery.tsx create mode 100644 src/components/PhotoIndex.tsx create mode 100644 src/pages/Photos.tsx diff --git a/.eslintrc.js b/.eslintrc.js index 3032b6e3..2cac5499 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -27,5 +27,6 @@ module.exports = { 'globals': { 'require': true, 'module': true, + 'gapi': true } } \ No newline at end of file diff --git a/docs/reference-guides/dev-quick-reference.md b/docs/reference-guides/dev-quick-reference.md index 2b86474d..9d53c734 100644 --- a/docs/reference-guides/dev-quick-reference.md +++ b/docs/reference-guides/dev-quick-reference.md @@ -258,8 +258,9 @@ You may also have to call the `kubectl ` commands as in the testing section :green_book: Check [sesctl docs](https://github.com/waggle-sensor/edge-scheduler/tree/main/docs/sesctl) for command line tool. -1. :point_up: Do not use capital letters/dots in the job name. -2. :point_up: make the plugin `public` in the Sage app portal. + +1. :point_up: Do not use `_`, upper case letters or `.` in the job name. Use only lowercase letters, numbers and `-`. +2. :point_up: Ensure that the plugin is set to 'public' in the Sage app portal. ### `job.yaml` example for USB device diff --git a/docusaurus.config.js b/docusaurus.config.js index 4b4f3a95..b2145b71 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -44,13 +44,15 @@ module.exports = { to: '/team', label: 'Team', position: 'left' - }, - { + }, {/* + to: '/photos', + label: 'Photos', + position: 'left' + */}, { to: '/docs/about/overview', position: 'left', label: 'Docs' - }, - { + }, { type: 'dropdown', position: 'right', className: 'header-github-link', @@ -107,6 +109,12 @@ module.exports = { } */ }, + scripts: [ + { + src: 'https://apis.google.com/js/api.js', + async: true, + }, + ], presets: [ [ '@docusaurus/preset-classic', diff --git a/news/2023-10-30-joann-blog-hawaii.md b/news/2023-10-30-joann-blog-hawaii.md index 26ccde1f..ceaa0a8a 100644 --- a/news/2023-10-30-joann-blog-hawaii.md +++ b/news/2023-10-30-joann-blog-hawaii.md @@ -12,12 +12,12 @@ My name is Joann Lenart and I am a current senior at Northwestern University. As -While in Hawaii, I observed some societal patterns and themes that were interesting to me. One of the first examples was at the airport. Directions and announcements were first stated in Native Hawaiian, then in English. Having done research with Indigenous groups in the past, this small detail has a broader impact regarding their status in the state. +While in Hawaii, I observed some societal patterns and themes that were interesting to me. One of the first examples was at the airport. Directions and announcements were first stated in Native Hawaiian, then in English. Having done research with Indigenous groups in the past, this small detail has a broader impact regarding their status in the state. -Additionally, the environmental laws passed in Hawaii are noticeable and prevalent in a positive way. To enter national parks, shoes need to be scrubbed to prevent invasives. Plastic bags are banned and the single-use cups and utensils are all eco friendly. Certain chemicals are banned from sunscreens. These laws work here but they are not seen on the mainland. It appears the key for these environmental laws to pass and function is the need from citizens to also want to help the environment. Helping the environment is a collective effort and there must be motivation from both parties to combat the effects of climate change. +Additionally, the environmental laws passed in Hawaii are noticeable and prevalent in a positive way. To enter national parks, shoes need to be scrubbed to prevent invasives. Plastic bags are banned and the single-use cups and utensils are all eco friendly. Certain chemicals are banned from sunscreens. These laws work here but they are not seen on the mainland. It appears the key for these environmental laws to pass and function is the need from citizens to also want to help the environment. Helping the environment is a collective effort and there must be motivation from both parties to combat the effects of climate change. On Day 6 of the trip, the research team went to a water treatment plant to survey the area since a new Sage Node will eventually be installed there on a weather tower. The tower overlooked the town of Lahaina which unfortunately was devastated by the wildfires earlier in August. This node will be used to detect smoke and track temperatures to see which area is most vulnerable to wildfires to try to prevent another disaster from occurring. The community members are still recovering and are still terrified months after this devastation. Once the sage node is up, the team will work with the local community by creating a dashboard with accessible information such as if the air quality is healthy. Additionally, after discussing with Chris, a hydrologist, about this data, there is potential to give this data to the government and council in charge to decide what policies to pass and to use this data in court cases to pass climate legislation and advance environmental justice. It is about being transparent and having the local community involved. Despite not being a computer scientist, there are many areas where the social sciences can be bridged with the computer sciences. It is about how you use the data collected with the community groups most impacted. On paper I may have been an outlier with my background, but during discussions with many other scientists and researchers, it did not feel as if there was a gap between our research. Many computer scientists want to bring in social sciences to their work and be more than just programmers. There is work to be done between these fields but it will bring in many benefits later on. -This was an amazing opportunity and I am very grateful to have gone :) +This was an amazing opportunity and I am very grateful to have gone :) diff --git a/src/components/PhotoGallery.tsx b/src/components/PhotoGallery.tsx new file mode 100644 index 00000000..7d025a64 --- /dev/null +++ b/src/components/PhotoGallery.tsx @@ -0,0 +1,44 @@ +import React, {useEffect, useState} from 'react' + + +type Props = { + driveFolderID: string +} + +export default function PhotoGallery(props: Props) { + const {driveFolderID} = props; + + const [imgIDs, setImgIDs] = useState() + + useEffect(() => { + function listFilesInFolder(folderId) { + gapi.load('client', init) + + async function init() { + await gapi.client.init({ + apiKey: 'AIzaSyD0xq74f1zILUzUGWqKrEgMca-HGwCDPgA', + discoveryDocs: ['https://www.googleapis.com/discovery/v1/apis/drive/v3/rest'] + }) + + const request = await gapi.client.drive.files.list({ + 'q': '\'' + folderId + '\' in parents', + 'fields': 'nextPageToken, files(id, name)' + }) + + const ids = request.result.files.map(o => o.id) + setImgIDs(ids) + } + } + + listFilesInFolder(driveFolderID) + }, [driveFolderID]) + + + return ( +
+ {imgIDs?.map((id) => + ) + } +
+ ) +} diff --git a/src/components/PhotoIndex.tsx b/src/components/PhotoIndex.tsx new file mode 100644 index 00000000..0e1f218b --- /dev/null +++ b/src/components/PhotoIndex.tsx @@ -0,0 +1,148 @@ +import React, {useEffect, useState} from 'react' +import styled from 'styled-components' +import { Link, useLocation } from 'react-router-dom' + + +import Card from '@mui/material/Card' + + + +async function listAllFiles(gapi, folderId) { + const query = `'${folderId}' in parents` + const fields = 'nextPageToken, files(id, name, mimeType)' + let files = [] + let nextPageToken = null + do { + const response = await gapi.client.drive.files.list({ + q: query, + fields: fields, + pageToken: nextPageToken, + pageSize: 1000, + }) + files = files.concat(response.result.files); + nextPageToken = response.result.nextPageToken; + } while (nextPageToken) + + const filesByDir = {} + for (const file of files) { + const {id, name, mimeType} = file + + if (!(name in filesByDir)) { + filesByDir[name] = [] + } + + if (mimeType === 'application/vnd.google-apps.folder') { + filesByDir[name] = await listAllFiles(gapi, id) + } else { + filesByDir[name] = file + } + } + return filesByDir +} + + + +type LinkCardProps = { + title: string + src: string + link: string + description?: string +} + +export function LinkCard(props: LinkCardProps) { + const {title, src, link} = props + return ( + + +

{title}

+
+ ) +} + + +type Props = { + driveFolderID: string +} + +export default function FileIndex(props: Props) { + const {driveFolderID} = props + + const params = new URLSearchParams(useLocation().search) + const collection = params.get('collection') + + const [files, setFiles] = useState() + + useEffect(() => { + function listIndex(folderId) { + gapi.load('client', init) + + async function init() { + await gapi.client.init({ + apiKey: 'AIzaSyD0xq74f1zILUzUGWqKrEgMca-HGwCDPgA', + discoveryDocs: ['https://www.googleapis.com/discovery/v1/apis/drive/v3/rest'] + }) + + const files = await listAllFiles(gapi, folderId) + console.log('files', files) + + setFiles(files) + } + } + listIndex(driveFolderID) + }, [collection, driveFolderID]) + + + return ( + + {!collection && files && + Object.keys(files).map(folderName => { + const filesByName = files[folderName] + const {id} = Object.values(filesByName)[0] + + return ( + + ) + }) + } + + {collection && files && +
+ {Object.values(files[collection]).map(({id}) => + ) + } +
+ } +
+ ) +} + + +const Root = styled.div` + img { + max-height: 200px; + } + + .card::after { + display: block; + position: relative; + background-image: linear-gradient(to bottom, transparent 0%, black 100%); + margin-top: -110px; + height: 110px; + width: 100%; + content: ''; + } + + .card:hover h3 { + color: rgb(0, 128, 199); + text-decoration: underline; + } +` \ No newline at end of file diff --git a/src/components/home/StatusChart.tsx b/src/components/home/StatusChart.tsx index 01eabd81..1496ec3f 100644 --- a/src/components/home/StatusChart.tsx +++ b/src/components/home/StatusChart.tsx @@ -15,18 +15,7 @@ import config from '../../config' const notShown = { - Scotland: ['W06B'], - Australia: [ - 'W04B', - 'W04C', - 'W04D', - 'W04E', - 'W04F', - 'W050', - 'W052', - 'W053', - 'W054' - ] + 'Scotland': ['W06B'] } const notShownVSNs = [].concat(...Object.values(notShown)) diff --git a/src/pages/Photos.tsx b/src/pages/Photos.tsx new file mode 100644 index 00000000..5ba864e1 --- /dev/null +++ b/src/pages/Photos.tsx @@ -0,0 +1,38 @@ +import React from 'react' +import styled from 'styled-components' +import Layout from '@theme/Layout' +import { useLocation } from 'react-router-dom' + +import PhotoIndex from '../components/PhotoIndex' + + + +export default function Photos() { + const params = new URLSearchParams(useLocation().search) + const collection = params.get('collection') + + return ( + +
+
+
+

+ {collection ? + <>Photos / {collection} : + 'Photo Galleries' + } +

+
+ +
+
+
+
+
+ ) +} + + diff --git a/src/theme/partners/CustomPartnerSidebar/index.tsx b/src/theme/partners/CustomPartnerSidebar/index.tsx index ef6c3f4b..fabfa96e 100644 --- a/src/theme/partners/CustomPartnerSidebar/index.tsx +++ b/src/theme/partners/CustomPartnerSidebar/index.tsx @@ -26,8 +26,10 @@ export default function CustomPartnerSidebar() { const partner = partners.find(obj => obj.id == project_id) const {url} = partner || {} + return (
+ {url &&

Website

From b79b6b0fc96aa1520e0d3acb34a983059b6b3004 Mon Sep 17 00:00:00 2001 From: nconrad <1194246+nconrad@users.noreply.github.com> Date: Sun, 5 Nov 2023 21:13:45 -0600 Subject: [PATCH 2/2] fix typo / linting --- docusaurus.config.js | 4 ++-- src/pages/Photos.tsx | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docusaurus.config.js b/docusaurus.config.js index b2145b71..2d4e7a21 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -44,11 +44,11 @@ module.exports = { to: '/team', label: 'Team', position: 'left' - }, {/* + }, /* { to: '/photos', label: 'Photos', position: 'left' - */}, { + },*/ { to: '/docs/about/overview', position: 'left', label: 'Docs' diff --git a/src/pages/Photos.tsx b/src/pages/Photos.tsx index 5ba864e1..d9c88ddb 100644 --- a/src/pages/Photos.tsx +++ b/src/pages/Photos.tsx @@ -1,5 +1,4 @@ import React from 'react' -import styled from 'styled-components' import Layout from '@theme/Layout' import { useLocation } from 'react-router-dom'