summaryrefslogtreecommitdiff
path: root/src/client/app/admin/views/ap-log.vue
blob: 6bc4a2f92daefdab1636a4c1c32a3ec4d37b6202 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<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');
		this.connection.on('log', this.onLog);
		this.connection.on('logs', this.onLogs);
		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
	padding 16px
	height 250px
	overflow auto
	box-shadow 0 2px 4px rgba(0, 0, 0, 0.1)
	background var(--adminDashboardCardBg)
	border-radius 8px

	> table
		width 100%
		max-width 100%
		overflow auto
		border-spacing 0
		border-collapse collapse
		color var(--adminDashboardCardFg)
		font-size 15px

		thead
			border-bottom solid 2px var(--adminDashboardCardDivider)

			tr
				th
					font-weight normal
					text-align left

		tbody
			tr
				&:nth-child(odd)
					background rgba(0, 0, 0, 0.025)

		th, td
			padding 8px 16px
			min-width 128px

		td.in
			color #d26755

		td.out
			color #55bb83

</style>