Restart application on button click
This commit is contained in:
parent
610349f24b
commit
7f2d61bc15
3 changed files with 28 additions and 5 deletions
|
@ -40,4 +40,13 @@ export async function removeSettings(configs, authHost, token) {
|
|||
})
|
||||
}
|
||||
|
||||
export async function restartApp(authHost, token) {
|
||||
return await request({
|
||||
baseURL: baseName(authHost),
|
||||
url: `/api/pleroma/admin/restart`,
|
||||
method: 'get',
|
||||
headers: authHeaders(token)
|
||||
})
|
||||
}
|
||||
|
||||
const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { fetchDescription, fetchSettings, removeSettings, updateSettings } from '@/api/settings'
|
||||
import { fetchDescription, fetchSettings, removeSettings, restartApp, updateSettings } from '@/api/settings'
|
||||
import { checkPartialUpdate, parseNonTuples, parseTuples, valueHasTuples, wrapUpdatedSettings } from './normalizers'
|
||||
import _ from 'lodash'
|
||||
|
||||
|
@ -9,10 +9,9 @@ const settings = {
|
|||
db: {},
|
||||
description: [],
|
||||
loading: true,
|
||||
needReboot: true,
|
||||
needReboot: false,
|
||||
settings: {},
|
||||
updatedSettings: {}
|
||||
|
||||
},
|
||||
mutations: {
|
||||
CLEAR_UPDATED_SETTINGS: (state) => {
|
||||
|
@ -52,6 +51,9 @@ const settings = {
|
|||
state.settings = newSettings
|
||||
state.db = newDbSettings
|
||||
},
|
||||
TOGGLE_REBOOT: (state, needReboot) => {
|
||||
state.needReboot = needReboot || false
|
||||
},
|
||||
TOGGLE_TABS: (state, status) => {
|
||||
state.configDisabled = status
|
||||
},
|
||||
|
@ -76,6 +78,7 @@ const settings = {
|
|||
const description = await fetchDescription(getters.authHost, getters.token)
|
||||
commit('SET_DESCRIPTION', description.data)
|
||||
commit('SET_SETTINGS', response.data.configs)
|
||||
commit('TOGGLE_REBOOT', response.data.need_reboot)
|
||||
} catch (_e) {
|
||||
commit('TOGGLE_TABS', true)
|
||||
commit('SET_ACTIVE_TAB', 'relays')
|
||||
|
@ -90,8 +93,13 @@ const settings = {
|
|||
const response = await fetchSettings(getters.authHost, getters.token)
|
||||
const { group, key, subkeys } = configs[0]
|
||||
commit('SET_SETTINGS', response.data.configs)
|
||||
commit('TOGGLE_REBOOT', response.data.need_reboot)
|
||||
commit('REMOVE_SETTING_FROM_UPDATED', { group, key, subkeys: subkeys || [] })
|
||||
},
|
||||
async RestartApplication({ commit, getters }) {
|
||||
await restartApp(getters.authHost, getters.token)
|
||||
commit('TOGGLE_REBOOT', false)
|
||||
},
|
||||
SetActiveTab({ commit }, tab) {
|
||||
commit('SET_ACTIVE_TAB', tab)
|
||||
},
|
||||
|
@ -104,6 +112,7 @@ const settings = {
|
|||
await updateSettings(configs, getters.authHost, getters.token)
|
||||
const response = await fetchSettings(getters.authHost, getters.token)
|
||||
commit('SET_SETTINGS', response.data.configs)
|
||||
commit('TOGGLE_REBOOT', response.data.need_reboot)
|
||||
commit('CLEAR_UPDATED_SETTINGS')
|
||||
},
|
||||
UpdateSettings({ commit }, { group, key, input, value, type }) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<div class="settings-header-container">
|
||||
<h1 class="settings-header">{{ $t('settings.settings') }}</h1>
|
||||
<div>
|
||||
<el-button v-if="needReboot" class="settings-reboot-button">
|
||||
<el-button v-if="needReboot" class="settings-reboot-button" @click="restartApp">
|
||||
<span>
|
||||
<i class="el-icon-refresh"/>
|
||||
{{ $t('settings.instanceReboot') }}
|
||||
|
@ -89,7 +89,7 @@
|
|||
<div v-if="isMobile || isTablet">
|
||||
<div class="settings-header-container">
|
||||
<h1 class="settings-header">{{ $t('settings.settings') }}</h1>
|
||||
<el-button v-if="needReboot" class="settings-reboot-button">
|
||||
<el-button v-if="needReboot" class="settings-reboot-button" @click="restartApp">
|
||||
<span>
|
||||
<i class="el-icon-refresh"/>
|
||||
{{ $t('settings.instanceReboot') }}
|
||||
|
@ -242,6 +242,11 @@ export default {
|
|||
},
|
||||
mounted: function() {
|
||||
this.$store.dispatch('FetchSettings')
|
||||
},
|
||||
methods: {
|
||||
restartApp() {
|
||||
this.$store.dispatch('RestartApplication')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue