Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions photon-client/src/views/CameraMatchingView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import PvDeleteModal from "@/components/common/pv-delete-modal.vue";
import PvCameraInfoCard from "@/components/common/pv-camera-info-card.vue";
import PvCameraMatchCard from "@/components/common/pv-camera-match-card.vue";
import { useTheme } from "vuetify";
import PvSelect from "@/components/common/pv-select.vue";

const theme = useTheme();

Expand Down Expand Up @@ -64,6 +65,19 @@ const deleteThisCamera = (cameraUniqueName: string) => {
});
};

const swapDialog = ref({ show: false, cameraName: "", uniquePath: "" });
const otherCamera = ref({ cameraName: "", uniquePath: "" });

const swapCamera = (cameraUniqueName: string, otherCameraUniqueName: string) => {
axiosPost("/utils/swapCameras", "swap two camera assignments", {
cameraUniqueName: cameraUniqueName,
otherCameraUniqueName: otherCameraUniqueName
}).finally(() => {
swapDialog.value.show = false;
otherCamera.value = { cameraName: "", uniquePath: "" };
});
};

const cameraConnected = (uniquePath: string): boolean => {
return (
useStateStore().vsmState.allConnectedCameras.find((it) => cameraInfoFor(it).uniquePath === uniquePath) !== undefined
Expand Down Expand Up @@ -274,6 +288,25 @@ const getMatchedDevice = (info: PVCameraInfo | undefined): PVCameraInfo => {
<v-icon size="x-large">mdi-trash-can-outline</v-icon>
</v-btn>
</v-col>
<v-col cols="6" md="3">
<v-btn
class="pa-0"
color="buttonPassive"
style="width: 100%"
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
tooltip="Swap Camera"
@click="
() =>
(swapDialog = {
show: true,
cameraName: cameraInfoFor(module.matchedCameraInfo).name,
uniquePath: cameraInfoFor(module.matchedCameraInfo).uniquePath
})
"
>
<v-icon size="x-large">mdi-swap-horizontal</v-icon>
</v-btn>
</v-col>
</v-row>
</v-card-text>
</v-card>
Expand Down Expand Up @@ -467,6 +500,47 @@ const getMatchedDevice = (info: PVCameraInfo | undefined): PVCameraInfo => {
</v-card>
</v-dialog>

<!-- Camera swapping modal -->
<v-dialog v-model="swapDialog.show" max-width="800">
<v-card flat color="surface">
<v-card-title class="d-flex justify-space-between">
<span>Swap Camera Configs</span>
</v-card-title>
<v-row>
<v-col> {{ swapDialog.cameraName }}</v-col>
<v-col><v-icon size="x-large" color="buttonPassive">mdi-swap-horizontal</v-icon> </v-col>
<v-col>
<pv-select
v-model="otherCamera.uniquePath"
label="Other Camera"
:select-cols="8"
:items="
activeVisionModules
.map((it) =>
cameraInfoFor(it.matchedCameraInfo).uniquePath !== swapDialog.uniquePath
? {
name: `${cameraInfoFor(it.matchedCameraInfo).name}`,
value: cameraInfoFor(it.matchedCameraInfo).uniquePath
}
: null
)
.filter((it) => it !== null)
"
/>
</v-col>
</v-row>
<v-btn
:disabled="otherCamera.uniquePath === '' || otherCamera.uniquePath === null"
color="buttonPassive"
style="width: 100%"
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
@click="swapCamera(swapDialog.uniquePath, otherCamera.uniquePath)"
>
<span>Swap Cameras</span>
</v-btn>
</v-card>
</v-dialog>

<pv-delete-modal
v-model="confirmDeleteDialog.show"
title="Delete Camera"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1393,4 +1393,20 @@ public static void onUnassignCameraRequest(Context ctx) {
return;
}
}

private record SwapCamerasRequest(String uniquePath, String otherUniquePath) {}

public static void onSwapCamerasRequest(Context ctx) {
logger.info(ctx.queryString());
try {
SwapCamerasRequest request = kObjectMapper.readValue(ctx.body(), SwapCamerasRequest.class);

logger.info("Swapping cameras: " + request.uniquePath + " and " + request.otherUniquePath);
} catch (IOException e) {
ctx.status(401);
logger.error("Failed to process swap cameras request", e);
ctx.result("Failed to process swap cameras request");
return;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ private static void start(int port) {
app.post("/api/utils/activateMatchedCamera", RequestHandler::onActivateMatchedCameraRequest);
app.post("/api/utils/assignUnmatchedCamera", RequestHandler::onAssignUnmatchedCameraRequest);
app.post("/api/utils/unassignCamera", RequestHandler::onUnassignCameraRequest);
app.post("/api/utils/swapCameras", RequestHandler::onSwapCamerasRequest);

// Calibration
app.post("/api/calibration/end", RequestHandler::onCalibrationEndRequest);
Expand Down
Loading