-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
777 additions
and
252 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<ngx-spinner bdColor="rgba(51,51,51,0.2)" size="large" type="ball-clip-rotate-multiple" color="#ff9800"></ngx-spinner> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { LoaderComponent } from './loader.component'; | ||
|
||
describe('LoaderComponent', () => { | ||
let component: LoaderComponent; | ||
let fixture: ComponentFixture<LoaderComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ LoaderComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(LoaderComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Subscription } from 'rxjs'; | ||
import { NgxSpinnerService } from 'ngx-spinner'; | ||
import { LoaderService } from '../../services'; | ||
|
||
@Component({ | ||
selector: 'app-loader', | ||
templateUrl: './loader.component.html', | ||
styleUrls: ['./loader.component.scss'] | ||
}) | ||
export class LoaderComponent implements OnInit { | ||
|
||
public loaderStatus = true; | ||
public subscription: Subscription; | ||
|
||
constructor(private spinner: NgxSpinnerService, private loaderService: LoaderService) { | ||
|
||
this.subscription = this.loaderService.loaderUpdateEvent.subscribe( item => { | ||
this.loaderStatus = this.loaderService.getStatus(); | ||
if (this.loaderStatus === true) { | ||
this.spinner.hide(); | ||
} else { | ||
this.spinner.show(); | ||
} | ||
}); | ||
} | ||
|
||
ngOnInit() { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {tap} from 'rxjs/operators'; | ||
import {Injectable} from '@angular/core'; | ||
import { | ||
HttpErrorResponse, | ||
HttpEvent, | ||
HttpHandler, | ||
HttpInterceptor, | ||
HttpRequest, | ||
HttpResponse | ||
} from '@angular/common/http'; | ||
import {Observable} from 'rxjs'; | ||
import { LoaderService } from '../services'; | ||
|
||
|
||
|
||
@Injectable() | ||
export class LoaderInterceptor implements HttpInterceptor { | ||
|
||
constructor(private loader: LoaderService) { | ||
} | ||
|
||
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | ||
return next.handle(request).pipe(tap((event: HttpEvent<any>) => { | ||
if (event instanceof HttpResponse) { | ||
this.loader.pop(request.url); | ||
} else { | ||
this.loader.push(request.url); | ||
} | ||
}, (error: any) => { | ||
if (error instanceof HttpErrorResponse) { | ||
this.loader.pop(request.url); | ||
} | ||
})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ export class Classroom { | |
capacity = 0; | ||
scheduleId: number; | ||
buildingId: number; | ||
available: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { LoaderService } from './loader.service'; | ||
|
||
describe('LoaderService', () => { | ||
beforeEach(() => TestBed.configureTestingModule({})); | ||
|
||
it('should be created', () => { | ||
const service: LoaderService = TestBed.get(LoaderService); | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable, Subject } from 'rxjs'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class LoaderService { | ||
|
||
public loaderUpdateEvent: Observable<boolean>; | ||
private loaderUpdateSubject: Subject<boolean>; | ||
private eventList: Array<string>; | ||
|
||
constructor() { | ||
this.loaderUpdateSubject = new Subject<boolean>(); | ||
this.loaderUpdateEvent = this.loaderUpdateSubject.asObservable(); | ||
this.eventList = []; | ||
} | ||
|
||
// if there is no event on the queue, then the loader is released. | ||
public getStatus() { | ||
return !(this.eventList.length > 0); | ||
} | ||
|
||
// pushed a callback | ||
public push(symbol: string): void { | ||
this.eventList.push(symbol); | ||
this.loaderUpdateSubject.next(true); | ||
} | ||
|
||
public clear() { | ||
this.eventList = []; | ||
this.loaderUpdateSubject.next(true); | ||
} | ||
|
||
// removes a callback | ||
public pop(symbol: string): void { | ||
const targetIndex = this.eventList.findIndex(item => { | ||
return item === symbol; | ||
}); | ||
this.eventList.splice(targetIndex, 1); | ||
this.loaderUpdateSubject.next(true); | ||
} | ||
} |
Oops, something went wrong.