feat(frontend): optimize frontend interaction (#8)

Support auto refresh. Change authentication method. Streamline the frontend code.
This commit is contained in:
Li4n0
2021-04-25 22:15:56 +08:00
committed by GitHub
parent 50a6749070
commit 7e99d93e43
21 changed files with 347 additions and 232 deletions
+82 -2
View File
@@ -28,7 +28,7 @@
</a-menu-item> </a-menu-item>
</a-sub-menu> </a-sub-menu>
<a-sub-menu key="rules"> <a-sub-menu key="rules">
<span slot="title"><a-icon type="radar-chart"/><span>Rules</span></span> <span slot="title"><rule-icon/><span>Rules</span></span>
<a-menu-item key="/rules/http"> <a-menu-item key="/rules/http">
<router-link to="/rules/http">HTTP Rules</router-link> <router-link to="/rules/http">HTTP Rules</router-link>
</a-menu-item> </a-menu-item>
@@ -54,12 +54,43 @@
:type="collapsed ? 'menu-unfold' : 'menu-fold'" :type="collapsed ? 'menu-unfold' : 'menu-fold'"
@click="() => (collapsed = !collapsed)" @click="() => (collapsed = !collapsed)"
/> />
<!-- <transition name="list1">-->
<div v-if="$route.path.includes('logs')" style="float: right; width:45% ;padding: 12px 0;line-height: 24px;">
<a-row :gutter="24" type="flex">
<a-col :span="21">
<a-form-model v-show="showSettings" ref="settings" layout="inline">
<a-row :gutter="24" type="flex">
<a-col :span="9" :offset="2">
<a-form-model-item label="Auto Refresh">
<a-switch id="auto-refresh" v-model="autoRefresh"></a-switch>
</a-form-model-item>
</a-col>
<a-col :span="13">
<a-form-model-item label="Refresh Interval">
<a-input-number style="margin-right: -3rem;" id="refresh-interval"
v-model="refreshInterval"
:disabled="!autoRefresh"></a-input-number>
</a-form-model-item>
</a-col>
</a-row>
</a-form-model>
</a-col>
<a-col :span="3">
<a-icon
:style="'font-size: 18px;padding: 12px 0;'+(showSettings?'color: #1b90ff;':'')"
type="setting"
@click="showSettings = !showSettings"
/>
</a-col>
</a-row>
</div>
<!-- </transition>-->
</a-layout-header> </a-layout-header>
<a-layout-content <a-layout-content
:style="{ margin: '24px 16px', padding: '24px', borderRadius: '20px',background: '#fff', minHeight: 'initial' }" :style="{ margin: '24px 16px', padding: '24px', borderRadius: '20px',background: '#fff', minHeight: 'initial' }"
> >
<transition name="fade-transform"> <transition name="fade-transform">
<router-view></router-view> <router-view ref='content'/>
</transition> </transition>
</a-layout-content> </a-layout-content>
</a-layout> </a-layout>
@@ -68,15 +99,53 @@
</template> </template>
<script> <script>
import Auth from '@/components/Auth' import Auth from '@/components/Auth'
import RuleIcon from "@/components/Icon";
export default { export default {
data() { data() {
return { return {
autoRefresh: localStorage.getItem("autoRefresh") === "true",
refreshInterval: localStorage.getItem("refreshInterval"),
collapsed: false, collapsed: false,
showSettings: false,
openKeys: ['logs', "rules"], openKeys: ['logs', "rules"],
}; };
}, },
methods: {
timing() {
if (this.timer !== null) {
clearInterval(this.timer)
}
this.timer = setInterval(() => {
this.$refs.content.fetch()
}, this.refreshInterval * 1000)
}
},
mounted() {
if (this.autoRefresh) {
this.timing()
}
},
destroyed() {
clearInterval(this.timer)
},
watch: {
autoRefresh(val) {
if (!val) {
clearInterval(this.timer)
} else {
this.timing()
}
localStorage.setItem('autoRefresh', val)
},
refreshInterval(val) {
clearInterval(this.timer)
this.timing()
localStorage.setItem('refreshInterval', val)
}
},
components: { components: {
RuleIcon,
Auth Auth
} }
}; };
@@ -87,6 +156,17 @@ html, body {
margin: 0; margin: 0;
} }
.fade-enter.fade-enter-active,
.fade-appear.fade-appear-active {
-webkit-animation-name: none;
animation-name: none;
}
.fade-leave.fade-leave-active {
-webkit-animation-name: none;
animation-name: none;
}
/* fade-transform */ /* fade-transform */
.fade-transform-leave-active, .fade-transform-leave-active,
.fade-transform-enter-active { .fade-transform-enter-active {
@@ -1,11 +1,12 @@
import request from './index' import request from './index'
export function ping() { export function auth(token) {
return request({ return request({
url: '/ping', url: '/auth',
method: 'get', method: 'get',
headers: {"Token": token},
validateStatus: function (status) { validateStatus: function (status) {
return status >= 200 && status < 300 // 默认的 return status >= 200 && status < 300
} }
}) })
} }
-9
View File
@@ -5,13 +5,4 @@ const service = axios.create({
timeout: 5000 // request timeout timeout: 5000 // request timeout
}) })
service.interceptors.request.use(function (config) {
const token = localStorage.getItem("token")
if (token !== null) {
config.headers['Token'] = token
}
// 在发送请求之前做些什么
return config
})
export default service export default service
+4 -8
View File
@@ -13,13 +13,13 @@
</template> </template>
<script> <script>
import {store} from "@/main"; import {store} from "@/main";
import {ping} from "@/api/ping" import {auth} from "@/api/auth"
export default { export default {
data() { data() {
return { return {
confirmLoading: false, confirmLoading: false,
token: localStorage.getItem("token") token: ""
}; };
}, },
computed: { computed: {
@@ -27,17 +27,13 @@ export default {
return !store.authed return !store.authed
}, },
}, },
watch: {
token: function (val) {
localStorage.setItem("token", val)
}
},
methods: { methods: {
auth() { auth() {
this.confirmLoading = true; this.confirmLoading = true;
ping().then(() => { auth(this.token).then(() => {
store.authed = true; store.authed = true;
this.confirmLoading = false; this.confirmLoading = false;
this.token = ""
}).catch(e => { }).catch(e => {
if (e.response.status === 403) { if (e.response.status === 403) {
this.$notification.error({ this.$notification.error({
@@ -0,0 +1,48 @@
<template>
<div
slot="filterDropdown"
style="padding: 8px"
>
<a-input
:placeholder="`Search ${column.dataIndex}`"
:value="selectedKeys[0]"
style="width: 188px; margin-bottom: 8px; display: block;"
@change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])"
@pressEnter="() => {
filters[column.dataIndex] = selectedKeys[0];
fetch()
}"
/>
<a-button
type="primary"
icon="search"
size="small"
style="width: 90px; margin-right: 8px"
@click="() => {
filters[column.dataIndex] = selectedKeys[0];
fetch()
}"
>
Search
</a-button>
<a-button size="small" style="width: 90px" @click="() =>{
clearFilters();
delete filters[column.dataIndex];
fetch()
}">
Reset
</a-button>
</div>
</template>
<script>
export default {
name: "FilterDropdown",
props:["setSelectedKeys","selectedKeys","clearFilters","column","filters","fetch"],
}
</script>
<style scoped>
</style>
+23
View File
@@ -0,0 +1,23 @@
<template>
<a-icon :component="RuleSvg"/>
</template>
<script>
const RuleSvg = {
template: `
<svg t="1619355924145" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2093" width="1rem" height="1rem"><path d="M922.666667 163.413333H598.826667a37.333333 37.333333 0 0 1 0-74.666666h323.84a37.333333 37.333333 0 0 1 0 74.666666zM922.666667 437.12H598.826667a37.333333 37.333333 0 0 1 0-74.666667h323.84a37.333333 37.333333 0 0 1 0 74.666667zM922.666667 661.333333H598.826667a37.333333 37.333333 0 0 1 0-74.666666h323.84a37.333333 37.333333 0 0 1 0 74.666666zM922.666667 934.826667H598.826667a37.333333 37.333333 0 0 1 0-74.666667h323.84a37.333333 37.333333 0 0 1 0 74.666667zM424.96 462.08H101.333333A37.333333 37.333333 0 0 1 64 424.746667V101.12A37.333333 37.333333 0 0 1 101.333333 64h323.626667a37.333333 37.333333 0 0 1 37.333333 37.333333v323.413334a37.546667 37.546667 0 0 1-37.333333 37.333333zM138.666667 387.413333h248.96V138.453333H138.666667zM424.96 960H101.333333A37.333333 37.333333 0 0 1 64 922.453333V598.826667a37.333333 37.333333 0 0 1 37.333333-37.333334h323.626667a37.546667 37.546667 0 0 1 37.333333 37.333334v323.626666A37.333333 37.333333 0 0 1 424.96 960zM138.666667 885.12h248.96V636.16H138.666667z" p-id="2094"></path></svg>
`
};
export default {
name: "RuleIcon",
data() {
return {
RuleSvg
}
}
};
</script>
<style scoped>
.custom-icons-list >>> .anticon {
margin-right: 6px;
}
</style>
+3 -1
View File
@@ -8,7 +8,9 @@ import '@/utils/index'
Vue.config.productionTip = false; Vue.config.productionTip = false;
Vue.use(Antd); Vue.use(Antd);
export const store = Vue.observable({authed: localStorage.getItem("token")}) export const store = Vue.observable({
authed: true,
})
/* eslint-disable no-new */ /* eslint-disable no-new */
new Vue({ new Vue({
router: router, router: router,
+22 -38
View File
@@ -7,41 +7,16 @@
@change="handleTableChange" @change="handleTableChange"
:rowClassName="(record, index) => index % 2 === 0 ? '' : 'gray-table-row'" :rowClassName="(record, index) => index % 2 === 0 ? '' : 'gray-table-row'"
> >
<div <filter-dropdown
slot="filterDropdown" slot="filterDropdown"
slot-scope="{ setSelectedKeys, selectedKeys, clearFilters, column }" slot-scope="{ setSelectedKeys, selectedKeys, clearFilters, column }"
style="padding: 8px" :set-selected-keys="setSelectedKeys"
> :selected-keys="selectedKeys"
<a-input :clear-filters="clearFilters"
:placeholder="`Search ${column.dataIndex}`" :column="column"
:value="selectedKeys[0]" :filters="filters"
style="width: 188px; margin-bottom: 8px; display: block;" :fetch="fetch"
@change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])" />
@pressEnter="() => {
filters[column.dataIndex] = selectedKeys[0];
fetch()
}"
/>
<a-button
type="primary"
icon="search"
size="small"
style="width: 90px; margin-right: 8px"
@click="() => {
filters[column.dataIndex] = selectedKeys[0];
fetch()
}"
>
Search
</a-button>
<a-button size="small" style="width: 90px" @click="() =>{
clearFilters();
delete filters[column.dataIndex];
fetch()
}">
Reset
</a-button>
</div>
<a-icon <a-icon
slot="filterIcon" slot="filterIcon"
slot-scope="filtered" slot-scope="filtered"
@@ -63,6 +38,7 @@
import {getDnsRecord} from '@/api/record' import {getDnsRecord} from '@/api/record'
import {store} from '@/main' import {store} from '@/main'
import FilterDropdown from '@/components/FilterDropdown'
const columns = [ const columns = [
{ {
@@ -125,6 +101,7 @@ export default {
name: 'DnsLogs', name: 'DnsLogs',
data() { data() {
return { return {
store,
data: [], data: [],
pagination: {current: 1}, pagination: {current: 1},
filters: {}, filters: {},
@@ -142,18 +119,17 @@ export default {
this.fetch(); this.fetch();
}, },
fetch: function () { fetch: function () {
this.loading = true;
let params = { let params = {
...this.filters, ...this.filters,
page: this.pagination.current, page: this.pagination.current,
order: this.order order: this.order
} }
this.loading = true;
getDnsRecord(params).then(res => { getDnsRecord(params).then(res => {
let result = res.data.result let result = res.data.result
this.data = result.data this.data = result.data
const pagination = {...this.pagination}; const pagination = {...this.pagination};
// Read total count from server
// pagination.total = data.totalCount;
pagination.total = result.count; pagination.total = result.count;
this.pagination = pagination; this.pagination = pagination;
this.loading = false this.loading = false
@@ -165,10 +141,18 @@ export default {
console.error(e) console.error(e)
} }
}) })
} },
}, },
mounted() { mounted() {
this.fetch({page: "1"}); this.fetch();
}, },
watch: {
'store.authed'() {
this.fetch()
}
},
components: {
FilterDropdown
}
} }
</script> </script>
+35 -39
View File
@@ -23,41 +23,16 @@
FINISHED FINISHED
</a-checkbox> </a-checkbox>
</div> </div>
<div <filter-dropdown
slot="filterDropdown" slot="filterDropdown"
slot-scope="{ setSelectedKeys, selectedKeys, clearFilters, column }" slot-scope="{ setSelectedKeys, selectedKeys, clearFilters, column }"
style="padding: 8px" :set-selected-keys="setSelectedKeys"
> :selected-keys="selectedKeys"
<a-input :clear-filters="clearFilters"
:placeholder="`Search ${column.dataIndex}`" :column="column"
:value="selectedKeys[0]" :filters="filters"
style="width: 188px; margin-bottom: 8px; display: block;" :fetch="fetch"
@change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])" />
@pressEnter="() => {
filters[column.dataIndex] = selectedKeys[0];
fetch()
}"
/>
<a-button
type="primary"
icon="search"
size="small"
style="width: 90px; margin-right: 8px"
@click="() => {
filters[column.dataIndex] = selectedKeys[0];
fetch()
}"
>
Search
</a-button>
<a-button size="small" style="width: 90px" @click="() =>{
clearFilters();
delete filters[column.dataIndex];
fetch()
}">
Reset
</a-button>
</div>
<a-icon <a-icon
slot="filterIcon" slot="filterIcon"
slot-scope="filtered" slot-scope="filtered"
@@ -86,6 +61,7 @@
import {getFtpRecord} from '@/api/record' import {getFtpRecord} from '@/api/record'
import {store} from '@/main' import {store} from '@/main'
import FilterDropdown from '@/components/FilterDropdown'
const colors = { const colors = {
"CRASHED": "#f50", "CRASHED": "#f50",
@@ -128,17 +104,29 @@ const columns = [
title: 'USER', title: 'USER',
dataIndex: 'user', dataIndex: 'user',
key: 'user', key: 'user',
scopedSlots: {
filterDropdown: 'filterDropdown',
filterIcon: 'filterIcon',
},
}, },
{ {
title: 'PASSWORD', title: 'PASSWORD',
dataIndex: 'password', dataIndex: 'password',
key: 'password', key: 'password',
scopedSlots: {
filterDropdown: 'filterDropdown',
filterIcon: 'filterIcon',
},
}, },
{ {
title: 'PATH', title: 'PATH',
dataIndex: 'path', dataIndex: 'path',
key: 'path', key: 'path',
ellipsis: true, ellipsis: true,
scopedSlots: {
filterDropdown: 'filterDropdown',
filterIcon: 'filterIcon',
},
}, },
{ {
title: 'STATUS', title: 'STATUS',
@@ -167,9 +155,10 @@ const columns = [
]; ];
export default { export default {
name: 'DnsLogs', name: 'FtpLogs',
data() { data() {
return { return {
store,
data: [], data: [],
pagination: {current: 1}, pagination: {current: 1},
filters: {}, filters: {},
@@ -188,18 +177,17 @@ export default {
this.fetch(); this.fetch();
}, },
fetch: function () { fetch: function () {
this.loading = true;
let params = { let params = {
...this.filters, ...this.filters,
page: this.pagination.current, page: this.pagination.current,
order: this.order order: this.order
} }
this.loading = true;
getFtpRecord(params).then(res => { getFtpRecord(params).then(res => {
let result = res.data.result let result = res.data.result
this.data = result.data this.data = result.data
const pagination = {...this.pagination}; const pagination = {...this.pagination};
// Read total count from server
// pagination.total = data.totalCount;
pagination.total = result.count; pagination.total = result.count;
this.pagination = pagination; this.pagination = pagination;
this.loading = false this.loading = false
@@ -211,10 +199,18 @@ export default {
console.error(e) console.error(e)
} }
}) })
} },
}, },
mounted() { mounted() {
this.fetch({page: "1"}); this.fetch();
}, },
watch: {
'store.authed'() {
this.fetch()
}
},
components: {
FilterDropdown
}
} }
</script> </script>
+22 -38
View File
@@ -7,41 +7,16 @@
@change="handleTableChange" @change="handleTableChange"
:rowClassName="(record, index) => index % 2 === 0 ? '' : 'gray-table-row'" :rowClassName="(record, index) => index % 2 === 0 ? '' : 'gray-table-row'"
> >
<div <filter-dropdown
slot="filterDropdown" slot="filterDropdown"
slot-scope="{ setSelectedKeys, selectedKeys, clearFilters, column }" slot-scope="{ setSelectedKeys, selectedKeys, clearFilters, column }"
style="padding: 8px" :set-selected-keys="setSelectedKeys"
> :selected-keys="selectedKeys"
<a-input :clear-filters="clearFilters"
:placeholder="`Search ${column.dataIndex}`" :column="column"
:value="selectedKeys[0]" :filters="filters"
style="width: 188px; margin-bottom: 8px; display: block;" :fetch="fetch"
@change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])" />
@pressEnter="() => {
filters[column.dataIndex] = selectedKeys[0];
fetch()
}"
/>
<a-button
type="primary"
icon="search"
size="small"
style="width: 90px; margin-right: 8px"
@click="() => {
filters[column.dataIndex] = selectedKeys[0];
fetch()
}"
>
Search
</a-button>
<a-button size="small" style="width: 90px" @click="() =>{
clearFilters();
delete filters[column.dataIndex];
fetch()
}">
Reset
</a-button>
</div>
<a-icon <a-icon
slot="filterIcon" slot="filterIcon"
slot-scope="filtered" slot-scope="filtered"
@@ -75,6 +50,7 @@
import {getHttpRecord} from '@/api/record' import {getHttpRecord} from '@/api/record'
import {store} from '@/main' import {store} from '@/main'
import FilterDropdown from '@/components/FilterDropdown'
const colors = { const colors = {
"GET": "#52c41a", "GET": "#52c41a",
@@ -157,6 +133,7 @@ export default {
name: 'HttpLogs', name: 'HttpLogs',
data() { data() {
return { return {
store,
data: [], data: [],
pagination: {current: 1}, pagination: {current: 1},
filters: {}, filters: {},
@@ -175,18 +152,17 @@ export default {
this.fetch(); this.fetch();
}, },
fetch: function () { fetch: function () {
this.loading = true;
let params = { let params = {
...this.filters, ...this.filters,
page: this.pagination.current, page: this.pagination.current,
order: this.order order: this.order
} }
this.loading = true;
getHttpRecord(params).then(res => { getHttpRecord(params).then(res => {
let result = res.data.result let result = res.data.result
this.data = result.data this.data = result.data
const pagination = {...this.pagination}; const pagination = {...this.pagination};
// Read total count from server
// pagination.total = data.totalCount;
pagination.total = result.count; pagination.total = result.count;
this.pagination = pagination; this.pagination = pagination;
this.loading = false this.loading = false
@@ -198,10 +174,18 @@ export default {
console.error(e) console.error(e)
} }
}) })
} },
}, },
mounted() { mounted() {
this.fetch({page: "1"}); this.fetch();
}, },
watch: {
'store.authed'() {
this.fetch()
}
},
components: {
FilterDropdown
}
} }
</script> </script>
+22 -38
View File
@@ -27,41 +27,16 @@
False False
</a-checkbox> </a-checkbox>
</div> </div>
<div <filter-dropdown
slot="filterDropdown" slot="filterDropdown"
slot-scope="{ setSelectedKeys, selectedKeys, clearFilters, column }" slot-scope="{ setSelectedKeys, selectedKeys, clearFilters, column }"
style="padding: 8px" :set-selected-keys="setSelectedKeys"
> :selected-keys="selectedKeys"
<a-input :clear-filters="clearFilters"
:placeholder="`Search ${column.dataIndex}`" :column="column"
:value="selectedKeys[0]" :filters="filters"
style="width: 188px; margin-bottom: 8px; display: block;" :fetch="fetch"
@change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])" />
@pressEnter="() => {
filters[column.dataIndex] = selectedKeys[0];
fetch()
}"
/>
<a-button
type="primary"
icon="search"
size="small"
style="width: 90px; margin-right: 8px"
@click="() => {
filters[column.dataIndex] = selectedKeys[0];
fetch()
}"
>
Search
</a-button>
<a-button size="small" style="width: 90px" @click="() =>{
clearFilters();
delete filters[column.dataIndex];
fetch()
}">
Reset
</a-button>
</div>
<a-icon <a-icon
slot="filterIcon" slot="filterIcon"
slot-scope="filtered" slot-scope="filtered"
@@ -96,6 +71,7 @@
import {getMysqlRecord} from '@/api/record' import {getMysqlRecord} from '@/api/record'
import {store} from '@/main' import {store} from '@/main'
import FilterDropdown from '@/components/FilterDropdown'
const colors = [ const colors = [
"#13c2c2", "#13c2c2",
@@ -200,6 +176,7 @@ export default {
name: 'MysqlLogs', name: 'MysqlLogs',
data() { data() {
return { return {
store,
data: [], data: [],
pagination: {current: 1}, pagination: {current: 1},
filters: {}, filters: {},
@@ -218,18 +195,17 @@ export default {
this.fetch(); this.fetch();
}, },
fetch: function () { fetch: function () {
this.loading = true;
let params = { let params = {
...this.filters, ...this.filters,
page: this.pagination.current, page: this.pagination.current,
order: this.order order: this.order
} }
this.loading = true;
getMysqlRecord(params).then(res => { getMysqlRecord(params).then(res => {
let result = res.data.result let result = res.data.result
this.data = result.data this.data = result.data
const pagination = {...this.pagination}; const pagination = {...this.pagination};
// Read total count from server
// pagination.total = data.totalCount;
pagination.total = result.count; pagination.total = result.count;
this.pagination = pagination; this.pagination = pagination;
this.loading = false this.loading = false
@@ -241,10 +217,18 @@ export default {
console.error(e) console.error(e)
} }
}) })
} },
}, },
mounted() { mounted() {
this.fetch({page: "1"}); this.fetch();
}, },
watch: {
'store.authed'() {
this.fetch()
}
},
components: {
FilterDropdown
}
} }
</script> </script>
+27 -39
View File
@@ -7,41 +7,16 @@
@change="handleTableChange" @change="handleTableChange"
:rowClassName="(record, index) => index % 2 === 0 ? '' : 'gray-table-row'" :rowClassName="(record, index) => index % 2 === 0 ? '' : 'gray-table-row'"
> >
<div <filter-dropdown
slot="filterDropdown" slot="filterDropdown"
slot-scope="{ setSelectedKeys, selectedKeys, clearFilters, column }" slot-scope="{ setSelectedKeys, selectedKeys, clearFilters, column }"
style="padding: 8px" :set-selected-keys="setSelectedKeys"
> :selected-keys="selectedKeys"
<a-input :clear-filters="clearFilters"
:placeholder="`Search ${column.dataIndex}`" :column="column"
:value="selectedKeys[0]" :filters="filters"
style="width: 188px; margin-bottom: 8px; display: block;" :fetch="fetch"
@change="e => setSelectedKeys(e.target.value ? [e.target.value] : [])" />
@pressEnter="() => {
filters[column.dataIndex] = selectedKeys[0];
fetch()
}"
/>
<a-button
type="primary"
icon="search"
size="small"
style="width: 90px; margin-right: 8px"
@click="() => {
filters[column.dataIndex] = selectedKeys[0];
fetch()
}"
>
Search
</a-button>
<a-button size="small" style="width: 90px" @click="() =>{
clearFilters();
delete filters[column.dataIndex];
fetch()
}">
Reset
</a-button>
</div>
<a-icon <a-icon
slot="filterIcon" slot="filterIcon"
slot-scope="filtered" slot-scope="filtered"
@@ -63,6 +38,7 @@
import {getRmiRecord} from '@/api/record' import {getRmiRecord} from '@/api/record'
import {store} from '@/main' import {store} from '@/main'
import FilterDropdown from '@/components/FilterDropdown'
const columns = [ const columns = [
{ {
@@ -101,6 +77,10 @@ const columns = [
dataIndex: 'path', dataIndex: 'path',
key: 'path', key: 'path',
ellipsis: true, ellipsis: true,
scopedSlots: {
filterDropdown: 'filterDropdown',
filterIcon: 'filterIcon',
},
}, },
{ {
title: 'REMOTE IP', title: 'REMOTE IP',
@@ -119,9 +99,10 @@ const columns = [
]; ];
export default { export default {
name: 'DnsLogs', name: 'RmiLogs',
data() { data() {
return { return {
store,
data: [], data: [],
pagination: {current: 1}, pagination: {current: 1},
filters: {}, filters: {},
@@ -139,18 +120,17 @@ export default {
this.fetch(); this.fetch();
}, },
fetch: function () { fetch: function () {
this.loading = true;
let params = { let params = {
...this.filters, ...this.filters,
page: this.pagination.current, page: this.pagination.current,
order: this.order order: this.order
} }
this.loading = true;
getRmiRecord(params).then(res => { getRmiRecord(params).then(res => {
let result = res.data.result let result = res.data.result
this.data = result.data this.data = result.data
const pagination = {...this.pagination}; const pagination = {...this.pagination};
// Read total count from server
// pagination.total = data.totalCount;
pagination.total = result.count; pagination.total = result.count;
this.pagination = pagination; this.pagination = pagination;
this.loading = false this.loading = false
@@ -162,10 +142,18 @@ export default {
console.error(e) console.error(e)
} }
}) })
} },
}, },
mounted() { mounted() {
this.fetch({page: "1"}); this.fetch();
}, },
watch: {
'store.authed'() {
this.fetch()
}
},
components: {
FilterDropdown
}
} }
</script> </script>
+8 -3
View File
@@ -288,6 +288,7 @@ export default {
name: 'DnsRules', name: 'DnsRules',
data() { data() {
return { return {
store,
data: [], data: [],
formVisible: false, formVisible: false,
pagination: {current: 1}, pagination: {current: 1},
@@ -311,18 +312,17 @@ export default {
this.fetch(); this.fetch();
}, },
fetch: function () { fetch: function () {
this.loading = true;
let params = { let params = {
...this.filters, ...this.filters,
page: this.pagination.current, page: this.pagination.current,
order: this.order order: this.order
} }
this.loading = true;
getDnsRule(params).then(res => { getDnsRule(params).then(res => {
let result = res.data.result let result = res.data.result
this.data = result.data this.data = result.data
const pagination = {...this.pagination}; const pagination = {...this.pagination};
// Read total count from server
// pagination.total = data.totalCount;
pagination.total = result.count; pagination.total = result.count;
this.pagination = pagination; this.pagination = pagination;
this.loading = false this.loading = false
@@ -430,6 +430,11 @@ export default {
mounted() { mounted() {
this.fetch({page: "1"}); this.fetch({page: "1"});
}, },
watch: {
'store.authed'() {
this.fetch()
}
},
components: { components: {
BasicRule, BasicRule,
} }
+8 -3
View File
@@ -210,6 +210,7 @@ export default {
name: 'FtpRules', name: 'FtpRules',
data() { data() {
return { return {
store,
data: [], data: [],
formVisible: false, formVisible: false,
pagination: {current: 1}, pagination: {current: 1},
@@ -230,18 +231,17 @@ export default {
this.fetch(); this.fetch();
}, },
fetch: function () { fetch: function () {
this.loading = true;
let params = { let params = {
...this.filters, ...this.filters,
page: this.pagination.current, page: this.pagination.current,
order: this.order order: this.order
} }
this.loading = true;
getFtpRule(params).then(res => { getFtpRule(params).then(res => {
let result = res.data.result let result = res.data.result
this.data = result.data this.data = result.data
const pagination = {...this.pagination}; const pagination = {...this.pagination};
// Read total count from server
// pagination.total = data.totalCount;
pagination.total = result.count; pagination.total = result.count;
this.pagination = pagination; this.pagination = pagination;
this.loading = false this.loading = false
@@ -349,6 +349,11 @@ export default {
mounted() { mounted() {
this.fetch({page: "1"}); this.fetch({page: "1"});
}, },
watch: {
'store.authed'() {
this.fetch()
}
},
components: { components: {
BasicRule, BasicRule,
} }
+8 -3
View File
@@ -274,6 +274,7 @@ export default {
name: 'HttpRules', name: 'HttpRules',
data() { data() {
return { return {
store,
data: [], data: [],
formVisible: false, formVisible: false,
pagination: {current: 1}, pagination: {current: 1},
@@ -341,18 +342,17 @@ export default {
this.fetch(); this.fetch();
}, },
fetch: function () { fetch: function () {
this.loading = true;
let params = { let params = {
...this.filters, ...this.filters,
page: this.pagination.current, page: this.pagination.current,
order: this.order order: this.order
} }
this.loading = true;
getHttpRule(params).then(res => { getHttpRule(params).then(res => {
let result = res.data.result let result = res.data.result
this.data = result.data this.data = result.data
const pagination = {...this.pagination}; const pagination = {...this.pagination};
// Read total count from server
// pagination.total = data.totalCount;
pagination.total = result.count; pagination.total = result.count;
this.pagination = pagination; this.pagination = pagination;
this.loading = false this.loading = false
@@ -497,6 +497,11 @@ export default {
mounted() { mounted() {
this.fetch({page: "1"}); this.fetch({page: "1"});
}, },
watch: {
'store.authed'() {
this.fetch()
}
},
components: { components: {
BasicRule, BasicRule,
} }
+8 -3
View File
@@ -248,6 +248,7 @@ export default {
name: 'MysqlRules', name: 'MysqlRules',
data() { data() {
return { return {
store,
data: [], data: [],
formVisible: false, formVisible: false,
pagination: {current: 1}, pagination: {current: 1},
@@ -270,18 +271,17 @@ export default {
this.fetch(); this.fetch();
}, },
fetch: function () { fetch: function () {
this.loading = true;
let params = { let params = {
...this.filters, ...this.filters,
page: this.pagination.current, page: this.pagination.current,
order: this.order order: this.order
} }
this.loading = true;
getMysqlRule(params).then(res => { getMysqlRule(params).then(res => {
let result = res.data.result let result = res.data.result
this.data = result.data this.data = result.data
const pagination = {...this.pagination}; const pagination = {...this.pagination};
// Read total count from server
// pagination.total = data.totalCount;
pagination.total = result.count; pagination.total = result.count;
this.pagination = pagination; this.pagination = pagination;
this.loading = false this.loading = false
@@ -420,6 +420,11 @@ export default {
mounted() { mounted() {
this.fetch({page: "1"}); this.fetch({page: "1"});
}, },
watch: {
'store.authed'() {
this.fetch()
}
},
components: { components: {
BasicRule, BasicRule,
} }
+8 -4
View File
@@ -185,6 +185,7 @@ export default {
name: 'RmiRules', name: 'RmiRules',
data() { data() {
return { return {
store,
data: [], data: [],
formVisible: false, formVisible: false,
pagination: {current: 1}, pagination: {current: 1},
@@ -205,18 +206,16 @@ export default {
this.fetch(); this.fetch();
}, },
fetch: function () { fetch: function () {
this.loading = true;
let params = { let params = {
...this.filters, ...this.filters,
page: this.pagination.current, page: this.pagination.current,
order: this.order order: this.order
} }
this.loading = true;
getRmiRule(params).then(res => { getRmiRule(params).then(res => {
let result = res.data.result let result = res.data.result
this.data = result.data this.data = result.data
const pagination = {...this.pagination}; const pagination = {...this.pagination};
// Read total count from server
// pagination.total = data.totalCount;
pagination.total = result.count; pagination.total = result.count;
this.pagination = pagination; this.pagination = pagination;
this.loading = false this.loading = false
@@ -319,11 +318,16 @@ export default {
handleCancel() { handleCancel() {
this.form = {} this.form = {}
this.closeDrawer() this.closeDrawer()
} },
}, },
mounted() { mounted() {
this.fetch({page: "1"}); this.fetch({page: "1"});
}, },
watch: {
'store.authed'() {
this.fetch()
}
},
components: { components: {
BasicRule, BasicRule,
} }
+1
View File
@@ -17,6 +17,7 @@ module.exports = {
} }
}, },
}, },
runtimeCompiler: true,
filenameHashing: false, filenameHashing: false,
publicPath: '' publicPath: ''
} }
+6
View File
@@ -67,6 +67,12 @@ func ListRecords(c *gin.Context) {
if ftpRecord.Flag != "" { if ftpRecord.Flag != "" {
db.Where("flag = ?", ftpRecord.Flag) db.Where("flag = ?", ftpRecord.Flag)
} }
if ftpRecord.User != "" {
db.Where("user like ?", "%"+ftpRecord.User+"%")
}
if ftpRecord.Password != "" {
db.Where("password like ?", "%"+ftpRecord.Password+"%")
}
if ftpRecord.Path != "" { if ftpRecord.Path != "" {
db.Where("path like ?", "%"+ftpRecord.Path+"%") db.Where("path like ?", "%"+ftpRecord.Path+"%")
} }
+7 -1
View File
@@ -2,17 +2,23 @@ package server
import ( import (
"io" "io"
"net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/li4n0/revsuit/internal/record" "github.com/li4n0/revsuit/internal/record"
log "unknwon.dev/clog/v2" log "unknwon.dev/clog/v2"
) )
func ping(c *gin.Context) { func auth(c *gin.Context) {
c.SetSameSite(http.SameSiteLaxMode)
c.SetCookie("token", c.Request.Header["Token"][0], 0, "/revsuit/api/", c.Request.Host, true, true) c.SetCookie("token", c.Request.Header["Token"][0], 0, "/revsuit/api/", c.Request.Host, true, true)
c.String(200, "pong") c.String(200, "pong")
} }
func ping(c *gin.Context) {
c.String(200, "pong")
}
func events(c *gin.Context) { func events(c *gin.Context) {
log.Info("Receive connection from %v", c.Request.RemoteAddr) log.Info("Receive connection from %v", c.Request.RemoteAddr)
c.Stream(func(w io.Writer) bool { c.Stream(func(w io.Writer) bool {
+1
View File
@@ -38,6 +38,7 @@ func (revsuit *Revsuit) registerPlatformRouter() {
revsuit.http.ApiGroup = api revsuit.http.ApiGroup = api
//platform routers //platform routers
api.GET("/auth", auth)
api.GET("/events", events) api.GET("/events", events)
api.GET("/ping", ping) api.GET("/ping", ping)
} }