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