only when logged in

This commit is contained in:
Daniel Ponte 2025-02-07 08:22:51 -05:00
parent 57f6e1254b
commit b41b5418d1
8 changed files with 41 additions and 35 deletions

View file

@ -180,7 +180,6 @@ export class CallsComponent {
}
setPage(p: PageEvent, force?: boolean) {
console.log("setpage")
this.selection.clear();
this.curPage = p;
if (p && p!.pageSize != this.perPage) {
@ -196,19 +195,16 @@ export class CallsComponent {
}
getCalls(p: PageEvent, force?: boolean) {
console.log("getcalls")
const pageStart = p.pageIndex * p.pageSize;
const serverPage = Math.floor(pageStart / reqPageSize) + 1;
this.pageWindow = pageStart % reqPageSize;
if (serverPage == this.currentServerPage && !force && this.currentSet) {
console.log("currentset");
this.callsResult.next(
this.callsResult
? this.currentSet.slice(this.pageWindow, this.pageWindow + p.pageSize)
: [],
);
} else {
console.log("not currentset");
this.currentServerPage = serverPage;
this.fetchCalls.next(this.buildParams(p, serverPage));
}
@ -248,7 +244,6 @@ export class CallsComponent {
.pipe(
debounceTime(500),
switchMap((params) => {
console.log("gc switchmap");
return this.callsSvc.getCalls(params);
}),
)

View file

@ -131,7 +131,6 @@ export class SafePipe implements PipeTransform {
return this._sanitizer.bypassSecurityTrustUrl(value);
case 'resourceUrl':
let res = this._sanitizer.bypassSecurityTrustResourceUrl(value);
console.log(res);
return res;
default:
return this._sanitizer.bypassSecurityTrustHtml(value);

View file

@ -7,18 +7,22 @@
><mat-icon>playlist_play</mat-icon></a
>
</h1>
@if (share == null) {
<button mat-icon-button (click)="editIncident(incID)">
<mat-icon>edit</mat-icon>
</button>
<button mat-icon-button [matMenuTriggerFor]="moreMenu">
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #moreMenu="matMenu">
<button class="deleteItem" mat-menu-item (click)="deleteIncident(incID)">
Delete
@if (share == null) {
<button mat-icon-button (click)="editIncident(incID)">
<mat-icon>edit</mat-icon>
</button>
</mat-menu>
<button mat-icon-button [matMenuTriggerFor]="moreMenu">
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #moreMenu="matMenu">
<button
class="deleteItem"
mat-menu-item
(click)="deleteIncident(incID)"
>
Delete
</button>
</mat-menu>
}
</div>
<div class="inc-heading">

View file

@ -10,10 +10,14 @@ import { ActivatedRoute, Router } from '@angular/router';
providedIn: 'root',
})
export class ShareService {
constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute) {}
constructor(
private http: HttpClient,
private router: Router,
private route: ActivatedRoute,
) {}
inShare(): string|null {
if(this.router.url.startsWith('/s/')) {
inShare(): string | null {
if (this.router.url.startsWith('/s/')) {
return this.route.snapshot.paramMap.get('id');
}

View file

@ -8,9 +8,8 @@ describe('SharesComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [SharesComponent]
})
.compileComponents();
imports: [SharesComponent],
}).compileComponents();
fixture = TestBed.createComponent(SharesComponent);
component = fixture.componentInstance;

View file

@ -4,8 +4,6 @@ import { Component } from '@angular/core';
selector: 'app-shares',
imports: [],
templateUrl: './shares.component.html',
styleUrl: './shares.component.scss'
styleUrl: './shares.component.scss',
})
export class SharesComponent {
}
export class SharesComponent {}

View file

@ -158,7 +158,6 @@ export class TalkgroupRecordComponent {
.getTalkgroup(Number(this.tgid.sys), Number(this.tgid.tg))
.pipe(
tap((tg) => {
console.log('tap run');
tg.alert_rules = tg.alert_rules
? tg.alert_rules.map((x) => Object.assign(new AlertRule(), x))
: [];

View file

@ -12,6 +12,7 @@ import {
import { Talkgroup, TalkgroupUpdate, TGID } from '../talkgroup';
import { Share } from '../shares';
import { ShareService } from '../share/share.service';
import { AuthService } from '../login/auth.service';
export interface Pagination {
page: number;
@ -31,9 +32,13 @@ export class TalkgroupService {
private readonly _getTalkgroup = new Map<string, ReplaySubject<Talkgroup>>();
private tgs$: Observable<Talkgroup[]>;
private tags$!: Observable<string[]>;
private fetchAll = new Subject<Share|null>();
private fetchAll = new ReplaySubject<Share | null>();
private subscriptions = new Subscription();
constructor(private http: HttpClient, private shareSvc: ShareService) {
constructor(
private http: HttpClient,
private shareSvc: ShareService,
private authSvc: AuthService,
) {
this.tgs$ = this.fetchAll.pipe(
switchMap((share) => this.getTalkgroups(share)),
shareReplay(),
@ -43,16 +48,17 @@ export class TalkgroupService {
shareReplay(),
);
let sh = this.shareSvc.inShare();
console.log(sh);
if (sh) {
this.shareSvc.getShare(sh).subscribe(this.fetchAll);
} else {
this.fetchAll.next(null);
if (this.authSvc.loggedIn) {
this.fetchAll.next(null);
}
}
this.fillTgMap();
}
setShare(share: Share|null) {
setShare(share: Share | null) {
this.fetchAll.next(share);
}
@ -64,8 +70,10 @@ export class TalkgroupService {
return this.http.get<string[]>('/api/talkgroup/tags');
}
getTalkgroups(share: Share|null): Observable<Talkgroup[]> {
return this.http.get<Talkgroup[]>(share ? `/share/${share.id}/talkgroups` : '/api/talkgroup/');
getTalkgroups(share: Share | null): Observable<Talkgroup[]> {
return this.http.get<Talkgroup[]>(
share ? `/share/${share.id}/talkgroups` : '/api/talkgroup/',
);
}
getTalkgroup(