Skip to content
Snippets Groups Projects
Commit 9c067761 authored by Angelina Filippova's avatar Angelina Filippova
Browse files

Create action for fetching single status

parent cd09e094
No related branches found
No related tags found
No related merge requests found
import { changeStatusScope, deleteStatus, fetchStatuses, fetchStatusesCount, fetchStatusesByInstance } from '@/api/status'
import { changeStatusScope, deleteStatus, fetchStatus, fetchStatuses, fetchStatusesCount, fetchStatusesByInstance } from '@/api/status'
const status = {
state: {
fetchedStatus: {},
fetchedStatuses: [],
loading: false,
statusesByInstance: {
......@@ -28,6 +29,9 @@ const status = {
CHANGE_SELECTED_INSTANCE: (state, instance) => {
state.statusesByInstance.selectedInstance = instance
},
SET_STATUS: (state, status) => {
state.fetchedStatus = status
},
SET_STATUSES_BY_INSTANCE: (state, statuses) => {
state.fetchedStatuses = statuses
},
......@@ -68,6 +72,13 @@ const status = {
dispatch('FetchStatusesByInstance')
}
},
async FetchStatus({ commit, getters }, id) {
commit('SET_LOADING', true)
const status = await fetchStatus(id, getters.authHost, getters.token)
console.log(status)
commit('SET_STATUS', status.data)
commit('SET_LOADING', false)
},
async FetchStatusesCount({ commit, getters }) {
commit('SET_LOADING', true)
const { data } = await fetchStatusesCount(getters.authHost, getters.token)
......
<template>
<main>
{{ status }}
<!-- <status :status="status" :account="status.account" :show-checkbox="false" :godmode="showPrivate"/> -->
</main>
</template>
<script>
import Status from '@/components/Status'
export default {
name: 'UsersShow',
components: { Status },
data() {
return {
showPrivate: false
}
},
computed: {
isDesktop() {
return this.$store.state.app.device === 'desktop'
},
isMobile() {
return this.$store.state.app.device === 'mobile'
},
isTablet() {
return this.$store.state.app.device === 'tablet'
},
status() {
return this.$store.state.status.fetchedStatus
}
},
mounted: function() {
this.$store.dispatch('NeedReboot')
this.$store.dispatch('GetNodeInfo')
this.$store.dispatch('FetchStatus', this.$route.params.id)
}
}
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment