Skip to content

Commit 2896a7d

Browse files
committed
convert to use modal
1 parent 4183d6d commit 2896a7d

File tree

5 files changed

+53
-211
lines changed

5 files changed

+53
-211
lines changed

photon-client/src/components/cameras/CameraCalibrationInfoCard.vue

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ const removeCalibration = (vf: VideoFormat) => {
2020
width: vf.resolution.width,
2121
height: vf.resolution.height
2222
});
23-
24-
confirmRemoveDialog.value.show = false;
2523
};
2624
2725
const exportCalibration = ref();
@@ -312,32 +310,12 @@ const calibrationImageURL = (index: number) =>
312310
</v-card-text>
313311
</v-card>
314312

315-
<v-dialog v-model="confirmRemoveDialog.show" width="600">
316-
<v-card color="surface" dark>
317-
<v-card-title>Delete Calibration</v-card-title>
318-
<v-card-text class="pt-0">
319-
Are you sure you want to delete the calibration for {{ confirmRemoveDialog.vf.resolution.width }}x{{
320-
confirmRemoveDialog.vf.resolution.height
321-
}}? This cannot be undone.
322-
<v-card-actions class="pt-5 pb-0 pr-0" style="justify-content: flex-end">
323-
<v-btn
324-
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
325-
color="primary"
326-
@click="() => (confirmRemoveDialog.show = false)"
327-
>
328-
Cancel
329-
</v-btn>
330-
<v-btn
331-
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
332-
color="error"
333-
@click="removeCalibration(confirmRemoveDialog.vf)"
334-
>
335-
Delete
336-
</v-btn>
337-
</v-card-actions>
338-
</v-card-text>
339-
</v-card>
340-
</v-dialog>
313+
<pv-delete-modal
314+
v-model="confirmRemoveDialog.show"
315+
:action="'Delete Calibration'"
316+
:description="`Are you sure you want to delete the calibration for '${confirmRemoveDialog.vf.resolution.width}x${confirmRemoveDialog.vf.resolution.height}'? This action cannot be undone.`"
317+
:on-delete="() => removeCalibration(confirmRemoveDialog.vf)"
318+
/>
341319
</template>
342320

343321
<style scoped>

