2018-02-06 23:16:01 -07:00
|
|
|
<template>
|
2018-02-26 03:23:53 -07:00
|
|
|
<div class="mk-stream-indicator">
|
2018-10-07 04:35:25 -06:00
|
|
|
<p v-if="stream.state == 'initializing'">
|
2018-11-05 09:40:11 -07:00
|
|
|
<fa icon="spinner .pulse"/>
|
2018-11-08 11:44:35 -07:00
|
|
|
<span>{{ $t('connecting') }}<mk-ellipsis/></span>
|
2018-02-16 11:01:00 -07:00
|
|
|
</p>
|
2018-10-07 04:35:25 -06:00
|
|
|
<p v-if="stream.state == 'reconnecting'">
|
2018-11-05 09:40:11 -07:00
|
|
|
<fa icon="spinner .pulse"/>
|
2018-11-08 11:44:35 -07:00
|
|
|
<span>{{ $t('reconnecting') }}<mk-ellipsis/></span>
|
2018-02-16 11:01:00 -07:00
|
|
|
</p>
|
2018-10-07 04:35:25 -06:00
|
|
|
<p v-if="stream.state == 'connected'">
|
2018-11-05 09:40:11 -07:00
|
|
|
<fa icon="check"/>
|
2018-11-08 11:44:35 -07:00
|
|
|
<span>{{ $t('connected') }}</span>
|
2018-02-16 11:01:00 -07:00
|
|
|
</p>
|
|
|
|
</div>
|
2018-02-06 23:16:01 -07:00
|
|
|
</template>
|
|
|
|
|
2018-02-16 11:01:00 -07:00
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 11:44:35 -07:00
|
|
|
import i18n from '../../../i18n';
|
2018-02-16 11:01:00 -07:00
|
|
|
import * as anime from 'animejs';
|
2018-02-06 23:16:01 -07:00
|
|
|
|
2018-02-16 11:01:00 -07:00
|
|
|
export default Vue.extend({
|
2018-11-08 11:44:35 -07:00
|
|
|
i18n: i18n('common/views/components/stream-indicator.vue'),
|
2018-02-26 03:23:53 -07:00
|
|
|
computed: {
|
|
|
|
stream() {
|
2018-10-07 04:35:25 -06:00
|
|
|
return (this as any).os.stream;
|
2018-02-26 03:23:53 -07:00
|
|
|
}
|
2018-02-16 11:01:00 -07:00
|
|
|
},
|
|
|
|
created() {
|
2018-02-26 03:23:53 -07:00
|
|
|
(this as any).os.stream.on('_connected_', this.onConnected);
|
|
|
|
(this as any).os.stream.on('_disconnected_', this.onDisconnected);
|
2018-02-16 11:01:00 -07:00
|
|
|
|
|
|
|
this.$nextTick(() => {
|
2018-02-06 23:16:01 -07:00
|
|
|
if (this.stream.state == 'connected') {
|
2018-02-16 11:01:00 -07:00
|
|
|
this.$el.style.opacity = '0';
|
2018-02-06 23:16:01 -07:00
|
|
|
}
|
2018-02-16 11:01:00 -07:00
|
|
|
});
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2018-02-26 03:23:53 -07:00
|
|
|
(this as any).os.stream.off('_connected_', this.onConnected);
|
|
|
|
(this as any).os.stream.off('_disconnected_', this.onDisconnected);
|
2018-02-16 11:01:00 -07:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onConnected() {
|
|
|
|
setTimeout(() => {
|
2018-02-06 23:16:01 -07:00
|
|
|
anime({
|
2018-02-16 11:01:00 -07:00
|
|
|
targets: this.$el,
|
|
|
|
opacity: 0,
|
2018-02-06 23:16:01 -07:00
|
|
|
easing: 'linear',
|
2018-02-16 11:01:00 -07:00
|
|
|
duration: 200
|
2018-02-06 23:16:01 -07:00
|
|
|
});
|
2018-02-16 11:01:00 -07:00
|
|
|
}, 1000);
|
|
|
|
},
|
|
|
|
onDisconnected() {
|
|
|
|
anime({
|
|
|
|
targets: this.$el,
|
|
|
|
opacity: 1,
|
|
|
|
easing: 'linear',
|
|
|
|
duration: 100
|
2018-02-06 23:16:01 -07:00
|
|
|
});
|
|
|
|
}
|
2018-02-16 11:01:00 -07:00
|
|
|
}
|
|
|
|
});
|
2018-02-06 23:16:01 -07:00
|
|
|
</script>
|
|
|
|
|
2018-02-07 02:30:17 -07:00
|
|
|
<style lang="stylus" scoped>
|
2018-02-16 11:01:00 -07:00
|
|
|
.mk-stream-indicator
|
|
|
|
pointer-events none
|
|
|
|
position fixed
|
|
|
|
z-index 16384
|
|
|
|
bottom 8px
|
|
|
|
right 8px
|
|
|
|
margin 0
|
|
|
|
padding 6px 12px
|
|
|
|
font-size 0.9em
|
|
|
|
color #fff
|
2018-04-28 17:51:17 -06:00
|
|
|
background rgba(#000, 0.8)
|
2018-02-16 11:01:00 -07:00
|
|
|
border-radius 4px
|
|
|
|
|
|
|
|
> p
|
2018-02-06 23:16:01 -07:00
|
|
|
display block
|
|
|
|
margin 0
|
|
|
|
|
2018-11-05 09:40:11 -07:00
|
|
|
> [data-icon]
|
2018-02-16 11:01:00 -07:00
|
|
|
margin-right 0.25em
|
2018-02-06 23:16:01 -07:00
|
|
|
|
|
|
|
</style>
|