mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
improve profile reactiveness and action page performance
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import { CameraSource } from "@capacitor/camera";
|
||||
|
||||
export interface ITakePictureParams {
|
||||
width?: number,
|
||||
height?: number,
|
||||
quality: number,
|
||||
source: CameraSource
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||
import { ITakePictureParams } from './adaptor';
|
||||
import { err, ok, Result } from 'neverthrow';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { error } from '../../services/Either/index';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CameraService {
|
||||
|
||||
constructor() { }
|
||||
|
||||
|
||||
async takePicture(data: ITakePictureParams, tracing?: TracingType): Promise<Result<string, any>> {
|
||||
try {
|
||||
tracing?.addEvent('take picture')
|
||||
const capturedImage = await Camera.getPhoto({
|
||||
...data,
|
||||
// allowEditing: true,
|
||||
resultType: CameraResultType.Base64,
|
||||
});
|
||||
tracing?.addEvent('end take picture')
|
||||
tracing.log('image log', {
|
||||
base64: capturedImage.base64String
|
||||
})
|
||||
return ok(capturedImage.base64String)
|
||||
} catch(error) {
|
||||
tracing?.log("camera error", {
|
||||
error
|
||||
})
|
||||
tracing?.hasError('capture image')
|
||||
return err(error)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user