Skip to content

Commit

Permalink
mergingMerge branch 'main' of github.uconn.edu:zjf19002/Class_Registr…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
zjf19002 committed Nov 1, 2023
2 parents 62a501a + 20b9b5b commit ea0f998
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 60 deletions.
5 changes: 3 additions & 2 deletions StudentFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def createStudent(studentID, studentPWD, enrolledCourses = []):
Item = {
'StudentId' : studentID,
'StudentPWD' : studentPWD,
'EnrolledCourses' : enrolledCourses
'EnrolledCourses' : enrolledCourses,
'AuthToken' : None
}
)

Expand All @@ -19,4 +20,4 @@ def createStudent(studentID, studentPWD, enrolledCourses = []):


if __name__ == "__main__":
createStudent("awp10101", "myPassword")
createStudent("testUser", "myNewPassword")
Binary file added class_registration_app/ngrok 2
Binary file not shown.
23 changes: 23 additions & 0 deletions class_registration_app/src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ a,
padding: 0 auto;
}
}



*/
.btn-97,
.btn-97 *,
Expand Down Expand Up @@ -97,3 +100,23 @@ a,
transform: translateY(-5px);
}

.course-list-item {
padding: 20px;
display: flex;
margin-top: 10px;
margin-bottom: 40px;
min-width: 80vw;
background-color: #ffffff;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.course-name {
margin-left: 1vw;
font-weight: 500;
}

