| @@ -1,6 +1,6 @@ | |||||
| { | { | ||||
| "$schema": "./node_modules/@angular/cli/lib/config/schema.json", | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||||
| "version": 1, | |||||
| "version": 2.0, | |||||
| "newProjectRoot": "projects", | "newProjectRoot": "projects", | ||||
| "projects": { | "projects": { | ||||
| "lms-app-new": { | "lms-app-new": { | ||||
| @@ -1,5 +1,5 @@ | |||||
| import { Component } from '@angular/core'; | import { Component } from '@angular/core'; | ||||
| import { UpdateService } from './services/update.service'; | |||||
| @Component({ | @Component({ | ||||
| selector: 'app-root', | selector: 'app-root', | ||||
| @@ -7,9 +7,11 @@ import { Component } from '@angular/core'; | |||||
| styleUrls: ['./app.component.scss'] | styleUrls: ['./app.component.scss'] | ||||
| }) | }) | ||||
| export class AppComponent { | export class AppComponent { | ||||
| constructor() { | |||||
| constructor( | |||||
| private updateService: UpdateService, | |||||
| ) { | |||||
| if (!localStorage.demoType) { | if (!localStorage.demoType) { | ||||
| localStorage.demoType = 'Teacher'; | |||||
| localStorage.demoType = 'Student'; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -11,6 +11,7 @@ import { DragDropModule } from '@angular/cdk/drag-drop'; | |||||
| // Import services | // Import services | ||||
| import { DemoService } from './services/demo.service'; | import { DemoService } from './services/demo.service'; | ||||
| import { UpdateService } from './services/update.service'; | |||||
| // Component imports | // Component imports | ||||
| import { AppComponent } from './app.component'; | import { AppComponent } from './app.component'; | ||||
| @@ -85,7 +86,8 @@ import { QuestionComponent } from './tabs/courses/test/question-sheet/question/q | |||||
| ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }) | ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }) | ||||
| ], | ], | ||||
| providers: [ | providers: [ | ||||
| DemoService | |||||
| DemoService, | |||||
| UpdateService | |||||
| ], | ], | ||||
| bootstrap: [AppComponent] | bootstrap: [AppComponent] | ||||
| }) | }) | ||||
| @@ -0,0 +1,16 @@ | |||||
| import { TestBed } from '@angular/core/testing'; | |||||
| import { UpdateService } from './update.service'; | |||||
| describe('UpdateService', () => { | |||||
| let service: UpdateService; | |||||
| beforeEach(() => { | |||||
| TestBed.configureTestingModule({}); | |||||
| service = TestBed.inject(UpdateService); | |||||
| }); | |||||
| it('should be created', () => { | |||||
| expect(service).toBeTruthy(); | |||||
| }); | |||||
| }); | |||||
| @@ -0,0 +1,29 @@ | |||||
| import { Injectable } from '@angular/core'; | |||||
| import { SwUpdate } from '@angular/service-worker'; | |||||
| @Injectable({ | |||||
| providedIn: 'root' | |||||
| }) | |||||
| export class UpdateService { | |||||
| constructor(private swUpdate: SwUpdate) { | |||||
| if (!this.swUpdate.isEnabled) { | |||||
| console.log('Nope SW'); | |||||
| } else { | |||||
| this.swUpdate.checkForUpdate().then((ev) => { | |||||
| console.log(ev); | |||||
| }, (err) => { | |||||
| console.log(err); | |||||
| }); | |||||
| } | |||||
| this.swUpdate.available.subscribe((evt: any) => { | |||||
| this.presentToastWithOptions('Update Available'); | |||||
| }); | |||||
| } | |||||
| public async presentToastWithOptions(message: string) { | |||||
| alert('New Update'); | |||||
| location.reload(); | |||||
| } | |||||
| } | |||||
| @@ -14,7 +14,7 @@ export class WelcomeComponent implements OnInit { | |||||
| private demoService: DemoService | private demoService: DemoService | ||||
| ) { } | ) { } | ||||
| ngOnInit(): void { | |||||
| ngOnInit(): void { | |||||
| this.demoType = localStorage.demoType; | this.demoType = localStorage.demoType; | ||||
| if (this.demoType === 'Student') { | if (this.demoType === 'Student') { | ||||
| this.classList = this.demoService.studentClassList; | this.classList = this.demoService.studentClassList; | ||||