diff options
Diffstat (limited to 'overlays/spm/frontend/src/app')
12 files changed, 186 insertions, 0 deletions
diff --git a/overlays/spm/frontend/src/app/app-routing.module.ts b/overlays/spm/frontend/src/app/app-routing.module.ts new file mode 100644 index 00000000..2da97cea --- /dev/null +++ b/overlays/spm/frontend/src/app/app-routing.module.ts | |||
@@ -0,0 +1,17 @@ | |||
1 | import { NgModule } from '@angular/core'; | ||
2 | import { RouterModule, Routes } from '@angular/router'; | ||
3 | |||
4 | import { SpmComponent } from './spm/spm.component'; | ||
5 | import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; | ||
6 | |||
7 | const routes: Routes = [ | ||
8 | { path: 'spm', component: SpmComponent }, | ||
9 | { path: '', redirectTo: '/spm', pathMatch: 'full' }, | ||
10 | { path: '**', component: PageNotFoundComponent } | ||
11 | ]; | ||
12 | |||
13 | @NgModule({ | ||
14 | imports: [RouterModule.forRoot(routes)], | ||
15 | exports: [RouterModule] | ||
16 | }) | ||
17 | export class AppRoutingModule { } | ||
diff --git a/overlays/spm/frontend/src/app/app.component.html b/overlays/spm/frontend/src/app/app.component.html new file mode 100644 index 00000000..f9b5b8fc --- /dev/null +++ b/overlays/spm/frontend/src/app/app.component.html | |||
@@ -0,0 +1,7 @@ | |||
1 | <mat-toolbar color="primary"> | ||
2 | <div> | ||
3 | <a mat-button routerLink="/spm" routerLinkActive="active">spm</a> | ||
4 | </div> | ||
5 | </mat-toolbar> | ||
6 | <!-- The routed views render in the <router-outlet> --> | ||
7 | <router-outlet></router-outlet> | ||
diff --git a/overlays/spm/frontend/src/app/app.component.sass b/overlays/spm/frontend/src/app/app.component.sass new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/overlays/spm/frontend/src/app/app.component.sass | |||
diff --git a/overlays/spm/frontend/src/app/app.component.ts b/overlays/spm/frontend/src/app/app.component.ts new file mode 100644 index 00000000..7c231203 --- /dev/null +++ b/overlays/spm/frontend/src/app/app.component.ts | |||
@@ -0,0 +1,21 @@ | |||
1 | import { Component, OnInit, OnDestroy } from '@angular/core'; | ||
2 | |||
3 | import { ColorSchemeService } from './color-scheme.service'; | ||
4 | |||
5 | @Component({ | ||
6 | selector: 'app-root', | ||
7 | templateUrl: './app.component.html', | ||
8 | styleUrls: ['./app.component.sass'] | ||
9 | }) | ||
10 | export class AppComponent implements OnInit, OnDestroy { | ||
11 | title = 'spm-frontend'; | ||
12 | |||
13 | constructor(private colorSchemeService: ColorSchemeService) {} | ||
14 | |||
15 | ngOnInit() { | ||
16 | this.colorSchemeService.init(); | ||
17 | } | ||
18 | ngOnDestroy() { | ||
19 | this.colorSchemeService.destroy(); | ||
20 | } | ||
21 | } | ||
diff --git a/overlays/spm/frontend/src/app/app.module.ts b/overlays/spm/frontend/src/app/app.module.ts new file mode 100644 index 00000000..914f73a2 --- /dev/null +++ b/overlays/spm/frontend/src/app/app.module.ts | |||
@@ -0,0 +1,32 @@ | |||
1 | import { NgModule } from '@angular/core'; | ||
2 | import { BrowserModule } from '@angular/platform-browser'; | ||
3 | |||
4 | import { AppRoutingModule } from './app-routing.module'; | ||
5 | import { AppComponent } from './app.component'; | ||
6 | import { SpmComponent } from './spm/spm.component'; | ||
7 | import { PageNotFoundComponent } from './page-not-found/page-not-found.component'; | ||
8 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
9 | import { MatIconModule } from '@angular/material/icon'; | ||
10 | import { HttpClientModule } from "@angular/common/http"; | ||
11 | import { MatToolbarModule } from '@angular/material/toolbar'; | ||
12 | import { MatButtonModule } from '@angular/material/button'; | ||
13 | |||
14 | @NgModule({ | ||
15 | declarations: [ | ||
16 | AppComponent, | ||
17 | SpmComponent, | ||
18 | PageNotFoundComponent | ||
19 | ], | ||
20 | imports: [ | ||
21 | BrowserModule, | ||
22 | AppRoutingModule, | ||
23 | BrowserAnimationsModule, | ||
24 | MatIconModule, | ||
25 | HttpClientModule, | ||
26 | MatToolbarModule, | ||
27 | MatButtonModule | ||
28 | ], | ||
29 | providers: [], | ||
30 | bootstrap: [AppComponent] | ||
31 | }) | ||
32 | export class AppModule { } | ||
diff --git a/overlays/spm/frontend/src/app/color-scheme.service.ts b/overlays/spm/frontend/src/app/color-scheme.service.ts new file mode 100644 index 00000000..c56e9c23 --- /dev/null +++ b/overlays/spm/frontend/src/app/color-scheme.service.ts | |||
@@ -0,0 +1,62 @@ | |||
1 | import { Injectable, Renderer2, RendererFactory2 } from '@angular/core'; | ||
2 | import { MediaMatcher } from '@angular/cdk/layout'; | ||
3 | import { LocalStorage } from 'ngx-webstorage'; | ||
4 | |||
5 | type ColorScheme = "dark" | "light"; | ||
6 | |||
7 | @Injectable({ | ||
8 | providedIn: 'root' | ||
9 | }) | ||
10 | export class ColorSchemeService { | ||
11 | private renderer: Renderer2; | ||
12 | matcher!: MediaQueryList; | ||
13 | |||
14 | @LocalStorage('prefers-color-scheme') | ||
15 | public colorSchemeOverride: ColorScheme; | ||
16 | |||
17 | public activeColorScheme: BehaviorSubject<ColorScheme> = new BehaviorSubject("light"); | ||
18 | |||
19 | constructor(rendererFactory: RendererFactory2, | ||
20 | mediaMatcher: MediaMatcher | ||
21 | ) { | ||
22 | // Create new renderer from renderFactory, to make it possible to use renderer2 in a service | ||
23 | this.renderer = rendererFactory.createRenderer(null, null); | ||
24 | this.matcher = mediaMatcher.matchMedia('(prefers-color-scheme: dark)'); | ||
25 | |||
26 | this._listener = this._listener.bind(this); | ||
27 | } | ||
28 | |||
29 | init() { | ||
30 | this.matcher.addEventListener('change', this._listener); | ||
31 | this.load(); | ||
32 | } | ||
33 | |||
34 | _listener(event: { matches: any; }) { | ||
35 | this.activeColorScheme.next(event.matches ? 'dark' : 'light'); | ||
36 | } | ||
37 | |||
38 | destroy() { | ||
39 | this.matcher.removeEventListener('change', this._listener); | ||
40 | } | ||
41 | |||
42 | _getColorScheme() { | ||
43 | if (this.colorSchemeOverride) { | ||
44 | this.colorSchemeOverride | ||
45 | } else { | ||
46 | this.matcher.matches ? 'dark' : 'light' | ||
47 | } | ||
48 | } | ||
49 | |||
50 | load() { | ||
51 | this.activeColorScheme.next(this._getColorScheme()); | ||
52 | } | ||
53 | |||
54 | update(scheme: ColorScheme) { | ||
55 | this.colorSchemeOverride = scheme; | ||
56 | this.activeColorScheme.next(scheme); | ||
57 | } | ||
58 | |||
59 | currentActive() { | ||
60 | return this.colorScheme; | ||
61 | } | ||
62 | } | ||
diff --git a/overlays/spm/frontend/src/app/page-not-found/page-not-found.component.html b/overlays/spm/frontend/src/app/page-not-found/page-not-found.component.html new file mode 100644 index 00000000..26a283ed --- /dev/null +++ b/overlays/spm/frontend/src/app/page-not-found/page-not-found.component.html | |||
@@ -0,0 +1,5 @@ | |||
1 | <div style="margin: 1rem;"> | ||
2 | <h1> | ||
3 | No Such Component | ||
4 | </h1> | ||
5 | </div> | ||
diff --git a/overlays/spm/frontend/src/app/page-not-found/page-not-found.component.sass b/overlays/spm/frontend/src/app/page-not-found/page-not-found.component.sass new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/overlays/spm/frontend/src/app/page-not-found/page-not-found.component.sass | |||
diff --git a/overlays/spm/frontend/src/app/page-not-found/page-not-found.component.ts b/overlays/spm/frontend/src/app/page-not-found/page-not-found.component.ts new file mode 100644 index 00000000..2d1091ce --- /dev/null +++ b/overlays/spm/frontend/src/app/page-not-found/page-not-found.component.ts | |||
@@ -0,0 +1,15 @@ | |||
1 | import { Component, OnInit } from '@angular/core'; | ||
2 | |||
3 | @Component({ | ||
4 | selector: 'app-page-not-found', | ||
5 | templateUrl: './page-not-found.component.html', | ||
6 | styleUrls: ['./page-not-found.component.sass'] | ||
7 | }) | ||
8 | export class PageNotFoundComponent implements OnInit { | ||
9 | |||
10 | constructor() { } | ||
11 | |||
12 | ngOnInit(): void { | ||
13 | } | ||
14 | |||
15 | } | ||
diff --git a/overlays/spm/frontend/src/app/spm/spm.component.html b/overlays/spm/frontend/src/app/spm/spm.component.html new file mode 100644 index 00000000..d1339d95 --- /dev/null +++ b/overlays/spm/frontend/src/app/spm/spm.component.html | |||
@@ -0,0 +1,3 @@ | |||
1 | <p>spm works!</p> | ||
2 | |||
3 | <mat-icon aria-hidden="false" aria-label="Thumbs up" svgIcon="thumb_up"></mat-icon> | ||
diff --git a/overlays/spm/frontend/src/app/spm/spm.component.sass b/overlays/spm/frontend/src/app/spm/spm.component.sass new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/overlays/spm/frontend/src/app/spm/spm.component.sass | |||
diff --git a/overlays/spm/frontend/src/app/spm/spm.component.ts b/overlays/spm/frontend/src/app/spm/spm.component.ts new file mode 100644 index 00000000..7d172052 --- /dev/null +++ b/overlays/spm/frontend/src/app/spm/spm.component.ts | |||
@@ -0,0 +1,24 @@ | |||
1 | import { Component, OnInit } from '@angular/core'; | ||
2 | import { MatIconRegistry, MatIconModule } from '@angular/material/icon'; | ||
3 | import { DomSanitizer } from "@angular/platform-browser"; | ||
4 | |||
5 | @Component({ | ||
6 | selector: 'app-spm', | ||
7 | templateUrl: './spm.component.html', | ||
8 | styleUrls: ['./spm.component.sass'] | ||
9 | }) | ||
10 | export class SpmComponent implements OnInit { | ||
11 | |||
12 | constructor(private matIconRegistry: MatIconRegistry, | ||
13 | private domSanitizer: DomSanitizer | ||
14 | ) { | ||
15 | this.matIconRegistry.addSvgIcon( | ||
16 | `thumb_up`, | ||
17 | this.domSanitizer.bypassSecurityTrustResourceUrl(`icons/thumb_up/baseline.svg`) | ||
18 | ); | ||
19 | } | ||
20 | |||
21 | ngOnInit(): void { | ||
22 | } | ||
23 | |||
24 | } | ||