Bereinigen und Entfernen von nicht mehr benötigten TinyMCE-Dateien und -Plugins; Aktualisierung der Internationalisierung für Deutsch und Englisch in den Falukant- und Navigationsmodulen; Verbesserung der Statusleiste und Router-Implementierung.
This commit is contained in:
150
frontend/src/components/falukant/MessagesDialog.vue
Normal file
150
frontend/src/components/falukant/MessagesDialog.vue
Normal file
@@ -0,0 +1,150 @@
|
||||
<template>
|
||||
<DialogWidget
|
||||
ref="dlg"
|
||||
name="falukant-messages"
|
||||
:title="'falukant.messages.title'"
|
||||
:isTitleTranslated="true"
|
||||
icon="falukant/messages24.png"
|
||||
:buttons="[{ text: 'message.close', action: 'close' }]"
|
||||
width="520px"
|
||||
height="420px"
|
||||
>
|
||||
<ul class="messages">
|
||||
<li v-for="n in messages" :key="n.id" :class="{ unread: !n.shown }">
|
||||
<div class="body">{{ $t(n.tr) }}</div>
|
||||
<div class="footer">
|
||||
<span>{{ formatDate(n.createdAt) }}</span>
|
||||
</div>
|
||||
</li>
|
||||
<li v-if="messages.length === 0" class="empty">{{ $t('falukant.messages.empty') }}</li>
|
||||
</ul>
|
||||
<div class="pagination" v-if="total > size">
|
||||
<button @click="firstPage" :disabled="!canPrev">«</button>
|
||||
<button @click="prevPage" :disabled="!canPrev">‹</button>
|
||||
<span>
|
||||
<input type="number" min="1" :max="totalPages" v-model.number="pageInput" @change="goToPage(pageInput)" />
|
||||
/ {{ totalPages }}
|
||||
</span>
|
||||
<button @click="nextPage" :disabled="!canNext">›</button>
|
||||
<button @click="lastPage" :disabled="!canNext">»</button>
|
||||
</div>
|
||||
</DialogWidget>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DialogWidget from '@/components/DialogWidget.vue';
|
||||
import apiClient from '@/utils/axios.js';
|
||||
|
||||
export default {
|
||||
name: 'FalukantMessagesDialog',
|
||||
components: { DialogWidget },
|
||||
data() {
|
||||
return {
|
||||
messages: [],
|
||||
page: 1,
|
||||
size: 10,
|
||||
total: 0,
|
||||
pageInput: 1,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async open() {
|
||||
this.page = 1;
|
||||
this.pageInput = 1;
|
||||
await this.load();
|
||||
this.$refs.dlg.open();
|
||||
// mark unread as shown
|
||||
try { await apiClient.post('/api/falukant/notifications/mark-shown'); } catch {}
|
||||
},
|
||||
async load() {
|
||||
try {
|
||||
const { data } = await apiClient.get('/api/falukant/notifications/all', { params: { page: this.page, size: this.size } });
|
||||
if (data && Array.isArray(data.items)) {
|
||||
this.messages = data.items;
|
||||
this.total = data.total || 0;
|
||||
} else {
|
||||
this.messages = Array.isArray(data) ? data : [];
|
||||
this.total = this.messages.length;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load messages', e);
|
||||
this.messages = [];
|
||||
this.total = 0;
|
||||
}
|
||||
},
|
||||
nextPage() {
|
||||
if (this.page < this.totalPages) {
|
||||
this.page++;
|
||||
this.pageInput = this.page;
|
||||
this.load();
|
||||
}
|
||||
},
|
||||
prevPage() {
|
||||
if (this.page > 1) {
|
||||
this.page--;
|
||||
this.pageInput = this.page;
|
||||
this.load();
|
||||
}
|
||||
},
|
||||
firstPage() {
|
||||
if (this.page !== 1) {
|
||||
this.page = 1;
|
||||
this.pageInput = 1;
|
||||
this.load();
|
||||
}
|
||||
},
|
||||
lastPage() {
|
||||
if (this.page !== this.totalPages) {
|
||||
this.page = this.totalPages;
|
||||
this.pageInput = this.page;
|
||||
this.load();
|
||||
}
|
||||
},
|
||||
goToPage(val) {
|
||||
let v = Number(val) || 1;
|
||||
if (v < 1) v = 1;
|
||||
if (v > this.totalPages) v = this.totalPages;
|
||||
if (v !== this.page) {
|
||||
this.page = v;
|
||||
this.pageInput = v;
|
||||
this.load();
|
||||
} else {
|
||||
this.pageInput = v;
|
||||
}
|
||||
},
|
||||
formatDate(dt) {
|
||||
try {
|
||||
return new Date(dt).toLocaleString();
|
||||
} catch { return dt; }
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
totalPages() {
|
||||
return Math.max(1, Math.ceil(this.total / this.size));
|
||||
},
|
||||
canPrev() { return this.page > 1; },
|
||||
canNext() { return this.page < this.totalPages; }
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.messages {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.messages > li { border: 1px solid #7BBE55; margin-bottom: .25em; padding: .5em; }
|
||||
.messages > li.unread { font-weight: bold; }
|
||||
.messages > li .footer { color: #f9a22c; font-size: .8em; margin-top: .3em; display: flex; }
|
||||
.messages > li .footer span:first-child { flex: 1; }
|
||||
.empty { text-align: center; color: #777; padding: 1em; }
|
||||
.pagination {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: .5em;
|
||||
margin-top: .5em;
|
||||
}
|
||||
.pagination button { padding: .25em .6em; }
|
||||
.pagination input[type="number"] { width: 4em; text-align: right; }
|
||||
</style>
|
||||
@@ -1,8 +1,20 @@
|
||||
<template>
|
||||
<div class="statusbar">
|
||||
<div class="status-item messages" @click="openMessages" :title="$t('falukant.messages.tooltip')">
|
||||
<span class="badge" v-if="unreadCount > 0">{{ unreadCount }}</span>
|
||||
<img src="/images/icons/falukant/messages24.png" class="menu-icon" />
|
||||
</div>
|
||||
<template v-for="item in statusItems" :key="item.key">
|
||||
<div class="status-item" v-if="item.value !== null && item.image == null" :title="$t(`falukant.statusbar.${item.key}`)">
|
||||
<span class="status-icon">{{ item.icon }}: {{ item.value }}</span>
|
||||
<span class="status-icon">
|
||||
<template v-if="item.iconImage">
|
||||
<img :src="'/images/icons/' + item.iconImage" class="inline-icon" width="16" height="16" />:
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ item.icon }}:
|
||||
</template>
|
||||
{{ item.value }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="status-item" v-else-if="item.image !== null" :title="$t(`falukant.statusbar.${item.key}`)">
|
||||
<span class="status-icon">{{ item.icon }}:</span> <img :src="'/images/icons/falukant/relationship-' + item.image + '.png'" class="relationship-icon" />
|
||||
@@ -13,24 +25,29 @@
|
||||
<img :src="'/images/icons/falukant/shortmap/' + key + '.png'" class="menu-icon" @click="openPage(menuItem)" :title="$t(`navigation.m-falukant.${key}`)" />
|
||||
</template>
|
||||
</span>
|
||||
<MessagesDialog ref="msgs" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState, mapGetters } from "vuex";
|
||||
import apiClient from "@/utils/axios.js";
|
||||
import MessagesDialog from './MessagesDialog.vue';
|
||||
|
||||
export default {
|
||||
name: "StatusBar",
|
||||
components: { MessagesDialog },
|
||||
data() {
|
||||
return {
|
||||
statusItems: [
|
||||
{ key: "age", icon: "👶", value: 0 },
|
||||
{ key: "age", icon: null, iconImage: 'falukant/age.png', value: 0 },
|
||||
{ key: "relationship", icon: "💑", image: null },
|
||||
{ key: "wealth", icon: "💰", value: 0 },
|
||||
{ key: "health", icon: "❤️", value: "Good" },
|
||||
{ key: "events", icon: "📰", value: null, image: null },
|
||||
{ key: "children", icon: "👶", value: null },
|
||||
],
|
||||
unreadCount: 0,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -38,7 +55,7 @@ export default {
|
||||
...mapGetters(['menu']),
|
||||
},
|
||||
async mounted() {
|
||||
await this.fetchStatus();
|
||||
await this.fetchStatus();
|
||||
if (this.socket) {
|
||||
this.socket.on("falukantUpdateStatus", this.fetchStatus);
|
||||
}
|
||||
@@ -63,6 +80,11 @@ export default {
|
||||
const relationship = response.data.character.relationshipsAsCharacter1[0]?.relationshipType?.tr
|
||||
|| response.data.character.relationshipsAsCharacter2[0]?.relationshipType?.tr
|
||||
|| null;
|
||||
// Children counts and unread notifications are now part of /info
|
||||
const childCount = Number(response.data.childrenCount) || 0;
|
||||
const unbaptisedCount = Number(response.data.unbaptisedChildrenCount) || 0;
|
||||
this.unreadCount = Number(response.data.unreadNotifications) || 0;
|
||||
const childrenDisplay = `${childCount}${unbaptisedCount > 0 ? `(${unbaptisedCount})` : ''}`;
|
||||
let healthStatus = '';
|
||||
if (health > 90) {
|
||||
healthStatus = this.$t("falukant.health.amazing");
|
||||
@@ -76,11 +98,12 @@ export default {
|
||||
healthStatus = this.$t("falukant.health.very_bad");
|
||||
}
|
||||
this.statusItems = [
|
||||
{ key: "age", icon: "👶", value: age },
|
||||
{ key: "age", icon: null, iconImage: 'falukant/age.png', value: age },
|
||||
{ key: "relationship", icon: "💑", image: relationship },
|
||||
{ key: "wealth", icon: "💰", value: Intl.NumberFormat(navigator.language, { minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(money) },
|
||||
{ key: "health", icon: "❤️", value: healthStatus },
|
||||
{ key: "events", icon: "📰", value: events || null, image: null },
|
||||
{ key: "children", icon: "👶", value: childrenDisplay },
|
||||
];
|
||||
} catch (error) {
|
||||
console.error("Error fetching status:", error);
|
||||
@@ -95,6 +118,9 @@ export default {
|
||||
if (data.event === "falukantUpdateStatus") {
|
||||
this.fetchStatus();
|
||||
}
|
||||
if (data.event === 'stock_change' || data.event === 'familychanged') {
|
||||
this.fetchStatus();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error parsing daemonSocket message:", error, event.data);
|
||||
}
|
||||
@@ -107,6 +133,11 @@ export default {
|
||||
this.$router.push(url);
|
||||
}
|
||||
},
|
||||
openMessages() {
|
||||
this.$refs.msgs.open();
|
||||
// After opening, refresh unread count after a short delay (server marks them shown)
|
||||
setTimeout(() => this.fetchStatus(), 500);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -147,4 +178,26 @@ export default {
|
||||
max-width: 24px;
|
||||
max-height: 24px;
|
||||
}
|
||||
|
||||
.messages { position: relative; }
|
||||
.badge {
|
||||
position: absolute;
|
||||
top: -6px;
|
||||
right: -2px;
|
||||
background: #e53935;
|
||||
color: #fff;
|
||||
border-radius: 10px;
|
||||
padding: 0 6px;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
min-width: 18px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.inline-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
vertical-align: middle;
|
||||
margin-right: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user