admin-fe/src/views/settings/index.vue

186 lines
5.3 KiB
Vue
Raw Normal View History

<template>
2020-04-17 22:27:00 +00:00
<div :class="rebootIsSidebarOpen" class="settings-container">
<div class="reboot-button-container">
<reboot-button/>
</div>
<div v-if="isDesktop">
<div :class="isSidebarOpen" class="settings-header-container">
<h1 class="settings-header">{{ $t('settings.settings') }}</h1>
2020-04-17 22:27:00 +00:00
<div class="docs-search-container">
<el-link
:underline="false"
href="https://docs-develop.pleroma.social/backend/administration/CLI_tasks/config/"
target="_blank">
<el-button class="settings-docs-button">
<span>
<i class="el-icon-document"/>
{{ $t('settings.seeDocs') }}
</span>
</el-button>
</el-link>
2020-02-23 21:17:24 +00:00
<el-autocomplete
2020-02-24 21:24:46 +00:00
v-model="searchQuery"
2020-02-23 21:17:24 +00:00
:fetch-suggestions="querySearch"
:trigger-on-focus="false"
clearable
2020-02-23 21:17:24 +00:00
placeholder="Search"
prefix-icon="el-icon-search"
2020-02-25 15:57:38 +00:00
class="settings-search-input"
@select="handleSearchSelect"/>
</div>
</div>
<component :is="componentName"/>
</div>
<div v-if="isMobile || isTablet">
<div :class="isSidebarOpen" class="settings-header-container">
<h1 class="settings-header">{{ $t('settings.settings') }}</h1>
</div>
<div class="nav-container">
<el-link
:underline="false"
href="https://docs-develop.pleroma.social/backend/administration/CLI_tasks/config/"
target="_blank">
<el-button class="settings-docs-button">
<span>
<i class="el-icon-document"/>
{{ $t('settings.seeDocs') }}
</span>
</el-button>
</el-link>
</div>
<!-- <div class="settings-search-input-container"/> -->
<component :is="componentName"/>
</div>
</div>
</template>
<script>
import { tabs } from './components/tabs'
import {
ActivityPub,
Authentication,
Captcha,
Esshd,
Frontend,
Gopher,
Http,
Instance,
JobQueue,
2020-07-24 20:29:12 +00:00
LinkFormatter,
Logger,
Mailer,
MediaProxy,
Metadata,
Mrf,
Other,
RateLimiters,
Relays,
Upload,
WebPush
} from './components'
2020-04-17 22:27:00 +00:00
import RebootButton from '@/components/RebootButton'
export default {
components: {
ActivityPub,
Authentication,
Captcha,
Esshd,
Frontend,
Gopher,
Http,
Instance,
JobQueue,
2020-07-24 20:29:12 +00:00
LinkFormatter,
Logger,
Mailer,
MediaProxy,
Metadata,
Mrf,
Other,
RateLimiters,
Relays,
2020-04-17 22:27:00 +00:00
RebootButton,
Upload,
WebPush
},
2020-02-06 16:53:30 +00:00
data() {
return {
2020-02-24 21:24:46 +00:00
searchQuery: ''
2020-02-06 16:53:30 +00:00
}
},
computed: {
componentName() {
return this.$route.path.split('/settings/').pop()
},
2020-02-01 13:08:10 +00:00
configDisabled() {
return this.$store.state.settings.configDisabled
},
2020-02-06 16:53:30 +00:00
isDesktop() {
return this.$store.state.app.device === 'desktop'
},
isMobile() {
return this.$store.state.app.device === 'mobile'
},
isSidebarOpen() {
return this.$store.state.app.sidebar.opened ? 'header-sidebar-opened' : 'header-sidebar-closed'
},
isTablet() {
return this.$store.state.app.device === 'tablet'
},
2020-04-17 22:27:00 +00:00
rebootIsSidebarOpen() {
return this.$store.state.app.sidebar.opened ? 'reboot-sidebar-opened' : 'reboot-sidebar-closed'
2020-02-24 21:24:46 +00:00
},
searchData() {
return this.$store.state.settings.searchData
},
tabs() {
2020-07-11 18:53:23 +00:00
return tabs(this.$store.state.settings.description)
}
},
mounted: function() {
2020-04-17 22:27:00 +00:00
this.$store.dispatch('GetNodeInfo')
this.$store.dispatch('NeedReboot')
this.$store.dispatch('FetchSettings')
2020-02-18 20:08:07 +00:00
},
methods: {
2020-03-12 20:48:50 +00:00
async handleSearchSelect(selectedValue) {
const tab = Object.keys(this.tabs).find(tab => {
return this.tabs[tab].settings.includes(selectedValue.group === ':pleroma' ? selectedValue.key : selectedValue.group)
})
2020-03-12 20:48:50 +00:00
await this.$store.dispatch('SetActiveTab', tab)
const selectedSetting = document.querySelector(`[data-search="${selectedValue.key}"]`)
if (selectedSetting) {
selectedSetting.scrollIntoView({ block: 'start', behavior: 'smooth' })
}
2020-02-25 15:57:38 +00:00
},
2020-02-24 21:24:46 +00:00
querySearch(queryString, cb) {
const results = this.searchData.filter(searchObj => searchObj.search.find(el => el.includes(queryString.toLowerCase())))
.map(searchObj => {
2020-07-27 16:35:21 +00:00
return { value: `${searchObj.label} in ${searchObj.groupLabel}`, group: searchObj.groupKey, key: searchObj.key }
})
2020-02-24 21:24:46 +00:00
cb(results)
},
settingsCantBeChanged(settings) {
const existingSettings = settings.filter(setting => {
2020-05-16 17:42:50 +00:00
if ([':esshd', ':cors_plug', ':quack', ':logger', ':swoosh', ':mime'].includes(setting)) {
return this.$store.state.settings.description.findIndex(el => el.group === setting) !== -1
} else if (setting === 'Pleroma.Web.Auth.Authenticator' || setting === ':admin_token') {
return this.$store.state.settings.description.findIndex(el => el.children[0].key === setting) !== -1
} else if (setting === 'relays') {
return [setting]
} else {
return this.$store.state.settings.description.findIndex(el => el.key === setting) !== -1
}
})
return existingSettings.length === 0
2020-02-18 20:08:07 +00:00
}
}
}
</script>
2020-04-17 22:27:00 +00:00
<style rel='stylesheet/scss' lang='scss' scoped>
@import './styles/main';
@include settings
</style>