diff --git a/web/src/app/app.component.ts b/web/src/app/app.component.ts
index 722cb6ba..d8396360 100644
--- a/web/src/app/app.component.ts
+++ b/web/src/app/app.component.ts
@@ -1,5 +1,6 @@
import { Component, Input } from '@angular/core';
import { NoticeService } from './services/notice.service';
+import { v4 as uuid } from 'uuid';
@Component({
selector: 'app-root',
@@ -17,6 +18,7 @@ export class AppComponent {
ngOnInit () {
this.showingSidebar = true;
+ sessionStorage.setItem('userID', uuid());
}
public toggleSidebar (): void {
diff --git a/web/src/app/header/component.html b/web/src/app/header/component.html
index a7a8ac57..f54a06a0 100644
--- a/web/src/app/header/component.html
+++ b/web/src/app/header/component.html
@@ -40,6 +40,11 @@
+
+
+ Login ;)
+
+
diff --git a/web/src/app/header/component.ts b/web/src/app/header/component.ts
index f5727d61..9962c51f 100644
--- a/web/src/app/header/component.ts
+++ b/web/src/app/header/component.ts
@@ -2,6 +2,8 @@ import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { Listing } from 'yacs-api-client';
+import { HttpClient, HttpHeaders } from '@angular/common/http';
+import qs from 'qs';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/debounceTime';
@@ -19,11 +21,24 @@ export class HeaderComponent {
dropDownSelected: boolean = false;
navbarCollapsed: boolean = true;
- constructor (private router: Router) { }
+ constructor (private router: Router, private http: HttpClient) { }
//keyup.enter generic search
search (term: string) {
if (this.isValidSearchTerm(term) && !this.dropDownSelected) {
+ //Sends the info about the user's search to the user system backend
+ this.http.post('https://api.yacs.maoyu.wang/userEvent', {
+ "uid": sessionStorage.getItem('userID'),
+ "eventID": "3",
+ "data": {
+ 'Search' : term
+
+ },
+ "createdAt": Date.now()
+ }).subscribe(
+ data => {console.log(data)},
+ err => {console.log(err)}
+ );
this.router.navigate(['/courses'], { queryParams: { search: term } });
}
this.dropDownSelected = false;
@@ -50,6 +65,18 @@ export class HeaderComponent {
//function for on-click typeahead bar
selectedCourse ($event: any) {
+ this.http.post('https://api.yacs.maoyu.wang/userEvent', {
+ "uid": sessionStorage.getItem('userID'),
+ "eventID": "3",
+ "data": {
+ 'Search' : $event.item
+ },
+ "createdAt": Date.now()
+ }).subscribe(
+ data => {console.log(data)},
+ err => {console.log(err)}
+ );
+
this.router.navigate(['/courses'],
{ queryParams: {
longname: $event.item
diff --git a/web/src/app/header/term-selector/component.html b/web/src/app/header/term-selector/component.html
index a44257e8..103f5b94 100644
--- a/web/src/app/header/term-selector/component.html
+++ b/web/src/app/header/term-selector/component.html
@@ -1,9 +1,9 @@
-
+
{{ internalName }}
-
+
diff --git a/web/src/app/listing/component.ts b/web/src/app/listing/component.ts
index fac28ec0..24ad2de7 100644
--- a/web/src/app/listing/component.ts
+++ b/web/src/app/listing/component.ts
@@ -4,6 +4,7 @@ import { ScheduleEvent } from '../models/schedule-event.model';
import { SelectionService } from '../services/selection.service';
import { ConflictsService } from '../services/conflicts.service';
import { SidebarService } from '../services/sidebar.service';
+import { HttpClient, HttpHeaders } from '@angular/common/http';
@Component({
selector: 'course',
@@ -21,7 +22,10 @@ export class ListingComponent implements OnInit{
constructor (
public selectionService : SelectionService,
public sidebarService : SidebarService,
- private conflictsService: ConflictsService) { }
+ private conflictsService: ConflictsService,
+ private http: HttpClient
+ ) { }
+
onKeydown(evt: KeyboardEvent) {
const keyCode = evt.which;
@@ -71,6 +75,31 @@ export class ListingComponent implements OnInit{
}
public clickCourse () {
+ let event: string;
+ if(this.isCourseSelected()){
+ event = "2";
+ }else{
+ event = "1";
+ }
+ let time: number = Date.now();
+
+ for(let sec of this.listing.sections){
+ if(event == "1" || this.isSectionSelected(sec)){
+ this.http.post('https://api.yacs.maoyu.wang/userEvent', {
+ "uid": sessionStorage.getItem('userID'),
+ "eventID": event,
+ "data": {
+ 'Course CRN' : sec.crn
+
+ },
+ "createdAt": time
+ }).subscribe(
+ data => {console.log(data)},
+ err => {console.log(err)}
+ );
+ }
+ }
+
this.selectionService.toggleCourse(this.listing);
}
@@ -84,6 +113,26 @@ export class ListingComponent implements OnInit{
public clickSection (section: Section): void {
this.selectionService.toggleSection(section);
+
+ let event: string;
+ if(this.isSectionSelected(section)){
+ event = "1";
+ }else{
+ event = "2";
+ }
+ //Sends the info about the course to the user system backend
+ this.http.post('https://api.yacs.maoyu.wang/userEvent', {
+ "uid": sessionStorage.getItem('userID'),
+ "eventID": event,
+ "data": {
+ 'Course CRN' : section.crn
+
+ },
+ "createdAt": Date.now()
+ }).subscribe(
+ data => {console.log(data)},
+ err => {console.log(err)}
+ );
}
public findProf (teacher: string): boolean{
diff --git a/web/src/app/school-list/school/component.ts b/web/src/app/school-list/school/component.ts
index 7ef574d2..37cc6277 100644
--- a/web/src/app/school-list/school/component.ts
+++ b/web/src/app/school-list/school/component.ts
@@ -1,6 +1,7 @@
import { Component, OnInit, Input } from '@angular/core';
import { Router } from '@angular/router';
import { School } from 'yacs-api-client';
+import { HttpClient, HttpHeaders } from '@angular/common/http';
@Component({
selector: 'school',
@@ -10,9 +11,30 @@ import { School } from 'yacs-api-client';
export class SchoolComponent {
@Input() school: School;
- constructor(private router:Router){}
+ constructor(private router:Router, private http: HttpClient){}
public changeRoute(id): void {
+ //gets the name of the department
+ let schoolName: string;
+ for(let sub of this.school.subjects){
+ if(sub.id == id){
+ schoolName = sub.longname;
+ }
+ }
+ //Sends the department the user clicked to the user system backend
+ this.http.post('https://api.yacs.maoyu.wang/userEvent', {
+ "uid": sessionStorage.getItem('userID'),
+ "eventID": "5",
+ "data": {
+ 'Department Title' : schoolName
+
+ },
+ "createdAt": Date.now()
+ }).subscribe(
+ data => {console.log(data)},
+ err => {console.log(err)}
+ );
+
this.router.navigateByUrl('/courses?subject_id=' + id);
}
@@ -20,6 +42,26 @@ export class SchoolComponent {
const keyCode = evt.which;
const enterKey = 13;
if(enterKey == keyCode){
+ //gets the name of the department
+ let schoolName: string;
+ for(let sub of this.school.subjects){
+ if(sub.id == id){
+ schoolName = sub.longname;
+ }
+ }
+ //Sends the department the user clicked to the user system backend
+ this.http.post('https://api.yacs.maoyu.wang/userEvent', {
+ "uid": sessionStorage.getItem('userID'),
+ "eventID": "5",
+ "data": {
+ 'Department Title' : schoolName
+
+ },
+ "createdAt": Date.now()
+ }).subscribe(
+ data => {console.log(data)},
+ err => {console.log(err)}
+ );
this.router.navigateByUrl('/courses?subject_id=' + id);
}
}