update api calls for Backup views

This commit is contained in:
axolotle 2021-02-19 18:47:04 +01:00
parent aa70e7e102
commit d5f5e0ca5a
3 changed files with 17 additions and 9 deletions

View file

@ -1,5 +1,5 @@
<template>
<view-base :queries="queries" @queries-response="formatData" skeleton="card-list-skeleton">
<view-base :queries="queries" @queries-response="onQueriesResponse" skeleton="card-list-skeleton">
<!-- FIXME switch to <card-form> ? -->
<card :title="$t('backup_create')" icon="archive" no-body>
<b-form-checkbox-group
@ -104,7 +104,10 @@ export default {
data () {
return {
queries: ['hooks/backup', 'apps?with_backup'],
queries: [
['GET', 'hooks/backup'],
['GET', 'apps?with_backup']
],
selected: [],
// api data
system: undefined,
@ -131,7 +134,7 @@ export default {
return data
},
formatData ({ hooks }, { apps }) {
onQueriesResponse ({ hooks }, { apps }) {
this.system = this.formatHooks(hooks)
// transform app array into literal object to match hooks data structure
this.apps = apps.reduce((obj, app) => {

View file

@ -1,5 +1,5 @@
<template>
<view-base :queries="queries" @queries-response="formatBackupData">
<view-base :queries="queries" @queries-response="onQueriesResponse">
<!-- BACKUP INFO -->
<card :title="$t('infos')" icon="info-circle" button-unbreak="sm">
<template #header-buttons>
@ -131,7 +131,9 @@ export default {
data () {
return {
queries: [`backup/archives/${this.name}?with_details`],
queries: [
['GET', `backup/archives/${this.name}?with_details`]
],
selected: [],
error: '',
isValid: null,
@ -169,7 +171,7 @@ export default {
return data
},
formatBackupData (data) {
onQueriesResponse (data) {
this.infos = {
name: this.name,
created_at: data.created_at,
@ -211,6 +213,7 @@ export default {
api.post('backup/restore/' + this.name, data).then(response => {
this.isValid = null
}).catch(err => {
if (err.name !== 'APIBadRequestError') throw err
this.error = err.message
this.isValid = false
})

View file

@ -1,5 +1,5 @@
<template>
<view-base :queries="queries" @queries-response="formatBackupList" skeleton="list-group-skeleton">
<view-base :queries="queries" @queries-response="onQueriesResponse" skeleton="list-group-skeleton">
<template #top>
<top-bar :button="{ text: $t('backup_new'), icon: 'plus', to: { name: 'backup-create' } }" />
</template>
@ -44,13 +44,15 @@ export default {
data () {
return {
queries: ['backup/archives?with_info'],
queries: [
['GET', 'backup/archives?with_info']
],
archives: undefined
}
},
methods: {
formatBackupList (data) {
onQueriesResponse (data) {
const archives = Object.entries(data.archives)
if (archives.length) {
this.archives = archives.map(([name, infos]) => {