Some checks failed
Tests / Go Tests (push) Has been cancelled
Tests / Python Tests (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / Go Lint (push) Has been cancelled
Tests / Python Lint (push) Has been cancelled
Tests / Security Scan (push) Has been cancelled
Tests / All Checks Passed (push) Has been cancelled
Security Scanning / Secret Scanning (push) Has been cancelled
Security Scanning / Dependency Vulnerability Scan (push) Has been cancelled
Security Scanning / Go Security Scan (push) Has been cancelled
Security Scanning / Python Security Scan (push) Has been cancelled
Security Scanning / Node.js Security Scan (push) Has been cancelled
Security Scanning / Docker Image Security (push) Has been cancelled
Security Scanning / Security Summary (push) Has been cancelled
CI/CD Pipeline / Go Tests (push) Has been cancelled
CI/CD Pipeline / Python Tests (push) Has been cancelled
CI/CD Pipeline / Website Tests (push) Has been cancelled
CI/CD Pipeline / Linting (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Docker Build & Push (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / CI Summary (push) Has been cancelled
ci/woodpecker/manual/build-ci-image Pipeline was successful
ci/woodpecker/manual/main Pipeline failed
All services: admin-v2, studio-v2, website, ai-compliance-sdk, consent-service, klausur-service, voice-service, and infrastructure. Large PDFs and compiled binaries excluded via .gitignore.
290 lines
6.9 KiB
Python
290 lines
6.9 KiB
Python
"""
|
|
Matrix Chat Widget fuer das Lehrer-Dashboard.
|
|
|
|
Zeigt die letzten Chat-Nachrichten aus dem Matrix Messenger.
|
|
"""
|
|
|
|
|
|
class MatrixWidget:
|
|
widget_id = 'matrix'
|
|
widget_name = 'Matrix-Chat'
|
|
widget_icon = '💬' # Speech bubble
|
|
widget_color = '#8b5cf6' # Purple
|
|
default_width = 'half'
|
|
has_settings = True
|
|
|
|
@staticmethod
|
|
def get_css() -> str:
|
|
return """
|
|
/* ===== Matrix Widget Styles ===== */
|
|
.widget-matrix {
|
|
background: var(--bp-surface, #1e293b);
|
|
border: 1px solid var(--bp-border, #475569);
|
|
border-radius: 12px;
|
|
padding: 16px;
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.widget-matrix .widget-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
margin-bottom: 12px;
|
|
padding-bottom: 12px;
|
|
border-bottom: 1px solid var(--bp-border-subtle, rgba(255,255,255,0.1));
|
|
}
|
|
|
|
.widget-matrix .widget-title {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
color: var(--bp-text, #e5e7eb);
|
|
}
|
|
|
|
.widget-matrix .widget-icon {
|
|
width: 28px;
|
|
height: 28px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
background: rgba(139, 92, 246, 0.15);
|
|
color: #8b5cf6;
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.widget-matrix .matrix-list {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.widget-matrix .chat-item {
|
|
display: flex;
|
|
gap: 10px;
|
|
padding: 10px 0;
|
|
border-bottom: 1px solid var(--bp-border-subtle, rgba(255,255,255,0.05));
|
|
cursor: pointer;
|
|
transition: background 0.2s;
|
|
}
|
|
|
|
.widget-matrix .chat-item:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.widget-matrix .chat-item:hover {
|
|
background: var(--bp-surface-elevated, #334155);
|
|
margin: 0 -12px;
|
|
padding: 10px 12px;
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.widget-matrix .chat-avatar {
|
|
width: 32px;
|
|
height: 32px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
background: rgba(139, 92, 246, 0.15);
|
|
color: #8b5cf6;
|
|
border-radius: 50%;
|
|
font-size: 12px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.widget-matrix .chat-content {
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
|
|
.widget-matrix .chat-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 2px;
|
|
}
|
|
|
|
.widget-matrix .chat-room {
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
color: var(--bp-text, #e5e7eb);
|
|
}
|
|
|
|
.widget-matrix .chat-time {
|
|
font-size: 10px;
|
|
color: var(--bp-text-muted, #9ca3af);
|
|
}
|
|
|
|
.widget-matrix .chat-message {
|
|
font-size: 12px;
|
|
color: var(--bp-text-muted, #9ca3af);
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.widget-matrix .chat-unread {
|
|
width: 8px;
|
|
height: 8px;
|
|
background: #8b5cf6;
|
|
border-radius: 50%;
|
|
margin-left: 8px;
|
|
}
|
|
|
|
.widget-matrix .matrix-empty {
|
|
text-align: center;
|
|
padding: 24px;
|
|
color: var(--bp-text-muted, #9ca3af);
|
|
font-size: 13px;
|
|
}
|
|
|
|
.widget-matrix .matrix-empty-icon {
|
|
font-size: 32px;
|
|
margin-bottom: 8px;
|
|
opacity: 0.5;
|
|
}
|
|
|
|
.widget-matrix .matrix-footer {
|
|
margin-top: 12px;
|
|
padding-top: 12px;
|
|
border-top: 1px solid var(--bp-border-subtle, rgba(255,255,255,0.1));
|
|
}
|
|
|
|
.widget-matrix .matrix-all-btn {
|
|
width: 100%;
|
|
padding: 10px;
|
|
background: transparent;
|
|
border: 1px dashed var(--bp-border, #475569);
|
|
border-radius: 8px;
|
|
color: var(--bp-text-muted, #9ca3af);
|
|
font-size: 12px;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.widget-matrix .matrix-all-btn:hover {
|
|
border-color: #8b5cf6;
|
|
color: #8b5cf6;
|
|
}
|
|
"""
|
|
|
|
@staticmethod
|
|
def get_html() -> str:
|
|
return """
|
|
<div class="widget-matrix" data-widget-id="matrix">
|
|
<div class="widget-header">
|
|
<div class="widget-title">
|
|
<span class="widget-icon">💬</span>
|
|
<span>Matrix-Chat</span>
|
|
</div>
|
|
<button class="widget-settings-btn" onclick="openWidgetSettings('matrix')" title="Einstellungen">⚙</button>
|
|
</div>
|
|
<div class="matrix-list" id="matrix-list">
|
|
<!-- Wird dynamisch gefuellt -->
|
|
</div>
|
|
<div class="matrix-footer">
|
|
<button class="matrix-all-btn" onclick="openMessenger()">+ Messenger oeffnen</button>
|
|
</div>
|
|
</div>
|
|
"""
|
|
|
|
@staticmethod
|
|
def get_js() -> str:
|
|
return """
|
|
// ===== Matrix Widget JavaScript =====
|
|
|
|
function getDefaultMatrixChats() {
|
|
const now = Date.now();
|
|
return [
|
|
{
|
|
id: 'room1',
|
|
room: 'Kollegium Deutsch',
|
|
lastMessage: 'Hat jemand das neue Curriculum?',
|
|
sender: 'Fr. Becker',
|
|
time: new Date(now - 30 * 60 * 1000).toISOString(),
|
|
unread: true
|
|
},
|
|
{
|
|
id: 'room2',
|
|
room: 'Klassenfahrt 10a',
|
|
lastMessage: 'Die Anmeldungen sind komplett!',
|
|
sender: 'Hr. Klein',
|
|
time: new Date(now - 3 * 60 * 60 * 1000).toISOString(),
|
|
unread: false
|
|
},
|
|
{
|
|
id: 'room3',
|
|
room: 'Fachschaft',
|
|
lastMessage: 'Termin fuer naechste Sitzung...',
|
|
sender: 'Sie',
|
|
time: new Date(now - 24 * 60 * 60 * 1000).toISOString(),
|
|
unread: false
|
|
}
|
|
];
|
|
}
|
|
|
|
function formatMatrixTime(timeStr) {
|
|
const time = new Date(timeStr);
|
|
const now = new Date();
|
|
const diffMs = now - time;
|
|
const diffMins = Math.floor(diffMs / (60 * 1000));
|
|
const diffHours = Math.floor(diffMs / (60 * 60 * 1000));
|
|
|
|
if (diffMins < 1) return 'jetzt';
|
|
if (diffMins < 60) return `${diffMins}m`;
|
|
if (diffHours < 24) return `${diffHours}h`;
|
|
return time.toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit' });
|
|
}
|
|
|
|
function renderMatrixChats() {
|
|
const list = document.getElementById('matrix-list');
|
|
if (!list) return;
|
|
|
|
const chats = getDefaultMatrixChats();
|
|
|
|
if (chats.length === 0) {
|
|
list.innerHTML = `
|
|
<div class="matrix-empty">
|
|
<div class="matrix-empty-icon">💬</div>
|
|
<div>Keine Chats verfuegbar</div>
|
|
</div>
|
|
`;
|
|
return;
|
|
}
|
|
|
|
list.innerHTML = chats.map(chat => `
|
|
<div class="chat-item" onclick="openMatrixRoom('${chat.id}')">
|
|
<div class="chat-avatar">💬</div>
|
|
<div class="chat-content">
|
|
<div class="chat-header">
|
|
<span class="chat-room">${chat.room}</span>
|
|
<span class="chat-time">${formatMatrixTime(chat.time)}</span>
|
|
</div>
|
|
<div class="chat-message">${chat.sender}: ${chat.lastMessage}</div>
|
|
</div>
|
|
${chat.unread ? '<div class="chat-unread"></div>' : ''}
|
|
</div>
|
|
`).join('');
|
|
}
|
|
|
|
function openMatrixRoom(roomId) {
|
|
if (typeof loadModule === 'function') {
|
|
loadModule('messenger');
|
|
console.log('Opening room:', roomId);
|
|
}
|
|
}
|
|
|
|
function openMessenger() {
|
|
if (typeof loadModule === 'function') {
|
|
loadModule('messenger');
|
|
}
|
|
}
|
|
|
|
function initMatrixWidget() {
|
|
renderMatrixChats();
|
|
}
|
|
"""
|