catchup #13

Merged
toniwalter.green merged 16 commits from devel into main 2026-09-15 01:47:26 +02:00
3 changed files with 20 additions and 3 deletions
Showing only changes of commit 4ac4be0368 - Show all commits
@@ -1,9 +1,14 @@
<h1>Gesammelte Veranstaltungen</h1> <h1>Gesammelte Veranstaltungen</h1>
<p> <p>
<button matButton="filled" (click)="subscribe()">Abbonieren</button> @if(this.pushService.isSubscribed()){
<span>Aboniert<mat-icon>check</mat-icon></span
><br />
<button matButton="filled" class="secondary-btn" (click)="unsubscribe()"> <button matButton="filled" class="secondary-btn" (click)="unsubscribe()">
Abmelden Abmelden
</button> </button>
}@else {
<button matButton="filled" (click)="subscribe()">Abonieren</button>
}
</p> </p>
<div class="table-container"> <div class="table-container">
<table mat-table [dataSource]="datasource" matSort> <table mat-table [dataSource]="datasource" matSort>
@@ -6,6 +6,7 @@ import {
viewChild, viewChild,
} from '@angular/core'; } from '@angular/core';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { MatSort, MatSortModule } from '@angular/material/sort'; import { MatSort, MatSortModule } from '@angular/material/sort';
import { MatTableDataSource, MatTableModule } from '@angular/material/table'; import { MatTableDataSource, MatTableModule } from '@angular/material/table';
import { parse } from 'date-fns'; import { parse } from 'date-fns';
@@ -15,13 +16,19 @@ import { PushService } from '../../services/push/pushService';
@Component({ @Component({
selector: 'app-events', selector: 'app-events',
imports: [MatTableModule, MatSortModule, MatButtonModule, Ellipsis], imports: [
MatTableModule,
MatSortModule,
MatButtonModule,
Ellipsis,
MatIconModule,
],
templateUrl: './events.html', templateUrl: './events.html',
styleUrl: './events.scss', styleUrl: './events.scss',
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
}) })
export class Events implements OnInit { export class Events implements OnInit {
private readonly pushService = inject(PushService); protected readonly pushService = inject(PushService);
protected readonly datasource = new MatTableDataSource<api.FoundEventDto>(); protected readonly datasource = new MatTableDataSource<api.FoundEventDto>();
protected readonly sort = viewChild.required(MatSort); protected readonly sort = viewChild.required(MatSort);
protected readonly displayedColumns = [ protected readonly displayedColumns = [
@@ -1,5 +1,7 @@
import { inject, Injectable } from '@angular/core'; import { inject, Injectable } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { SwPush } from '@angular/service-worker'; import { SwPush } from '@angular/service-worker';
import { map } from 'rxjs';
import { v7 as uuidv7 } from 'uuid'; import { v7 as uuidv7 } from 'uuid';
import * as api from '../../generated-api/api'; import * as api from '../../generated-api/api';
import VAPID from './vapid.json' with { type: 'json' }; import VAPID from './vapid.json' with { type: 'json' };
@@ -9,6 +11,9 @@ const SUBSCRIPTION_CLIENT_ID = 'subscriptionClientId';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class PushService { export class PushService {
private readonly swPush = inject(SwPush); private readonly swPush = inject(SwPush);
public readonly isSubscribed = toSignal(
this.swPush.subscription.pipe(map(x => x != null)),
);
private arrayBufferToString(buffer: ArrayBuffer | null) { private arrayBufferToString(buffer: ArrayBuffer | null) {
if (buffer == null) { if (buffer == null) {