Move card-controller out of utils.

This commit is contained in:
Dermot Duffy
2023-10-03 20:14:08 -07:00
parent 913355ad1d
commit ed91c87899
45 changed files with 8008 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
import { CardCameraURLAPI } from './types';
export class CameraURLManager {
protected _api: CardCameraURLAPI;
constructor(api: CardCameraURLAPI) {
this._api = api;
}
public openURL(): void {
const url = this.getCameraURL();
if (url) {
window.open(url);
}
}
public hasCameraURL(): boolean {
return !!this.getCameraURL();
}
public getCameraURL(): string | null {
const view = this._api.getViewManager().getView();
const media = view?.queryResults?.getSelectedResult() ?? null;
const endpoints = view?.camera
? this._api.getCameraManager().getCameraEndpoints(view.camera, {
view: view.view,
...(media && { media: media }),
}) ?? null
: null;
return endpoints?.ui?.endpoint ?? null;
}
}