From 6109a4dab7e0ae574a7c6fe4fd0d57b390ce8cb4 Mon Sep 17 00:00:00 2001 From: Martin Araneda Date: Sun, 12 Feb 2023 16:34:03 -0300 Subject: [PATCH] minor fixes to topbar, chart --- frontend/src/layout/AppTopbar.vue | 49 +++++++++++++++++++------------ frontend/src/views/Chart.vue | 28 ++++++++++++++---- frontend/src/views/Login.vue | 12 ++++++-- 3 files changed, 63 insertions(+), 26 deletions(-) diff --git a/frontend/src/layout/AppTopbar.vue b/frontend/src/layout/AppTopbar.vue index 9e770c7..48ec746 100644 --- a/frontend/src/layout/AppTopbar.vue +++ b/frontend/src/layout/AppTopbar.vue @@ -5,6 +5,7 @@ import { useRouter } from 'vue-router'; import { useToast } from 'primevue/usetoast'; import axios from 'axios'; import jwt_decode from 'jwt-decode'; +import auth from '../utils/Auth'; const { onMenuToggle } = useLayout(); @@ -17,15 +18,6 @@ const submitted = ref(false); const toast = useToast(); const menu = ref(); const items = ref([ - { - label: 'Log out', - icon: 'pi pi-sign-out', - command: () => { - toast.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted', life: 3000 }); - localStorage.removeItem('token'); - router.push('/'); - } - }, { label: 'Change password', icon: 'pi pi-key', @@ -34,6 +26,15 @@ const items = ref([ submitted.value = false; user.value = {}; } + }, + { + label: 'Log out', + icon: 'pi pi-sign-out', + command: () => { + toast.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted', life: 3000 }); + localStorage.removeItem('token'); + router.push('/'); + } } ]); @@ -50,28 +51,40 @@ onBeforeUnmount(() => { }); -async function onClickPasswordChange() { +const onClickPasswordChange = () => { submitted.value = true; - console.log(user.value); var pass = - { password: user.value.current_password, new_password: user.value.new_password }; + if (user.value.new_password != user.value.confirm_new_password) { + console.log("gola"); + toast.add({ severity: 'error', summary: 'Error', detail: 'Passwords are not the same', life: 3000 }); + return; + } + savePassword(pass); +} + +async function savePassword(pass) { var token = localStorage.getItem("token"); var decoded = jwt_decode(token); try { - const response = await axios.patch(`http://localhost:3001/user/` + decoded.id, auth.getTokenHeader()); + const response = await axios.patch(`http://localhost:3001/user/` + decoded.id, pass, auth.getTokenHeader()); if (response.status !== 204) { console.error(response); } + } catch (error) { console.error(error); } } +const hideDialog = () => { + changePasswordDialog.value = false; + submitted.value = false; +}; const onTopBarMenuButton = () => { @@ -129,29 +142,29 @@ const isOutsideClicked = (event) => { - +
- Actual password is required.
- New password is required.
- Confirm the new password is required.
diff --git a/frontend/src/views/Chart.vue b/frontend/src/views/Chart.vue index 8783896..7f69814 100644 --- a/frontend/src/views/Chart.vue +++ b/frontend/src/views/Chart.vue @@ -2,12 +2,16 @@ import { ref, watch, onMounted } from 'vue'; import { useLayout } from '@/layout/composables/layout'; import auth from '../utils/Auth'; +import { useToast } from 'primevue/usetoast'; +import axios from 'axios'; const { layoutConfig } = useLayout(); +const toast = useToast(); let documentStyle = getComputedStyle(document.documentElement); let textColor = documentStyle.getPropertyValue('--text-color'); let textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary'); let surfaceBorder = documentStyle.getPropertyValue('--surface-border'); +const time_elapsed = ref([]); const lineData = ref(null); const lineOptions = ref(null); @@ -18,9 +22,22 @@ const setColorOptions = () => { textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary'); surfaceBorder = documentStyle.getPropertyValue('--surface-border'); }; -const setChart = () => { +async function setChart() { + try { + const response = await axios.get(`http://localhost:3001/frame?limit=5000&game_id=4`); + //console.log(response.data); + time_elapsed.value = response.data; + time_elapsed.value = time_elapsed.value.filter(x => x = 1); + console.log(time_elapsed.value); + } + catch (error) { + console.error(error); + } + + + ///////////////////////////////// lineData.value = { - labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], + labels: [0], datasets: [ { label: 'First Dataset', @@ -75,7 +92,7 @@ watch( layoutConfig.theme, () => { setColorOptions(); - setChart(); + //setChart(); }, { immediate: true } ); @@ -94,8 +111,8 @@ const checkAuth = () => {
- - +
@@ -105,6 +122,7 @@ const checkAuth = () => {
Linear Chart
+
diff --git a/frontend/src/views/Login.vue b/frontend/src/views/Login.vue index 8d21b75..fb784b4 100644 --- a/frontend/src/views/Login.vue +++ b/frontend/src/views/Login.vue @@ -1,5 +1,5 @@