diff --git a/index.html b/index.html
index 6dcb980..86d2695 100644
--- a/index.html
+++ b/index.html
@@ -6,7 +6,7 @@
Vite App
-
+
diff --git a/src/App.vue b/src/App.vue
index c9f0c5b..a4db9d0 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -3,8 +3,12 @@
-
-
+
+
+
+
+
+
@@ -18,11 +22,28 @@ import VNavigation from './components/VNavigation.vue';
-
diff --git a/src/components/Employees/SimpleSearch.vue b/src/components/Employees/SimpleSearch.vue
index b2abfbf..a912c41 100644
--- a/src/components/Employees/SimpleSearch.vue
+++ b/src/components/Employees/SimpleSearch.vue
@@ -29,6 +29,7 @@
import { ref, computed} from 'vue';
import type { PropType, Ref } from 'vue';
import { union } from 'lodash';
+import _debounce from 'lodash/debounce'
const props = defineProps({
columns: {
@@ -50,9 +51,9 @@ const unionColumns = computed(() => {
return union(props.columns, columnsChecked.value)
})
-async function search() {
+const search = _debounce(() => {
emit('search', queryString.value)
-}
+}, 150)
diff --git a/src/components/VNavigation.vue b/src/components/VNavigation.vue
index 4d4b4c7..e456bb8 100644
--- a/src/components/VNavigation.vue
+++ b/src/components/VNavigation.vue
@@ -1,19 +1,3 @@
-
-
+
+
\ No newline at end of file
diff --git a/src/components/VProfileControls.vue b/src/components/VProfileControls.vue
index eddfd5b..7bc6a51 100644
--- a/src/components/VProfileControls.vue
+++ b/src/components/VProfileControls.vue
@@ -29,25 +29,50 @@ function onCancel() {
Zurück
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
diff --git a/src/stores/notifications.ts b/src/stores/notifications.ts
index 9fc0bf0..0a72045 100644
--- a/src/stores/notifications.ts
+++ b/src/stores/notifications.ts
@@ -23,7 +23,7 @@ export const useNotifications = defineStore('notifications', {
text:text,
}
)
- if (timeout !== -1) setTimeout(() => this.remove(id), timeout)
+ if (timeout > -1) setTimeout(() => this.remove(id), timeout)
}
}
})
diff --git a/src/stores/user.ts b/src/stores/user.ts
index cbbb780..cb588ee 100644
--- a/src/stores/user.ts
+++ b/src/stores/user.ts
@@ -1,20 +1,18 @@
-import { defineStore, storeToRefs } from 'pinia'
+import { defineStore } from 'pinia'
import { useNotifications } from './notifications'
-import { getUnixTime } from 'date-fns'
-import { AxiosError } from 'axios'
-import axios from '@/axios'
-import { apiUrl } from '@/axios'
-import Axios from 'axios'
+import { ref, reactive } from 'vue'
import { useRequest } from 'vue-request'
-import { json } from 'stream/consumers'
+import axios from '@/axios'
+import Axios from 'axios'
+import { useRouter } from 'vue-router'
+import type { Router } from 'vue-router'
type AuthSuccResult = {
- user: string,
- role: string,
+ user: string,
+ role: string,
token: string
}
-
export const useUser = defineStore({
id: 'storeUser',
@@ -23,8 +21,9 @@ export const useUser = defineStore({
user: '',
role: '',
isLoggedIn: false,
- rememberMe: false,
- token: ''
+ token: '',
+ errorMessage: '',
+ loading: ref(false)
}
},
@@ -36,18 +35,27 @@ export const useUser = defineStore({
},
actions: {
- async login(username: string, password: string):
- Promise
- {
-
+ async login(username: string, password: string, router: Router) {
+ this.loading = true
const notifications = useNotifications()
-
+
+ function sleep(ms: number): Promise {
+ return new Promise(resolve => setTimeout(resolve, ms));
+ }
+
+ /* async function axiosQuery(username: string, password: string){
+ return await axios.post('login',{
+ username,
+ password
+ })
+ }
+
+ const { loading } = useRequest(axiosQuery(username, password))
+ this.loading */
try {
const response = await axios.post('login', {
- username: username,
- password: password
+ username,
+ password
})
this.isLoggedIn = true
@@ -57,53 +65,43 @@ export const useUser = defineStore({
notifications.add('success', 'Login successful.')
- return true
- } catch(err : unknown) {
+ await router.push({name: 'Home'})
+ this.loading = false
+ } catch(err : unknown) {
+ this.loading = false
if (Axios.isAxiosError(err) && err.response && err.response.data){
- const data = err.response.data
-
- if(
- data === 'E_INVALID_AUTH_PASSWORD: Password mis-match' ||
- data === 'E_INVALID_AUTH_UID: User not found'
- ) return data
+ this.errorMessage = err.response.data as string
}
else if(err instanceof Error){
notifications.add('danger', err.message, -1)
- return false
}
-
- notifications.add('danger', err as string, -1)
- return false
- }
+ }
},
- async logout(): Promise {
+ async logout(router: Router) {
const notifications = useNotifications()
try {
- await axios.post('logout', '', {
+ const result = await axios.post('logout', '', {
headers: {
'Authorization': 'Bearer '+useUser().token
}
})
-
+ await router.push({name: 'Login'})
notifications.add('success','Logged out successfully')
this.$reset()
-
- return true
}
catch(error) {
if(error instanceof Error) {
notifications.add('danger', error.message, -1)
}
- return false
}
}
},
diff --git a/src/views/Employees/Details.vue b/src/views/Employees/Details.vue
index e94f635..4c891a6 100644
--- a/src/views/Employees/Details.vue
+++ b/src/views/Employees/Details.vue
@@ -231,7 +231,7 @@ function onToggleEdit() {
}
watch(() => [route.params, route.name], ([newParam, newName], [oldParam, oldName]) => {
- if(newName === oldName && newParam !== oldParam) {
+ if(newName === oldName && newParam?.toString() !== oldParam?.toString()) {
state.fetchFromApi(route.params.id)
createUser.value = false
}
diff --git a/src/views/Employees/Index.vue b/src/views/Employees/Index.vue
index 8b3a336..f01efc7 100644
--- a/src/views/Employees/Index.vue
+++ b/src/views/Employees/Index.vue
@@ -1,5 +1,5 @@
-
+
-
-
+
|
|
-
-
+
+
|
- {{ employee[col] }}
+ {{ employee[col] }}
|
-
-
+
Keine Daten anzuzeigen...
@@ -56,7 +54,7 @@
:last-page="store.meta.last_page"
@set-page="paginatorSetPage"
/>
-
+
-