2020-01-29 21:37:25 +02:00
|
|
|
<template>
|
2020-10-17 14:12:00 +03:00
|
|
|
<MkContainer :show-header="props.showHeader" :style="`height: ${props.height}px;`" :scrollable="true">
|
2020-07-11 04:13:11 +03:00
|
|
|
<template #header>
|
|
|
|
<button @click="choose" class="_button">
|
2021-04-20 17:22:59 +03:00
|
|
|
<i v-if="props.src === 'home'" class="fas fa-home"></i>
|
|
|
|
<i v-else-if="props.src === 'local'" class="fas fa-comments"></i>
|
|
|
|
<i v-else-if="props.src === 'social'" class="fas fa-share-alt"></i>
|
|
|
|
<i v-else-if="props.src === 'global'" class="fas fa-globe"></i>
|
|
|
|
<i v-else-if="props.src === 'list'" class="fas fa-list-ul"></i>
|
|
|
|
<i v-else-if="props.src === 'antenna'" class="fas fa-satellite"></i>
|
2020-07-11 04:13:11 +03:00
|
|
|
<span style="margin-left: 8px;">{{ props.src === 'list' ? props.list.name : props.src === 'antenna' ? props.antenna.name : $t('_timelines.' + props.src) }}</span>
|
2021-04-20 17:22:59 +03:00
|
|
|
<i :class="menuOpened ? 'fas fa-angle-up' : 'fas fa-angle-down'" style="margin-left: 8px;"></i>
|
2020-07-11 04:13:11 +03:00
|
|
|
</button>
|
|
|
|
</template>
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2020-07-11 04:13:11 +03:00
|
|
|
<div>
|
2020-10-17 14:12:00 +03:00
|
|
|
<XTimeline :key="props.src === 'list' ? `list:${props.list.id}` : props.src === 'antenna' ? `antenna:${props.antenna.id}` : props.src" :src="props.src" :list="props.list ? props.list.id : null" :antenna="props.antenna ? props.antenna.id : null"/>
|
2020-07-11 04:13:11 +03:00
|
|
|
</div>
|
2020-10-17 14:12:00 +03:00
|
|
|
</MkContainer>
|
2020-01-29 21:37:25 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 14:12:00 +03:00
|
|
|
import { defineComponent } from 'vue';
|
2021-03-23 10:30:14 +02:00
|
|
|
import MkContainer from '@client/components/ui/container.vue';
|
|
|
|
import XTimeline from '@client/components/timeline.vue';
|
2020-01-29 21:37:25 +02:00
|
|
|
import define from './define';
|
2021-03-23 10:30:14 +02:00
|
|
|
import * as os from '@client/os';
|
2020-01-29 21:37:25 +02:00
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
const widget = define({
|
2020-01-29 21:37:25 +02:00
|
|
|
name: 'timeline',
|
|
|
|
props: () => ({
|
2020-07-11 04:13:11 +03:00
|
|
|
showHeader: {
|
|
|
|
type: 'boolean',
|
|
|
|
default: true,
|
|
|
|
},
|
2020-07-11 18:19:47 +03:00
|
|
|
height: {
|
|
|
|
type: 'number',
|
|
|
|
default: 300,
|
|
|
|
},
|
2020-07-11 04:13:11 +03:00
|
|
|
src: {
|
|
|
|
type: 'string',
|
|
|
|
default: 'home',
|
|
|
|
hidden: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
type: 'object',
|
|
|
|
default: null,
|
|
|
|
hidden: true,
|
|
|
|
},
|
2020-01-29 21:37:25 +02:00
|
|
|
})
|
2020-10-17 14:12:00 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
extends: widget,
|
2020-01-29 21:37:25 +02:00
|
|
|
components: {
|
|
|
|
MkContainer,
|
|
|
|
XTimeline,
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
menuOpened: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async choose(ev) {
|
|
|
|
this.menuOpened = true;
|
|
|
|
const [antennas, lists] = await Promise.all([
|
2020-10-17 14:12:00 +03:00
|
|
|
os.api('antennas/list'),
|
|
|
|
os.api('users/lists/list')
|
2020-01-29 21:37:25 +02:00
|
|
|
]);
|
|
|
|
const antennaItems = antennas.map(antenna => ({
|
|
|
|
text: antenna.name,
|
2021-04-20 17:22:59 +03:00
|
|
|
icon: 'fas fa-satellite',
|
2020-01-29 21:37:25 +02:00
|
|
|
action: () => {
|
|
|
|
this.props.antenna = antenna;
|
|
|
|
this.setSrc('antenna');
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
const listItems = lists.map(list => ({
|
|
|
|
text: list.name,
|
2021-04-20 17:22:59 +03:00
|
|
|
icon: 'fas fa-list-ul',
|
2020-01-29 21:37:25 +02:00
|
|
|
action: () => {
|
|
|
|
this.props.list = list;
|
|
|
|
this.setSrc('list');
|
|
|
|
}
|
|
|
|
}));
|
2020-10-17 14:12:00 +03:00
|
|
|
os.modalMenu([{
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts._timelines.home,
|
2021-04-20 17:22:59 +03:00
|
|
|
icon: 'fas fa-home',
|
2020-10-17 14:12:00 +03:00
|
|
|
action: () => { this.setSrc('home') }
|
|
|
|
}, {
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts._timelines.local,
|
2021-04-20 17:22:59 +03:00
|
|
|
icon: 'fas fa-comments',
|
2020-10-17 14:12:00 +03:00
|
|
|
action: () => { this.setSrc('local') }
|
|
|
|
}, {
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts._timelines.social,
|
2021-04-20 17:22:59 +03:00
|
|
|
icon: 'fas fa-share-alt',
|
2020-10-17 14:12:00 +03:00
|
|
|
action: () => { this.setSrc('social') }
|
|
|
|
}, {
|
2020-12-26 03:47:36 +02:00
|
|
|
text: this.$ts._timelines.global,
|
2021-04-20 17:22:59 +03:00
|
|
|
icon: 'fas fa-globe',
|
2020-10-17 14:12:00 +03:00
|
|
|
action: () => { this.setSrc('global') }
|
|
|
|
}, antennaItems.length > 0 ? null : undefined, ...antennaItems, listItems.length > 0 ? null : undefined, ...listItems], ev.currentTarget || ev.target).then(() => {
|
2020-01-29 21:37:25 +02:00
|
|
|
this.menuOpened = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
setSrc(src) {
|
|
|
|
this.props.src = src;
|
|
|
|
this.save();
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|