This file contains hidden or 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
| import { Injectable } from '@angular/core'; | |
| import { HttpResponse } from '@angular/common/http'; | |
| @Injectable({ | |
| providedIn: 'root' | |
| }) | |
| export class HttpCacheService { | |
| private requests: any = { }; |
This file contains hidden or 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
| import { Injectable } from '@angular/core'; | |
| import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpResponse } from '@angular/common/http'; | |
| import { Observable, of } from 'rxjs'; | |
| import { tap } from 'rxjs/operators'; | |
| import { HttpCacheService } from 'app/services/http-cache.service'; // https://gist.github.com/kudchikarsk/f2f8754eca3cf86db3fbbc833c330e55 | |
| @Injectable() | |
| export class CacheInterceptor implements HttpInterceptor { |
This file contains hidden or 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
| import { Injectable } from '@angular/core'; | |
| import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http'; | |
| import { Observable } from 'rxjs'; | |
| @Injectable() | |
| export class AddHeaderInterceptor implements HttpInterceptor { | |
| intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | |
| console.log(`AddHeaderInterceptor - ${req.url}`); | |
This file contains hidden or 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
| import { TestBed } from '@angular/core/testing'; | |
| import { HttpClientTestingModule, HttpTestingController, TestRequest } from '@angular/common/http/testing'; | |
| import { DataService } from './data.service'; | |
| import { Book } from 'app/models/book'; | |
| import { BookTrackerError } from 'app/models/bookTrackerError'; | |
| describe('DataService Tests', () => { | |
| let dataService: DataService; |
This file contains hidden or 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
| (function() { | |
| var app = angular.module('app', ['ngRoute']); | |
| app.config(['$logProvider', '$routeProvider', '$locationProvider', function ($logProvider, $routeProvider, $locationProvider) { | |
| $logProvider.debugEnabled(true); | |
| //$locationProvider.hashPrefix('!'); |
This file contains hidden or 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
| (function () { | |
| angular.module('app') | |
| .factory('dataService', ['$http', '$q', '$log', '$timeout', dataService]); | |
| function dataService($http, $q, $log, $timeout) { | |
| return { | |
| getAllSchools: getAllSchools, | |
| getAllClassrooms: getAllClassrooms, |
This file contains hidden or 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
| (function () { | |
| angular.module('app') | |
| .controller('ClassroomController', ['dataService', 'notifier', '$routeParams', ClassroomController]); | |
| function ClassroomController(dataService, notifier, $routeParams) { | |
| var vm = this; | |
| vm.month = $routeParams.month; |
This file contains hidden or 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
| (function(module) { | |
| var addToken = function(currentUser, $q) { | |
| return { | |
| request: function(config) { | |
| if (currentUser.profile.token) { | |
| config.headers.Authorization = "Bearer " + currentUser.profile.token; | |
| } | |
| return $q.when(config); |
This file contains hidden or 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
| //refer https://gist.github.com/kudchikarsk/f8ae377255f04cdc00a0fbc35287dbb5 for currentUser Service | |
| (function (module) { | |
| var oauth = function () { | |
| var url = "/login"; | |
| this.setUrl = function (newUrl) { | |
| url = newUrl; | |
| }; |
This file contains hidden or 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
| (function (module) { | |
| var loginRedirect = function () { | |
| var loginUrl = "/login"; | |
| var lastPath = ""; | |
| this.setLoginUrl = function (value) { | |
| loginUrl = value; | |
| }; |