diff --git a/src/main.ts b/src/main.ts index ceb0da5..ad32f96 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,6 +11,8 @@ import { EditorCollector } from './collectors/editor-collector'; import { SystemCollector } from './collectors/system-collector'; import { LogfireSettingTab } from './ui/settings-tab'; import { InitialScanModal } from './ui/initial-scan-modal'; +import { StatusBar } from './ui/status-bar'; +import { EventStreamView, EVENT_STREAM_VIEW_TYPE } from './ui/event-stream-view'; export default class LogfirePlugin extends Plugin { settings!: LogfireSettings; @@ -24,6 +26,7 @@ export default class LogfirePlugin extends Plugin { private navCollector!: NavCollector; private editorCollector!: EditorCollector; private systemCollector!: SystemCollector; + private statusBar!: StatusBar; private paused = false; @@ -77,6 +80,21 @@ export default class LogfirePlugin extends Plugin { // UI: Settings tab this.addSettingTab(new LogfireSettingTab(this.app, this)); + // UI: Event stream view + this.registerView( + EVENT_STREAM_VIEW_TYPE, + (leaf) => new EventStreamView(leaf, this.eventBus), + ); + + // UI: Status bar + this.statusBar = new StatusBar(this); + this.statusBar.start(); + + // Ribbon icon + this.addRibbonIcon('activity', 'Logfire: Event-Stream', () => { + this.activateEventStream(); + }); + // Commands this.registerCommands(); @@ -107,6 +125,7 @@ export default class LogfirePlugin extends Plugin { async onunload(): Promise { console.log('[Logfire] Entlade Plugin...'); + this.statusBar?.destroy(); this.stopTracking(); if (this.sessionManager) { @@ -217,6 +236,12 @@ export default class LogfirePlugin extends Plugin { // --------------------------------------------------------------------------- private registerCommands(): void { + this.addCommand({ + id: 'show-event-stream', + name: 'Event-Stream anzeigen', + callback: () => this.activateEventStream(), + }); + this.addCommand({ id: 'toggle-tracking', name: 'Tracking pausieren/fortsetzen', @@ -263,6 +288,23 @@ export default class LogfirePlugin extends Plugin { }); } + // --------------------------------------------------------------------------- + // Event stream view + // --------------------------------------------------------------------------- + + private async activateEventStream(): Promise { + const existing = this.app.workspace.getLeavesOfType(EVENT_STREAM_VIEW_TYPE); + if (existing.length > 0) { + this.app.workspace.revealLeaf(existing[0]); + return; + } + const leaf = this.app.workspace.getRightLeaf(false); + if (leaf) { + await leaf.setViewState({ type: EVENT_STREAM_VIEW_TYPE, active: true }); + this.app.workspace.revealLeaf(leaf); + } + } + // --------------------------------------------------------------------------- // Settings // ---------------------------------------------------------------------------