monkeeShark/src/client/app/admin/views/ap-log.vue

108 lines
2 KiB
Vue
Raw Normal View History

2018-11-03 02:38:00 +00:00
<template>
<div class="hyhctythnmwihguaaapnbrbszsjqxpio">
<table>
<thead>
<tr>
2018-11-14 05:57:59 +00:00
<th><fa :icon="faExchangeAlt"/> In/Out</th>
<th><fa :icon="faBolt"/> Activity</th>
<th><fa icon="server"/> Host</th>
<th><fa icon="user"/> Actor</th>
2018-11-03 02:38:00 +00:00
</tr>
</thead>
<tbody>
<tr v-for="log in logs" :key="log.id">
<td :class="log.direction">{{ log.direction == 'in' ? '<' : '>' }} {{ log.direction }}</td>
<td>{{ log.activity }}</td>
2018-11-14 05:57:59 +00:00
<td>{{ log.host }}</td>
2018-11-03 02:38:00 +00:00
<td>@{{ log.actor }}</td>
</tr>
</tbody>
</table>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
2018-11-14 05:57:59 +00:00
import { faBolt, faExchangeAlt } from '@fortawesome/free-solid-svg-icons';
2018-11-03 02:38:00 +00:00
export default Vue.extend({
data() {
return {
logs: [],
2018-11-14 05:57:59 +00:00
connection: null,
faBolt, faExchangeAlt
2018-11-03 02:38:00 +00:00
};
},
mounted() {
2018-11-08 23:13:34 +00:00
this.connection = this.$root.stream.useSharedConnection('apLog');
2018-11-03 18:44:06 +00:00
this.connection.on('log', this.onLog);
this.connection.on('logs', this.onLogs);
2018-11-03 02:38:00 +00:00
this.connection.send('requestLog', {
id: Math.random().toString().substr(2, 8),
length: 50
});
},
beforeDestroy() {
this.connection.dispose();
},
methods: {
onLog(log) {
log.id = Math.random();
this.logs.unshift(log);
if (this.logs.length > 50) this.logs.pop();
},
onLogs(logs) {
logs.reverse().forEach(log => this.onLog(log));
}
}
});
</script>
<style lang="stylus" scoped>
.hyhctythnmwihguaaapnbrbszsjqxpio
display block
2018-11-04 09:31:27 +00:00
padding 12px 16px 16px 16px
2018-11-03 02:38:00 +00:00
height 250px
2018-11-04 09:31:27 +00:00
overflow hidden
2018-11-03 02:38:00 +00:00
box-shadow 0 2px 4px rgba(0, 0, 0, 0.1)
2018-11-04 02:08:03 +00:00
background var(--adminDashboardCardBg)
2018-11-03 02:38:00 +00:00
border-radius 8px
> table
width 100%
max-width 100%
overflow auto
border-spacing 0
border-collapse collapse
2018-11-04 02:08:03 +00:00
color var(--adminDashboardCardFg)
2018-11-04 09:31:27 +00:00
font-size 14px
2018-11-03 02:38:00 +00:00
thead
2018-11-04 09:31:27 +00:00
border-bottom solid 1px var(--adminDashboardCardDivider)
2018-11-03 02:38:00 +00:00
tr
th
2018-11-03 04:39:17 +00:00
font-weight normal
2018-11-03 02:38:00 +00:00
text-align left
tbody
tr
&:nth-child(odd)
2018-11-04 02:08:03 +00:00
background rgba(0, 0, 0, 0.025)
2018-11-03 02:38:00 +00:00
th, td
padding 8px 16px
min-width 128px
td.in
color #d26755
td.out
color #55bb83
</style>