Skip to content

Commit e71f765

Browse files
deep-project凹凸曼
andauthored
feat: ssh登录日志增加一键屏蔽ip #1309 (#1352)
Co-authored-by: 凹凸曼 <xx@xx>
1 parent 2b7f68f commit e71f765

File tree

1 file changed

+35
-1
lines changed
  • frontend/src/views/host/ssh/log

1 file changed

+35
-1
lines changed

frontend/src/views/host/ssh/log/log.vue

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
<el-tag type="danger" size="large" style="margin-left: 5px">
2626
{{ $t('commons.status.failed') }}: {{ faliedCount }}
2727
</el-tag>
28+
<el-button plain @click="onDeny" :disabled="selects.length === 0" style="margin-left: 5px">
29+
{{ $t('firewall.deny') }}
30+
</el-button>
2831
</el-col>
2932
<el-col :xs="24" :sm="8" :md="8" :lg="8" :xl="8">
3033
<TableSetting @search="search()" />
@@ -44,7 +47,13 @@
4447
</template>
4548

4649
<template #main>
47-
<ComplexTable :pagination-config="paginationConfig" :data="data" @search="search">
50+
<ComplexTable
51+
:pagination-config="paginationConfig"
52+
v-model:selects="selects"
53+
:data="data"
54+
@search="search"
55+
>
56+
<el-table-column type="selection" :selectable="selectable" fix />
4857
<el-table-column min-width="80" :label="$t('logs.loginIP')" prop="address" />
4958
<el-table-column min-width="60" :label="$t('ssh.belong')" prop="area" />
5059
<el-table-column min-width="60" :label="$t('firewall.port')" prop="port" />
@@ -83,6 +92,9 @@ import TableSetting from '@/components/table-setting/index.vue';
8392
import { dateFormat } from '@/utils/util';
8493
import { onMounted, reactive, ref } from '@vue/runtime-core';
8594
import { loadSSHLogs } from '@/api/modules/host';
95+
import { operateIPRule } from '@/api/modules/host';
96+
import { MsgSuccess } from '@/utils/message';
97+
import i18n from '@/lang';
8698
8799
const loading = ref();
88100
const data = ref();
@@ -95,6 +107,28 @@ const searchInfo = ref();
95107
const searchStatus = ref('All');
96108
const successfulCount = ref(0);
97109
const faliedCount = ref(0);
110+
const selects = ref<any>([]);
111+
112+
function selectable(row: any): boolean {
113+
return row.address !== '127.0.0.1' && row.address !== '::1';
114+
}
115+
116+
function select2address(): string {
117+
let res = [];
118+
selects.value.forEach((item: any) => {
119+
if (!res.includes(item.address)) res.push(item.address);
120+
});
121+
return res.join(',');
122+
}
123+
124+
const onDeny = async () => {
125+
let address = select2address();
126+
if (!address) return;
127+
await operateIPRule({ operation: 'add', address: address, strategy: 'drop' }).then(() => {
128+
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
129+
search();
130+
});
131+
};
98132
99133
const search = async () => {
100134
let params = {

0 commit comments

Comments
 (0)