Add command table functionality to chat store and ChatView component

- Introduced `commandTable` state in chat store to manage command output.
- Implemented WebSocket listener for `commandTable` messages.
- Enhanced ChatView.vue to display command table with dynamic content and styling.
- Added `clearCommandTable` method to reset command table state.
- Updated server broadcast logic to send structured command table data for various statistics.
This commit is contained in:
Torsten Schulz (local)
2026-03-19 14:00:08 +01:00
parent 51040391e8
commit 448f2ffb6f
3 changed files with 130 additions and 13 deletions

View File

@@ -21,6 +21,7 @@ export const useChatStore = defineStore('chat', () => {
const historyResults = ref([]);
const unreadChatsCount = ref(0);
const errorMessage = ref(null);
const commandTable = ref(null);
const remainingSecondsToTimeout = ref(1800);
const awaitingLoginUsername = ref(false);
const awaitingLoginPassword = ref(false);
@@ -191,6 +192,10 @@ export const useChatStore = defineStore('chat', () => {
handleWebSocketMessage({ type: 'commandResult', ...data });
});
socketInstance.on('commandTable', (data) => {
handleWebSocketMessage({ type: 'commandTable', ...data });
});
socketInstance.on('unreadChats', (data) => {
handleWebSocketMessage({ type: 'unreadChats', ...data });
});
@@ -315,6 +320,15 @@ export const useChatStore = defineStore('chat', () => {
}, 5000);
break;
}
case 'commandTable': {
const title = data.title || 'Ausgabe';
const columns = Array.isArray(data.columns) ? data.columns : [];
const rows = Array.isArray(data.rows) ? data.rows : [];
commandTable.value = { title, columns, rows };
// Tabelle ist persistent; temporäre Fehlermeldung löschen
errorMessage.value = null;
break;
}
case 'unreadChats':
unreadChatsCount.value = data.count || 0;
break;
@@ -543,6 +557,10 @@ export const useChatStore = defineStore('chat', () => {
socket.value.emit('requestOpenConversations');
}
function clearCommandTable() {
commandTable.value = null;
}
function setView(view) {
currentView.value = view;
@@ -574,6 +592,7 @@ export const useChatStore = defineStore('chat', () => {
searchResults.value = [];
inboxResults.value = [];
historyResults.value = [];
commandTable.value = null;
searchData.value = {
nameIncludes: '',
minAge: null,
@@ -689,6 +708,7 @@ export const useChatStore = defineStore('chat', () => {
unreadChatsCount,
remainingSecondsToTimeout,
errorMessage,
commandTable,
searchData,
awaitingLoginUsername,
awaitingLoginPassword,
@@ -703,6 +723,7 @@ export const useChatStore = defineStore('chat', () => {
userSearch,
requestHistory,
requestOpenConversations,
clearCommandTable,
setView,
logout,
restoreSession