share context

This commit is contained in:
Daniel Ponte 2025-02-04 10:08:15 -05:00
parent b5eb5800b0
commit f14e50d258
3 changed files with 13 additions and 2 deletions

View file

@ -7,6 +7,7 @@
><mat-icon>playlist_play</mat-icon></a ><mat-icon>playlist_play</mat-icon></a
> >
</h1> </h1>
@if (!inShare) {
<button mat-icon-button (click)="editIncident(incID)"> <button mat-icon-button (click)="editIncident(incID)">
<mat-icon>edit</mat-icon> <mat-icon>edit</mat-icon>
</button> </button>
@ -18,6 +19,7 @@
Delete Delete
</button> </button>
</mat-menu> </mat-menu>
}
</div> </div>
<div class="inc-heading"> <div class="inc-heading">
<div class="field field-start field-label">Start</div> <div class="field field-start field-label">Start</div>

View file

@ -9,7 +9,7 @@ import {
FormControl, FormControl,
FormsModule, FormsModule,
} from '@angular/forms'; } from '@angular/forms';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { MatInputModule } from '@angular/material/input'; import { MatInputModule } from '@angular/material/input';
import { MatFormFieldModule } from '@angular/material/form-field'; import { MatFormFieldModule } from '@angular/material/form-field';
import { MatCheckboxModule } from '@angular/material/checkbox'; import { MatCheckboxModule } from '@angular/material/checkbox';
@ -40,6 +40,7 @@ import { CallPlayerComponent } from '../../calls/player/call-player/call-player.
import { FmtDatePipe } from '../incidents.component'; import { FmtDatePipe } from '../incidents.component';
import { MatMenuModule } from '@angular/material/menu'; import { MatMenuModule } from '@angular/material/menu';
import { Share } from '../../shares'; import { Share } from '../../shares';
import { ShareService } from '../../share/share.service';
export interface EditDialogData { export interface EditDialogData {
incID: string; incID: string;
@ -152,6 +153,7 @@ export class IncidentEditDialogComponent {
styleUrl: './incident.component.scss', styleUrl: './incident.component.scss',
}) })
export class IncidentComponent { export class IncidentComponent {
inShare = false;
incPrime = new Subject<IncidentRecord>(); incPrime = new Subject<IncidentRecord>();
inc$!: Observable<IncidentRecord>; inc$!: Observable<IncidentRecord>;
@Input() share?: Share; @Input() share?: Share;
@ -174,6 +176,7 @@ export class IncidentComponent {
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private shareSvc: ShareService,
private incSvc: IncidentsService, private incSvc: IncidentsService,
private location: Location, private location: Location,
) {} ) {}
@ -181,6 +184,7 @@ export class IncidentComponent {
saveIncName(ev: Event) {} saveIncName(ev: Event) {}
ngOnInit() { ngOnInit() {
this.inShare = this.shareSvc.isInShare();
let incOb: Observable<IncidentRecord>; let incOb: Observable<IncidentRecord>;
if (this.route.component === this.constructor) { if (this.route.component === this.constructor) {
// loaded by route // loaded by route

View file

@ -4,12 +4,17 @@ import { map, Observable, switchMap } from 'rxjs';
import { IncidentRecord } from '../incidents'; import { IncidentRecord } from '../incidents';
import { CallRecord } from '../calls'; import { CallRecord } from '../calls';
import { Share, ShareType } from '../shares'; import { Share, ShareType } from '../shares';
import { Router } from '@angular/router';
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class ShareService { export class ShareService {
constructor(private http: HttpClient) {} constructor(private http: HttpClient, private router: Router) {}
isInShare(): boolean {
return this.router.url.startsWith('/s/');
}
getShare(id: string): Observable<Share> { getShare(id: string): Observable<Share> {
return this.http.get<Share>(`/share/${id}`); return this.http.get<Share>(`/share/${id}`);