mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
update api calls for Domain views
This commit is contained in:
parent
4658c3d712
commit
9ede3740a8
5 changed files with 33 additions and 22 deletions
|
@ -8,6 +8,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import api from '@/api'
|
||||
import { DomainForm } from '@/views/_partials'
|
||||
|
||||
export default {
|
||||
|
@ -15,23 +16,24 @@ export default {
|
|||
|
||||
data () {
|
||||
return {
|
||||
queries: [{ uri: 'domains' }],
|
||||
queries: [
|
||||
['GET', { uri: 'domains' }]
|
||||
],
|
||||
serverError: ''
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
onSubmit ({ domain, domainType }) {
|
||||
const query = {
|
||||
uri: 'domains' + (domainType === 'dynDomain' ? '?dyndns' : ''),
|
||||
data: { domain },
|
||||
storeKey: 'domains'
|
||||
}
|
||||
|
||||
this.$store.dispatch('POST', query).then(() => {
|
||||
const uri = 'domains' + (domainType === 'dynDomain' ? '?dyndns' : '')
|
||||
api.post(
|
||||
{ uri, storeKey: 'domains' },
|
||||
{ domain }
|
||||
).then(() => {
|
||||
this.$router.push({ name: 'domain-list' })
|
||||
}).catch(error => {
|
||||
this.serverError = error.message
|
||||
}).catch(err => {
|
||||
if (err.name !== 'APIBadRequestError') throw err
|
||||
this.serverError = err.message
|
||||
})
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<view-base :queries="queries" @queries-response="formatCertData" ref="view">
|
||||
<view-base :queries="queries" @queries-response="onQueriesResponse" ref="view">
|
||||
<card v-if="cert" :title="$t('certificate_status')" icon="lock">
|
||||
<p :class="'alert alert-' + cert.alert.type">
|
||||
<icon :iname="cert.alert.icon" /> {{ $t('certificate_alert_' + cert.alert.trad) }}
|
||||
|
@ -83,7 +83,9 @@ export default {
|
|||
|
||||
data () {
|
||||
return {
|
||||
queries: [`domains/cert-status/${this.name}?full`],
|
||||
queries: [
|
||||
['GET', `domains/cert-status/${this.name}?full`]
|
||||
],
|
||||
cert: undefined,
|
||||
actionsEnabled: undefined
|
||||
}
|
||||
|
@ -106,7 +108,7 @@ export default {
|
|||
}
|
||||
},
|
||||
|
||||
formatCertData (data) {
|
||||
onQueriesResponse (data) {
|
||||
const certData = data.certificates[this.name]
|
||||
|
||||
const cert = {
|
||||
|
|
|
@ -22,7 +22,9 @@ export default {
|
|||
|
||||
data () {
|
||||
return {
|
||||
queries: [`domains/${this.name}/dns`],
|
||||
queries: [
|
||||
['GET', `domains/${this.name}/dns`]
|
||||
],
|
||||
dnsConfig: ''
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
import api from '@/api'
|
||||
|
||||
export default {
|
||||
name: 'DomainInfo',
|
||||
|
||||
|
@ -58,9 +60,11 @@ export default {
|
|||
}
|
||||
},
|
||||
|
||||
data () {
|
||||
data: () => {
|
||||
return {
|
||||
queries: [{ uri: 'domains/main', storeKey: 'main_domain' }]
|
||||
queries: [
|
||||
['GET', { uri: 'domains/main', storeKey: 'main_domain' }]
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -78,7 +82,7 @@ export default {
|
|||
const confirmed = await this.$askConfirmation(this.$i18n.t('confirm_delete', { name: this.name }))
|
||||
if (!confirmed) return
|
||||
|
||||
this.$store.dispatch('DELETE',
|
||||
api.delete(
|
||||
{ uri: 'domains', param: this.name }
|
||||
).then(() => {
|
||||
this.$router.push({ name: 'domain-list' })
|
||||
|
@ -89,10 +93,11 @@ export default {
|
|||
const confirmed = await this.$askConfirmation(this.$i18n.t('confirm_change_maindomain'))
|
||||
if (!confirmed) return
|
||||
|
||||
this.$store.dispatch('PUT',
|
||||
{ uri: 'domains/main', data: { new_main_domain: this.name }, storeKey: 'main_domain' }
|
||||
api.put(
|
||||
{ uri: 'domains/main', storeKey: 'main_domain' },
|
||||
{ new_main_domain: this.name }
|
||||
).then(() => {
|
||||
// Have to commit by hand here since the response is empty
|
||||
// FIXME Have to commit by hand here since the response is empty (should return the given name)
|
||||
this.$store.commit('UPDATE_MAIN_DOMAIN', this.name)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -47,8 +47,8 @@ export default {
|
|||
data () {
|
||||
return {
|
||||
queries: [
|
||||
{ uri: 'domains/main', storeKey: 'main_domain' },
|
||||
{ uri: 'domains' }
|
||||
['GET', { uri: 'domains/main', storeKey: 'main_domain' }],
|
||||
['GET', { uri: 'domains' }]
|
||||
],
|
||||
search: ''
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue