some shit..

This commit is contained in:
Sockenklaus
2021-11-12 23:37:17 +01:00
parent 8204135b0f
commit de2052d136
6 changed files with 46 additions and 11 deletions

15
package-lock.json generated
View File

@@ -22,6 +22,7 @@
"uuid": "^8.3.2", "uuid": "^8.3.2",
"vue": "^3.2.21", "vue": "^3.2.21",
"vue-imask": "^6.2.2", "vue-imask": "^6.2.2",
"vue-request": "^1.2.3",
"vue-router": "^4.0.12", "vue-router": "^4.0.12",
"vue-tsc": "^0.3.0" "vue-tsc": "^0.3.0"
}, },
@@ -1822,6 +1823,14 @@
} }
} }
}, },
"node_modules/vue-request": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/vue-request/-/vue-request-1.2.3.tgz",
"integrity": "sha512-Yo1KxKpucNZyv/angPv7S8q00MMhFi7mFyITVIIaNMzz6Mu7QrPfP1fIQOoupEqFK+dgbXa8M7/v+7UBPMrCMQ==",
"peerDependencies": {
"vue": "^3.0.0"
}
},
"node_modules/vue-router": { "node_modules/vue-router": {
"version": "4.0.12", "version": "4.0.12",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.0.12.tgz", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.0.12.tgz",
@@ -3156,6 +3165,12 @@
} }
} }
}, },
"vue-request": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/vue-request/-/vue-request-1.2.3.tgz",
"integrity": "sha512-Yo1KxKpucNZyv/angPv7S8q00MMhFi7mFyITVIIaNMzz6Mu7QrPfP1fIQOoupEqFK+dgbXa8M7/v+7UBPMrCMQ==",
"requires": {}
},
"vue-router": { "vue-router": {
"version": "4.0.12", "version": "4.0.12",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.0.12.tgz", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.0.12.tgz",

View File

@@ -22,6 +22,7 @@
"uuid": "^8.3.2", "uuid": "^8.3.2",
"vue": "^3.2.21", "vue": "^3.2.21",
"vue-imask": "^6.2.2", "vue-imask": "^6.2.2",
"vue-request": "^1.2.3",
"vue-router": "^4.0.12", "vue-router": "^4.0.12",
"vue-tsc": "^0.3.0" "vue-tsc": "^0.3.0"
}, },

View File

@@ -2,4 +2,6 @@ import axios from 'axios'
export default axios.create({ export default axios.create({
baseURL: 'http://localhost:3333/api/v1/' baseURL: 'http://localhost:3333/api/v1/'
}) })
export const apiUrl = 'http://localhost:3333/api/v1/'

View File

@@ -1,5 +1,7 @@
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { useEmployees } from "../employees"; import { useEmployees } from "../employees";
import { useUser } from "../user";
import axios from '@/axios'
import _clone from "lodash/clone"; import _clone from "lodash/clone";
import _difference from "lodash/difference"; import _difference from "lodash/difference";
import _pull from "lodash/pull"; import _pull from "lodash/pull";
@@ -40,8 +42,21 @@ export const settingsEmployeesIndex = defineStore({
* Persist columnsSelected to API * Persist columnsSelected to API
*/ */
async persist() { async persist() {
console.log("persist") const user = useUser()
console.log(this.columnsSelected)
const result = await axios.post('settings',
{
settings: [
{
key: "employees-index-columns-selected",
value: JSON.stringify(this.columnsSelected)
}
]
},
{
headers: user.header
})
console.log(result)
} }
} }
}) })

View File

@@ -3,7 +3,10 @@ import { useNotifications } from './notifications'
import { getUnixTime } from 'date-fns' import { getUnixTime } from 'date-fns'
import { AxiosError } from 'axios' import { AxiosError } from 'axios'
import axios from '@/axios' import axios from '@/axios'
import { apiUrl } from '@/axios'
import Axios from 'axios' import Axios from 'axios'
import { useRequest } from 'vue-request'
import { json } from 'stream/consumers'
type AuthSuccResult = { type AuthSuccResult = {
user: string, user: string,
@@ -34,21 +37,18 @@ export const useUser = defineStore({
actions: { actions: {
async login(username: string, password: string): async login(username: string, password: string):
Promise< Promise<boolean |
boolean |
'E_INVALID_AUTH_PASSWORD: Password mis-match' | 'E_INVALID_AUTH_PASSWORD: Password mis-match' |
'E_INVALID_AUTH_UID: User not found' 'E_INVALID_AUTH_UID: User not found'>
> { {
const notifications = useNotifications() const notifications = useNotifications()
try { try {
const response = await axios.post<AuthSuccResult>('login', { const response = await axios.post<AuthSuccResult>('login', {
username: username, username: username,
password: password password: password
}) })
console.log(response)
this.isLoggedIn = true this.isLoggedIn = true
this.user = response.data.user this.user = response.data.user
@@ -76,7 +76,7 @@ export const useUser = defineStore({
notifications.add('danger', err as string, -1) notifications.add('danger', err as string, -1)
return false return false
} }
}, },

View File

@@ -92,6 +92,8 @@ async function onClick() {
if(!(await v$.value.$validate())) return if(!(await v$.value.$validate())) return
const result = await userStore.login(input.username, input.password) const result = await userStore.login(input.username, input.password)
console.log("back in login form: "+result)
switch(result) { switch(result) {
case true: case true: