rudeshark.net/src/client/app/admin/views/ap-log.vue

106 lines
1.9 KiB
Vue
Raw Normal View History

2018-11-03 03:38:00 +01:00
<template>
<div class="hyhctythnmwihguaaapnbrbszsjqxpio">
<table>
<thead>
<tr>
<th>%fa:exchange-alt% In/Out</th>
<th>%fa:server% Host</th>
<th>%fa:bolt% Activity</th>
<th>%fa:user% Actor</th>
</tr>
</thead>
<tbody>
<tr v-for="log in logs" :key="log.id">
<td :class="log.direction">{{ log.direction == 'in' ? '<' : '>' }} {{ log.direction }}</td>
<td>{{ log.host }}</td>
<td>{{ log.activity }}</td>
<td>@{{ log.actor }}</td>
</tr>
</tbody>
</table>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
data() {
return {
logs: [],
connection: null
};
},
mounted() {
this.connection = (this as any).os.stream.useSharedConnection('apLog');
2018-11-03 19:44:06 +01:00
this.connection.on('log', this.onLog);
this.connection.on('logs', this.onLogs);
2018-11-03 03:38:00 +01: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 10:31:27 +01:00
padding 12px 16px 16px 16px
2018-11-03 03:38:00 +01:00
height 250px
2018-11-04 10:31:27 +01:00
overflow hidden
2018-11-03 03:38:00 +01:00
box-shadow 0 2px 4px rgba(0, 0, 0, 0.1)
2018-11-04 03:08:03 +01:00
background var(--adminDashboardCardBg)
2018-11-03 03:38:00 +01:00
border-radius 8px
> table
width 100%
max-width 100%
overflow auto
border-spacing 0
border-collapse collapse
2018-11-04 03:08:03 +01:00
color var(--adminDashboardCardFg)
2018-11-04 10:31:27 +01:00
font-size 14px
2018-11-03 03:38:00 +01:00
thead
2018-11-04 10:31:27 +01:00
border-bottom solid 1px var(--adminDashboardCardDivider)
2018-11-03 03:38:00 +01:00
tr
th
2018-11-03 05:39:17 +01:00
font-weight normal
2018-11-03 03:38:00 +01:00
text-align left
tbody
tr
&:nth-child(odd)
2018-11-04 03:08:03 +01:00
background rgba(0, 0, 0, 0.025)
2018-11-03 03:38:00 +01:00
th, td
padding 8px 16px
min-width 128px
td.in
color #d26755
td.out
color #55bb83
</style>