Echtzeit-UI in main.ts verdrahtet
Event-Stream-View registriert, StatusBar mit Live-Updates, Ribbon-Icon für Event-Stream, Kommando 'Event-Stream anzeigen', activateEventStream-Methode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
22a6c2e188
commit
bf63f5f9e3
1 changed files with 42 additions and 0 deletions
42
src/main.ts
42
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<void> {
|
||||
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<void> {
|
||||
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
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue