merge chat

This commit is contained in:
Peter Maquiran
2024-09-13 12:27:39 +01:00
471 changed files with 17419 additions and 53900 deletions
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { CameraService } from './camera.service';
describe('CameraService', () => {
let service: CameraService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(CameraService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+37 -1
View File
@@ -5,6 +5,21 @@ import { err, ok, Result } from 'neverthrow';
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
import { error } from '../../services/Either/index';
/**
* Parameters for taking a picture.
* @typedef {Object} takePictureParams
* @property {number} [quality=90] - The quality of the picture, from 0 to 100.
* @property {CameraResultType} cameraResultType - The result type of the photo, e.g., Base64, URI.
*/
export type takePictureParams = {
quality?: number;
cameraResultType: CameraResultType;
};
/**
* Service for handling camera functionality.
* This service provides methods to interact with the device's camera.
*/
@Injectable({
providedIn: 'root'
})
@@ -13,7 +28,7 @@ export class CameraService {
constructor() { }
async takePicture(data: ITakePictureParams, tracing?: TracingType): Promise<Result<string, any>> {
async takePictureAgenda(data: ITakePictureParams, tracing?: TracingType): Promise<Result<string, any>> {
try {
tracing?.addEvent('take picture')
const capturedImage = await Camera.getPhoto({
@@ -35,4 +50,25 @@ export class CameraService {
}
}
/**
* Takes a picture using the device's camera.
* @param {takePictureParams} params - The parameters for taking the picture.
* @param {number} [params.quality=90] - The quality of the picture, from 0 to 100.
* @param {CameraResultType} params.cameraResultType - The result type of the photo.
* @returns {Promise<ok<File> | err<any>>} A promise that resolves with an `ok` result containing the file or an `err` result containing the error.
*/
async takePicture({quality = 90, cameraResultType }: takePictureParams) {
try {
const file = await Camera.getPhoto({
quality: quality,
resultType: cameraResultType,
source: CameraSource.Camera
});
return ok(file);
} catch (e) {
return err(e);
}
}
}