|
@@ -4,20 +4,22 @@ import { ReloadOutlined } from '@ant-design/icons-vue'
|
|
import gettext from '@/gettext'
|
|
import gettext from '@/gettext'
|
|
import ngx from '@/api/ngx'
|
|
import ngx from '@/api/ngx'
|
|
import { logLevel } from '@/views/config/constants'
|
|
import { logLevel } from '@/views/config/constants'
|
|
|
|
+import { NginxStatus } from '@/constants'
|
|
|
|
|
|
const { $gettext } = gettext
|
|
const { $gettext } = gettext
|
|
|
|
+
|
|
const status = ref(0)
|
|
const status = ref(0)
|
|
function get_status() {
|
|
function get_status() {
|
|
ngx.status().then(r => {
|
|
ngx.status().then(r => {
|
|
if (r?.running === true)
|
|
if (r?.running === true)
|
|
- status.value = 0
|
|
|
|
|
|
+ status.value = NginxStatus.Running
|
|
else
|
|
else
|
|
- status.value = -1
|
|
|
|
|
|
+ status.value = NginxStatus.Stopped
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
function reload_nginx() {
|
|
function reload_nginx() {
|
|
- status.value = 1
|
|
|
|
|
|
+ status.value = NginxStatus.Reloading
|
|
ngx.reload().then(r => {
|
|
ngx.reload().then(r => {
|
|
if (r.level < logLevel.Warn)
|
|
if (r.level < logLevel.Warn)
|
|
message.success($gettext('Nginx reloaded successfully'))
|
|
message.success($gettext('Nginx reloaded successfully'))
|
|
@@ -27,13 +29,11 @@ function reload_nginx() {
|
|
message.error(r.message)
|
|
message.error(r.message)
|
|
}).catch(e => {
|
|
}).catch(e => {
|
|
message.error(`${$gettext('Server error')} ${e?.message}`)
|
|
message.error(`${$gettext('Server error')} ${e?.message}`)
|
|
- }).finally(() => {
|
|
|
|
- status.value = 0
|
|
|
|
- })
|
|
|
|
|
|
+ }).finally(() => get_status())
|
|
}
|
|
}
|
|
|
|
|
|
function restart_nginx() {
|
|
function restart_nginx() {
|
|
- status.value = 2
|
|
|
|
|
|
+ status.value = NginxStatus.Restarting
|
|
ngx.restart().then(r => {
|
|
ngx.restart().then(r => {
|
|
if (r.level < logLevel.Warn)
|
|
if (r.level < logLevel.Warn)
|
|
message.success($gettext('Nginx restarted successfully'))
|
|
message.success($gettext('Nginx restarted successfully'))
|
|
@@ -43,9 +43,7 @@ function restart_nginx() {
|
|
message.error(r.message)
|
|
message.error(r.message)
|
|
}).catch(e => {
|
|
}).catch(e => {
|
|
message.error(`${$gettext('Server error')} ${e?.message}`)
|
|
message.error(`${$gettext('Server error')} ${e?.message}`)
|
|
- }).finally(() => {
|
|
|
|
- status.value = 0
|
|
|
|
- })
|
|
|
|
|
|
+ }).finally(() => get_status())
|
|
}
|
|
}
|
|
|
|
|
|
const visible = ref(false)
|
|
const visible = ref(false)
|
|
@@ -66,17 +64,17 @@ watch(visible, v => {
|
|
<div class="content-wrapper">
|
|
<div class="content-wrapper">
|
|
<h4>{{ $gettext('Nginx Control') }}</h4>
|
|
<h4>{{ $gettext('Nginx Control') }}</h4>
|
|
<ABadge
|
|
<ABadge
|
|
- v-if="status === 0"
|
|
|
|
|
|
+ v-if="status === NginxStatus.Running"
|
|
color="green"
|
|
color="green"
|
|
:text="$gettext('Running')"
|
|
:text="$gettext('Running')"
|
|
/>
|
|
/>
|
|
<ABadge
|
|
<ABadge
|
|
- v-else-if="status === 1"
|
|
|
|
|
|
+ v-else-if="status === NginxStatus.Reloading"
|
|
color="blue"
|
|
color="blue"
|
|
:text="$gettext('Reloading')"
|
|
:text="$gettext('Reloading')"
|
|
/>
|
|
/>
|
|
<ABadge
|
|
<ABadge
|
|
- v-else-if="status === 2"
|
|
|
|
|
|
+ v-else-if="status === NginxStatus.Restarting"
|
|
color="orange"
|
|
color="orange"
|
|
:text="$gettext('Restarting')"
|
|
:text="$gettext('Restarting')"
|
|
/>
|
|
/>
|