Skip to content

Commit

Permalink
Merge branch 'alert-2.0' into alert-2.0-status-update
Browse files Browse the repository at this point in the history
  • Loading branch information
esinx committed Nov 19, 2024
2 parents 204b3cc + 01dd582 commit 334e9c8
Show file tree
Hide file tree
Showing 40 changed files with 4,063 additions and 227 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ pcr-backup*
./Pipfile
./Pipfile.lock
./package.json
./yarn.lock
./yarn.lock
*.pem
6 changes: 5 additions & 1 deletion frontend/alert-2.0/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ dist-ssr
*.sln
*.sw?

*.env

.terraform
*.tfstate*
*.tfstate
*.tfstate.backup
>>>>>>> alert-2.0
20 changes: 10 additions & 10 deletions frontend/alert-2.0/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Penn Course Alert 2.0</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
6 changes: 3 additions & 3 deletions frontend/alert-2.0/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"@radix-ui/react-switch": "^1.1.0",
"@tanstack/react-query": "^5.53.3",
"@tanstack/react-router": "^1.51.6",
"@trpc/client": "^11.0.0-rc.498",
"@trpc/react-query": "^11.0.0-rc.498",
"@trpc/server": "^11.0.0-rc.498",
"@trpc/client": "^11.0.0-rc.608",
"@trpc/react-query": "^11.0.0-rc.608",
"@trpc/server": "^11.0.0-rc.608",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"cmdk": "1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const CourseSectionAutocomplete: React.FC<Props> = ({
},
{
placeholderData: keepPreviousData,
enabled: () => debouncedQuery.length > 0,
},
)
return (
Expand Down
100 changes: 50 additions & 50 deletions frontend/alert-2.0/src/components/ui/card.tsx
Original file line number Diff line number Diff line change
@@ -1,76 +1,76 @@
import * as React from "react"
import * as React from 'react'

import { cn } from "@/lib/utils"
import { cn } from '@/lib/utils'

const Card = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn(
"rounded-xl border bg-card text-card-foreground shadow",
className
)}
{...props}
/>
<div
ref={ref}
className={cn(
'rounded-xl border bg-card text-card-foreground shadow',
className,
)}
{...props}
/>
))
Card.displayName = "Card"
Card.displayName = 'Card'

const CardHeader = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex flex-col space-y-1.5 p-6", className)}
{...props}
/>
<div
ref={ref}
className={cn('flex flex-col space-y-1.5 p-6', className)}
{...props}
/>
))
CardHeader.displayName = "CardHeader"
CardHeader.displayName = 'CardHeader'

const CardTitle = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h3
ref={ref}
className={cn("font-semibold leading-none tracking-tight", className)}
{...props}
/>
<h3
ref={ref}
className={cn('font-semibold leading-none tracking-tight', className)}
{...props}
/>
))
CardTitle.displayName = "CardTitle"
CardTitle.displayName = 'CardTitle'

const CardDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<p
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
<p
ref={ref}
className={cn('text-sm text-muted-foreground', className)}
{...props}
/>
))
CardDescription.displayName = "CardDescription"
CardDescription.displayName = 'CardDescription'

const CardContent = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
<div ref={ref} className={cn('p-6 pt-0', className)} {...props} />
))
CardContent.displayName = "CardContent"
CardContent.displayName = 'CardContent'

const CardFooter = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex items-center p-6 pt-0", className)}
{...props}
/>
<div
ref={ref}
className={cn('flex items-center p-6 pt-0', className)}
{...props}
/>
))
CardFooter.displayName = "CardFooter"
CardFooter.displayName = 'CardFooter'

export { Card, CardContent,CardDescription, CardFooter, CardHeader, CardTitle }
export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle }
5 changes: 1 addition & 4 deletions frontend/alert-2.0/src/providers/AuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import { userManager } from '@/core/auth'

const config = {
userManager,
onSigninCallback: user => {
console.log(user)
window.history.replaceState({}, document.title, '/')
},
onSigninCallback: () => window.history.replaceState({}, document.title, '/'),
} satisfies AuthProviderProps

