activated typescript strict mode

This commit is contained in:
2021-05-22 15:30:04 +02:00
parent a195fafa6b
commit cb2c028ca4
76 changed files with 511 additions and 296 deletions

View File

@@ -12,15 +12,16 @@ import {ShowSongService} from '../../../modules/shows/services/show-song.service
styleUrls: ['./add-song.component.less'],
})
export class AddSongComponent {
@Input() public songs: Song[];
@Input() public showSongs: ShowSong[];
@Input() public showId: string;
@Input() public songs: Song[] | null = null;
@Input() public showSongs: ShowSong[] | null = null;
@Input() public showId: string | null = null;
@Input() public addedLive = false;
public filteredSongsControl = new FormControl();
public constructor(private showSongService: ShowSongService) {}
public filteredSongs(): Song[] {
if (!this.songs) return [];
const songs = this.songs
.filter(_ => !!_)
.filter(_ => !!_.title)
@@ -41,6 +42,7 @@ export class AddSongComponent {
}
public async onAddSongSelectionChanged(event: MatSelectChange): Promise<void> {
if (!this.showSongs || !this.showId) return;
const order = this.showSongs.reduce((oa, u) => Math.max(oa, u.order), 0) + 1;
await this.showSongService.new$(this.showId, event.value, order, this.addedLive);
event.source.value = null;

View File

@@ -1,5 +1,5 @@
import {Component} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {ActivatedRoute, Params, Router} from '@angular/router';
@Component({
selector: 'app-filter',
@@ -7,13 +7,12 @@ import {ActivatedRoute, Router} from '@angular/router';
styleUrls: ['./filter.component.less'],
})
export class FilterComponent {
public value: string;
public value = '';
public constructor(private router: Router, activatedRoute: ActivatedRoute) {
activatedRoute.queryParams.subscribe((_: {q: string}) => {
if (_.q) {
this.value = _.q;
}
activatedRoute.queryParams.subscribe((params: Params) => {
const typedParams = params as {q: string};
if (typedParams.q) this.value = typedParams.q;
});
}

View File

@@ -1,5 +1,6 @@
import {Component, Input} from '@angular/core';
import {IconProp} from '@fortawesome/fontawesome-svg-core';
import {faCross} from '@fortawesome/free-solid-svg-icons/faCross';
@Component({
selector: 'app-link',
@@ -7,7 +8,7 @@ import {IconProp} from '@fortawesome/fontawesome-svg-core';
styleUrls: ['./link.component.less'],
})
export class LinkComponent {
@Input() public text: string;
@Input() public link: string;
@Input() public icon: IconProp;
@Input() public text: string | null = null;
@Input() public link: string | null = null;
@Input() public icon: IconProp = faCross;
}

View File

@@ -1,4 +1,4 @@
<nav [class.hidden]="(windowScroll$ | async) > 60" class="head">
<nav [class.hidden]="isNavigationHidden(windowScroll$|async)" class="head">
<div class="links">
<app-brand routerLink="/brand"></app-brand>
<app-link

View File

@@ -2,7 +2,7 @@ import {Component} from '@angular/core';
import {faMusic} from '@fortawesome/free-solid-svg-icons/faMusic';
import {faPersonBooth} from '@fortawesome/free-solid-svg-icons/faPersonBooth';
import {faUserCog} from '@fortawesome/free-solid-svg-icons/faUserCog';
import {fromEvent} from 'rxjs';
import {fromEvent, Observable} from 'rxjs';
import {distinctUntilChanged, map, shareReplay, startWith} from 'rxjs/operators';
import {faChalkboard} from '@fortawesome/free-solid-svg-icons/faChalkboard';
@@ -17,10 +17,12 @@ export class NavigationComponent {
public faUser = faUserCog;
public faPresentation = faChalkboard;
public readonly windowScroll$ = fromEvent(window, 'scroll').pipe(
public readonly windowScroll$: Observable<number> = fromEvent(window, 'scroll').pipe(
map(() => window.scrollY),
startWith(0),
distinctUntilChanged(),
shareReplay(1)
);
public isNavigationHidden = (scroll: number | null): boolean => (scroll ?? 0) > 60;
}

View File

@@ -1,5 +1,6 @@
import {Component, Input} from '@angular/core';
import {IconProp} from '@fortawesome/fontawesome-svg-core';
import {faCross} from '@fortawesome/free-solid-svg-icons/faCross';
@Component({
selector: 'app-button',
@@ -7,5 +8,5 @@ import {IconProp} from '@fortawesome/fontawesome-svg-core';
styleUrls: ['./button.component.less'],
})
export class ButtonComponent {
@Input() public icon: IconProp;
@Input() public icon: IconProp = faCross;
}

View File

@@ -8,8 +8,8 @@ import {faTimes} from '@fortawesome/free-solid-svg-icons/faTimes';
})
export class CardComponent {
@Input() public padding = true;
@Input() public heading: string;
@Input() public closeLink: string;
@Input() public heading: string | null = null;
@Input() public closeLink: string | null = null;
public faClose = faTimes;
}

View File

@@ -1,5 +1,6 @@
import {Component, Input} from '@angular/core';
import {IconProp} from '@fortawesome/fontawesome-svg-core';
import {faCross} from '@fortawesome/free-solid-svg-icons/faCross';
@Component({
selector: 'app-menu-button',
@@ -7,5 +8,5 @@ import {IconProp} from '@fortawesome/fontawesome-svg-core';
styleUrls: ['./menu-button.component.less'],
})
export class MenuButtonComponent {
@Input() public icon: IconProp;
@Input() public icon: IconProp = faCross;
}

View File

@@ -17,13 +17,13 @@ export type ChordMode = 'show' | 'hide' | 'onlyFirst';
animations: [songSwitch],
})
export class SongTextComponent implements OnInit {
public sections: Section[];
public sections: Section[] = [];
@Input() public index = -1;
@Input() public fullscreen = false;
@Input() public showSwitch = false;
@Input() public transpose: TransposeMode = null;
@Input() public transpose: TransposeMode | null = null;
@Output() public chordModeChanged = new EventEmitter<ChordMode>();
@ViewChildren('section') public viewSections: QueryList<ElementRef<HTMLElement>>;
@ViewChildren('section') public viewSections: QueryList<ElementRef<HTMLElement>> | null = null;
public faLines = faGripLines;
public offset = 0;
public iChordMode: ChordMode = 'hide';
@@ -37,10 +37,13 @@ export class SongTextComponent implements OnInit {
@Input()
public set text(value: string) {
this.sections = null;
this.sections = [];
this.offset = 0;
if (this.fullscreen) {
setTimeout(() => (this.sections = this.textRenderingService.parse(value, this.transpose).sort((a, b) => a.type - b.type)), 100);
setTimeout(
() => (this.sections = this.textRenderingService.parse(value, this.transpose).sort((a, b) => a.type - b.type)),
100
);
} else {
this.sections = this.textRenderingService.parse(value, this.transpose).sort((a, b) => a.type - b.type);
}
@@ -48,11 +51,11 @@ export class SongTextComponent implements OnInit {
public ngOnInit(): void {
setInterval(() => {
if (!this.fullscreen || this.index === -1 || !this.viewSections.toArray()[this.index]) {
if (!this.fullscreen || this.index === -1 || !this.viewSections?.toArray()[this.index]) {
this.offset = 0;
return;
}
this.offset = -this.viewSections.toArray()[this.index].nativeElement.offsetTop;
this.offset = -this.viewSections?.toArray()[this.index].nativeElement.offsetTop;
}, 100);
}

View File

@@ -18,6 +18,7 @@ export class RoleGuard implements CanActivate {
return this.userService.user$.pipe(
map(user => {
if (!user) return false;
const roles = user.role?.split(';') ?? [];
if (roles.indexOf('admin') !== -1) {
return true;

View File

@@ -25,5 +25,7 @@ export class ShowTypePipe implements PipeTransform {
case 'misc-private':
return 'sonstige private Veranstaltung';
}
return 'unbekannter Veranstaltungstyp';
}
}