mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
update firewall api routes
This commit is contained in:
parent
e94d43566a
commit
6438ea5414
1 changed files with 16 additions and 26 deletions
|
@ -115,8 +115,8 @@ export default {
|
||||||
|
|
||||||
// Ports form data
|
// Ports form data
|
||||||
actionChoices: [
|
actionChoices: [
|
||||||
{ value: 'open', text: this.$i18n.t('open') },
|
{ value: 'allow', text: this.$i18n.t('open') },
|
||||||
{ value: 'close', text: this.$i18n.t('close') }
|
{ value: 'disallow', text: this.$i18n.t('close') }
|
||||||
],
|
],
|
||||||
connectionChoices: [
|
connectionChoices: [
|
||||||
{ value: 'ipv4', text: this.$i18n.t('ipv4') },
|
{ value: 'ipv4', text: this.$i18n.t('ipv4') },
|
||||||
|
@ -128,7 +128,7 @@ export default {
|
||||||
{ value: 'Both', text: this.$i18n.t('both') }
|
{ value: 'Both', text: this.$i18n.t('both') }
|
||||||
],
|
],
|
||||||
form: {
|
form: {
|
||||||
action: 'open',
|
action: 'allow',
|
||||||
port: undefined,
|
port: undefined,
|
||||||
connection: 'ipv4',
|
connection: 'ipv4',
|
||||||
protocol: 'TCP'
|
protocol: 'TCP'
|
||||||
|
@ -176,27 +176,17 @@ export default {
|
||||||
this.upnpEnabled = data.uPnP.enabled
|
this.upnpEnabled = data.uPnP.enabled
|
||||||
},
|
},
|
||||||
|
|
||||||
togglePort ({ action, port, protocol, connection }) {
|
async togglePort ({ action, port, protocol, connection }) {
|
||||||
return new Promise((resolve, reject) => {
|
const confirmed = await this.$askConfirmation(
|
||||||
this.$askConfirmation(
|
this.$i18n.t('confirm_firewall_' + action, { port, protocol, connection })
|
||||||
this.$i18n.t('confirm_firewall_' + action, { port, protocol, connection })
|
)
|
||||||
).then(confirmed => {
|
if (!confirmed) {
|
||||||
if (confirmed) {
|
return Promise.resolve(confirmed)
|
||||||
const method = action === 'open' ? 'post' : 'delete'
|
}
|
||||||
api[method](
|
return api.put(
|
||||||
`/firewall/port?${connection}_only`,
|
`firewall/${protocol}/${action}/${port}?${connection}_only`,
|
||||||
{ port, protocol },
|
{ wait: false }
|
||||||
{ wait: false }
|
).then(() => confirmed)
|
||||||
).then(() => {
|
|
||||||
resolve(confirmed)
|
|
||||||
}).catch(error => {
|
|
||||||
reject(error)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
resolve(confirmed)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async toggleUpnp (value) {
|
async toggleUpnp (value) {
|
||||||
|
@ -204,7 +194,7 @@ export default {
|
||||||
const confirmed = await this.$askConfirmation(this.$i18n.t('confirm_upnp_' + action))
|
const confirmed = await this.$askConfirmation(this.$i18n.t('confirm_upnp_' + action))
|
||||||
if (!confirmed) return
|
if (!confirmed) return
|
||||||
|
|
||||||
api.get('firewall/upnp?action=' + action, null, { websocket: true, wait: true }).then(() => {
|
api.put('firewall/upnp/' + action).then(() => {
|
||||||
// FIXME Couldn't test when it works.
|
// FIXME Couldn't test when it works.
|
||||||
this.$refs.view.fetchQueries()
|
this.$refs.view.fetchQueries()
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
|
@ -215,7 +205,7 @@ export default {
|
||||||
|
|
||||||
onTablePortToggling (port, protocol, connection, index, value) {
|
onTablePortToggling (port, protocol, connection, index, value) {
|
||||||
this.$set(this.protocols[protocol][index], connection, value)
|
this.$set(this.protocols[protocol][index], connection, value)
|
||||||
const action = value ? 'open' : 'close'
|
const action = value ? 'allow' : 'disallow'
|
||||||
this.togglePort({ action, port, protocol, connection }).then(toggled => {
|
this.togglePort({ action, port, protocol, connection }).then(toggled => {
|
||||||
// Revert change on cancel
|
// Revert change on cancel
|
||||||
if (!toggled) {
|
if (!toggled) {
|
||||||
|
|
Loading…
Reference in a new issue