Shares #109

Merged
amigan merged 59 commits from shareUI into trunk 2025-02-14 00:25:03 -05:00
3 changed files with 55 additions and 0 deletions
Showing only changes of commit 6bd30a9dd6 - Show all commits

View file

@ -1,4 +1,6 @@
import { Component } from '@angular/core';
import { ShareService } from './share.service';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-share',
@ -7,5 +9,12 @@ import { Component } from '@angular/core';
styleUrl: './share.component.scss'
})
export class ShareComponent {
constructor(
private route: ActivatedRoute,
private shareSvc: ShareService,
) {}
ngOnInit() {
}
}

View file

@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ShareService } from './share.service';
describe('ShareService', () => {
let service: ShareService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ShareService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View file

@ -0,0 +1,30 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { map, Observable, switchMap } from 'rxjs';
import { IncidentRecord } from '../incidents';
type Share = IncidentRecord | ArrayBuffer;
@Injectable({
providedIn: 'root'
})
export class ShareService {
constructor(
private http: HttpClient,
) { }
getShare(id: string): Observable<Share|null> {
return this.http.get<Share>(`/share/${id}`, {observe: 'response'}).pipe(
map((res) => {
let typ = res.headers.get('X-Share-Type');
switch(typ) {
case 'call':
return (res.body as ArrayBuffer);
case 'incident':
return (res.body as IncidentRecord);
}
return null;
})
);
}
}