export const AuthProvider: React.FC<PropsWithChildren> = ({ children }) => {
Expand Down
17 changes: 9 additions & 8 deletions frontend/alert-2.0/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,17 @@ const Navbar: React.FC = () => {
<NavigationMenu
className={cn(
'max-w-[100vw]',
'p-4',
'py-4',
'px-8',
'bg-white',
'border-b-border',
'border-b-2',
'justify-between',
)}
>
{/* width of avatar is fixed to w-10, we use this dummy to algin menu to center */}
<div className={cn('w-10')} />
<NavigationMenuList>
<NavigationMenuItem>
<Avatar>
<AvatarFallback>{initials}</AvatarFallback>
</Avatar>
</NavigationMenuItem>
<NavigationMenuItem className={cn('w-4')}></NavigationMenuItem>
<NavigationMenuItem>
<NavigationMenuLink className={navigationMenuTriggerStyle()} asChild>
<Link to="/">Home</Link>
Expand All @@ -72,6 +70,9 @@ const Navbar: React.FC = () => {
</NavigationMenuLink>
</NavigationMenuItem>
</NavigationMenuList>
<Avatar>
<AvatarFallback>{initials}</AvatarFallback>
</Avatar>
</NavigationMenu>
)
}
Expand Down Expand Up @@ -143,7 +144,7 @@ const Root: React.FC = () => {
</>
)}
<Toaster position="bottom-center" />
<TanStackRouterDevtools />
{import.meta.env.DEV && <TanStackRouterDevtools />}
</div>
</ErrorBoundary>
)
Expand Down
24 changes: 24 additions & 0 deletions frontend/alert-2.0/terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions frontend/alert-2.0/terraform/cert.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
resource "aws_acm_certificate" "website" {
domain_name = "staging.penncoursealert.com"
validation_method = "DNS"
}

resource "aws_route53_record" "website_cert" {
for_each = {
for dvo in aws_acm_certificate.website.domain_validation_options : dvo.domain_name => {
name = dvo.resource_record_name
record = dvo.resource_record_value
type = dvo.resource_record_type
}
}

allow_overwrite = true
name = each.value.name
records = [each.value.record]
ttl = 60
type = each.value.type
zone_id = data.aws_route53_zone.penncoursealert.id
}

resource "aws_acm_certificate_validation" "website" {
certificate_arn = aws_acm_certificate.website.arn
validation_record_fqdns = [for record in aws_route53_record.website_cert : record.fqdn]
}
95 changes: 95 additions & 0 deletions frontend/alert-2.0/terraform/cloudfront.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
resource "aws_cloudfront_origin_access_control" "website" {
name = "org_pennlabs_course_alert"
description = "Origin Access Control for Penn Course Alert"
origin_access_control_origin_type = "s3"
signing_behavior = "always"
signing_protocol = "sigv4"
}

resource "aws_cloudfront_cache_policy" "website" {
name = "org_pennlabs_course_alert"
default_ttl = 0
max_ttl = 0
min_ttl = 0
parameters_in_cache_key_and_forwarded_to_origin {
cookies_config {
cookie_behavior = "none"
}
headers_config {
header_behavior = "none"
}
query_strings_config {
query_string_behavior = "none"
}
}
}

resource "aws_cloudfront_distribution" "website" {
origin {
domain_name = aws_s3_bucket.website.bucket_regional_domain_name
origin_access_control_id = aws_cloudfront_origin_access_control.website.id
origin_id = "s3-${aws_s3_bucket.website.bucket}"
}

enabled = true

comment = "Penn Course Alert"
default_root_object = "index.html"

custom_error_response {
error_caching_min_ttl = 0
error_code = 404
response_code = 200
response_page_path = "/index.html"
}

aliases = ["staging.penncoursealert.com"]
default_cache_behavior {
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
cached_methods = ["GET", "HEAD"]
target_origin_id = "s3-${aws_s3_bucket.website.bucket}"
viewer_protocol_policy = "redirect-to-https"
cache_policy_id = aws_cloudfront_cache_policy.website.id
}
price_class = "PriceClass_100"
restrictions {
geo_restriction {
restriction_type = "none"
}
}
tags = {
Environment = "staging"
}
viewer_certificate {
acm_certificate_arn = aws_acm_certificate.website.arn
ssl_support_method = "sni-only"
}
}

resource "aws_s3_bucket_policy" "website" {
bucket = aws_s3_bucket.website.bucket
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Principal = {
Service = "cloudfront.amazonaws.com"
}
Action = [
"s3:GetObject",
"s3:ListBucket"
]
Resource = [
aws_s3_bucket.website.arn,
"${aws_s3_bucket.website.arn}/*"
]
Condition = {
StringEquals = {
"AWS:SourceArn" : aws_cloudfront_distribution.website.arn
}
}
}
]
})
}
Loading

0 comments on commit 334e9c8

Please sign in to comment.