mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
[review, add time modal]
This commit is contained in:
1 parent
90cd75349c
commit
17a044b118
19 files changed
+228
-158
No files matched your search
@@ -29,11 +29,11 @@
|
||||
<v-btn class="menu-dropdown" v-bind="props">
|
||||
<div class="d-flex justify-between align-center">
|
||||
<p class="employee-select-avatar d-flex justify-center align-center" @click.stop="$router.push({name: 'Dashboard - User'})">
|
||||
{{ user.user.name.charAt(0) + user.user.surname.charAt(0) }}
|
||||
{{ user.name.charAt(0) + user.surname.charAt(0) }}
|
||||
</p>
|
||||
|
||||
<div>
|
||||
<span class="employee-name ml-4">{{ `${user.user.name} ${user.user.surname}` }}</span>
|
||||
<span class="employee-name ml-4">{{ `${user.name} ${user.surname}` }}</span>
|
||||
<v-icon class="ml-3" icon="mdi-chevron-down" size="x-small"></v-icon>
|
||||
</div>
|
||||
</div>
|
||||
@@ -41,7 +41,7 @@
|
||||
</template>
|
||||
|
||||
<v-list class="text-center">
|
||||
<v-list-item class="cursor-pointer hover-background">Working hours </v-list-item>
|
||||
<v-list-item class="cursor-pointer hover-background" @click.stop="$router.push({name: 'Dashboard - User'})">Profil</v-list-item>
|
||||
<v-list-item>
|
||||
<v-btn class="button" @click="logOut()">Odhlásiť sa</v-btn>
|
||||
</v-list-item>
|
||||
@@ -58,6 +58,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
import ZTeamModal from '@/plugins/tm@modal/team/z-team-modal.vue'
|
||||
import ZBlockerModal from '@/plugins/tm@modal/blocker/z-blocker-modal.vue'
|
||||
import ZMasterTaskModal from '@/plugins/tm@modal/master-task/z-master-task-modal.vue'
|
||||
@@ -71,19 +72,13 @@ export default {
|
||||
ZSubTaskModal
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
user: null,
|
||||
search: ''
|
||||
}
|
||||
computed: {
|
||||
...mapGetters('auth', ['user']),
|
||||
},
|
||||
|
||||
async created() {
|
||||
// Kravarik: Toto negetuj takto ale cez ...mapGetters z auth store
|
||||
try {
|
||||
this.user = await this.$axios.get_auth_data('v1/auth/info')
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
data() {
|
||||
return {
|
||||
search: ''
|
||||
}
|
||||
},
|
||||
|
||||
@@ -94,8 +89,7 @@ export default {
|
||||
this.$router.push('/')
|
||||
this.$toast.success('Boli ste odhlásený')
|
||||
} catch (error) {
|
||||
// Kravarik: Do toastu posielaj len error, on si to vo vnutri vyparsuje (ak ne tak to treba dokodit v toaste)
|
||||
this.$toast.error(error.data.error)
|
||||
this.$toast.error(error)
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -40,8 +40,7 @@ export default {
|
||||
await this.$axios.post_data('v1/auth/forgot', this.form)
|
||||
this.$router.push({ name: 'Reset password' })
|
||||
} catch (error) {
|
||||
// Kravarik: Error upravit
|
||||
this.$toast.error(error.data.error)
|
||||
this.$toast.error(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,7 @@ export default {
|
||||
await this.$axios.post_data('v1/auth/login', this.form)
|
||||
this.$router.push({ name: 'Overview - Ongoing tasks'})
|
||||
} catch (error) {
|
||||
// Kravarik: Error upravit
|
||||
this.$toast.error(error.data.error)
|
||||
this.$toast.error(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ export default {
|
||||
await this.$axios.post_data('v1/auth/reset', this.form)
|
||||
this.$router.push({ name: 'Login' })
|
||||
} catch (error) {
|
||||
// Kravarik: Error upravit
|
||||
this.$toast.error(error.data.error)
|
||||
this.$toast.error(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
>
|
||||
<template v-slot:split-label="{ split }">
|
||||
<div class="w-100 h-100 d-flex flex-column">
|
||||
<h1 @click="addTimeModal()">Tu mas napojeny modal</h1>
|
||||
<span v-if="split.date" class="d-flex align-center">
|
||||
<img v-if="getHeadingDate(split.date) == 'Dnes'" :src="require('./_img/home-icon.svg')" class="mr-2">
|
||||
<p class="weekday-label">{{ getHeadingDate(split.date) }}</p>
|
||||
@@ -87,6 +88,7 @@
|
||||
<!-- Kravarik: Prerobit modaly na novy sposob -->
|
||||
<Z-complete-task-modal v-if="showCompleteModal" :visible="showCompleteModal ? true : false" :task="showCompleteModal.task" @completeTask="completeTask" @close="showCompleteModal = null" />
|
||||
<Z-delete-task-modal v-if="showDeleteModal" :visible="showDeleteModal ? true : false" :task="showDeleteModal.task" @deleteTask="deleteTask" @close="showDeleteModal = null" />
|
||||
<Z-add-time-task-modal ref="z-add-time-task-modal" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -94,12 +96,15 @@
|
||||
import ZCompleteTaskModal from '@/plugins/tm@modal/task/z-complete-task-modal.vue'
|
||||
import ZDeleteTaskModal from '@/plugins/tm@modal/task/z-delete-task-modal.vue'
|
||||
import ZSubTaskModal from '@/plugins/tm@modal/sub-task/z-sub-task-modal.vue'
|
||||
import ZAddTimeTaskModal from '@/plugins/tm@modal/sub-task/z-add-time-task-modal.vue'
|
||||
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ZCompleteTaskModal,
|
||||
ZDeleteTaskModal,
|
||||
ZSubTaskModal
|
||||
ZSubTaskModal,
|
||||
ZAddTimeTaskModal
|
||||
},
|
||||
|
||||
props: {
|
||||
@@ -216,6 +221,10 @@ export default {
|
||||
this.$refs['z-sub-task-modal'].create(subTask, editMode)
|
||||
},
|
||||
|
||||
addTimeModal() {
|
||||
this.$refs['z-add-time-task-modal'].showModal()
|
||||
},
|
||||
|
||||
deleteTask(id) {
|
||||
this.$emit('deleteTask', id)
|
||||
}
|
||||
|
||||
@@ -15,16 +15,16 @@ export default {
|
||||
ZMasterTaskModal
|
||||
},
|
||||
|
||||
// Kravarik: Prepisat propy na objektovy zapis
|
||||
props: ['events', 'month'],
|
||||
props: {
|
||||
events: {
|
||||
required: true
|
||||
},
|
||||
|
||||
methods: {
|
||||
editTask(masterTask, editMode) {
|
||||
this.$refs['z-master-task-modal'].create(masterTask, editMode)
|
||||
month: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
// Kravarik: Comuted ma byt za data hned
|
||||
computed: {
|
||||
calendarOptions() {
|
||||
return {
|
||||
@@ -36,31 +36,34 @@ export default {
|
||||
firstDay: 1,
|
||||
dayHeaderClassNames: ['w-day-header'],
|
||||
events: this.events,
|
||||
// Kravarik: Skus toto prepisat na arrow function ako je v eventClick
|
||||
eventContent: function (eventInfo) {
|
||||
eventContent: (eventInfo) => {
|
||||
return { html: eventInfo.event.extendedProps.title_html }
|
||||
},
|
||||
eventClick: (info) => {
|
||||
this.editTask(info.event._def.publicId, false)
|
||||
return this.editTask(info.event._def.publicId, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Kravarik: Toto nechat na konci
|
||||
mounted() {
|
||||
const currentYear = new Date().getFullYear()
|
||||
this.calendarOptions.events = this.events
|
||||
this.$refs.fullCalendar?.getApi().gotoDate(new Date(currentYear, this.month, 1))
|
||||
},
|
||||
|
||||
methods: {
|
||||
editTask(masterTask, editMode) {
|
||||
this.$refs['z-master-task-modal'].create(masterTask, editMode)
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
month(selectedMonth) {
|
||||
const currentYear = new Date().getFullYear()
|
||||
this.$refs.fullCalendar?.getApi().gotoDate(new Date(currentYear, selectedMonth, 1))
|
||||
}
|
||||
},
|
||||
|
||||
// Kravarik: Posunut nad methods
|
||||
mounted() {
|
||||
const currentYear = new Date().getFullYear()
|
||||
this.calendarOptions.events = this.events
|
||||
this.$refs.fullCalendar?.getApi().gotoDate(new Date(currentYear, this.month, 1))
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="sass" scoped>
|
||||
@@ -93,12 +96,17 @@ export default {
|
||||
&:deep(.fc-day-today)
|
||||
background: white
|
||||
a
|
||||
background: #3700B3
|
||||
width: 32px
|
||||
height: 32px
|
||||
color: white
|
||||
text-align: center
|
||||
border-radius: 50%
|
||||
border: 5px solid white
|
||||
line-height: 15px
|
||||
background: #3700B3
|
||||
width: 28px
|
||||
color: white
|
||||
text-align: center
|
||||
border-radius: 50%
|
||||
height: 28px
|
||||
line-height: 27px
|
||||
position: relative
|
||||
padding: 0
|
||||
margin: 0
|
||||
border: none
|
||||
top: 2px
|
||||
right: 4px
|
||||
</style>
|
||||
@@ -17,6 +17,10 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
emits: ['filterChanged'],
|
||||
|
||||
props: ['projects', 'teams', 'employees'],
|
||||
|
||||
data() {
|
||||
return {
|
||||
months: [
|
||||
@@ -43,12 +47,6 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// Kravarik: Props hodit nad data
|
||||
props: ['projects', 'teams', 'employees'],
|
||||
|
||||
// Kravarik: Emits ma byt uplne prve
|
||||
emits: ['filterChanged'],
|
||||
|
||||
watch: {
|
||||
filter: {
|
||||
handler() {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- Kravarik: Dat velke A -->
|
||||
<a-project-filter :projects="projects" @filterChanged="onFilterChanged"></a-project-filter>
|
||||
<a-project-calendar :events="filteredEvents" :month="filter.selectedMonth"></a-project-calendar>
|
||||
<A-project-filter :projects="projects" @filterChanged="onFilterChanged" />
|
||||
<A-project-calendar :events="filteredEvents" :month="filterSettings.selectedMonth" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -17,8 +16,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// Kravarik: Toto premenuj na nejaky filterSettings alebo co to je
|
||||
filter: {
|
||||
filterSettings: {
|
||||
selectedEmployee: null,
|
||||
selectedMonth: new Date().getMonth(),
|
||||
selectedProject: null,
|
||||
@@ -33,22 +31,23 @@ export default {
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
// Kravarik: Toto preco nieje v trycatch?
|
||||
const events = await this.$axios.get_auth_data('v1/overview/projects')
|
||||
|
||||
// Kravarik: Nemusis nahodou z map returnovat? Ci ked {} obalis to () tak nemusis potom?
|
||||
this.events = events.map((item) => ({
|
||||
id: item.id,
|
||||
title: `${item.project_code} - ${item.name}`,
|
||||
title_html: `${item.project_code} - <b>${item.name}</b>`,
|
||||
start: item.starts_at,
|
||||
end: item.deadline,
|
||||
is_finished: item.is_finished,
|
||||
project_code: item.project_code,
|
||||
backgroundColor: item.color,
|
||||
borderColor: item.color
|
||||
}))
|
||||
try {
|
||||
const events = await this.$axios.get_auth_data('v1/overview/projects')
|
||||
this.events = events.map((item) => ({
|
||||
id: item.id,
|
||||
title: `${item.project_code} - ${item.name}`,
|
||||
title_html: `${item.project_code} - <b>${item.name}</b>`,
|
||||
start: item.starts_at,
|
||||
end: item.deadline,
|
||||
is_finished: item.is_finished,
|
||||
project_code: item.project_code,
|
||||
backgroundColor: item.color,
|
||||
borderColor: item.color
|
||||
}))
|
||||
this.filteredEvents = this.events.filter((item) => !item.is_finished)
|
||||
} catch (error) {
|
||||
this.$toast.error(error)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// Kravarik: TODO prepojit filtrovanie na BE
|
||||
|
||||
@@ -353,8 +353,7 @@ export default {
|
||||
// this.masterTask = await this.$axios.get_auth_data(`v1/master-task/${this.masterTaksId}`)
|
||||
// this.selectedTeam = `${this.masterTask.team.name} - ${this.masterTask.team.id}`)
|
||||
} catch (error) {
|
||||
// Kravarik: Pridaj toast
|
||||
console.log(error)
|
||||
this.$toast(error)
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<template>
|
||||
<v-dialog v-model="show" max-width="650">
|
||||
<v-card>
|
||||
<div class="d-flex justify-space-between align-center">
|
||||
<h1>Prosím zadajte odpracovaný čas</h1>
|
||||
|
||||
<v-icon
|
||||
@click.stop="close()"
|
||||
icon="mdi-close"
|
||||
size="large"
|
||||
></v-icon>
|
||||
</div>
|
||||
<v-card-actions class="mt-10 d-flex justify-start align-center">
|
||||
<v-text-field
|
||||
class="modal-input"
|
||||
label="Odpracovaný čas"
|
||||
variant="solo"
|
||||
type="number"
|
||||
placeholder="h"
|
||||
append-inner-icon="mdi-timer-outline"
|
||||
></v-text-field>
|
||||
</v-card-actions>
|
||||
<v-btn class="z-btn mt-5">Potvrdiť</v-btn>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
emits: ['close'],
|
||||
|
||||
data() {
|
||||
return {
|
||||
visible: false
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
showModal() {
|
||||
this.visible = true
|
||||
},
|
||||
|
||||
close() {
|
||||
this.visible = false
|
||||
this.$emit('close', this.blocker)
|
||||
this.blocker = null
|
||||
},
|
||||
},
|
||||
|
||||
computed: {
|
||||
show: {
|
||||
get() {
|
||||
return this.visible
|
||||
},
|
||||
|
||||
set(value) {
|
||||
if (!value) this.$emit('close')
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="sass" scoped>
|
||||
.z-btn
|
||||
height: 48px !important
|
||||
|
||||
h1
|
||||
font-size: 34px
|
||||
</style>
|
||||
@@ -241,7 +241,7 @@
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<v-text-field
|
||||
v-model="task.nieco"
|
||||
v-model="task.spent_time"
|
||||
class="modal-input"
|
||||
variant="solo"
|
||||
type="number"
|
||||
@@ -264,7 +264,7 @@
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p>{{ task.remaining_time }} h</p>
|
||||
<p>{{ remaining_time }} h</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -345,8 +345,7 @@ export default {
|
||||
this.masterTasks = await this.$axios.get_auth_data('v1/master-tasks')
|
||||
this.employees = await this.$axios.get_auth_data('v1/employees')
|
||||
} catch (error) {
|
||||
// Kravarik: Pridaj toast
|
||||
console.log(error)
|
||||
this.$toast(error)
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -120,6 +120,20 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
async create(team = null) {
|
||||
if (team) {
|
||||
this.team = team
|
||||
await this._load()
|
||||
} else {
|
||||
this.team = {
|
||||
name: '',
|
||||
employees: []
|
||||
}
|
||||
}
|
||||
|
||||
this.visible = true
|
||||
},
|
||||
|
||||
close() {
|
||||
this.visible = false
|
||||
this.$emit('close', this.team)
|
||||
|
||||
@@ -33,8 +33,7 @@ export default {
|
||||
try {
|
||||
this.employees = await this.$axios.get_auth_data('v1/employees')
|
||||
} catch (error) {
|
||||
// Kravarik: Pridaj toast
|
||||
console.log(error)
|
||||
this.$toast(error)
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
<Z-tasks-search @queryChange="filterOngoingTasks" />
|
||||
<Z-tasks-search @queryChange="onSearch" />
|
||||
|
||||
<W-loadable :content="ongoingTasks">
|
||||
<W-loadable :content="filteredOngoingTasks" :emptyMessage="searchQuery.length ? 'Neboli nájdené žiadne úlohy' : 'Nenašli sa žiadne záznamy'">
|
||||
<A-ongoing-table :tasks="filteredOngoingTasks" />
|
||||
<h6
|
||||
v-if="filteredOngoingTasks && !filteredOngoingTasks.length"
|
||||
class="px-4"
|
||||
>
|
||||
Aktuálnemu hľadaniu nevyhovujú žiadne prebiehajúce úlohy
|
||||
</h6>
|
||||
</W-loadable>
|
||||
|
||||
</div>
|
||||
@@ -28,30 +22,36 @@ export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
ongoingTasks: null,
|
||||
filteredOngoingTasks: []
|
||||
searchQuery: '',
|
||||
ongoingTasks: null
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
filteredOngoingTasks() {
|
||||
if (!this.ongoingTasks)
|
||||
return null
|
||||
|
||||
if (!this.searchQuery)
|
||||
return this.ongoingTasks
|
||||
|
||||
return this.ongoingTasks.filter((task) => {
|
||||
return this.filterParams(this.searchQuery, task.title) || this.filterParams(this.searchQuery, task.project_code)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async created() {
|
||||
try {
|
||||
this.ongoingTasks = await this.$axios.get_auth_data('v1/overview/ongoing-tasks')
|
||||
this.filterOngoingTasks()
|
||||
} catch (error) {
|
||||
// Kravarik: ked to je takto ze idu data do w-loadable tak musis dat this.ongoingTasks = {error}
|
||||
// Ten toast vyhod a to kde nastavujes error musis dat do {} ako v riadku hore lebo ono to pozera if (content.error)
|
||||
this.ongoingTasks = error
|
||||
this.$toast.error(error)
|
||||
this.ongoingTasks = {error}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
// Kravarik: Toto sprav cez computed. A bude tam ze if (!searchQuerry) return this.ongoing tasks. Else to prefiltrujes
|
||||
filterOngoingTasks(searchQuery) {
|
||||
if(!searchQuery) return this.filteredOngoingTasks = this.ongoingTasks
|
||||
this.filteredOngoingTasks = this.ongoingTasks.filter((task) => {
|
||||
return this.filterParams(searchQuery, task.title) || this.filterParams(searchQuery, task.project_code)
|
||||
})
|
||||
onSearch(searchQuery) {
|
||||
this.searchQuery = searchQuery
|
||||
},
|
||||
|
||||
filterParams(searchQuery, row) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
<Z-tasks-search @queryChange="filterUnscheduledTasks" />
|
||||
<Z-tasks-search @queryChange="onSearch" />
|
||||
|
||||
<W-loadable :content="unscheduledTasks">
|
||||
<W-loadable :content="filteredUnscheduledTasks" :emptyMessage="searchQuery.length ? 'Neboli nájdené žiadne úlohy' : 'Nenašli sa žiadne záznamy'">
|
||||
<A-unscheduled-table :tasks="filteredUnscheduledTasks" />
|
||||
<h6
|
||||
v-if="filteredUnscheduledTasks && !filteredUnscheduledTasks.length"
|
||||
@@ -28,31 +28,37 @@ export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
unscheduledTasks: null,
|
||||
filteredUnscheduledTasks: []
|
||||
searchQuery: '',
|
||||
unscheduledTasks: null
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
filteredUnscheduledTasks() {
|
||||
if (!this.unscheduledTasks)
|
||||
return null
|
||||
|
||||
if (!this.searchQuery)
|
||||
return this.unscheduledTasks
|
||||
|
||||
return this.unscheduledTasks.filter((task) => {
|
||||
return this.filterParams(this.searchQuery, task.title) || this.filterParams(this.searchQuery, task.project_code)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async created() {
|
||||
try {
|
||||
this.unscheduledTasks = await this.$axios.get_auth_data('v1/overview/unscheduled-tasks')
|
||||
this.filterUnscheduledTasks()
|
||||
} catch (error) {
|
||||
// Kravarik: ked to je takto ze idu data do w-loadable tak musis dat this.ongoingTasks = {error}
|
||||
// Ten toast vyhod a to kde nastavujes error musis dat do {} ako v riadku hore lebo ono to pozera if (content.error)
|
||||
this.unscheduledTasks = error
|
||||
this.$toast.error(error)
|
||||
this.unscheduledTasks = {error}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
// Kravarik: Toto sprav cez computed. A bude tam ze if (!searchQuerry) return this.unscheduled tasks. Else to prefiltrujes
|
||||
filterUnscheduledTasks(searchQuery) {
|
||||
if(!searchQuery) return this.filteredUnscheduledTasks = this.unscheduledTasks
|
||||
this.filteredUnscheduledTasks = this.unscheduledTasks.filter((task) => {
|
||||
return this.filterParams(searchQuery, task.title) || this.filterParams(searchQuery, task.project_code)
|
||||
})
|
||||
},
|
||||
onSearch(searchQuery) {
|
||||
this.searchQuery = searchQuery
|
||||
},
|
||||
|
||||
filterParams(searchQuery, row) {
|
||||
return row.toLowerCase().includes(searchQuery.toLowerCase())
|
||||
|
||||
@@ -22,10 +22,7 @@ export default {
|
||||
try {
|
||||
this.teams = await this.$axios.get_auth_data('v1/teams')
|
||||
} catch (error) {
|
||||
// Kravarik: ked to je takto ze idu data do w-loadable tak musis dat this.ongoingTasks = {error}
|
||||
// Ten toast vyhod a to kde nastavujes error musis dat do {} ako v riadku hore lebo ono to pozera if (content.error)
|
||||
this.teams = {error: error.data.error}
|
||||
this.$toast.error(error.data.error)
|
||||
this.teams = {error}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,15 +84,6 @@ export default {
|
||||
...mapGetters('auth', ['user']),
|
||||
},
|
||||
|
||||
created() {
|
||||
// TEMP
|
||||
// Kravarik: Vyhodit
|
||||
this.$store.dispatch('auth/login', {
|
||||
email: 'xx@asdasd.asd',
|
||||
password: 'sdfsdfsdf'
|
||||
})
|
||||
},
|
||||
|
||||
validations() {
|
||||
return {
|
||||
user: {
|
||||
@@ -112,8 +103,7 @@ export default {
|
||||
|
||||
this.$toast.success('Profil bol úspešne zmenený')
|
||||
} catch (error) {
|
||||
// Kravarik: Posli iba errror
|
||||
this.$toast.error(error.response.data.error)
|
||||
this.$toast.error(error)
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -4,18 +4,13 @@ import './refreshExpired'
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
status: '',
|
||||
_token: localStorage.getItem('wzo_vue_user_token') || '',
|
||||
token: localStorage.getItem('wzo_vue_user_token') || '',
|
||||
user: JSON.parse(localStorage.getItem('wzo_vue_user_user') || '{}'),
|
||||
},
|
||||
mutations: {
|
||||
auth_request(state: any) {
|
||||
state.status = 'loading'
|
||||
},
|
||||
auth_success(state: any, data: any) {
|
||||
state.status = 'success'
|
||||
if (data.token) {
|
||||
state._token = data.token
|
||||
state.token = data.token
|
||||
localStorage.setItem('wzo_vue_user_token', data.token)
|
||||
}
|
||||
|
||||
@@ -25,24 +20,21 @@ export default {
|
||||
}
|
||||
},
|
||||
auth_error(state: any) {
|
||||
state.status = 'error'
|
||||
state._token = ''
|
||||
state.token = ''
|
||||
localStorage.removeItem('wzo_vue_user_token')
|
||||
localStorage.removeItem('wzo_vue_user_user')
|
||||
},
|
||||
logout(state: any) {
|
||||
state.status = ''
|
||||
state._token = ''
|
||||
state.token = ''
|
||||
state.user = null
|
||||
localStorage.removeItem('wzo_vue_user_token')
|
||||
localStorage.removeItem('wzo_vue_user_user')
|
||||
window.open(location.origin, "_self")
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
login({commit}: {commit: any}, credentials: any) {
|
||||
return new Promise((resolve, reject) => {
|
||||
commit('auth_request')
|
||||
|
||||
axios.post_data('v1/auth/login', credentials)
|
||||
.then((response: any) => {
|
||||
const token = response.token
|
||||
@@ -81,6 +73,7 @@ export default {
|
||||
})
|
||||
})
|
||||
},
|
||||
// eslint-disable-next-line
|
||||
logout({commit}: {commit: any}) {
|
||||
return new Promise((resolve) => {
|
||||
axios.post_auth_data('v1/auth/invalidate')
|
||||
@@ -90,14 +83,16 @@ export default {
|
||||
})
|
||||
})
|
||||
},
|
||||
forgotPassword(credentials: any) {
|
||||
// eslint-disable-next-line
|
||||
forgotPassword({commit}: {commit: any}, credentials: any) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.post_auth_data('v1/auth/forgot', credentials)
|
||||
.then(response => resolve(response))
|
||||
.catch(error => reject(error))
|
||||
})
|
||||
},
|
||||
resetPassword(credentials: any) {
|
||||
// eslint-disable-next-line
|
||||
resetPassword({commit}: {commit: any}, credentials: any) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.post_auth_data('v1/auth/reset', credentials)
|
||||
.then(response => resolve(response))
|
||||
@@ -157,17 +152,13 @@ export default {
|
||||
},
|
||||
getters: {
|
||||
isLoggedIn: (state: any) => {
|
||||
return !!state._token
|
||||
return !!state.token
|
||||
},
|
||||
// authStatus: (state: any) => {
|
||||
// return state.status
|
||||
// },
|
||||
user: (state: any) => {
|
||||
return state.user
|
||||
},
|
||||
token: (state: any) => {
|
||||
return state.token
|
||||
}
|
||||
// token: (state: any) => {
|
||||
// return state._token
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user