mirror of
https://github.com/tnb-labs/panel.git
synced 2026-09-19 01:55:32 +08:00
101 lines
2.5 KiB
Vue
101 lines
2.5 KiB
Vue
<script setup lang="ts">
|
|
defineOptions({
|
|
name: 'apps-redis-index'
|
|
})
|
|
|
|
import Editor from '@guolao/vue-monaco-editor'
|
|
import { NButton, NDataTable } from 'naive-ui'
|
|
import { useGettext } from 'vue3-gettext'
|
|
|
|
import redis from '@/api/apps/redis'
|
|
import ServiceStatus from '@/components/common/ServiceStatus.vue'
|
|
|
|
const { $gettext } = useGettext()
|
|
const currentTab = ref('status')
|
|
|
|
const { data: config } = useRequest(redis.config, {
|
|
initialData: ''
|
|
})
|
|
const { data: load } = useRequest(redis.load, {
|
|
initialData: []
|
|
})
|
|
|
|
const loadColumns: any = [
|
|
{
|
|
title: $gettext('Property'),
|
|
key: 'name',
|
|
minWidth: 200,
|
|
resizable: true,
|
|
ellipsis: { tooltip: true }
|
|
},
|
|
{
|
|
title: $gettext('Current Value'),
|
|
key: 'value',
|
|
minWidth: 200,
|
|
ellipsis: { tooltip: true }
|
|
}
|
|
]
|
|
|
|
const handleSaveConfig = () => {
|
|
useRequest(redis.saveConfig(config.value)).onSuccess(() => {
|
|
window.$message.success($gettext('Saved successfully'))
|
|
})
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<common-page show-footer>
|
|
<template #action>
|
|
<n-button
|
|
v-if="currentTab == 'config'"
|
|
class="ml-16"
|
|
type="primary"
|
|
@click="handleSaveConfig"
|
|
>
|
|
{{ $gettext('Save') }}
|
|
</n-button>
|
|
</template>
|
|
<n-tabs v-model:value="currentTab" type="line" animated>
|
|
<n-tab-pane name="status" :tab="$gettext('Running Status')">
|
|
<service-status service="redis" />
|
|
</n-tab-pane>
|
|
<n-tab-pane name="config" :tab="$gettext('Main Configuration')">
|
|
<n-space vertical>
|
|
<n-alert type="warning">
|
|
{{
|
|
$gettext(
|
|
'This modifies the Redis main configuration file. If you do not understand the meaning of each parameter, please do not modify it randomly!'
|
|
)
|
|
}}
|
|
</n-alert>
|
|
<Editor
|
|
v-model:value="config"
|
|
language="ini"
|
|
theme="vs-dark"
|
|
height="60vh"
|
|
mt-8
|
|
:options="{
|
|
automaticLayout: true,
|
|
formatOnType: true,
|
|
formatOnPaste: true
|
|
}"
|
|
/>
|
|
</n-space>
|
|
</n-tab-pane>
|
|
<n-tab-pane name="load" :tab="$gettext('Load Status')">
|
|
<n-data-table
|
|
striped
|
|
remote
|
|
:scroll-x="1000"
|
|
:loading="false"
|
|
:columns="loadColumns"
|
|
:data="load"
|
|
/>
|
|
</n-tab-pane>
|
|
<n-tab-pane name="run-log" :tab="$gettext('Runtime Logs')">
|
|
<realtime-log service="redis" />
|
|
</n-tab-pane>
|
|
</n-tabs>
|
|
</common-page>
|
|
</template>
|