2023-08-21 01:51:35 -04:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { computed, inject } from "vue";
|
|
|
|
|
import { useCameraSettingsStore } from "@/stores/settings/CameraSettingsStore";
|
|
|
|
|
import { useStateStore } from "@/stores/StateStore";
|
|
|
|
|
import loadingImage from "@/assets/images/loading.svg";
|
|
|
|
|
import type { StyleValue } from "vue/types/jsx";
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
2023-08-31 16:56:58 -04:00
|
|
|
streamType: "Raw" | "Processed";
|
|
|
|
|
id?: string;
|
2023-08-21 01:51:35 -04:00
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
const src = computed<string>(() => {
|
2023-08-31 16:56:58 -04:00
|
|
|
const port =
|
|
|
|
|
useCameraSettingsStore().currentCameraSettings.stream[props.streamType === "Raw" ? "inputPort" : "outputPort"];
|
2023-08-21 01:51:35 -04:00
|
|
|
|
2023-08-31 16:56:58 -04:00
|
|
|
if (!useStateStore().backendConnected || port === 0) {
|
2023-08-21 01:51:35 -04:00
|
|
|
return loadingImage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return `http://${inject("backendHostname")}:${port}/stream.mjpg`;
|
|
|
|
|
});
|
|
|
|
|
const alt = computed<string>(() => `${props.streamType} Stream View`);
|
|
|
|
|
|
|
|
|
|
const style = computed<StyleValue>(() => {
|
2023-08-31 16:56:58 -04:00
|
|
|
if (useStateStore().colorPickingMode) {
|
2023-08-21 01:51:35 -04:00
|
|
|
return { cursor: "crosshair" };
|
2023-08-31 16:56:58 -04:00
|
|
|
} else if (src.value !== loadingImage) {
|
2023-08-21 01:51:35 -04:00
|
|
|
return { cursor: "pointer" };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const handleClick = () => {
|
2023-08-31 16:56:58 -04:00
|
|
|
if (!useStateStore().colorPickingMode && src.value !== loadingImage) {
|
2023-08-21 01:51:35 -04:00
|
|
|
window.open(src.value);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2023-08-31 16:56:58 -04:00
|
|
|
<img :id="id" crossorigin="anonymous" :src="src" :alt="alt" :style="style" @click="handleClick" />
|
2023-08-21 01:51:35 -04:00
|
|
|
</template>
|