mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
update api calls for App views
This commit is contained in:
parent
b65bd23d08
commit
7c8dd388d8
6 changed files with 41 additions and 35 deletions
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<view-base
|
||||
:queries="queries" @queries-response="formatAppActions"
|
||||
:queries="queries" @queries-response="onQueriesResponse"
|
||||
ref="view" skeleton="card-form-skeleton"
|
||||
>
|
||||
<template v-if="actions" #default>
|
||||
|
@ -47,6 +47,8 @@ import { objectToParams } from '@/helpers/commons'
|
|||
export default {
|
||||
name: 'AppActions',
|
||||
|
||||
mixins: [validationMixin],
|
||||
|
||||
props: {
|
||||
id: { type: String, required: true }
|
||||
},
|
||||
|
@ -54,10 +56,10 @@ export default {
|
|||
data () {
|
||||
return {
|
||||
queries: [
|
||||
`apps/${this.id}/actions`,
|
||||
{ uri: 'domains' },
|
||||
{ uri: 'domains/main', storeKey: 'main_domain' },
|
||||
{ uri: 'users' }
|
||||
['GET', `apps/${this.id}/actions`],
|
||||
['GET', { uri: 'domains' }],
|
||||
['GET', { uri: 'domains/main', storeKey: 'main_domain' }],
|
||||
['GET', { uri: 'users' }]
|
||||
],
|
||||
actions: undefined
|
||||
}
|
||||
|
@ -74,7 +76,7 @@ export default {
|
|||
},
|
||||
|
||||
methods: {
|
||||
formatAppActions (data) {
|
||||
onQueriesResponse (data) {
|
||||
if (!data.actions) {
|
||||
this.actions = null
|
||||
return
|
||||
|
@ -95,17 +97,16 @@ export default {
|
|||
},
|
||||
|
||||
performAction (action) {
|
||||
// FIXME api expects at least one argument ?! (fake one given with { wut } )
|
||||
const args = objectToParams(action.form ? formatFormData(action.form) : { wut: undefined })
|
||||
// FIXME api expects at least one argument ?! (fake one given with { dontmindthis } )
|
||||
const args = objectToParams(action.form ? formatFormData(action.form) : { dontmindthis: undefined })
|
||||
|
||||
api.put(`apps/${this.id}/actions/${action.id}`, { args }).then(response => {
|
||||
this.$refs.view.fetchQueries()
|
||||
}).catch(error => {
|
||||
action.serverError = error.message
|
||||
}).catch(err => {
|
||||
if (err.name !== 'APIBadRequestError') throw err
|
||||
action.serverError = err.message
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
mixins: [validationMixin]
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<view-search
|
||||
:items="apps" :filtered-items="filteredApps" items-name="apps"
|
||||
:queries="queries" @queries-response="formatAppData"
|
||||
:queries="queries" @queries-response="onQueriesResponse"
|
||||
>
|
||||
<template #top-bar>
|
||||
<div id="view-top-bar">
|
||||
|
@ -158,7 +158,9 @@ export default {
|
|||
|
||||
data () {
|
||||
return {
|
||||
queries: ['appscatalog?full&with_categories'],
|
||||
queries: [
|
||||
['GET', 'appscatalog?full&with_categories']
|
||||
],
|
||||
|
||||
// Data
|
||||
apps: undefined,
|
||||
|
@ -280,7 +282,7 @@ export default {
|
|||
return 'danger'
|
||||
},
|
||||
|
||||
formatAppData (data) {
|
||||
onQueriesResponse (data) {
|
||||
// APPS
|
||||
const apps = []
|
||||
for (const key in data.apps) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<view-base :queries="queries" @queries-response="formatAppConfig" skeleton="card-form-skeleton">
|
||||
<view-base :queries="queries" @queries-response="onQueriesResponse" skeleton="card-form-skeleton">
|
||||
<template v-if="panels" #default>
|
||||
<b-alert variant="warning" class="mb-4">
|
||||
<icon iname="exclamation-triangle" /> {{ $t('experimental_warning') }}
|
||||
|
@ -61,17 +61,17 @@ export default {
|
|||
data () {
|
||||
return {
|
||||
queries: [
|
||||
`apps/${this.id}/config-panel`,
|
||||
{ uri: 'domains' },
|
||||
{ uri: 'domains/main', storeKey: 'main_domain' },
|
||||
{ uri: 'users' }
|
||||
['GET', `apps/${this.id}/config-panel`],
|
||||
['GET', { uri: 'domains' }],
|
||||
['GET', { uri: 'domains/main', storeKey: 'main_domain' }],
|
||||
['GET', { uri: 'users' }]
|
||||
],
|
||||
panels: undefined
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
formatAppConfig (data) {
|
||||
onQueriesResponse (data) {
|
||||
if (!data.config_panel || data.config_panel.length === 0) {
|
||||
this.panels = null
|
||||
return
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<view-base :queries="queries" @queries-response="formatAppData" ref="view">
|
||||
<view-base :queries="queries" @queries-response="onQueriesResponse" ref="view">
|
||||
<!-- BASIC INFOS -->
|
||||
<card v-if="infos" :title="`${$t('infos')} — ${infos.label}`" icon="info-circle">
|
||||
<b-row
|
||||
|
@ -172,9 +172,9 @@ export default {
|
|||
data () {
|
||||
return {
|
||||
queries: [
|
||||
`apps/${this.id}?full`,
|
||||
{ uri: 'users/permissions?full', storeKey: 'permissions' },
|
||||
{ uri: 'domains' }
|
||||
['GET', `apps/${this.id}?full`],
|
||||
['GET', { uri: 'users/permissions?full', storeKey: 'permissions' }],
|
||||
['GET', { uri: 'domains' }]
|
||||
],
|
||||
infos: undefined,
|
||||
app: undefined,
|
||||
|
@ -203,7 +203,7 @@ export default {
|
|||
},
|
||||
|
||||
methods: {
|
||||
formatAppData (app) {
|
||||
onQueriesResponse (app) {
|
||||
const form = { labels: [] }
|
||||
|
||||
const mainPermission = app.permissions[this.id + '.main']
|
||||
|
@ -263,7 +263,7 @@ export default {
|
|||
api.put(
|
||||
`apps/${this.id}/changeurl`,
|
||||
{ domain, path: '/' + path }
|
||||
).then(this.fetchData)
|
||||
).then(this.$refs.view.fetchQueries)
|
||||
},
|
||||
|
||||
async setAsDefaultDomain () {
|
||||
|
|
|
@ -132,6 +132,7 @@ export default {
|
|||
api.post('apps', data).then(response => {
|
||||
this.$router.push({ name: 'app-list' })
|
||||
}).catch(err => {
|
||||
if (err.name !== 'APIBadRequestError') throw err
|
||||
this.serverError = err.message
|
||||
})
|
||||
}
|
||||
|
@ -141,10 +142,10 @@ export default {
|
|||
const isCustom = this.$route.name === 'app-install-custom'
|
||||
Promise.all([
|
||||
isCustom ? this.getExternalManifest() : this.getApiManifest(),
|
||||
this.$store.dispatch('FETCH_ALL', [
|
||||
{ uri: 'domains' },
|
||||
{ uri: 'domains/main', storeKey: 'main_domain' },
|
||||
{ uri: 'users' }
|
||||
api.fetchAll([
|
||||
['GET', { uri: 'domains' }],
|
||||
['GET', { uri: 'domains/main', storeKey: 'main_domain' }],
|
||||
['GET', { uri: 'users' }]
|
||||
])
|
||||
]).then((responses) => this.formatManifestData(responses[0]))
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
:items="apps"
|
||||
:filtered-items="filteredApps"
|
||||
:queries="queries"
|
||||
@queries-response="formatAppData"
|
||||
@queries-response="onQueriesResponse"
|
||||
>
|
||||
<template #top-bar-buttons>
|
||||
<b-button variant="success" :to="{ name: 'app-catalog' }">
|
||||
|
@ -42,7 +42,9 @@ export default {
|
|||
|
||||
data () {
|
||||
return {
|
||||
queries: ['apps?full'],
|
||||
queries: [
|
||||
['GET', 'apps?full']
|
||||
],
|
||||
search: '',
|
||||
apps: undefined
|
||||
}
|
||||
|
@ -60,7 +62,7 @@ export default {
|
|||
},
|
||||
|
||||
methods: {
|
||||
formatAppData ({ apps }) {
|
||||
onQueriesResponse ({ apps }) {
|
||||
if (apps.length === 0) {
|
||||
this.apps = null
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue