mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
update api calls for Group and Service views
This commit is contained in:
parent
9ede3740a8
commit
aa70e7e102
4 changed files with 27 additions and 24 deletions
|
@ -12,6 +12,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { validationMixin } from 'vuelidate'
|
import { validationMixin } from 'vuelidate'
|
||||||
|
|
||||||
|
import api from '@/api'
|
||||||
import { required, alphalownum_ } from '@/helpers/validators'
|
import { required, alphalownum_ } from '@/helpers/validators'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -42,13 +43,14 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onSubmit () {
|
onSubmit () {
|
||||||
this.$store.dispatch(
|
api.post(
|
||||||
'POST', { uri: 'users/groups', data: this.form, storeKey: 'groups' }
|
{ uri: 'users/groups', storeKey: 'groups' },
|
||||||
|
this.form
|
||||||
).then(() => {
|
).then(() => {
|
||||||
this.$router.push({ name: 'group-list' })
|
this.$router.push({ name: 'group-list' })
|
||||||
}).catch(error => {
|
}).catch(err => {
|
||||||
this.error.groupname = error.message
|
if (err.name !== 'APIBadRequestError') throw err
|
||||||
this.isValid.groupname = false
|
this.serverError = err.message
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
:items="normalGroups"
|
:items="normalGroups"
|
||||||
:filtered-items="filteredGroups"
|
:filtered-items="filteredGroups"
|
||||||
:queries="queries"
|
:queries="queries"
|
||||||
@queries-response="formatGroups"
|
@queries-response="onQueriesResponse"
|
||||||
skeleton="card-form-skeleton"
|
skeleton="card-form-skeleton"
|
||||||
>
|
>
|
||||||
<template #top-bar-buttons>
|
<template #top-bar-buttons>
|
||||||
|
@ -120,12 +120,17 @@ import BaseSelectize from '@/components/BaseSelectize'
|
||||||
export default {
|
export default {
|
||||||
name: 'GroupList',
|
name: 'GroupList',
|
||||||
|
|
||||||
|
components: {
|
||||||
|
ZoneSelectize,
|
||||||
|
BaseSelectize
|
||||||
|
},
|
||||||
|
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
queries: [
|
queries: [
|
||||||
{ uri: 'users' },
|
['GET', { uri: 'users' }],
|
||||||
{ uri: 'users/groups?full&include_primary_groups', storeKey: 'groups' },
|
['GET', { uri: 'users/groups?full&include_primary_groups', storeKey: 'groups' }],
|
||||||
{ uri: 'users/permissions?full', storeKey: 'permissions' }
|
['GET', { uri: 'users/permissions?full', storeKey: 'permissions' }]
|
||||||
],
|
],
|
||||||
search: '',
|
search: '',
|
||||||
permissions: undefined,
|
permissions: undefined,
|
||||||
|
@ -166,7 +171,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
formatGroups (users, allGroups, permissions) {
|
onQueriesResponse (users, allGroups, permissions) {
|
||||||
// Do not use computed properties to get values from the store here to avoid auto
|
// Do not use computed properties to get values from the store here to avoid auto
|
||||||
// updates while modifying values.
|
// updates while modifying values.
|
||||||
const normalGroups = {}
|
const normalGroups = {}
|
||||||
|
@ -247,17 +252,12 @@ export default {
|
||||||
const confirmed = await this.$askConfirmation(this.$i18n.t('confirm_delete', { name }))
|
const confirmed = await this.$askConfirmation(this.$i18n.t('confirm_delete', { name }))
|
||||||
if (!confirmed) return
|
if (!confirmed) return
|
||||||
|
|
||||||
this.$store.dispatch('DELETE',
|
api.delete(
|
||||||
{ uri: 'users/groups', param: name, storeKey: 'groups' }
|
{ uri: 'users/groups', param: name, storeKey: 'groups' }
|
||||||
).then(() => {
|
).then(() => {
|
||||||
Vue.delete(this.normalGroups, name)
|
Vue.delete(this.normalGroups, name)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
components: {
|
|
||||||
ZoneSelectize,
|
|
||||||
BaseSelectize
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<view-base
|
<view-base
|
||||||
:queries="queries" @queries-response="formatServiceData"
|
:queries="queries" @queries-response="onQueriesResponse"
|
||||||
ref="view" skeleton="card-info-skeleton"
|
ref="view" skeleton="card-info-skeleton"
|
||||||
>
|
>
|
||||||
<!-- INFO CARD -->
|
<!-- INFO CARD -->
|
||||||
|
@ -82,8 +82,8 @@ export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
queries: [
|
queries: [
|
||||||
'services/' + this.name,
|
['GET', 'services/' + this.name],
|
||||||
`services/${this.name}/log?number=50`
|
['GET', `services/${this.name}/log?number=50`]
|
||||||
],
|
],
|
||||||
// Service data
|
// Service data
|
||||||
infos: undefined,
|
infos: undefined,
|
||||||
|
@ -96,7 +96,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
formatServiceData (
|
onQueriesResponse (
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
{ status, description, start_on_boot, last_state_change, configuration },
|
{ status, description, start_on_boot, last_state_change, configuration },
|
||||||
logs
|
logs
|
||||||
|
@ -126,7 +126,6 @@ export default {
|
||||||
? `services/${this.name}/restart`
|
? `services/${this.name}/restart`
|
||||||
: 'services/' + this.name
|
: 'services/' + this.name
|
||||||
|
|
||||||
// FIXME API doesn't return anything to the PUT so => json err
|
|
||||||
api[method](uri).then(this.$refs.view.fetchQueries)
|
api[method](uri).then(this.$refs.view.fetchQueries)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
:filtered-items="filteredServices"
|
:filtered-items="filteredServices"
|
||||||
items-name="services"
|
items-name="services"
|
||||||
:queries="queries"
|
:queries="queries"
|
||||||
@queries-response="formatServices"
|
@queries-response="onQueriesResponse"
|
||||||
>
|
>
|
||||||
<b-list-group>
|
<b-list-group>
|
||||||
<b-list-group-item
|
<b-list-group-item
|
||||||
|
@ -42,7 +42,9 @@ export default {
|
||||||
|
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
queries: ['services'],
|
queries: [
|
||||||
|
['GET', 'services']
|
||||||
|
],
|
||||||
search: '',
|
search: '',
|
||||||
services: undefined
|
services: undefined
|
||||||
}
|
}
|
||||||
|
@ -60,7 +62,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
formatServices (services) {
|
onQueriesResponse (services) {
|
||||||
this.services = Object.keys(services).sort().map(name => {
|
this.services = Object.keys(services).sort().map(name => {
|
||||||
const service = services[name]
|
const service = services[name]
|
||||||
if (service.last_state_change === 'unknown') {
|
if (service.last_state_change === 'unknown') {
|
||||||
|
|
Loading…
Add table
Reference in a new issue