diff --git a/frontend/src/layout/AppMenu.vue b/frontend/src/layout/AppMenu.vue index 61b2eb3..309383c 100644 --- a/frontend/src/layout/AppMenu.vue +++ b/frontend/src/layout/AppMenu.vue @@ -9,7 +9,8 @@ const model = ref([ items: [ { label: 'Dashboard', icon: 'pi pi-fw pi-home', to: '/home' }, { label: 'Chart', icon: 'pi pi-fw pi-chart-bar', to: '/charts' }, - { label: 'Crud', icon: 'pi pi-fw pi-pencil', to: '/crud' }] + { label: 'OS', icon: 'pi pi-fw pi-pencil', to: '/os' }, + { label: 'User', icon: 'pi pi-fw pi-pencil', to: '/user' }] } ]); diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index c5c40f9..27e53ab 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -4,7 +4,8 @@ import HomeView from '../views/HomeView.vue'; import Landing from '../views/Landing.vue'; import Login from '../views/Login.vue'; import Chart from '@/views/Chart.vue'; -import Crud from '@/views/Crud.vue'; +import OsCrud from '@/views/OsCrud.vue'; +import UserCrud from '@/views/UserCrud.vue'; const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), @@ -32,9 +33,14 @@ const router = createRouter({ component: Chart }, { - path: '/crud', - name: 'crud', - component: Crud + path: '/os', + name: 'OS', + component: OsCrud + }, + { + path: '/user', + name: 'User', + component: UserCrud } /* , diff --git a/frontend/src/views/Crud.vue b/frontend/src/views/OsCrud.vue similarity index 83% rename from frontend/src/views/Crud.vue rename to frontend/src/views/OsCrud.vue index 2e535bb..0165f27 100644 --- a/frontend/src/views/Crud.vue +++ b/frontend/src/views/OsCrud.vue @@ -8,6 +8,7 @@ import auth from '../utils/Auth'; const toast = useToast(); const products = ref(null); const productDialog = ref(false); +const productDialogChange = ref(false); const deleteProductDialog = ref(false); const deleteProductsDialog = ref(false); const os = ref({}); @@ -70,11 +71,36 @@ const hideDialog = () => { submitted.value = false; }; +const hideDialogChange = () => { + productDialogChange.value = false; + submitted.value = false; +}; + const editProduct = (editProduct) => { os.value = { ...editProduct }; - console.log(os); - productDialog.value = true; + console.log(os.value.ID); + productDialogChange.value = true; }; +async function onChangeOS() { + var changeOS = + { + name: os.value.name + }; + try { + const response = await axios.patch(`http://localhost:3001/os/` + os.value.ID, changeOS, auth.getTokenHeader()); + + if (response.status === 204) { + toast.add({ severity: 'success', summary: 'Successful', detail: 'OS Modified', life: 3000 }); + productDialogChange.value = false; + } + else { + console.error(response); + } + } + catch (error) { + console.error(error); + } +} const confirmDeleteProduct = (editProduct) => { os.value = editProduct; @@ -101,7 +127,7 @@ async function deleteProduct() { const confirmDeleteSelected = () => { deleteProductsDialog.value = true; }; -async function deleteSelectedProducts() { +const deleteSelectedProducts = () => { selectedProducts.value.forEach(element => { try { const response = axios.delete(`http://localhost:3001/os/` + element.ID, auth.getTokenHeader()); @@ -181,8 +207,8 @@ const initFilters = () => { - +
{
+ +
+ + + Name is required. +
+ +
diff --git a/frontend/src/views/UserCrud.vue b/frontend/src/views/UserCrud.vue new file mode 100644 index 0000000..9e94276 --- /dev/null +++ b/frontend/src/views/UserCrud.vue @@ -0,0 +1,312 @@ + + + + +