summaryrefslogtreecommitdiffstats
path: root/src/components/ItemDashboard.vue
blob: a7a0f4e0c34fa3692c975dca2ce4f393df4dfbe5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<template>
	<NcDashboardWidget :items="items">
		<template #default="{ item }">
			<NcDashboardWidgetItem
				:main-text="item.mainText"
				:sub-text="item.subText"
				:target-url="item.targetURL">

			<NcDashboardWidgetItem>
		</template>
	</NcDashboardWidget>
</template>

<script>
import NcDashboardWidget from '@nextcloud/vue/dist/Components/NcDashboardWidget.js'
import NcDashboardWidgetItem from '@nextcloud/vue/dist/Components/NcDashboardWidgetItem'
import { loadState } from '@nextcloud/initial-state'
import { generateUrl } from '@nextcloud/router'

const newsItems = loadState('news', 'dashboard-widget-items')

console.log(newsItems)

export default {
	name: 'NewsItemWidget',
	components: {
		NcDashboardWidget,
		NcDashboardWidgetItem,
	},
	props: [],
	data() {
		return {
			newsItems: newsItems
		}
	},

	computed: {
		items() {
			return this.newsItems.map((g) => {
				return {
					id: g.id,
					mainText: g.title,
					subText: g.intro,
					targetURL: generateUrl(`/apps/news/#/items/feeds/${g.feedId}`)
				}
			})
		}
	}
}
</script>