.course-location {
margin-left: 1vh;

}
131 changes: 100 additions & 31 deletions class_registration_app/src/components/CourseSearch.vue
Original file line number Diff line number Diff line change
@@ -1,67 +1,136 @@
<script setup lang="ts">
import axios from 'axios';
//arn:aws:execute-api:us-east-1:671289147354:5prodolbi7/*/GET/courses
const apiUrl = 'https://5prodolbi7.execute-api.us-east-1.amazonaws.com/Beta';
// Make a GET request
axios.get(`${apiUrl}/courses`, {
params: {
// Query parameters, if any
import { defineAsyncComponent } from 'vue';
const AsyncComponent = defineAsyncComponent(() =>
import('./CourseSearch.vue')
);
function handleSearch() {
const elementsToRemove = document.querySelectorAll(`.${"course-list-item"}`);
elementsToRemove.forEach(element => {
element.remove();
});
console.log("button clicked");
//arn:aws:execute-api:us-east-1:671289147354:5prodolbi7/*/GET/courses
const apiUrl = 'https://5prodolbi7.execute-api.us-east-1.amazonaws.com/Beta';
let courseJson = fetch(`${apiUrl}/courses`)
.then(response => {
if (response.ok) {
return response.json()
} else{
throw "Error"
}
}).then(response => {
console.log(response.Items);
let searchbar = document.getElementById("search");
let filteredCourses = response.Items.filter(function (str: string) { return str.CourseId.includes(searchbar.value.toUpperCase())} );
filteredCourses.forEach((Course: { CourseId: string; CourseLocation: string;}) => {
let container = document.getElementById("container");
let div = document.createElement("div");
let course_name = document.createElement('h2');
let course_location = document.createElement('h2');
// Set class or any other attributes for the div
div.className = "course-list-item"; // You can set class name here
// Set content or any other properties for the div
course_name.className = "course-name";
course_name.textContent = Course.CourseId + " -"; // You can set content here
course_location.className = "course-location";
course_location.textContent = Course.CourseLocation;
// Append the div to the container
if (container != null){
container.appendChild(div);
div.appendChild(course_name);
div.appendChild(course_location);
}
return response;
})
})
}
document.addEventListener("click", function() {
// Get the button element by its ID
const button = document.getElementById("searchButton");
// Check if the button element exists
if (button) {
// Assign the handleClick function to the button's onclick property
button.addEventListener("click", handleSearch);
}
})
.then(response => {
// Handle the response
console.log(response.data);
})
.catch(error => {
// Handle errors
console.error(error);
});
</script>
// Your API Gateway endpoint URL
</script>



<template>
<div class="container">
<h1>UConn Course Search</h1>
<input type="text" class="search-bar" placeholder="Enter course name or code">
<div class="container" id="container">
<h1 class="title">UConn Course Search</h1>
<div class="search">
<input type="text" id="search" class="search-bar" placeholder="Enter course name or code">
<button id="searchButton" class="btn-97">Search</button>
</div>
<ul class="course-list">
<li class="course-list-item">CSE 101 - Introduction to Computer Science</li>
<li class="course-list-item">ENG 101 - English Composition</li>
<li class="course-list-item">MAT 115 - Calculus I</li>
<li class="course-list-item">CHEM 111 - General Chemistry</li>
<li class="course-list-item">HIST 200 - U.S. History</li>

</ul>
</div>
</template>

<style scoped>
.container {
max-width: 600px;
margin: 0 auto;
min-width: 80vw;
left: 50%;
top: 5%;
position: absolute;
transform: translate(-50%);
padding: 20px;
background-color: #ffffff;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
overflow-y: auto;
}
.title {
position:relative;
font-weight: 700;
}
.search {
display: flex;
flex-wrap: wrap;
}
.search-bar {
width: 100%;
width: 30%;
padding: 10px;
margin-right: 1vw;
margin-bottom: 20px;
border: none;
border-radius: 5px;
font-size: 16px;
border: solid 1px navy;
}
.course-list {
list-style: none;
padding: 0;
}
.course-list-item {
margin-bottom: 10px;
button {
line-height: 0;
height: 30px;
}
</style>
2 changes: 2 additions & 0 deletions class_registration_app/src/components/DashBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
<RouterLink to="./courses">
<button class="uconn-button">Course Search</button>
</RouterLink>
<RouterLink to="./my_courses">
<button class="uconn-button">Current Classes</button>
</RouterLink>
</div>
</div>
</template>
Expand Down
12 changes: 12 additions & 0 deletions class_registration_app/src/components/EnrolledCourseList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script setup lang="ts">
</script>

<template>
<div class="container">
<h1>My Classes</h1>
</div>

</template>

<style scoped>
</style>
91 changes: 64 additions & 27 deletions class_registration_app/src/components/LoginPage.vue
Original file line number Diff line number Diff line change
@@ -1,22 +1,58 @@
<script setup lang="ts">
</script>

<template>
<section class="form animated flipInX">
<h2>Login To Your Account</h2>
<p class="valid">Valid. Please wait a moment.</p>
<p class="error">Error. Please enter correct Username &amp; password.</p>
<form class="loginbox" autocomplete="off">
<input placeholder="Username" type="text" id="username"/>
<input placeholder="Password" type="password" id="password"/>
<RouterLink to="./dashboard">
<button id="submit">Login</button>
<section class="form animated flipInX">
<h2>Login To Your Account</h2>
<p class="valid">Valid. Please wait a moment.</p>
<p class="error">Error. Please enter correct Username &amp; password.</p>
<form class="loginbox" autocomplete="off">
<input placeholder="Username" type="text" id="username" v-model="data.username" />
<input placeholder="Password" type="password" id="password" v-model="data.password"/>
<RouterLink v-if="!authenticationFailed" to="./dashboard" @click.prevent="tryLogin"> <!--use v-if here-->
<button id="submit">Login</button>
</RouterLink>
</form>
<RouterLink to="/">Back</RouterLink>
</section>
</form>
<RouterLink to="/">Back</RouterLink>
</section>
</template>

<script setup lang="ts">
import router from '@/router';
import axios from 'axios';
import { reactive } from 'vue';
const data = reactive({
username: '',
password: '',
});
let authenticationFailed = false;
const tryLogin = async () => {
const apiUrl = `https://yqoa0pwe5b.execute-api.us-east-1.amazonaws.com/login/get-list?username=${data.username}&password=${data.password}`;
try {
const response = await axios.get(apiUrl, {
params: {
// Enter query parameters here
},
});
console.log(response.data);
const res = response.data;
if (authenticationSucceeds(res)) {
await router.push({path: '/dashboard'});
} else {
authenticationFailed = true;
}
} catch (error) {
console.error(error);
authenticationFailed = true;
}
};
const authenticationSucceeds = (response) => {
return response.data && response.data.statusCode === 200;
};
</script>

<style scoped>
section {
Expand Down Expand Up @@ -73,17 +109,18 @@
border: 1px solid #44c4e7;
}
}
button {
cursor: pointer;
background: #44c4e7;
width: 100%;
padding: 10px 15px;
border: 0;
color: #fff;
font-family: "Roboto";
font-size: 14px;
font-weight: 400;
}
}
button {
cursor: pointer;
background: #44c4e7;
width: 100%;
padding: 10px 15px;
border: 0;
color: #fff;
font-family: "Roboto";
font-size: 14px;
font-weight: 400;
}
.error, .valid{display:none;}
Expand Down
6 changes: 6 additions & 0 deletions class_registration_app/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import RegisterAccount from '../components/RegisterAccount.vue'
import CourseSearch from '../components/CourseSearch.vue'
import ScheduleView from '../components/ScheduleView.vue'
import DashBoard from '../components/DashBoard.vue'
import EnrolledCourseList from '../components/EnrolledCourseList.vue'

const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
Expand Down Expand Up @@ -41,6 +42,11 @@ const router = createRouter({
path: '/schedule_viewer',
name: 'Schedule Viewer',
component: ScheduleView
},
{
path: '/my_courses',
name: 'My Courses',
component: EnrolledCourseList
}

]
Expand Down

0 comments on commit ea0f998

Please sign in to comment.