diff options
author | Benjamin Brahmer <info@b-brahmer.de> | 2023-02-24 16:35:32 +0100 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2023-03-01 17:23:12 +0100 |
commit | a131dd3aa27fe31cb126396d1c606a29266a27be (patch) | |
tree | 310280ed0fa654dd3b9340cc0b6e1ce4f16814fe /src | |
parent | 7dfa18973ad448a4aa0b18884b68fdf85d649b2b (diff) |
draft first dashboarddashboard
Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/FeedDashboard.vue | 53 | ||||
-rw-r--r-- | src/components/ItemDashboard.vue | 50 | ||||
-rw-r--r-- | src/dashboard-feeds.js | 11 | ||||
-rw-r--r-- | src/dashboard-items.js | 11 | ||||
-rw-r--r-- | src/vueBootstrap.js | 7 |
5 files changed, 132 insertions, 0 deletions
diff --git a/src/components/FeedDashboard.vue b/src/components/FeedDashboard.vue new file mode 100644 index 000000000..f917ebf36 --- /dev/null +++ b/src/components/FeedDashboard.vue @@ -0,0 +1,53 @@ +<template> + <NcDashboardWidget :items="items"> + <template #default="{ item }"> + <NcDashboardWidgetItem + :main-text="item.mainText" + :sub-text="item.subText" + :target-url="item.targetURL" + :avatar-is-no-user="true" + :avatar-url="item.favicon"> + + <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-feeds') + +console.log(newsItems) + +export default { + name: 'NewsFeedWidget', + components: { + NcDashboardWidget, + NcDashboardWidgetItem, + }, + props: [], + data() { + return { + newsItems: newsItems + } + }, + + computed: { + items() { + return this.newsItems.map((g) => { + return { + id: g.id, + mainText: g.title, + subText: `Unread: ${g.unreadCount}`, + targetURL: generateUrl(`/apps/news/#/items/feeds/${g.id}`), + favicon: g.faviconLink, + } + }) + } + } +} +</script>
\ No newline at end of file diff --git a/src/components/ItemDashboard.vue b/src/components/ItemDashboard.vue new file mode 100644 index 000000000..a7a0f4e0c --- /dev/null +++ b/src/components/ItemDashboard.vue @@ -0,0 +1,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>
\ No newline at end of file diff --git a/src/dashboard-feeds.js b/src/dashboard-feeds.js new file mode 100644 index 000000000..1ae896414 --- /dev/null +++ b/src/dashboard-feeds.js @@ -0,0 +1,11 @@ +import Vue from 'vue' +import NewsFeedWidget from './components/FeedDashboard.vue' + +document.addEventListener('DOMContentLoaded', () => { + console.log("I'm alive") + OCA.Dashboard.register('news-feed-widget', (el) => { + console.log("Dashboard registered") + const View = Vue.extend(NewsFeedWidget) + new View().$mount(el) + }) +}) diff --git a/src/dashboard-items.js b/src/dashboard-items.js new file mode 100644 index 000000000..564d10d62 --- /dev/null +++ b/src/dashboard-items.js @@ -0,0 +1,11 @@ +import Vue from 'vue' +import NewsItemWidget from './components/ItemDashboard.vue' + +document.addEventListener('DOMContentLoaded', () => { + console.log("I'm alive") + OCA.Dashboard.register('news-item-widget', (el) => { + console.log("Dashboard registered") + const View = Vue.extend(NewsItemWidget) + new View().$mount(el) + }) +}) diff --git a/src/vueBootstrap.js b/src/vueBootstrap.js new file mode 100644 index 000000000..fec6f7a09 --- /dev/null +++ b/src/vueBootstrap.js @@ -0,0 +1,7 @@ +import Vue from 'vue' +import { translate, translatePlural } from '@nextcloud/l10n' + +Vue.prototype.t = translate +Vue.prototype.n = translatePlural +Vue.prototype.OC = window.OC +Vue.prototype.OCA = window.OCA
\ No newline at end of file |