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