diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 068eb67d50f10069056a933086d7a7c916ae5624..dc14932cc6a792291545f6c1dda73a123641d985 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -7,7 +7,6 @@ import { RouterTestingModule } from '@angular/router/testing'; import { CoreModule } from '@app/core/core.module'; import { SharedModule } from '@app/shared/shared.module'; import { AppComponent } from './app.component'; -import { SidenavService } from './core/service/sidenav.service'; const routes: Routes = [ { @@ -38,7 +37,7 @@ describe('AppComponent', () => { RouterTestingModule.withRoutes(routes), ], schemas: [NO_ERRORS_SCHEMA], - providers: [SidenavService], + providers: [], declarations: [AppComponent], }).compileComponents(); })); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 9422145c2b40a2f4383f36ec3547d2ef7fcba7d4..8c514b10fd56097442a368d93b10e77629e8077a 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -9,7 +9,6 @@ import { } from '@angular/forms'; import { Course } from '@app/core/models/course'; import { DegreePlannerApiService } from '@app/degree-planner/services/api.service'; -import { SidenavService } from '@app/core/service/sidenav.service'; import { CourseDetailsDialogComponent } from '@app/degree-planner/dialogs/course-details-dialog/course-details-dialog.component'; @Component({ @@ -27,7 +26,6 @@ export class AppComponent implements OnInit { constructor( public dialog: MatDialog, - private sidenavService: SidenavService, private fb: FormBuilder, private api: DegreePlannerApiService, ) { @@ -47,9 +45,7 @@ export class AppComponent implements OnInit { // ); } - ngOnInit() { - // this.sidenavService.setSidenav(this.rightAddCourse); - } + ngOnInit() {} openCourseDetailsDialog(course) { this.api diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 0d71beb323ceb83865c2ad301cd5742cc9f7f292..5c556e500f8f5e438850c02eeba7d91227a29c1a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -11,7 +11,6 @@ import { AppComponent } from './app.component'; import { CoreModule } from '@app/core/core.module'; import { SharedModule } from '@app/shared/shared.module'; import { HeaderComponent } from './core/header/header.component'; -import { SidenavService } from './core/service/sidenav.service'; import { degreePlannerReducer } from '@app/degree-planner/store/reducer'; import { DegreePlanEffects } from '@app/degree-planner/store/effects/plan.effects'; import { NoteEffects } from '@app/degree-planner/store/effects/note.effects'; @@ -44,7 +43,7 @@ import { CourseDetailsDialogComponent } from './degree-planner/dialogs/course-de ], declarations: [AppComponent, HeaderComponent], entryComponents: [CourseDetailsDialogComponent], - providers: [SidenavService], + providers: [], bootstrap: [AppComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA], }) diff --git a/src/app/core/config.service.ts b/src/app/core/config.service.ts deleted file mode 100644 index 9e76fbc762ab52b4f88a72073a35abb5e7108269..0000000000000000000000000000000000000000 --- a/src/app/core/config.service.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Injectable } from '@angular/core'; - -@Injectable() -export class ConfigService { - public readonly apiPlannerUrl = '/api/planner/v1'; - public readonly apiSearchUrl = '/api/search/v1'; -} diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts index abc65acff828896f2e90e612ee557fd5a3731797..628a950465bd101e253d0e8ad2c6e751b4b80f05 100644 --- a/src/app/core/core.module.ts +++ b/src/app/core/core.module.ts @@ -1,10 +1,11 @@ import { NgModule, Optional, SkipSelf } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterModule } from '@angular/router'; +import { MAT_SNACK_BAR_DEFAULT_OPTIONS } from '@angular/material/snack-bar'; +import { environment } from './../../environments/environment'; import { SharedModule } from '../shared/shared.module'; import { NavigationComponent } from './navigation/navigation.component'; -import { ConfigService } from './config.service'; import { throwIfAlreadyLoaded } from './module-import-check'; @NgModule({ @@ -15,7 +16,12 @@ import { throwIfAlreadyLoaded } from './module-import-check'; ], exports: [NavigationComponent], declarations: [NavigationComponent], - providers: [ConfigService], + providers: [ + { + provide: MAT_SNACK_BAR_DEFAULT_OPTIONS, + useValue: { duration: environment.snackbarDuration }, + }, + ], }) export class CoreModule { constructor(@Optional() @SkipSelf() parentModule: CoreModule) { diff --git a/src/app/core/service/sidenav.service.ts b/src/app/core/service/sidenav.service.ts deleted file mode 100644 index ee5270156d76a9c729de9fb669ef1962de87afe3..0000000000000000000000000000000000000000 --- a/src/app/core/service/sidenav.service.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Injectable } from '@angular/core'; -import { MatSidenav } from '@angular/material'; - -@Injectable() -export class SidenavService { - private sidenav: MatSidenav; - - public setSidenav(sidenav: MatSidenav) { - this.sidenav = sidenav; - } - - public open() { - return this.sidenav.open(); - } - - public close() { - return this.sidenav.close(); - } - - public toggle(): void { - this.sidenav.toggle(); - } -} diff --git a/src/app/degree-planner/degree-planner.component.spec.ts b/src/app/degree-planner/degree-planner.component.spec.ts index f16f07be37499ca95080694c2645386b2246a09d..bb965e3d40fc9ed3de958b07878f4cab50397efc 100644 --- a/src/app/degree-planner/degree-planner.component.spec.ts +++ b/src/app/degree-planner/degree-planner.component.spec.ts @@ -1,4 +1,3 @@ -import { SidenavService } from './../core/service/sidenav.service'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; @@ -25,7 +24,7 @@ describe('DegreePlannerComponent', () => { BrowserAnimationsModule, ], declarations: [DegreePlannerComponent], - providers: [SidenavService, { provide: MAT_DIALOG_DATA }], + providers: [{ provide: MAT_DIALOG_DATA }], schemas: [NO_ERRORS_SCHEMA], }).compileComponents(); })); diff --git a/src/app/degree-planner/services/api.service.ts b/src/app/degree-planner/services/api.service.ts index f33cf522349d8283a6d70c9b8fae16c2515101e2..3519533e3e7478cb7778d3aef1c7f16b6e2ecb9e 100644 --- a/src/app/degree-planner/services/api.service.ts +++ b/src/app/degree-planner/services/api.service.ts @@ -7,7 +7,7 @@ import { Observable } from 'rxjs'; import { map, filter } from 'rxjs/operators'; // Services -import { ConfigService } from '@app/core/config.service'; +import { environment } from './../../../environments/environment'; // Models import { Note } from '@app/core/models/note'; @@ -25,22 +25,22 @@ const HTTP_OPTIONS = { @Injectable({ providedIn: 'root' }) export class DegreePlannerApiService { - constructor(private http: HttpClient, private config: ConfigService) {} + constructor(private http: HttpClient) {} public getSavedForLaterCourses(): Observable<SavedForLaterCourseBase[]> { return this.http.get<SavedForLaterCourseBase[]>( - `${this.config.apiPlannerUrl}/favorites`, + `${environment.apiPlannerUrl}/favorites`, ); } public createDegreePlan(name: string, primary: boolean = false) { - const url = `${this.config.apiPlannerUrl}/degreePlan`; + const url = `${environment.apiPlannerUrl}/degreePlan`; const payload = { name, primary }; return this.http.post<DegreePlan>(url, payload); } public deleteDegreePlan(roadmapId: number) { - const url = `${this.config.apiPlannerUrl}/degreePlan/${roadmapId}`; + const url = `${environment.apiPlannerUrl}/degreePlan/${roadmapId}`; return this.http.delete<void>(url); } @@ -75,7 +75,7 @@ export class DegreePlannerApiService { courseId: string, ): Observable<CourseDetails[]> { return this.http.get<CourseDetails[]>( - this.config.apiSearchUrl + '/course/0000/' + subjectCode + '/' + courseId, + environment.apiSearchUrl + '/course/0000/' + subjectCode + '/' + courseId, HTTP_OPTIONS, ); } @@ -90,7 +90,7 @@ export class DegreePlannerApiService { public updateCourseTerm(roadmapId, recordId, termCode): Observable<any> { return this.http.put<CourseBase>( - this.config.apiPlannerUrl + + environment.apiPlannerUrl + '/degreePlan/' + roadmapId + '/courses/' + @@ -167,7 +167,7 @@ export class DegreePlannerApiService { termCode: string, ): Observable<CourseBase> { return this.http.post<CourseBase>( - this.config.apiPlannerUrl + '/degreePlan/' + planId + '/courses', + environment.apiPlannerUrl + '/degreePlan/' + planId + '/courses', { subjectCode, courseId, termCode }, HTTP_OPTIONS, ); @@ -175,7 +175,7 @@ export class DegreePlannerApiService { public removeCourse(planId: number, recordId: number): Observable<void> { return this.http.delete<void>( - this.config.apiPlannerUrl + + environment.apiPlannerUrl + '/degreePlan/' + planId + '/courses/' + @@ -189,7 +189,7 @@ export class DegreePlannerApiService { courseId: string, ): Observable<SavedForLaterCourseBase> { return this.http.post<SavedForLaterCourseBase>( - this.config.apiPlannerUrl + '/favorites/' + subjectCode + '/' + courseId, + environment.apiPlannerUrl + '/favorites/' + subjectCode + '/' + courseId, HTTP_OPTIONS, ); } @@ -199,7 +199,7 @@ export class DegreePlannerApiService { courseId: string, ): Observable<SavedForLaterCourseBase> { return this.http.delete<SavedForLaterCourseBase>( - this.config.apiPlannerUrl + '/favorites/' + subjectCode + '/' + courseId, + environment.apiPlannerUrl + '/favorites/' + subjectCode + '/' + courseId, HTTP_OPTIONS, ); } @@ -269,7 +269,7 @@ export class DegreePlannerApiService { .concat(parts.map(part => part.toString())) .reduce((soFar, next) => { return Location.joinWithSlash(soFar, next); - }, this.config.apiPlannerUrl); + }, environment.apiPlannerUrl); } private searchEndpoint(...parts: any[]): string { @@ -277,6 +277,6 @@ export class DegreePlannerApiService { .map(part => part.toString()) .reduce((soFar, next) => { return Location.joinWithSlash(soFar, next); - }, this.config.apiSearchUrl); + }, environment.apiSearchUrl); } } diff --git a/src/app/degree-planner/shared/course-item/course-item.component.scss b/src/app/degree-planner/shared/course-item/course-item.component.scss index 0fa80decba702cb7c511b3527f472250d7cb3342..67254758e9b4624a15b87b0682e5456fec7e037f 100644 --- a/src/app/degree-planner/shared/course-item/course-item.component.scss +++ b/src/app/degree-planner/shared/course-item/course-item.component.scss @@ -25,8 +25,7 @@ box-shadow: none; .course-credits, - .course-number, - .course-title { + .course-number { font-weight: bold; } } diff --git a/src/app/degree-planner/store/effects/course.effects.ts b/src/app/degree-planner/store/effects/course.effects.ts index 4c380e68c5c70efbff3d8c3649f5462a93e1f977..73f2d9d8057183a8c5f5b02b51c0d7545847d1cd 100644 --- a/src/app/degree-planner/store/effects/course.effects.ts +++ b/src/app/degree-planner/store/effects/course.effects.ts @@ -76,7 +76,7 @@ export class CourseEffects { state.payload.to, ); const message = `Course has been moved to ${touchedTerm}`; - this.snackBar.open(message, undefined, { duration: 2000 }); + this.snackBar.open(message, undefined, {}); }), catchError(error => { @@ -133,7 +133,7 @@ export class CourseEffects { const message = `${touchedCourse.subject} ${ touchedCourse.catalogNumber } has been added to ${touchedTerm}`; - this.snackBar.open(message, undefined, { duration: 2000 }); + this.snackBar.open(message, undefined, {}); }), catchError(error => { @@ -215,7 +215,7 @@ export class CourseEffects { tap(() => { const message = 'Course has been saved for later'; - this.snackBar.open(message, undefined, { duration: 2000 }); + this.snackBar.open(message, undefined, {}); }), catchError(error => { diff --git a/src/app/degree-planner/store/effects/note.effects.ts b/src/app/degree-planner/store/effects/note.effects.ts index 67681789b168376efb1a8bcefbccd033ccc85cd6..c3547ee231db1f023bf54b3b2297a833f67a523d 100644 --- a/src/app/degree-planner/store/effects/note.effects.ts +++ b/src/app/degree-planner/store/effects/note.effects.ts @@ -83,7 +83,7 @@ export class NoteEffects { tap(() => { const message = 'Note has been saved'; - this.snackBar.open(message, undefined, { duration: 2000 }); + this.snackBar.open(message, undefined, {}); }), catchError(error => { @@ -121,7 +121,7 @@ export class NoteEffects { tap(() => { const message = 'Note has been deleted'; - this.snackBar.open(message, undefined, { duration: 2000 }); + this.snackBar.open(message, undefined, {}); }), catchError(error => { diff --git a/src/app/degree-planner/store/effects/plan.effects.ts b/src/app/degree-planner/store/effects/plan.effects.ts index 4cacf324fe80392d2cb512ff10f7c1819d02368a..d3cf2cad2b90d6d6f346958117e644d1398a2bfb 100644 --- a/src/app/degree-planner/store/effects/plan.effects.ts +++ b/src/app/degree-planner/store/effects/plan.effects.ts @@ -164,7 +164,7 @@ export class DegreePlanEffects { tap(state => { const touchedPlan = state.payload.visibleDegreePlan.name; const message = `Switched to ${touchedPlan}`; - this.snackBar.open(message, undefined, { duration: 2000 }); + this.snackBar.open(message, undefined, {}); }), catchError(error => { return of( @@ -197,7 +197,7 @@ export class DegreePlanEffects { }), tap(() => { const message = 'This plan has been set as the primary plan'; - this.snackBar.open(message, undefined, { duration: 2000 }); + this.snackBar.open(message, undefined, {}); }), catchError(error => { return of( @@ -229,7 +229,7 @@ export class DegreePlanEffects { }), tap(() => { const message = `Plan has been renamed to ${newName}`; - this.snackBar.open(message, undefined, { duration: 2000 }); + this.snackBar.open(message, undefined, {}); }), catchError(() => { return of(new ChangePlanNameFailure({ roadmapId, oldName })); @@ -264,7 +264,7 @@ export class DegreePlanEffects { }), tap(() => { const message = `New plan has been created`; - this.snackBar.open(message, undefined, { duration: 2000 }); + this.snackBar.open(message, undefined, {}); }), catchError(error => { return of( diff --git a/src/app/degree-planner/term-container/term-container.component.spec.ts b/src/app/degree-planner/term-container/term-container.component.spec.ts index b32934bf40b6458a30ab3721394ae3063908c76f..66f1b4f241e7778977dbd5e08121e1c5a96c29e5 100644 --- a/src/app/degree-planner/term-container/term-container.component.spec.ts +++ b/src/app/degree-planner/term-container/term-container.component.spec.ts @@ -10,7 +10,6 @@ import { HttpClient, HttpClientModule } from '@angular/common/http'; import { TermContainerComponent } from './term-container.component'; import { PlannedTerm } from '@app/core/models/planned-term'; -import { SidenavService } from '@app/core/service/sidenav.service'; describe('TermContainerComponent', () => { let termComponent: TermContainerComponent; @@ -25,7 +24,7 @@ describe('TermContainerComponent', () => { SharedModule, ], declarations: [TermContainerComponent], - providers: [SidenavService], + providers: [], schemas: [NO_ERRORS_SCHEMA], }).compileComponents(); })); diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 0382f71c8c6f5bb434eea680ca274c869aa43039..89d7282bda1cf58726a9b62ad8d5ed674a75c8f2 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,4 +1,7 @@ export const environment = { production: true, version: '0.0.1', + apiPlannerUrl: '/api/planner/v1', + apiSearchUrl: '/api/search/v1', + snackbarDuration: 4000, }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 44608059eb96cb7e56dadc3653b38ada6f45559c..3e1f1732c1fc72a8d5901baa1d3d323f364d0b98 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -2,9 +2,13 @@ // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`. // The list of file replacements can be found in `angular.json`. +// Don't forget to add properties to the `evironment.prod.ts` if needed export const environment = { production: false, version: 'DEV', + apiPlannerUrl: '/api/planner/v1', + apiSearchUrl: '/api/search/v1', + snackbarDuration: 4000, }; /*