summaryrefslogtreecommitdiff
path: root/src/web/app/desktop/views/components/widgets/channel.vue
blob: 5c3afd9ecf1c99f104a52e63cc69054e08a01b67 (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
106
107
<template>
<div class="mkw-channel">
	<template v-if="!props.compact">
		<p class="title">%fa:tv%{{ channel ? channel.title : '%i18n:desktop.tags.mk-channel-home-widget.title%' }}</p>
		<button @click="settings" title="%i18n:desktop.tags.mk-channel-home-widget.settings%">%fa:cog%</button>
	</template>
	<p class="get-started" v-if="props.channel == null">%i18n:desktop.tags.mk-channel-home-widget.get-started%</p>
	<x-channel class="channel" :channel="channel" v-if="channel != null"/>
</div>
</template>

<script lang="ts">
import define from '../../../../common/define-widget';
import XChannel from './channel.channel.vue';

export default define({
	name: 'server',
	props: () => ({
		channel: null,
		compact: false
	})
}).extend({
	components: {
		XChannel
	},
	data() {
		return {
			fetching: true,
			channel: null
		};
	},
	mounted() {
		if (this.props.channel) {
				this.zap();
			}
	},
	methods: {
		func() {
			this.props.compact = !this.props.compact;
		},
		settings() {
			const id = window.prompt('チャンネルID');
			if (!id) return;
			this.props.channel = id;
			this.zap();
		},
		zap() {
			this.fetching = true;

			(this as any).api('channels/show', {
				channel_id: this.props.channel
			}).then(channel => {
				this.channel = channel;
				this.fetching = false;
			});
		}
	}
});
</script>

<style lang="stylus" scoped>
.mkw-channel
	background #fff
	border solid 1px rgba(0, 0, 0, 0.075)
	border-radius 6px
	overflow hidden

	> .title
		z-index 2
		margin 0
		padding 0 16px
		line-height 42px
		font-size 0.9em
		font-weight bold
		color #888
		box-shadow 0 1px rgba(0, 0, 0, 0.07)

		> [data-fa]
			margin-right 4px

	> button
		position absolute
		z-index 2
		top 0
		right 0
		padding 0
		width 42px
		font-size 0.9em
		line-height 42px
		color #ccc

		&:hover
			color #aaa

		&:active
			color #999

	> .get-started
		margin 0
		padding 16px
		text-align center
		color #aaa

	> .channel
		height 200px

</style>