From 1aa6bc80c9b2ebd2c77986dd8c2d0726fa449890 Mon Sep 17 00:00:00 2001 From: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com> Date: Tue, 17 Oct 2023 09:02:13 -0400 Subject: [PATCH 1/2] File upload robustness (#956) Fixes issues uploading multiple files manually --- .../components/settings/DeviceControlCard.vue | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/photon-client/src/components/settings/DeviceControlCard.vue b/photon-client/src/components/settings/DeviceControlCard.vue index 29ae2e92d0..b7dfeff249 100644 --- a/photon-client/src/components/settings/DeviceControlCard.vue +++ b/photon-client/src/components/settings/DeviceControlCard.vue @@ -63,19 +63,18 @@ const offlineUpdate = ref(); const openOfflineUpdatePrompt = () => { offlineUpdate.value.click(); }; -const handleOfflineUpdate = (payload: Event) => { +const handleOfflineUpdate = (payload: Event & { target: (EventTarget & HTMLInputElement) | null }) => { + if (payload.target === null || !payload.target.files) return; + + const formData = new FormData(); + formData.append("jarData", payload.target.files[0]); + useStateStore().showSnackbarMessage({ message: "New Software Upload in Progress...", color: "secondary", timeout: -1 }); - const formData = new FormData(); - - if (payload.target == null || !payload.target?.files) return; - const files: FileList = payload.target.files as FileList; - formData.append("jarData", files[0]); - axios .post("/utils/offlineUpdate", formData, { headers: { "Content-Type": "multipart/form-data" }, @@ -138,21 +137,17 @@ enum ImportType { HardwareSettings, NetworkConfig } - const showImportDialog = ref(false); const importType = ref(-1); -const importFile = ref(null); +const importFile = ref(null); const handleSettingsImport = () => { if (importType.value === -1 || importFile.value === null) return; const formData = new FormData(); formData.append("data", importFile.value); - let settingsEndpoint; + let settingsEndpoint: string; switch (importType.value) { - case ImportType.AllSettings: - settingsEndpoint = ""; - break; case ImportType.HardwareConfig: settingsEndpoint = "/hardwareConfig"; break; @@ -162,6 +157,10 @@ const handleSettingsImport = () => { case ImportType.NetworkConfig: settingsEndpoint = "/networkConfig"; break; + default: + case ImportType.AllSettings: + settingsEndpoint = ""; + break; } axios @@ -245,21 +244,22 @@ const handleSettingsImport = () => { Import Settings Upload and apply previously saved or exported PhotonVision settings to this device - + Date: Tue, 17 Oct 2023 09:08:25 -0400 Subject: [PATCH 2/2] Take Snapshots from PhotonClient (#940) --- .../components/app/photon-camera-stream.vue | 74 +++++++++++++--- .../cameras/CameraCalibrationCard.vue | 2 +- .../src/components/cameras/CamerasView.vue | 6 +- .../stores/settings/CameraSettingsStore.ts | 29 ++++++- .../frame/consumer/FileSaveFrameConsumer.java | 86 ++++++++++--------- .../vision/processes/VisionModule.java | 8 ++ .../VisionModuleChangeSubscriber.java | 6 ++ .../server/DataSocketHandler.java | 24 ++++++ .../server/DataSocketMessageType.java | 2 + 9 files changed, 177 insertions(+), 60 deletions(-) diff --git a/photon-client/src/components/app/photon-camera-stream.vue b/photon-client/src/components/app/photon-camera-stream.vue index 2868ae7180..1349da2f9d 100644 --- a/photon-client/src/components/app/photon-camera-stream.vue +++ b/photon-client/src/components/app/photon-camera-stream.vue @@ -4,13 +4,14 @@ 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"; +import CvIcon from "@/components/common/cv-icon.vue"; const props = defineProps<{ streamType: "Raw" | "Processed"; id?: string; }>(); -const src = computed(() => { +const streamSrc = computed(() => { const port = useCameraSettingsStore().currentCameraSettings.stream[props.streamType === "Raw" ? "inputPort" : "outputPort"]; @@ -20,25 +21,74 @@ const src = computed(() => { return `http://${inject("backendHostname")}:${port}/stream.mjpg`; }); -const alt = computed(() => `${props.streamType} Stream View`); - -const style = computed(() => { +const streamDesc = computed(() => `${props.streamType} Stream View`); +const streamStyle = computed(() => { if (useStateStore().colorPickingMode) { - return { cursor: "crosshair" }; - } else if (src.value !== loadingImage) { - return { cursor: "pointer" }; + return { width: "100%", cursor: "crosshair" }; + } else if (streamSrc.value !== loadingImage) { + return { width: "100%", cursor: "pointer" }; } - return {}; + return { width: "100%" }; }); -const handleClick = () => { - if (!useStateStore().colorPickingMode && src.value !== loadingImage) { - window.open(src.value); +const overlayStyle = computed(() => { + if (useStateStore().colorPickingMode || streamSrc.value == loadingImage) { + return { display: "none" }; + } else { + return {}; + } +}); + +const handleStreamClick = () => { + if (!useStateStore().colorPickingMode && streamSrc.value !== loadingImage) { + window.open(streamSrc.value); + } +}; +const handleCaptureClick = () => { + if (props.streamType === "Raw") { + useCameraSettingsStore().saveInputSnapshot(); + } else { + useCameraSettingsStore().saveOutputSnapshot(); } }; + + diff --git a/photon-client/src/components/cameras/CameraCalibrationCard.vue b/photon-client/src/components/cameras/CameraCalibrationCard.vue index fb12224656..969dffa86b 100644 --- a/photon-client/src/components/cameras/CameraCalibrationCard.vue +++ b/photon-client/src/components/cameras/CameraCalibrationCard.vue @@ -384,7 +384,7 @@ const endCalibration = () => { color="secondary" style="width: 100%" :disabled="!settingsValid" - @click="isCalibrating ? useCameraSettingsStore().takeCalibrationSnapshot(true) : startCalibration()" + @click="isCalibrating ? useCameraSettingsStore().takeCalibrationSnapshot() : startCalibration()" > {{ isCalibrating ? "Take Snapshot" : "Start Calibration" }} diff --git a/photon-client/src/components/cameras/CamerasView.vue b/photon-client/src/components/cameras/CamerasView.vue index 8b7f1785dc..c9e3d32cb9 100644 --- a/photon-client/src/components/cameras/CamerasView.vue +++ b/photon-client/src/components/cameras/CamerasView.vue @@ -41,7 +41,7 @@ const fpsTooLow = computed(() => {