domaininfo: remove some info and update view with action handling

This commit is contained in:
axolotle 2022-10-06 21:07:55 +02:00
parent 7f5392389e
commit 69d1d7ec1e
4 changed files with 47 additions and 87 deletions

View file

@ -146,9 +146,9 @@
"domain": { "domain": {
"cert": { "cert": {
"types": { "types": {
"self-signed": "Self-signed", "selfsigned": "Self-signed",
"lets-encrypt": "Let's Encrypt", "letsencrypt": "Let's Encrypt",
"other-unknown": "Other/Unknown" "other": "Other/Unknown"
}, },
"valid_for": "valid for {days}" "valid_for": "valid for {days}"
}, },
@ -188,8 +188,6 @@
"info": { "info": {
"apps_on_domain": "Apps installed on domain", "apps_on_domain": "Apps installed on domain",
"certificate_authority": "SSL Certification authority", "certificate_authority": "SSL Certification authority",
"dns_config_method": "DNS config method",
"dns_semi_auto_config_feature": "Semi-auto DNS configuration feature",
"domain_type": "Domain type", "domain_type": "Domain type",
"registrar": "Registrar" "registrar": "Registrar"
}, },

View file

@ -141,14 +141,22 @@ const routes = [
} }
}, },
{ {
name: 'domain-info',
path: '/domains/:name', path: '/domains/:name',
component: () => import(/* webpackChunkName: "views/domain/info" */ '@/views/domain/DomainInfo'), component: () => import(/* webpackChunkName: "views/domain/info" */ '@/views/domain/DomainInfo'),
props: true, props: true,
meta: { children: [
args: { param: 'name' }, {
breadcrumb: ['domain-list', 'domain-info'] name: 'domain-info',
} path: ':tabId?',
component: () => import(/* webpackChunkName: "components/configPanel" */ '@/components/ConfigPanel'),
props: true,
meta: {
routerParams: ['name'], // Override router key params to avoid view recreation at tab change.
args: { param: 'name' },
breadcrumb: ['domain-list', 'domain-info']
}
}
]
}, },
{ {
// no need for name here, only children are visited // no need for name here, only children are visited

View file

@ -34,8 +34,8 @@ export default {
state.domains = domains state.domains = domains
}, },
'SET_DOMAINS_DETAILS' (state, [name, { domains }]) { 'SET_DOMAINS_DETAILS' (state, [name, details]) {
Vue.set(state.domains_details, name, domains[name]) Vue.set(state.domains_details, name, details)
}, },
'UPDATE_DOMAINS_DETAILS' (state, payload) { 'UPDATE_DOMAINS_DETAILS' (state, payload) {

View file

@ -1,5 +1,8 @@
<template> <template>
<view-base :queries="queries" @queries-response="onQueriesResponse" skeleton="card-list-skeleton"> <view-base
:queries="queries" @queries-response="onQueriesResponse"
ref="view" skeleton="card-list-skeleton"
>
<!-- INFO CARD --> <!-- INFO CARD -->
<card v-if="domain" :title="name" icon="globe"> <card v-if="domain" :title="name" icon="globe">
<template #header-buttons> <template #header-buttons>
@ -31,49 +34,20 @@
id="explain-main-domain" id="explain-main-domain"
:title="$t('domain.types.main_domain')" :title="$t('domain.types.main_domain')"
:content="$t('domain.explain.main_domain', { domain: name })" :content="$t('domain.explain.main_domain', { domain: name })"
>{{ $t('domain.types.main_domain') }}</explain-what> >{{ $t('domain.types.main_domain') }}</explain-what>,&nbsp;
,&nbsp;
</span> </span>
{{ $t('domain.types.' + (parentName ? 'subdomain' : 'parent_domain' )) }} {{ $t('domain.types.' + (parentName ? 'subdomain' : 'parent_domain' )) }}
</description-row> </description-row>
<!-- DOMAIN CERT AUTHORITY --> <!-- DOMAIN CERT AUTHORITY -->
<description-row :term="$t('domain.info.certificate_authority')"> <description-row :term="$t('domain.info.certificate_authority')">
<icon :iname="cert.status.icon" :variant="cert.status.variant" class="mr-1" /> <icon :iname="cert.icon" :variant="cert.variant" class="mr-1" />
{{ $t('domain.cert.types.' + cert.authority) }} {{ $t('domain.cert.types.' + cert.authority) }}
({{ $t('domain.cert.valid_for', { days: $tc('day_validity', cert.validity) }) }}) ({{ $t('domain.cert.valid_for', { days: $tc('day_validity', cert.validity) }) }})
</description-row> </description-row>
<!-- DOMAIN DNS METHOD -->
<description-row v-if="dns" :term="$t('domain.info.dns_config_method')">
{{ $t('domain.dns.methods.' + dns.method) }}
<template v-if="dns.method === 'semi_auto'">
(<icon :iname="semiAuto.icon" :variant="semiAuto.variant" class="mr-1" />
{{ $t('domain.dns.semi_auto_status.' + dns.semi_auto_status) }})
</template>
<template v-else-if="dns.method === 'handled_in_parent'">
<b-button
variant="outline-dark" size="xs" class="py-0 ml-1"
:to="{ name: 'domain-info', params: { name: parentName }}"
>
{{ parentName }}
</b-button>
</template>
</description-row>
<!-- DOMAIN SEMI-AUTO OPTIONAL FEATURE STATUS -->
<description-row
v-if="!['semi_auto', 'auto', 'handled_in_parent', 'none'].includes(dns.method)"
:term="$t('domain.info.dns_semi_auto_config_feature')"
>
<icon :iname="semiAuto.icon" :variant="semiAuto.variant" class="mr-1" />
{{ $t('domain.dns.semi_auto_status.' + dns.semi_auto_status) }}
</description-row>
<!-- DOMAIN REGISTRAR --> <!-- DOMAIN REGISTRAR -->
<description-row v-if="dns.registrar" :term="$t('domain.info.registrar')" :details="dns.registrar" /> <description-row v-if="domain.registrar" :term="$t('domain.info.registrar')" :details="domain.registrar" />
<!-- DOMAIN APPS --> <!-- DOMAIN APPS -->
<description-row :term="$t('domain.info.apps_on_domain')"> <description-row :term="$t('domain.info.apps_on_domain')">
@ -93,11 +67,11 @@
</b-button> </b-button>
</b-button-group> </b-button-group>
{{ domain.apps ? '' : $t('words.none') }} {{ domain.apps.length ? '' : $t('words.none') }}
</description-row> </description-row>
</card> </card>
<config-panels v-if="config.panels" v-bind="config" @submit="applyConfig" /> <config-panels v-if="config.panels" v-bind="config" @submit="onConfigSubmit" />
</view-base> </view-base>
</template> </template>
@ -146,26 +120,19 @@ export default {
return this.$store.getters.highestDomainParentName(this.name) return this.$store.getters.highestDomainParentName(this.name)
}, },
certStatus () {
const cert = this.domain.certificate
const trad = (cert.validity < 15 ? 'renew.' : '') + cert.authority
if (cert.validity <= 0) {
return { trad: 'invalid', icon: 'times', variant: 'danger' }
} else if (cert.authority === 'other-unknown') {
return cert.validity < 15
? { trad, icon: 'exclamation', variant: 'danger' }
: { trad, icon: 'check', variant: 'success' }
} else if (cert.authority === 'lets-encrypt') {
return { trad, icon: 'thumbs-up', variant: 'success' }
}
return { trad, icon: 'exclamation', variant: 'warning' }
},
cert () { cert () {
return { const { CA_type: authority, validity } = this.domain.certificate
...this.domain.certificate, const baseInfos = { authority, validity }
status: this.certStatus if (validity <= 0) {
return { icon: 'times', variant: 'danger', ...baseInfos }
} else if (authority === 'other') {
return validity < 15
? { icon: 'exclamation', variant: 'danger', ...baseInfos }
: { icon: 'check', variant: 'success', ...baseInfos }
} else if (authority === 'letsencrypt') {
return { icon: 'thumbs-up', variant: 'success', ...baseInfos }
} }
return { icon: 'exclamation', variant: 'warning', ...baseInfos }
}, },
dns () { dns () {
@ -175,18 +142,6 @@ export default {
isMainDomain () { isMainDomain () {
if (!this.mainDomain) return if (!this.mainDomain) return
return this.name === this.mainDomain return this.name === this.mainDomain
},
semiAuto () {
const status = this.dns.semi_auto_status
if (!status) return
if (status === 'unavailable') return { icon: 'times', variant: 'danger' }
if (status === 'activable') return { icon: 'check', variant: 'info' }
if (status === 'activated') return { icon: 'check', variant: 'success' }
// FIXME mutate status on push --dry_run (misconfigured + has_diff)
if (status === 'has_changes') return { icon: 'wrench', variant: 'warning' }
if (status === 'misconfigured') return { icon: 'times', variant: 'danger' }
return undefined
} }
}, },
@ -195,23 +150,22 @@ export default {
this.config = formatYunoHostConfigPanels(config) this.config = formatYunoHostConfigPanels(config)
}, },
async applyConfig (id_) { async onConfigSubmit ({ id, form, action, name }) {
const formatedData = await formatFormData( const args = await formatFormData(form, { removeEmpty: false, removeNull: true })
this.config.forms[id_],
{ removeEmpty: false, removeNull: true, multipart: false }
)
api.put( api.put(
`domains/${this.name}/config`, action
{ key: id_, args: objectToParams(formatedData) }, ? `domain/${this.name}/actions/${action}`
{ key: 'domains.update_config', name: this.name } : `domains/${this.name}/config/${id}`,
{ args: objectToParams(args) },
{ key: `domains.${action ? 'action' : 'update'}_config`, id, name: this.name }
).then(() => { ).then(() => {
this.$refs.view.fetchQueries({ triggerLoading: true }) this.$refs.view.fetchQueries({ triggerLoading: true })
}).catch(err => { }).catch(err => {
if (err.name !== 'APIBadRequestError') throw err if (err.name !== 'APIBadRequestError') throw err
const panel = this.config.panels.find(({ id }) => id_ === id) const panel = this.config.panels.find(panel => panel.id === id)
if (err.data.name) { if (err.data.name) {
this.config.errors[id_][err.data.name].message = err.message this.config.errors[id][err.data.name].message = err.message
} else this.$set(panel, 'serverError', err.message) } else this.$set(panel, 'serverError', err.message)
}) })
}, },