summaryrefslogtreecommitdiff
path: root/src/client/app/desktop/views/components/settings.signins.vue
blob: a414c95c279053d2764c0ecc8adeadc6dec854b8 (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
<template>
<div class="root">
<div class="signins" v-if="signins.length != 0">
	<div v-for="signin in signins">
		<header @click="signin._show = !signin._show">
			<template v-if="signin.success">%fa:check%</template>
			<template v-else>%fa:times%</template>
			<span class="ip">{{ signin.ip }}</span>
			<mk-time :time="signin.createdAt"/>
		</header>
		<div class="headers" v-show="signin._show">
			<tree-view :data="signin.headers"/>
		</div>
	</div>
</div>
</div>
</template>

<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
	data() {
		return {
			fetching: true,
			signins: [],
			connection: null,
			connectionId: null
		};
	},
	mounted() {
		(this as any).api('i/signin_history').then(signins => {
			this.signins = signins;
			this.fetching = false;
		});

		this.connection = (this as any).os.stream.getConnection();
		this.connectionId = (this as any).os.stream.use();

		this.connection.on('signin', this.onSignin);
	},
	beforeDestroy() {
		this.connection.off('signin', this.onSignin);
		(this as any).os.stream.dispose(this.connectionId);
	},
	methods: {
		onSignin(signin) {
			this.signins.unshift(signin);
		}
	}
});
</script>

<style lang="stylus" scoped>
.root
	> .signins
		> div
			border-bottom solid 1px #eee

			> header
				display flex
				padding 8px 0
				line-height 32px
				cursor pointer

				> [data-fa]
					margin-right 8px
					text-align left

					&.check
						color #0fda82

					&.times
						color #ff3100

				> .ip
					display inline-block
					text-align left
					padding 8px
					line-height 16px
					font-family monospace
					font-size 14px
					color #444
					background #f8f8f8
					border-radius 4px

				> .mk-time
					margin-left auto
					text-align right
					color #777

			> .headers
				overflow auto
				margin 0 0 16px 0
				max-height 100px
				white-space pre-wrap
				word-break break-all

</style>