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