diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 26971d6773ab3c05f60a8fbe26422d95205e3aee..1d6e466711379908772e56d8fefe893924f2c1aa 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -8,7 +8,6 @@ import { AppComponent } from './app.component'; import { CoreModule } from './core/core.module'; import { SharedModule } from './shared/shared.module'; import { DegreePlannerModule } from './degree-planner/degree-planner.module'; -import { ConfigService } from './core/config.service'; @NgModule({ imports: [ diff --git a/src/app/core/config.service.ts b/src/app/core/config.service.ts index f29df19c9166a422fe097a15f6531652633b19aa..1730e489f1241e0161773e30a3711280e27a0f1d 100644 --- a/src/app/core/config.service.ts +++ b/src/app/core/config.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; @Injectable() export class ConfigService { - apiUrl = '/api/v1/'; + apiPlannerUrl = '/api/planner/v1/'; constructor() { } } diff --git a/src/app/core/data.service.ts b/src/app/core/data.service.ts index ea4a10f0af30ffa5957df187a900da1b9e77ca6e..1ea2ea5c59b018c6bdcf1399f5e75bb24e361972 100644 --- a/src/app/core/data.service.ts +++ b/src/app/core/data.service.ts @@ -1,42 +1,25 @@ -import { identifierModuleUrl } from '@angular/compiler'; +import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { Router } from '@angular/router'; -import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { Response } from '@angular/http'; +import { throwError, Observable } from 'rxjs'; +import { catchError, map } from 'rxjs/operators'; import { ConfigService } from './config.service'; -import { Response, ResponseContentType } from '@angular/http'; -import { Observable } from 'rxjs'; -import { catchError, map, tap } from 'rxjs/operators'; -import { throwError } from 'rxjs'; +import { Course } from './models/course'; @Injectable() export class DataService { - private api: string; - private coursesUrl = 'https://dev.enroll.wisc.edu/api/planner/v1/degreePlan/519261/courses'; - private log: any; + private plannerApiUrl: string; constructor(private http: HttpClient, private configService: ConfigService) { - this.api = this.configService.apiUrl; + this.plannerApiUrl = this.configService.apiPlannerUrl; } - getCourseData() { - return this.http - .get(this.coursesUrl) - // .subscribe( - // data => console.log('data: ', data), // success path - // error => console.log('error: ', error) // error path - // ); - .pipe( - map(this.extractData), - catchError(this.errorHandler) - ); - } - - private extractData(res: Response) { - return res.text() ? res.json() : {}; + getCourseData(): Observable<Course> { + return this.http.get<Course>(this.plannerApiUrl + '/degreePlan/520224/courses') + .pipe(catchError(this.errorHandler)); } private errorHandler(error: Response) { - // console.error(error); return throwError(error || 'Server Error'); } diff --git a/src/app/core/models/course.ts b/src/app/core/models/course.ts new file mode 100644 index 0000000000000000000000000000000000000000..5094caa6e9c054d23a5ed31029edd5156894e001 --- /dev/null +++ b/src/app/core/models/course.ts @@ -0,0 +1,33 @@ +export interface Course { + id: number; + courseId: string; + termCode: string; + topicId: number; + title: string; + subjectCode: string; + catalogNumber: string; + credits: number; + creditMin: number; + creditMax: number; + grade: any; + classNumber: string; + courseOrder: number; + honors: string; + waitlist: string; + relatedClassNumber1: any; + relatedClassNumber2: any; + classPermissionNumber: any; + sessionCode: any; + validationResults: any[]; + enrollmentResults: any[]; + pendingEnrollments: any[]; + details: any; + classMeetings: any; + enrollmentOptions: any; + packageEnrollmentStatus: any; + creditRange: any; +} + +export interface TermContainer { + termCode: string; +} diff --git a/src/app/core/models/courses.ts b/src/app/core/models/courses.ts deleted file mode 100644 index 4b422e53aee0d329704bfa03fdddeda45333177b..0000000000000000000000000000000000000000 --- a/src/app/core/models/courses.ts +++ /dev/null @@ -1,33 +0,0 @@ -export interface Course { - id: number; - courseId: string; - termCode: string; - topicId: number; - title: string; - subjectCode: string; - catalogNumber: string; - credits: number; - creditMin: number; - creditMax: number; - grade: any; - classNumber: string; - courseOrder: number; - honors: string; - waitlist: string; - relatedClassNumber1: any; - relatedClassNumber2: any; - classPermissionNumber: any; - sessionCode: any; - validationResults: any[]; - enrollmentResults: any[]; - pendingEnrollments: any[]; - details: any; - classMeetings: any; - enrollmentOptions: any; - packageEnrollmentStatus: any; - creditRange: any; -} - -export interface TermContainer { - termCode: string; -} diff --git a/src/app/degree-planner/degree-planner.component.ts b/src/app/degree-planner/degree-planner.component.ts index 8236a69e2c729989a02e5ae8ee39421003465abd..1ab6fe0023f5fe7e0ef30bf695bd128e0633c3f1 100644 --- a/src/app/degree-planner/degree-planner.component.ts +++ b/src/app/degree-planner/degree-planner.component.ts @@ -1,7 +1,5 @@ -import { ActivatedRoute, Params } from '@angular/router'; import { Component, OnInit } from '@angular/core'; import { DataService } from '../core/data.service'; -import { HttpClient } from '@angular/common/http'; @Component({ selector: 'app-degree-planner', @@ -10,7 +8,7 @@ import { HttpClient } from '@angular/common/http'; }) export class DegreePlannerComponent implements OnInit { - constructor(private http: HttpClient, private dataService: DataService, private activatedRoute: ActivatedRoute) { } + constructor(private dataService: DataService) { } ngOnInit() { this.getCourseData();