photon-client/src/components/cameras/CameraSettingsCard.vue

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import PvSelect, { type SelectItem } from "@/components/common/pv-select.vue";
3-
import PvInput from "@/components/common/pv-input.vue";
3+
import pvDeleteModal from "../common/pv-delete-modal.vue";
44
import PvNumberInput from "@/components/common/pv-number-input.vue";
55
import { useCameraSettingsStore } from "@/stores/settings/CameraSettingsStore";
66
import { useStateStore } from "@/stores/StateStore";
@@ -112,17 +112,9 @@ watchEffect(() => {
112112
});
113113
114114
const showDeleteCamera = ref(false);
115-
const yesDeleteMySettingsText = ref("");
116-
const deletingCamera = ref(false);
117115
const deleteThisCamera = () => {
118-
if (deletingCamera.value) return;
119-
deletingCamera.value = true;
120-
121-
const payload = { cameraUniqueName: useStateStore().currentCameraUniqueName };
122-
123-
axiosPost("/utils/nukeOneCamera", "delete this camera", payload).finally(() => {
124-
deletingCamera.value = false;
125-
showDeleteCamera.value = false;
116+
axiosPost("/utils/nukeOneCamera", "delete this camera", {
117+
cameraUniqueName: useStateStore().currentCameraUniqueName
126118
});
127119
};
128120
const wrappedCameras = computed<SelectItem[]>(() =>
@@ -195,45 +187,13 @@ const wrappedCameras = computed<SelectItem[]>(() =>
195187
</v-col>
196188
</v-card-text>
197189

198-
<v-dialog v-model="showDeleteCamera" width="800">
199-
<v-card color="surface" flat>
200-
<v-card-title> Delete {{ useCameraSettingsStore().currentCameraSettings.nickname }}? </v-card-title>
201-
<v-card-text class="pt-0 pb-10px">
202-
Are you sure you want to delete "{{ useCameraSettingsStore().currentCameraSettings.nickname }}"? This cannot
203-
be undone.
204-
</v-card-text>
205-
<v-card-text class="pt-0 pb-10px">
206-
<pv-input
207-
v-model="yesDeleteMySettingsText"
208-
:label="'Type &quot;' + useCameraSettingsStore().currentCameraName + '&quot;:'"
209-
:label-cols="6"
210-
:input-cols="6"
211-
/>
212-
</v-card-text>
213-
<v-card-actions class="pa-5 pt-0">
214-
<v-btn
215-
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
216-
color="primary"
217-
class="text-black"
218-
@click="showDeleteCamera = false"
219-
>
220-
Cancel
221-
</v-btn>
222-
<v-btn
223-
color="error"
224-
:disabled="
225-
yesDeleteMySettingsText.toLowerCase() !== useCameraSettingsStore().currentCameraName.toLowerCase()
226-
"
227-
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
228-
:loading="deletingCamera"
229-
@click="deleteThisCamera"
230-
>
231-
<v-icon start class="open-icon" size="large"> mdi-trash-can-outline </v-icon>
232-
<span class="open-label">Delete</span>
233-
</v-btn>
234-
</v-card-actions>
235-
</v-card>
236-
</v-dialog>
190+
<pv-delete-modal
191+
v-model="showDeleteCamera"
192+
action="Delete Camera"
193+
:description="`Are you sure you want to delete the camera '${useCameraSettingsStore().currentCameraSettings.nickname}'? This action cannot be undone.`"
194+
:expected="useCameraSettingsStore().currentCameraSettings.nickname"
195+
:on-delete="deleteThisCamera"
196+
/>
237197
</v-card>
238198
</template>
239199

photon-client/src/components/settings/DeviceControlCard.vue

Lines changed: 9 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { inject, ref } from "vue";
33
import { useStateStore } from "@/stores/StateStore";
44
import PvSelect from "@/components/common/pv-select.vue";
5-
import PvInput from "@/components/common/pv-input.vue";
5+
import pvDeleteModal from "../common/pv-delete-modal.vue";
66
import { useTheme } from "vuetify";
77
import { axiosPost } from "@/lib/PhotonUtils";
88
@@ -113,12 +113,8 @@ const handleSettingsImport = () => {
113113
};
114114
115115
const showFactoryReset = ref(false);
116-
const expected = "Delete Everything";
117-
const yesDeleteMySettingsText = ref("");
118116
const nukePhotonConfigDirectory = () => {
119117
axiosPost("/utils/nukeConfigDirectory", "delete the config directory");
120-
121-
showFactoryReset.value = false;
122118
};
123119
</script>
124120

@@ -280,63 +276,14 @@ const nukePhotonConfigDirectory = () => {
280276
</v-col>
281277
</v-row>
282278
</div>
283-
<v-dialog v-model="showFactoryReset" width="800" dark>
284-
<v-card color="surface" flat>
285-
<v-card-title style="display: flex; justify-content: center">
286-
<span class="open-label">
287-
<v-icon end color="red" class="open-icon ma-1" size="large">mdi-alert-outline</v-icon>
288-
Factory Reset PhotonVision
289-
<v-icon end color="red" class="open-icon ma-1" size="large">mdi-alert-outline</v-icon>
290-
</span>
291-
</v-card-title>
292-
<v-card-text class="pt-0 pb-10px">
293-
<v-row class="align-center text-white">
294-
<v-col cols="12" md="6">
295-
<span> This will delete ALL OF YOUR SETTINGS and restart PhotonVision. </span>
296-
</v-col>
297-
<v-col cols="12" md="6">
298-
<v-btn
299-
color="primary"
300-
style="float: right"
301-
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
302-
@click="openExportSettingsPrompt"
303-
>
304-
<v-icon start class="open-icon" size="large"> mdi-export </v-icon>
305-
<span class="open-label">Backup Settings</span>
306-
<a
307-
ref="exportSettings"
308-
style="color: black; text-decoration: none; display: none"
309-
:href="`http://${address}/api/settings/photonvision_config.zip`"
310-
download="photonvision-settings.zip"
311-
target="_blank"
312-
/>
313-
</v-btn>
314-
</v-col>
315-
</v-row>
316-
</v-card-text>
317-
<v-card-text class="pt-0 pb-0">
318-
<pv-input
319-
v-model="yesDeleteMySettingsText"
320-
:label="'Type &quot;' + expected + '&quot;:'"
321-
:label-cols="6"
322-
:input-cols="6"
323-
/>
324-
</v-card-text>
325-
<v-card-text class="pt-10px">
326-
<v-btn
327-
color="error"
328-
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
329-
:disabled="yesDeleteMySettingsText.toLowerCase() !== expected.toLowerCase()"
330-
@click="nukePhotonConfigDirectory"
331-
>
332-
<v-icon start class="open-icon" size="large"> mdi-trash-can-outline </v-icon>
333-
<span class="open-label">
334-
{{ $vuetify.display.mdAndUp ? "Delete everything, I have backed up what I need" : "Delete Everything" }}
335-
</span>
336-
</v-btn>
337-
</v-card-text>
338-
</v-card>
339-
</v-dialog>
279+
<pv-delete-modal
280+
v-model="showFactoryReset"
281+
action="Factory Reset PhotonVision"
282+
description="This will delete all settings and configurations stored on this device, including network settings. This action cannot be undone."
283+
expected="Delete Everything"
284+
:on-delete="nukePhotonConfigDirectory"
285+
:on-backup="openExportSettingsPrompt"
286+
/>
340287
</v-card>
341288
</template>
342289

photon-client/src/components/settings/ObjectDetectionCard.vue

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,9 @@ const handleImport = async () => {
7373
};
7474
7575
const deleteModel = async (model: ObjectDetectionModelProperties) => {
76-
useStateStore().showSnackbarMessage({
77-
message: "Deleting Object Detection Model...",
78-
color: "secondary",
79-
timeout: -1
80-
});
81-
8276
axiosPost("/objectdetection/delete", "delete an object detection model", {
8377
modelPath: model.modelPath
8478
});
85-
86-
confirmDeleteDialog.value.show = false;
8779
};
8880
8981
const renameModel = async (model: ObjectDetectionModelProperties, newName: string) => {

photon-client/src/views/CameraMatchingView.vue

Lines changed: 28 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ import {
77
PVCameraInfo,
88
type PVCSICameraInfo,
99
type PVFileCameraInfo,
10-
type PVUsbCameraInfo,
11-
type UiCameraConfiguration
10+
type PVUsbCameraInfo
1211
} from "@/types/SettingTypes";
1312
import { axiosPost, getResolutionString } from "@/lib/PhotonUtils";
1413
import PhotonCameraStream from "@/components/app/photon-camera-stream.vue";
15-
import PvInput from "@/components/common/pv-input.vue";
14+
import PvDeleteModal from "@/components/common/pv-delete-modal.vue";
1615
import PvCameraInfoCard from "@/components/common/pv-camera-info-card.vue";
1716
import PvCameraMatchCard from "@/components/common/pv-camera-match-card.vue";
18-
import type { WebsocketCameraSettingsUpdate } from "@/types/WebsocketDataTypes";
1917
import { useTheme } from "vuetify";
2018
2119
const theme = useTheme();
@@ -55,18 +53,10 @@ const deactivateModule = (cameraUniqueName: string) => {
5553
);
5654
};
5755
58-
const deletingCamera = ref(false);
59-
const deleteThisCamera = (cameraName: string) => {
60-
if (deletingCamera.value) return;
61-
deletingCamera.value = true;
62-
const payload = {
63-
cameraUniqueName: cameraName
64-
};
56+
const confirmDeleteDialog = ref({ show: false, nickname: "", cameraUniqueName: "" });
6557
66-
axiosPost("/utils/nukeOneCamera", "delete a camera", payload).finally(() => {
67-
setCameraDeleting(null);
68-
deletingCamera.value = false;
69-
});
58+
const deleteThisCamera = (cameraUniqueName: string) => {
59+
axiosPost("/utils/nukeOneCamera", "delete a camera", { cameraUniqueName: cameraUniqueName });
7060
};
7161
7262
const cameraConnected = (uniquePath: string): boolean => {
@@ -110,15 +100,6 @@ const setCameraView = (camera: PVCameraInfo | null, isConnected: boolean | null)
110100
viewingCamera.value = [camera, isConnected];
111101
};
112102
113-
const viewingDeleteCamera = ref(false);
114-
const cameraToDelete = ref<UiCameraConfiguration | WebsocketCameraSettingsUpdate | null>(null);
115-
const setCameraDeleting = (camera: UiCameraConfiguration | WebsocketCameraSettingsUpdate | null) => {
116-
yesDeleteMySettingsText.value = "";
117-
viewingDeleteCamera.value = camera !== null;
118-
cameraToDelete.value = camera;
119-
};
120-
const yesDeleteMySettingsText = ref("");
121-
122103
/**
123104
* Get the connection-type-specific camera info from the given PVCameraInfo object.
124105
*/
@@ -275,7 +256,14 @@ const getMatchedDevice = (info: PVCameraInfo | undefined): PVCameraInfo => {
275256
color="error"
276257
style="width: 100%"
277258
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
278-
@click="setCameraDeleting(module)"
259+
@click="
260+
() =>
261+
(confirmDeleteDialog = {
262+
show: true,
263+
nickname: module.nickname,
264+
cameraUniqueName: module.uniqueName
265+
})
266+
"
279267
>
280268
<v-icon size="x-large">mdi-trash-can-outline</v-icon>
281269
</v-btn>
@@ -361,7 +349,14 @@ const getMatchedDevice = (info: PVCameraInfo | undefined): PVCameraInfo => {
361349
color="error"
362350
style="width: 100%"
363351
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
364-
@click="setCameraDeleting(module)"
352+
@click="
353+
() =>
354+
(confirmDeleteDialog = {
355+
show: true,
356+
nickname: module.nickname,
357+
cameraUniqueName: module.uniqueName
358+
})
359+
"
365360
>
366361
<v-icon size="x-large">mdi-trash-can-outline</v-icon>
367362
</v-btn>
@@ -465,43 +460,13 @@ const getMatchedDevice = (info: PVCameraInfo | undefined): PVCameraInfo => {
465460
</v-card>
466461
</v-dialog>
467462

468-
<!-- Camera delete modal -->
469-
<v-dialog v-model="viewingDeleteCamera" width="800">
470-
<v-card v-if="cameraToDelete !== null" class="dialog-container" color="surface" flat>
471-
<v-card-title> Delete {{ cameraToDelete.nickname }}? </v-card-title>
472-
<v-card-text class="pb-10px">
473-
Are you sure you want to delete "{{ cameraToDelete.nickname }}"? This cannot be undone.
474-
</v-card-text>
475-
<v-card-text class="pt-0 pb-10px">
476-
<pv-input
477-
v-model="yesDeleteMySettingsText"
478-
:label="'Type &quot;' + cameraToDelete.nickname + '&quot;:'"
479-
:label-cols="6"
480-
:input-cols="6"
481-
/>
482-
</v-card-text>
483-
<v-card-actions class="pa-5 pt-0">
484-
<v-btn
485-
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
486-
color="primary"
487-
class="text-black"
488-
@click="cameraToDelete = null"
489-
>
490-
Cancel
491-
</v-btn>
492-
<v-btn
493-
color="error"
494-
:disabled="yesDeleteMySettingsText.toLowerCase() !== cameraToDelete.nickname.toLowerCase()"
495-
:loading="deletingCamera"
496-
:variant="theme.global.name.value === 'LightTheme' ? 'elevated' : 'outlined'"
497-
@click="deleteThisCamera(cameraToDelete.uniqueName)"
498-
>
499-
<v-icon start class="open-icon" size="large"> mdi-trash-can-outline </v-icon>
500-
<span class="open-label">Delete</span>
501-
</v-btn>
502-
</v-card-actions>
503-
</v-card>
504-
</v-dialog>
463+
<pv-delete-modal
464+
v-model="confirmDeleteDialog.show"
465+
action="Delete Camera"
466+
:description="`Are you sure you want to delete the camera '${useCameraSettingsStore().currentCameraSettings.nickname}'? This action cannot be undone.`"
467+
:expected="confirmDeleteDialog.nickname"
468+
:on-delete="() => deleteThisCamera(confirmDeleteDialog.cameraUniqueName)"
469+
/>
505470
</div>
506471
</template>
507472

0 commit comments

Comments
 (0)