70 lines
1.7 KiB
Vue
70 lines
1.7 KiB
Vue
<script setup>
|
|
import { Card, Btn } from "@3ba/vue";
|
|
import Alert from "../components/Alert.vue"
|
|
</script>
|
|
|
|
<template>
|
|
<div style="display: flex; flex-direction: column; gap: 20px;">
|
|
<template v-for="hearsay in news">
|
|
<Alert style="display: flex; text-align: left;" :tone="info ? 'info' : 'warn'" :timestamp="hearsay.updated_at" :title="hearsay.title + ' (' + hearsay.author + ')'"
|
|
v-if="(hearsay.type==='important' && important) || (hearsay.type==='info' && info)">{{ hearsay.body }}</Alert>
|
|
</template>
|
|
<h2 v-if="!has_important && important">Nincs semmi halaszthatatlan hír</h2>
|
|
<h2 v-if="!has_info && info">Nincs semmi tájékoztató jellegű hír</h2>
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios';
|
|
|
|
let interval;
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
news: [],
|
|
has_info: false,
|
|
has_important: false,
|
|
}
|
|
},
|
|
props: {
|
|
important: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
info: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
},
|
|
mounted() {
|
|
const call = () =>
|
|
{
|
|
axios
|
|
.get('/api/fetch_news')
|
|
.then(response => {
|
|
this.news = response.data;
|
|
for (const i of response.data) {
|
|
if (i.type=='info') this.has_info = true;
|
|
if (i.type=='important') this.has_important = true;
|
|
}
|
|
});
|
|
}
|
|
|
|
call();
|
|
|
|
interval = setInterval( call , 10000 );
|
|
},
|
|
unmounted() {
|
|
clearInterval(interval);
|
|
}
|
|
};
|
|
|
|
</script>
|
|
|
|
<style scoped>
|
|
div {
|
|
text-align: left !important;
|
|
}
|
|
</style> |