[Merge] API

This commit is contained in:
Matej Glasnák committed 2023-01-31 15:56:25 +01:00
commit 9d1fd6c16b
11 files changed
+34 -33

No files matched your search

+4 -4
View File
@@ -5,11 +5,11 @@
</v-main> </v-main>
</v-app> </v-app>
<Z-team-modal ref="z-team-modal" /> <Z-team-modal ref="z-team-modal" @update="onTeamUpdate" />
<Z-delete-team-modal ref="z-delete-team-modal" @deleted="onTeamDeleted" /> <Z-delete-team-modal ref="z-delete-team-modal" @update="onTeamUpdate" />
<Z-task-modal ref="z-task-modal" /> <Z-task-modal ref="z-task-modal" />
<Z-delete-task-modal ref="z-delete-task-modal" @deleted="onTaskDeleted" /> <Z-delete-task-modal ref="z-delete-task-modal" @update="onTaskDeleted" />
<Z-complete-task-modal ref="z-complete-task-modal" /> <Z-complete-task-modal ref="z-complete-task-modal" />
<Z-task-add-time-modal ref="z-task-add-time-modal" /> <Z-task-add-time-modal ref="z-task-add-time-modal" />
<Z-blocker-modal ref="z-blocker-modal" /> <Z-blocker-modal ref="z-blocker-modal" />
@@ -76,7 +76,7 @@ export default {
}, },
methods: { methods: {
onTeamDeleted(team) { onTeamUpdate(team) {
this.$events.emit('on-team-deleted', team) this.$events.emit('on-team-deleted', team)
}, },
+5 -5
View File
@@ -47,8 +47,8 @@ const options: Options = {
'POST v1/auth/login': true, 'POST v1/auth/login': true,
'POST v1/auth/post': true, 'POST v1/auth/post': true,
'GET v1/master-tasks/(id)': true, // 'GET v1/master-tasks/(id)': true,
'GET v1/master-tasks': true, // 'GET v1/master-tasks': true,
'POST v1/master-tasks/(id)': true, 'POST v1/master-tasks/(id)': true,
'DELETE v1/master-tasks/(id)': true, 'DELETE v1/master-tasks/(id)': true,
'POST v1/master-tasks': true, 'POST v1/master-tasks': true,
@@ -64,11 +64,11 @@ const options: Options = {
'DELETE v1/tasks/(id)': true, 'DELETE v1/tasks/(id)': true,
// 'GET v1/teams/(id)': true, // 'GET v1/teams/(id)': true,
'POST v1/teams/(id)': true, // 'POST v1/teams/(id)': true,
'DELETE v1/teams/(id)': true, // 'DELETE v1/teams/(id)': true,
// 'GET v1/teams': true, // 'GET v1/teams': true,
// 'GET v1/teamsx': true, // 'GET v1/teamsx': true,
'POST v1/teams': true, // 'POST v1/teams': true,
// 'GET v1/employees': true, // 'GET v1/employees': true,
'GET v1/search': true, 'GET v1/search': true,
@@ -53,7 +53,7 @@ export default {
// format masterTasks to event format for calendar // format masterTasks to event format for calendar
events = events.map(event => { events = events.map(event => {
const color = this._stringToHexColor(`${event.project_code}${event.name}`) const color = this._stringToHexColor(event.color)
return { return {
id: event.id, id: event.id,
@@ -81,7 +81,7 @@ export default {
try { try {
this.teams = await this.$axios.get_auth_data('v1/teams') this.teams = await this.$axios.get_auth_data('v1/teams')
this.employees = await this.$axios.get_auth_data('v1/employees') this.employees = await this.$axios.get_auth_data('v1/employees')
this.masterTasks = await this.$axios.get_auth_data('v1/master-tasks') this.masterTasks = await this.$axios.get_auth_data('v1/mastertasks')
} catch (error) { } catch (error) {
this.masterTasks = {error} this.masterTasks = {error}
} }
@@ -98,18 +98,18 @@ export default {
}, },
_stringToHexColor(string) { _stringToHexColor(string) {
let hash = 0; let hash = 0
for (let i = 0; i < string.length; i++) { for (let i = 0; i < string.length; i++) {
hash = string.charCodeAt(i) + ((hash << 5) - hash); hash = string.charCodeAt(i) + ((hash << 5) - hash)
} }
let color = '#'; let color = '#'
for (let i = 0; i < 3; i++) { for (let i = 0; i < 3; i++) {
let value = (hash >> (i * 8)) & 0xFF; let value = (hash >> (i * 8)) & 0xFF
color += ('00' + value.toString(16)).substr(-2); color += ('00' + value.toString(16)).substr(-2)
} }
return color; return color
} }
} }
} }
@@ -3,7 +3,7 @@
<v-select <v-select
v-model="selectedEmployee" v-model="selectedEmployee"
class="subheader-input" class="subheader-input"
:items="employees" :items="[null, ...employees]"
item-title="fullName" item-title="fullName"
item-value="id" item-value="id"
label="Zamestnanec" label="Zamestnanec"
@@ -393,10 +393,10 @@ export default {
try { try {
if (this.masterTask.id) if (this.masterTask.id)
await this.$axios.post_auth(`v1/master-tasks/${this.masterTask.id}`, this.masterTask) await this.$axios.patch_auth(`v1/master-tasks/${this.masterTask.id}`, this.masterTask)
else else
await this.$axios.post_auth('v1/mastertasks') await this.$axios.post_auth('v1/mastertasks', this.masterTask)
this.closeModal() this.closeModal()
// this.$router.push({ name: 'Dashboard - Tasks' }) // this.$router.push({ name: 'Dashboard - Tasks' })
@@ -37,9 +37,10 @@ export default {
async complete() { async complete() {
try { try {
await this.$axios.post(`v1/tasks/${this.task.id}`, {...this.task, is_finished: true}) const task = {...this.task, is_finished: true}
await this.$axios.patch_auth(`v1/tasks/${this.task.id}`, task)
this.visible = false this.visible = false
this.$emit('task-completed', this.task) this.$emit('task-completed', task)
} catch (error) { } catch (error) {
this.$toast.error(error) this.$toast.error(error)
} }
@@ -418,9 +418,9 @@ export default {
try { try {
if (this.task.id) { if (this.task.id) {
await this.$axios.post_auth(`v1/master-tasks/${this.task.id}`) await this.$axios.patch_auth(`v1/master-tasks/${this.task.id}`, this.task)
} else { } else {
await this.$axios.post_auth('v1/mastertasks') await this.$axios.post_auth('v1/mastertasks', this.task)
} }
this.closeModal() this.closeModal()
@@ -18,7 +18,7 @@
<script> <script>
export default { export default {
emits: ['deleted'], emits: ['update'],
data() { data() {
return { return {
@@ -39,9 +39,9 @@ export default {
async deleteTeam() { async deleteTeam() {
try { try {
await this.$axios.delete(`v1/teams/${this.team.id}`) await this.$axios.delete_auth(`v1/teams/${this.team.id}`)
this.visible = false this.visible = false
this.$emit('deleted', this.team) this.$emit('update', this.team)
} catch (error) { } catch (error) {
this.$toast.error(error) this.$toast.error(error)
} }
@@ -70,7 +70,7 @@ import tmUtils from '@/plugins/tm@_utils/tm.utils'
const atLeastOne = (value) => value.length const atLeastOne = (value) => value.length
export default { export default {
emits: ['close'], emits: ['close', 'update'],
components: { components: {
ZAutocomplete, ZAutocomplete,
+1 -1
View File
@@ -1,6 +1,6 @@
<template> <template>
<W-loadable :content="teams"> <W-loadable :content="teams">
<A-teams-table :teams="teams" /> <A-teams-table :teams="teams" @reloadData="_loadData" />
</W-loadable> </W-loadable>
</template> </template>
+4 -4
View File
@@ -34,7 +34,7 @@ export default {
async post(url: string, params = null, config?: any) { async post(url: string, params = null, config?: any) {
return axios.post(url, params, config) return axios.post(url, {data: params}, config)
.then(response => response.data) .then(response => response.data)
.catch(error => Promise.reject(error)) .catch(error => Promise.reject(error))
}, },
@@ -42,14 +42,14 @@ export default {
async post_auth(url: string, params = null, config?: any) { async post_auth(url: string, params = null, config?: any) {
config = this._config(config) config = this._config(config)
return axios.post(url, params, config) return axios.post(url, {data: params}, config)
.then(response => response.data) .then(response => response.data)
.catch(error => Promise.reject(error)) .catch(error => Promise.reject(error))
}, },
async post_data(url: string, params = null, config?: any) { async post_data(url: string, params = null, config?: any) {
return axios.post(url, params, config) return axios.post(url, {data: params}, config)
.then(response => response.data.data) .then(response => response.data.data)
.catch(error => Promise.reject(error.response || error)) .catch(error => Promise.reject(error.response || error))
}, },
@@ -57,7 +57,7 @@ export default {
async post_auth_data(url: string, params = null, config?: any) { async post_auth_data(url: string, params = null, config?: any) {
config = this._config(config) config = this._config(config)
return axios.post(url, params, config) return axios.post(url, {data: params}, config)
.then(response => response.data.data) .then(response => response.data.data)
.catch(error => Promise.reject(error.response || error)) .catch(error => Promise.reject(error.response || error))
}, },