+
+
+
+
+
+
+
+ {{ $t('container.maxSize') }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t('container.maxFile') }}
+
+
+
+
@@ -163,6 +189,7 @@ import {
updateDaemonJsonByfile,
} from '@/api/modules/container';
import { MsgSuccess } from '@/utils/message';
+import { checkNumberRange } from '@/global/form-rules';
const loading = ref(false);
const showDaemonJsonAlert = ref(false);
@@ -178,6 +205,14 @@ const form = reactive({
liveRestore: false,
iptables: true,
cgroupDriver: '',
+ logOptionShow: false,
+ logMaxSize: 10,
+ sizeUnit: 'm',
+ logMaxFile: 3,
+});
+const rules = reactive({
+ logMaxSize: [checkNumberRange(1, 1024000)],
+ logMaxFile: [checkNumberRange(1, 100)],
});
const formRef = ref();
@@ -276,7 +311,14 @@ const onSubmitSave = async () => {
liveRestore: form.liveRestore,
iptables: form.iptables,
cgroupDriver: form.cgroupDriver,
+ logMaxSize: form.logMaxSize + form.sizeUnit,
+ logMaxFile: form.logMaxFile + '',
};
+ if (!form.logOptionShow) {
+ param.logMaxFile = '';
+ param.logMaxSize = '';
+ }
+
loading.value = true;
await updateDaemonJson(param)
.then(() => {
@@ -308,15 +350,50 @@ const changeMode = async () => {
};
const search = async () => {
- const res = await loadDaemonJson();
- form.isSwarm = res.data.isSwarm;
- form.status = res.data.status;
- form.version = res.data.version;
- form.cgroupDriver = res.data.cgroupDriver;
- form.liveRestore = res.data.liveRestore;
- form.iptables = res.data.iptables;
- form.mirrors = res.data.registryMirrors ? res.data.registryMirrors.join('\n') : '';
- form.registries = res.data.insecureRegistries ? res.data.insecureRegistries.join('\n') : '';
+ loading.value = true;
+ await loadDaemonJson()
+ .then((res) => {
+ loading.value = false;
+ form.isSwarm = res.data.isSwarm;
+ form.status = res.data.status;
+ form.version = res.data.version;
+ form.cgroupDriver = res.data.cgroupDriver;
+ form.liveRestore = res.data.liveRestore;
+ form.iptables = res.data.iptables;
+ form.mirrors = res.data.registryMirrors ? res.data.registryMirrors.join('\n') : '';
+ form.registries = res.data.insecureRegistries ? res.data.insecureRegistries.join('\n') : '';
+ if (res.data.logMaxFile || res.data.logMaxSize) {
+ form.logOptionShow = true;
+ }
+ form.logMaxFile = Number(res.data.logMaxFile);
+ form.logMaxSize = loadSize(res.data.logMaxSize);
+ })
+ .catch(() => {
+ loading.value = false;
+ });
+};
+
+const loadSize = (value: string) => {
+ if (value.indexOf('b') !== -1 || value.indexOf('B') !== -1) {
+ form.sizeUnit = 'b';
+ return Number(value.replaceAll('b', '').replaceAll('B', ''));
+ }
+ if (value.indexOf('k') !== -1 || value.indexOf('K') !== -1) {
+ form.sizeUnit = 'k';
+ return Number(value.replaceAll('k', '').replaceAll('K', ''));
+ }
+ if (value.indexOf('m') !== -1 || value.indexOf('M') !== -1) {
+ form.sizeUnit = 'm';
+ return Number(value.replaceAll('m', '').replaceAll('M', ''));
+ }
+ if (value.indexOf('g') !== -1 || value.indexOf('G') !== -1) {
+ form.sizeUnit = 'g';
+ return Number(value.replaceAll('g', '').replaceAll('G', ''));
+ }
+ if (value.indexOf('t') !== -1 || value.indexOf('T') !== -1) {
+ form.sizeUnit = 't';
+ return Number(value.replaceAll('t', '').replaceAll('T', ''));
+ }
};
onMounted(() => {