From a1ccd392f520952603a9aa174da9a17978363109 Mon Sep 17 00:00:00 2001 From: Cris Date: Tue, 25 Oct 2022 14:28:25 +0200 Subject: [PATCH] Added News Widget --- public/js/components/DashboardWidget/News.js | 115 +++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 public/js/components/DashboardWidget/News.js diff --git a/public/js/components/DashboardWidget/News.js b/public/js/components/DashboardWidget/News.js new file mode 100644 index 000000000..6b5fc73d1 --- /dev/null +++ b/public/js/components/DashboardWidget/News.js @@ -0,0 +1,115 @@ +import AbstractWidget from './Abstract'; +import BsModal from '../Bootstrap/Modal'; +const MAX_LOADED_NEWS = 10; + +export default { + name: 'WidgetsNews', + components: { BsModal }, + data: () => ({ + allNewsList: [], + singleNews: {} + }), + mixins: [ + AbstractWidget + ], + computed: { + newsList(){ + //Return news amount depending on widget width and size + let quantity = this.width; + + if (this.width === 1) { + quantity = this.height === 1 ? 4 : 10; + } + + return this.allNewsList.slice(0, quantity); + } + }, + created(){ + axios + .get(this.apiurl + '/dashboard/Api/getNews', {params: {limit: MAX_LOADED_NEWS}}) + .then(res => { this.allNewsList = res.data }) + .catch(err => { console.error('ERROR: ', err.response.data) }); + + this.$emit('setConfig', false); + }, + methods: { + setSingleNews(singleNews){ + this.singleNews = singleNews; + this.$refs.newsModal.show(); + } + }, + template: `
+
+
+
Top News
+ + Alle News +
+
+
+
+
+ {{ news.betreff }}
+ {{ formatDateTime(news.insertamum) }} +
+
+
+
+
+
+
+
+ {{ news.betreff }}
+ {{ formatDateTime(news.insertamum) }} +

{{ news.text }}

+
+
+
+
+
+
+
+ + +
+ {{ news.betreff }}
+

{{ news.text }}

+
+
+
+
+
+
+ + + + + + + + + + + + ` +} \ No newline at end of file