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

110 lines
2 KiB
Vue
Raw Normal View History

2018-11-03 04:38:00 +02:00
<template>
<div class="hyhctythnmwihguaaapnbrbszsjqxpio">
<table>
<thead>
<tr>
2018-11-14 07:57:59 +02: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 04:38:00 +02: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 07:57:59 +02:00
<td>{{ log.host }}</td>
2018-11-03 04:38:00 +02:00
<td>@{{ log.actor }}</td>
</tr>
</tbody>
</table>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
2018-11-14 07:57:59 +02:00
import { faBolt, faExchangeAlt } from '@fortawesome/free-solid-svg-icons';
2018-11-03 04:38:00 +02:00
export default Vue.extend({
data() {
return {
logs: [],
2018-11-14 07:57:59 +02:00
connection: null,
faBolt, faExchangeAlt
2018-11-03 04:38:00 +02:00
};
},
mounted() {
2018-11-09 01:13:34 +02:00
this.connection = this.$root.stream.useSharedConnection('apLog');
2018-11-03 20:44:06 +02:00
this.connection.on('log', this.onLog);
this.connection.on('logs', this.onLogs);
2018-11-03 04:38:00 +02: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) {
for (const log of logs.reverse()) {
this.onLog(log)
}
2018-11-03 04:38:00 +02:00
}
}
});
</script>
<style lang="stylus" scoped>
.hyhctythnmwihguaaapnbrbszsjqxpio
display block
2018-11-04 11:31:27 +02:00
padding 12px 16px 16px 16px
2018-11-03 04:38:00 +02:00
height 250px
overflow auto
2018-11-03 04:38:00 +02:00
box-shadow 0 2px 4px rgba(0, 0, 0, 0.1)
2018-11-04 04:08:03 +02:00
background var(--adminDashboardCardBg)
2018-11-03 04:38:00 +02:00
border-radius 8px
> table
width 100%
max-width 100%
overflow auto
border-spacing 0
border-collapse collapse
2018-11-04 04:08:03 +02:00
color var(--adminDashboardCardFg)
2018-11-04 11:31:27 +02:00
font-size 14px
2018-11-03 04:38:00 +02:00
thead
2018-11-04 11:31:27 +02:00
border-bottom solid 1px var(--adminDashboardCardDivider)
2018-11-03 04:38:00 +02:00
tr
th
2018-11-03 06:39:17 +02:00
font-weight normal
2018-11-03 04:38:00 +02:00
text-align left
tbody
tr
&:nth-child(odd)
2018-11-04 04:08:03 +02:00
background rgba(0, 0, 0, 0.025)
2018-11-03 04:38:00 +02:00
th, td
padding 8px 16px
min-width 128px
td.in
color #d26755
td.out
color #55bb83
</style>