Skip to content

Commit 420048c

Browse files
committed
wip
1 parent 606156b commit 420048c

File tree

6 files changed

+574
-536
lines changed

6 files changed

+574
-536
lines changed

ui/src/components/Sessions/SessionClose.vue

+41-50
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
</div>
4848
</template>
4949

50-
<script lang="ts">
51-
import { defineComponent, PropType, ref } from "vue";
50+
<script setup lang="ts">
51+
import { PropType, ref } from "vue";
5252
import {
5353
INotificationsError,
5454
INotificationsSuccess,
@@ -57,55 +57,46 @@ import { IDevice } from "../../interfaces/IDevice";
5757
import { useStore } from "../../store";
5858
import handleError from "../../utils/handleError";
5959
60-
export default defineComponent({
61-
props: {
62-
uid: {
63-
type: String,
64-
required: true,
65-
},
66-
device: {
67-
type: Object as PropType<IDevice>,
68-
required: true,
69-
},
70-
notHasAuthorization: {
71-
type: Boolean,
72-
default: false,
73-
},
74-
style: {
75-
type: [String, Object],
76-
default: undefined,
77-
},
60+
const props = defineProps({
61+
uid: {
62+
type: String,
63+
required: true,
7864
},
79-
emits: ["update"],
80-
setup(props, ctx) {
81-
const showDialog = ref(false);
82-
const store = useStore();
83-
84-
const closeSession = async () => {
85-
try {
86-
await store.dispatch("sessions/close", {
87-
uid: props.uid,
88-
device_uid: props.device.uid,
89-
});
90-
showDialog.value = false;
91-
store.dispatch(
92-
"snackbar/showSnackbarSuccessAction",
93-
INotificationsSuccess.sessionClose,
94-
);
95-
ctx.emit("update");
96-
} catch (error: unknown) {
97-
store.dispatch(
98-
"snackbar/showSnackbarErrorAction",
99-
INotificationsError.sessionClose,
100-
);
101-
handleError(error);
102-
}
103-
};
104-
105-
return {
106-
showDialog,
107-
closeSession,
108-
};
65+
device: {
66+
type: Object as PropType<IDevice>,
67+
required: true,
68+
},
69+
notHasAuthorization: {
70+
type: Boolean,
71+
required: true,
72+
},
73+
style: {
74+
type: [String, Object],
75+
default: undefined,
10976
},
11077
});
78+
const emit = defineEmits(["update"]);
79+
const showDialog = ref(false);
80+
const store = useStore();
81+
82+
const closeSession = async () => {
83+
try {
84+
await store.dispatch("sessions/close", {
85+
uid: props.uid,
86+
device_uid: props.device.uid,
87+
});
88+
showDialog.value = false;
89+
store.dispatch(
90+
"snackbar/showSnackbarSuccessAction",
91+
INotificationsSuccess.sessionClose,
92+
);
93+
emit("update");
94+
} catch (error: unknown) {
95+
store.dispatch(
96+
"snackbar/showSnackbarErrorAction",
97+
INotificationsError.sessionClose,
98+
);
99+
handleError(error);
100+
}
101+
};
111102
</script>

ui/src/components/Sessions/SessionDelete.vue

+36-44
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div>
33
<v-list-item
44
@click="showDialog = true"
5-
:disabled="notHasAuthorization"
5+
:disabled="props.notHasAuthorization"
66
>
77
<div class="d-flex align-center">
88
<div class="mr-2">
@@ -46,57 +46,49 @@
4646
</div>
4747
</template>
4848

49-
<script lang="ts">
50-
import { defineComponent, ref } from "vue";
49+
<script setup lang="ts">
50+
import { PropType, ref } from "vue";
5151
import {
5252
INotificationsError,
5353
INotificationsSuccess,
5454
} from "../../interfaces/INotifications";
5555
import { useStore } from "../../store";
5656
import handleError from "../../utils/handleError";
5757
58-
export default defineComponent({
59-
props: {
60-
uid: {
61-
type: String,
62-
required: true,
63-
},
64-
notHasAuthorization: {
65-
type: Boolean,
66-
default: false,
67-
},
68-
style: {
69-
type: [String, Object],
70-
default: undefined,
71-
},
58+
const props = defineProps({
59+
uid: {
60+
type: String,
61+
required: true,
7262
},
73-
emits: ["update"],
74-
setup(props, ctx) {
75-
const showDialog = ref(false);
76-
const store = useStore();
77-
78-
const deleteRecord = async () => {
79-
try {
80-
await store.dispatch("sessions/deleteSessionLogs", props.uid);
81-
showDialog.value = false;
82-
store.dispatch(
83-
"snackbar/showSnackbarSuccessAction",
84-
INotificationsSuccess.sessionRemoveRecord,
85-
);
86-
ctx.emit("update");
87-
} catch (error: unknown) {
88-
store.dispatch(
89-
"snackbar/showSnackbarErrorAction",
90-
INotificationsError.sessionRemoveRecord,
91-
);
92-
handleError(error);
93-
}
94-
};
95-
96-
return {
97-
showDialog,
98-
deleteRecord,
99-
};
63+
notHasAuthorization: {
64+
type: Boolean,
65+
required: true,
66+
},
67+
style: {
68+
type: [String, Object] as PropType<string | object>,
69+
default: undefined,
10070
},
10171
});
72+
73+
const emit = defineEmits(["update"]);
74+
const showDialog = ref(false);
75+
const store = useStore();
76+
77+
const deleteRecord = async () => {
78+
try {
79+
await store.dispatch("sessions/deleteSessionLogs", props.uid);
80+
showDialog.value = false;
81+
store.dispatch(
82+
"snackbar/showSnackbarSuccessAction",
83+
INotificationsSuccess.sessionRemoveRecord,
84+
);
85+
emit("update");
86+
} catch (error: unknown) {
87+
store.dispatch(
88+
"snackbar/showSnackbarErrorAction",
89+
INotificationsError.sessionRemoveRecord,
90+
);
91+
handleError(error);
92+
}
93+
};
10294
</script>

0 commit comments

Comments
 (0)