polyv-live-cli 1.1.4 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/account.commands.d.ts +3 -0
- package/dist/commands/account.commands.d.ts.map +1 -0
- package/dist/commands/account.commands.js +386 -0
- package/dist/commands/account.commands.js.map +1 -0
- package/dist/commands/channel.commands.d.ts.map +1 -1
- package/dist/commands/channel.commands.js +84 -60
- package/dist/commands/channel.commands.js.map +1 -1
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +7 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/monitor.commands.d.ts +12 -0
- package/dist/commands/monitor.commands.d.ts.map +1 -0
- package/dist/commands/monitor.commands.js +75 -0
- package/dist/commands/monitor.commands.js.map +1 -0
- package/dist/commands/stream.commands.d.ts.map +1 -1
- package/dist/commands/stream.commands.js +141 -63
- package/dist/commands/stream.commands.js.map +1 -1
- package/dist/commands/use.commands.d.ts +9 -0
- package/dist/commands/use.commands.d.ts.map +1 -0
- package/dist/commands/use.commands.js +66 -0
- package/dist/commands/use.commands.js.map +1 -0
- package/dist/components/alert.panel.d.ts +98 -0
- package/dist/components/alert.panel.d.ts.map +1 -0
- package/dist/components/alert.panel.js +1001 -0
- package/dist/components/alert.panel.js.map +1 -0
- package/dist/components/base.component.d.ts +61 -0
- package/dist/components/base.component.d.ts.map +1 -0
- package/dist/components/base.component.js +346 -0
- package/dist/components/base.component.js.map +1 -0
- package/dist/components/batch-operations.dialog.d.ts +58 -0
- package/dist/components/batch-operations.dialog.d.ts.map +1 -0
- package/dist/components/batch-operations.dialog.js +340 -0
- package/dist/components/batch-operations.dialog.js.map +1 -0
- package/dist/components/channel-details.popup.d.ts +55 -0
- package/dist/components/channel-details.popup.d.ts.map +1 -0
- package/dist/components/channel-details.popup.js +416 -0
- package/dist/components/channel-details.popup.js.map +1 -0
- package/dist/components/channel-status.panel.d.ts +129 -0
- package/dist/components/channel-status.panel.d.ts.map +1 -0
- package/dist/components/channel-status.panel.js +858 -0
- package/dist/components/channel-status.panel.js.map +1 -0
- package/dist/components/component-registry.d.ts +36 -0
- package/dist/components/component-registry.d.ts.map +1 -0
- package/dist/components/component-registry.js +119 -0
- package/dist/components/component-registry.js.map +1 -0
- package/dist/components/context-menu-factory.d.ts +13 -0
- package/dist/components/context-menu-factory.d.ts.map +1 -0
- package/dist/components/context-menu-factory.js +341 -0
- package/dist/components/context-menu-factory.js.map +1 -0
- package/dist/components/context-menu.d.ts +54 -0
- package/dist/components/context-menu.d.ts.map +1 -0
- package/dist/components/context-menu.js +235 -0
- package/dist/components/context-menu.js.map +1 -0
- package/dist/components/grid-manager.d.ts +52 -0
- package/dist/components/grid-manager.d.ts.map +1 -0
- package/dist/components/grid-manager.js +404 -0
- package/dist/components/grid-manager.js.map +1 -0
- package/dist/components/help-panel.d.ts +34 -0
- package/dist/components/help-panel.d.ts.map +1 -0
- package/dist/components/help-panel.js +249 -0
- package/dist/components/help-panel.js.map +1 -0
- package/dist/components/index.d.ts +21 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +43 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/interaction-manager.d.ts +47 -0
- package/dist/components/interaction-manager.d.ts.map +1 -0
- package/dist/components/interaction-manager.js +597 -0
- package/dist/components/interaction-manager.js.map +1 -0
- package/dist/components/layout-manager.d.ts +76 -0
- package/dist/components/layout-manager.d.ts.map +1 -0
- package/dist/components/layout-manager.js +538 -0
- package/dist/components/layout-manager.js.map +1 -0
- package/dist/components/monitoring-dashboard.d.ts +85 -0
- package/dist/components/monitoring-dashboard.d.ts.map +1 -0
- package/dist/components/monitoring-dashboard.js +908 -0
- package/dist/components/monitoring-dashboard.js.map +1 -0
- package/dist/components/search-panel.d.ts +80 -0
- package/dist/components/search-panel.d.ts.map +1 -0
- package/dist/components/search-panel.js +585 -0
- package/dist/components/search-panel.js.map +1 -0
- package/dist/components/status-bar.d.ts +77 -0
- package/dist/components/status-bar.d.ts.map +1 -0
- package/dist/components/status-bar.js +482 -0
- package/dist/components/status-bar.js.map +1 -0
- package/dist/components/status.component.d.ts +16 -0
- package/dist/components/status.component.d.ts.map +1 -0
- package/dist/components/status.component.js +79 -0
- package/dist/components/status.component.js.map +1 -0
- package/dist/components/stream-metrics.panel.d.ts +86 -0
- package/dist/components/stream-metrics.panel.d.ts.map +1 -0
- package/dist/components/stream-metrics.panel.js +395 -0
- package/dist/components/stream-metrics.panel.js.map +1 -0
- package/dist/components/system-resource.panel.d.ts +78 -0
- package/dist/components/system-resource.panel.d.ts.map +1 -0
- package/dist/components/system-resource.panel.js +642 -0
- package/dist/components/system-resource.panel.js.map +1 -0
- package/dist/components/tooltip.d.ts +35 -0
- package/dist/components/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip.js +156 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/config/account-config.d.ts +27 -0
- package/dist/config/account-config.d.ts.map +1 -0
- package/dist/config/account-config.js +358 -0
- package/dist/config/account-config.js.map +1 -0
- package/dist/config/account-crypto.d.ts +17 -0
- package/dist/config/account-crypto.d.ts.map +1 -0
- package/dist/config/account-crypto.js +129 -0
- package/dist/config/account-crypto.js.map +1 -0
- package/dist/config/account-encryption.d.ts +35 -0
- package/dist/config/account-encryption.d.ts.map +1 -0
- package/dist/config/account-encryption.js +207 -0
- package/dist/config/account-encryption.js.map +1 -0
- package/dist/config/auth-adapter.d.ts +23 -0
- package/dist/config/auth-adapter.d.ts.map +1 -0
- package/dist/config/auth-adapter.js +49 -0
- package/dist/config/auth-adapter.js.map +1 -0
- package/dist/config/auth-provider.d.ts +27 -0
- package/dist/config/auth-provider.d.ts.map +1 -0
- package/dist/config/auth-provider.js +54 -0
- package/dist/config/auth-provider.js.map +1 -0
- package/dist/config/auth-source-manager.d.ts +61 -0
- package/dist/config/auth-source-manager.d.ts.map +1 -0
- package/dist/config/auth-source-manager.js +402 -0
- package/dist/config/auth-source-manager.js.map +1 -0
- package/dist/config/config-io.d.ts +63 -0
- package/dist/config/config-io.d.ts.map +1 -0
- package/dist/config/config-io.js +352 -0
- package/dist/config/config-io.js.map +1 -0
- package/dist/config/config-manager.d.ts +51 -0
- package/dist/config/config-manager.d.ts.map +1 -0
- package/dist/config/config-manager.js +404 -0
- package/dist/config/config-manager.js.map +1 -0
- package/dist/config/config-recovery-manager.d.ts +67 -0
- package/dist/config/config-recovery-manager.d.ts.map +1 -0
- package/dist/config/config-recovery-manager.js +593 -0
- package/dist/config/config-recovery-manager.js.map +1 -0
- package/dist/config/config-validator.d.ts +27 -0
- package/dist/config/config-validator.d.ts.map +1 -0
- package/dist/config/config-validator.js +421 -0
- package/dist/config/config-validator.js.map +1 -0
- package/dist/config/config-version-manager.d.ts +44 -0
- package/dist/config/config-version-manager.d.ts.map +1 -0
- package/dist/config/config-version-manager.js +319 -0
- package/dist/config/config-version-manager.js.map +1 -0
- package/dist/config/custom-theme-builder.d.ts +88 -0
- package/dist/config/custom-theme-builder.d.ts.map +1 -0
- package/dist/config/custom-theme-builder.js +458 -0
- package/dist/config/custom-theme-builder.js.map +1 -0
- package/dist/config/file-permission-manager.d.ts +41 -0
- package/dist/config/file-permission-manager.d.ts.map +1 -0
- package/dist/config/file-permission-manager.js +290 -0
- package/dist/config/file-permission-manager.js.map +1 -0
- package/dist/config/layout-manager.d.ts +60 -0
- package/dist/config/layout-manager.d.ts.map +1 -0
- package/dist/config/layout-manager.js +596 -0
- package/dist/config/layout-manager.js.map +1 -0
- package/dist/config/monitoring.d.ts +27 -0
- package/dist/config/monitoring.d.ts.map +1 -0
- package/dist/config/monitoring.js +276 -0
- package/dist/config/monitoring.js.map +1 -0
- package/dist/config/secure-account-manager.d.ts +54 -0
- package/dist/config/secure-account-manager.d.ts.map +1 -0
- package/dist/config/secure-account-manager.js +438 -0
- package/dist/config/secure-account-manager.js.map +1 -0
- package/dist/config/session-state.d.ts +37 -0
- package/dist/config/session-state.d.ts.map +1 -0
- package/dist/config/session-state.js +207 -0
- package/dist/config/session-state.js.map +1 -0
- package/dist/config/session-storage.d.ts +21 -0
- package/dist/config/session-storage.d.ts.map +1 -0
- package/dist/config/session-storage.js +235 -0
- package/dist/config/session-storage.js.map +1 -0
- package/dist/config/theme-manager.d.ts +53 -0
- package/dist/config/theme-manager.d.ts.map +1 -0
- package/dist/config/theme-manager.js +491 -0
- package/dist/config/theme-manager.js.map +1 -0
- package/dist/handlers/monitor.handler.d.ts +28 -0
- package/dist/handlers/monitor.handler.d.ts.map +1 -0
- package/dist/handlers/monitor.handler.js +457 -0
- package/dist/handlers/monitor.handler.js.map +1 -0
- package/dist/handlers/stream.handler.d.ts.map +1 -1
- package/dist/handlers/stream.handler.js +6 -0
- package/dist/handlers/stream.handler.js.map +1 -1
- package/dist/handlers/use.handler.d.ts +13 -0
- package/dist/handlers/use.handler.d.ts.map +1 -0
- package/dist/handlers/use.handler.js +118 -0
- package/dist/handlers/use.handler.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -12
- package/dist/index.js.map +1 -1
- package/dist/performance/adaptive-polling.d.ts +69 -0
- package/dist/performance/adaptive-polling.d.ts.map +1 -0
- package/dist/performance/adaptive-polling.js +313 -0
- package/dist/performance/adaptive-polling.js.map +1 -0
- package/dist/performance/api-analytics.d.ts +137 -0
- package/dist/performance/api-analytics.d.ts.map +1 -0
- package/dist/performance/api-analytics.js +351 -0
- package/dist/performance/api-analytics.js.map +1 -0
- package/dist/performance/api-optimizer.d.ts +66 -0
- package/dist/performance/api-optimizer.d.ts.map +1 -0
- package/dist/performance/api-optimizer.js +368 -0
- package/dist/performance/api-optimizer.js.map +1 -0
- package/dist/performance/batch-request-manager.d.ts +90 -0
- package/dist/performance/batch-request-manager.d.ts.map +1 -0
- package/dist/performance/batch-request-manager.js +355 -0
- package/dist/performance/batch-request-manager.js.map +1 -0
- package/dist/performance/change-detector.d.ts +75 -0
- package/dist/performance/change-detector.d.ts.map +1 -0
- package/dist/performance/change-detector.js +421 -0
- package/dist/performance/change-detector.js.map +1 -0
- package/dist/performance/connection-pool-manager.d.ts +99 -0
- package/dist/performance/connection-pool-manager.d.ts.map +1 -0
- package/dist/performance/connection-pool-manager.js +474 -0
- package/dist/performance/connection-pool-manager.js.map +1 -0
- package/dist/performance/error-recovery-manager.d.ts +134 -0
- package/dist/performance/error-recovery-manager.d.ts.map +1 -0
- package/dist/performance/error-recovery-manager.js +673 -0
- package/dist/performance/error-recovery-manager.js.map +1 -0
- package/dist/performance/fallback-manager.d.ts +123 -0
- package/dist/performance/fallback-manager.d.ts.map +1 -0
- package/dist/performance/fallback-manager.js +524 -0
- package/dist/performance/fallback-manager.js.map +1 -0
- package/dist/performance/index.d.ts +25 -0
- package/dist/performance/index.d.ts.map +1 -0
- package/dist/performance/index.js +28 -0
- package/dist/performance/index.js.map +1 -0
- package/dist/performance/memory-manager.d.ts +97 -0
- package/dist/performance/memory-manager.d.ts.map +1 -0
- package/dist/performance/memory-manager.js +417 -0
- package/dist/performance/memory-manager.js.map +1 -0
- package/dist/performance/performance-monitor.d.ts +149 -0
- package/dist/performance/performance-monitor.d.ts.map +1 -0
- package/dist/performance/performance-monitor.js +513 -0
- package/dist/performance/performance-monitor.js.map +1 -0
- package/dist/performance/performance-optimizer.d.ts +110 -0
- package/dist/performance/performance-optimizer.d.ts.map +1 -0
- package/dist/performance/performance-optimizer.js +476 -0
- package/dist/performance/performance-optimizer.js.map +1 -0
- package/dist/performance/render-optimizer.d.ts +95 -0
- package/dist/performance/render-optimizer.d.ts.map +1 -0
- package/dist/performance/render-optimizer.js +408 -0
- package/dist/performance/render-optimizer.js.map +1 -0
- package/dist/services/index.d.ts +4 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +3 -1
- package/dist/services/index.js.map +1 -1
- package/dist/services/system-resource.service.d.ts +168 -0
- package/dist/services/system-resource.service.d.ts.map +1 -0
- package/dist/services/system-resource.service.js +544 -0
- package/dist/services/system-resource.service.js.map +1 -0
- package/dist/types/account.types.d.ts +79 -0
- package/dist/types/account.types.d.ts.map +1 -0
- package/dist/types/account.types.js +23 -0
- package/dist/types/account.types.js.map +1 -0
- package/dist/types/alert.d.ts +147 -0
- package/dist/types/alert.d.ts.map +1 -0
- package/dist/types/alert.js +3 -0
- package/dist/types/alert.js.map +1 -0
- package/dist/types/auth-source.types.d.ts +62 -0
- package/dist/types/auth-source.types.d.ts.map +1 -0
- package/dist/types/auth-source.types.js +25 -0
- package/dist/types/auth-source.types.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/interaction.d.ts +147 -0
- package/dist/types/interaction.d.ts.map +1 -0
- package/dist/types/interaction.js +3 -0
- package/dist/types/interaction.js.map +1 -0
- package/dist/types/monitoring.d.ts +233 -0
- package/dist/types/monitoring.d.ts.map +1 -0
- package/dist/types/monitoring.js +35 -0
- package/dist/types/monitoring.js.map +1 -0
- package/dist/types/session.types.d.ts +43 -0
- package/dist/types/session.types.d.ts.map +1 -0
- package/dist/types/session.types.js +27 -0
- package/dist/types/session.types.js.map +1 -0
- package/dist/utils/alert-history-manager.d.ts +72 -0
- package/dist/utils/alert-history-manager.d.ts.map +1 -0
- package/dist/utils/alert-history-manager.js +492 -0
- package/dist/utils/alert-history-manager.js.map +1 -0
- package/dist/utils/alert-manager.d.ts +75 -0
- package/dist/utils/alert-manager.d.ts.map +1 -0
- package/dist/utils/alert-manager.js +348 -0
- package/dist/utils/alert-manager.js.map +1 -0
- package/dist/utils/alert-rule-manager.d.ts +51 -0
- package/dist/utils/alert-rule-manager.d.ts.map +1 -0
- package/dist/utils/alert-rule-manager.js +515 -0
- package/dist/utils/alert-rule-manager.js.map +1 -0
- package/dist/utils/auth-diagnostics.d.ts +47 -0
- package/dist/utils/auth-diagnostics.d.ts.map +1 -0
- package/dist/utils/auth-diagnostics.js +245 -0
- package/dist/utils/auth-diagnostics.js.map +1 -0
- package/dist/utils/data-manager.d.ts +53 -0
- package/dist/utils/data-manager.d.ts.map +1 -0
- package/dist/utils/data-manager.js +228 -0
- package/dist/utils/data-manager.js.map +1 -0
- package/dist/utils/formatter.d.ts +5 -0
- package/dist/utils/formatter.d.ts.map +1 -1
- package/dist/utils/formatter.js +19 -0
- package/dist/utils/formatter.js.map +1 -1
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/keyboard-handler.d.ts +32 -0
- package/dist/utils/keyboard-handler.d.ts.map +1 -0
- package/dist/utils/keyboard-handler.js +193 -0
- package/dist/utils/keyboard-handler.js.map +1 -0
- package/dist/utils/mouse-handler.d.ts +61 -0
- package/dist/utils/mouse-handler.d.ts.map +1 -0
- package/dist/utils/mouse-handler.js +192 -0
- package/dist/utils/mouse-handler.js.map +1 -0
- package/dist/utils/stream-verification.d.ts.map +1 -1
- package/dist/utils/stream-verification.js +2 -13
- package/dist/utils/stream-verification.js.map +1 -1
- package/dist/utils/terminal.d.ts +24 -0
- package/dist/utils/terminal.d.ts.map +1 -0
- package/dist/utils/terminal.js +148 -0
- package/dist/utils/terminal.js.map +1 -0
- package/dist/utils/time-series.processor.d.ts +65 -0
- package/dist/utils/time-series.processor.d.ts.map +1 -0
- package/dist/utils/time-series.processor.js +263 -0
- package/dist/utils/time-series.processor.js.map +1 -0
- package/package.json +40 -4
|
@@ -0,0 +1,1001 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.AlertPanel = void 0;
|
|
37
|
+
const blessed = __importStar(require("blessed"));
|
|
38
|
+
const base_component_1 = require("./base.component");
|
|
39
|
+
let screen = null;
|
|
40
|
+
const getScreen = () => {
|
|
41
|
+
if (!screen) {
|
|
42
|
+
try {
|
|
43
|
+
screen = blessed.screen({
|
|
44
|
+
smartCSR: true,
|
|
45
|
+
dockBorders: true,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
screen = {
|
|
50
|
+
render: () => { },
|
|
51
|
+
destroy: () => { },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return screen;
|
|
56
|
+
};
|
|
57
|
+
class AlertPanel extends base_component_1.BaseComponent {
|
|
58
|
+
constructor(config, eventBus) {
|
|
59
|
+
super(config, eventBus);
|
|
60
|
+
this.alerts = [];
|
|
61
|
+
this.filteredAlerts = [];
|
|
62
|
+
this.selectedAlertIndex = 0;
|
|
63
|
+
this.currentFilter = {};
|
|
64
|
+
this.showDetailsPane = false;
|
|
65
|
+
this.showFilterPane = false;
|
|
66
|
+
this.showStatisticsPane = false;
|
|
67
|
+
this.levelIcons = {
|
|
68
|
+
info: 'ⓘ',
|
|
69
|
+
warning: '⚠',
|
|
70
|
+
error: '✗',
|
|
71
|
+
critical: '🔴'
|
|
72
|
+
};
|
|
73
|
+
this.typeIcons = {
|
|
74
|
+
system: '⚙',
|
|
75
|
+
stream: '📹',
|
|
76
|
+
channel: '📺',
|
|
77
|
+
network: '🌐'
|
|
78
|
+
};
|
|
79
|
+
this.panelConfig = {
|
|
80
|
+
maxDisplayItems: 50,
|
|
81
|
+
autoScroll: true,
|
|
82
|
+
showTimestamps: true,
|
|
83
|
+
showSources: true,
|
|
84
|
+
showIds: false,
|
|
85
|
+
timeFormat: 'relative',
|
|
86
|
+
colorCoding: true,
|
|
87
|
+
compactMode: false,
|
|
88
|
+
...config.config['panelConfig'],
|
|
89
|
+
...config.config['alertPanel']
|
|
90
|
+
};
|
|
91
|
+
this.setupAlertEventListeners();
|
|
92
|
+
}
|
|
93
|
+
setupAlertEventListeners() {
|
|
94
|
+
this.subscribe('alert:new', this.handleNewAlert.bind(this));
|
|
95
|
+
this.subscribe('alert:acknowledged', this.handleAlertAcknowledged.bind(this));
|
|
96
|
+
this.subscribe('alert:resolved', this.handleAlertResolved.bind(this));
|
|
97
|
+
this.subscribe('alert:updated', this.handleAlertUpdated.bind(this));
|
|
98
|
+
this.subscribe('alert:filter', this.handleFilterChanged.bind(this));
|
|
99
|
+
this.subscribe('alert:clear', this.handleClearAlerts.bind(this));
|
|
100
|
+
}
|
|
101
|
+
createWidget() {
|
|
102
|
+
try {
|
|
103
|
+
this.widget = blessed.box({
|
|
104
|
+
parent: getScreen(),
|
|
105
|
+
top: this.config.position.y || 0,
|
|
106
|
+
left: this.config.position.x || 0,
|
|
107
|
+
width: this.config.position.width || '100%',
|
|
108
|
+
height: this.config.position.height || '100%',
|
|
109
|
+
label: ' Alert Center ',
|
|
110
|
+
border: { type: 'line' },
|
|
111
|
+
style: {
|
|
112
|
+
border: { fg: 'blue' },
|
|
113
|
+
label: { fg: 'white' },
|
|
114
|
+
},
|
|
115
|
+
keys: true,
|
|
116
|
+
mouse: true,
|
|
117
|
+
scrollable: true,
|
|
118
|
+
});
|
|
119
|
+
this.container = this.widget;
|
|
120
|
+
this.createAlertList();
|
|
121
|
+
this.createDetailsBox();
|
|
122
|
+
this.createFilterBox();
|
|
123
|
+
this.createStatisticsBox();
|
|
124
|
+
this.createActionBar();
|
|
125
|
+
this.actionBar.setContent(this.generateActionBarContent());
|
|
126
|
+
this.updateLayout();
|
|
127
|
+
this.bindKeyboardEvents();
|
|
128
|
+
this.bindMouseEvents();
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
this.handleError(error instanceof Error ? error : new Error('Widget creation failed'));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
createAlertList() {
|
|
135
|
+
this.alertList = blessed.list({
|
|
136
|
+
parent: this.container,
|
|
137
|
+
top: 1,
|
|
138
|
+
left: 0,
|
|
139
|
+
width: this.showDetailsPane ? '60%' : '100%',
|
|
140
|
+
height: this.showFilterPane || this.showStatisticsPane ? '70%' : '85%',
|
|
141
|
+
label: ' Alerts ',
|
|
142
|
+
border: { type: 'line' },
|
|
143
|
+
style: {
|
|
144
|
+
border: { fg: 'cyan' },
|
|
145
|
+
selected: { bg: 'blue', fg: 'white' },
|
|
146
|
+
item: { fg: 'white' },
|
|
147
|
+
},
|
|
148
|
+
keys: true,
|
|
149
|
+
mouse: true,
|
|
150
|
+
scrollable: true,
|
|
151
|
+
alwaysScroll: true,
|
|
152
|
+
scrollbar: {
|
|
153
|
+
ch: ' ',
|
|
154
|
+
track: {
|
|
155
|
+
bg: 'gray',
|
|
156
|
+
},
|
|
157
|
+
style: {
|
|
158
|
+
inverse: true,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
createDetailsBox() {
|
|
164
|
+
this.detailsBox = blessed.box({
|
|
165
|
+
parent: this.container,
|
|
166
|
+
top: 1,
|
|
167
|
+
left: '60%',
|
|
168
|
+
width: '40%',
|
|
169
|
+
height: this.showFilterPane || this.showStatisticsPane ? '70%' : '85%',
|
|
170
|
+
label: ' Alert Details ',
|
|
171
|
+
border: { type: 'line' },
|
|
172
|
+
style: {
|
|
173
|
+
border: { fg: 'green' },
|
|
174
|
+
label: { fg: 'white' },
|
|
175
|
+
},
|
|
176
|
+
hidden: !this.showDetailsPane,
|
|
177
|
+
scrollable: true,
|
|
178
|
+
alwaysScroll: true,
|
|
179
|
+
keys: true,
|
|
180
|
+
mouse: true,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
createFilterBox() {
|
|
184
|
+
this.filterBox = blessed.box({
|
|
185
|
+
parent: this.container,
|
|
186
|
+
top: '71%',
|
|
187
|
+
left: 0,
|
|
188
|
+
width: this.showDetailsPane ? '60%' : '100%',
|
|
189
|
+
height: '14%',
|
|
190
|
+
label: ' Filter & Search ',
|
|
191
|
+
border: { type: 'line' },
|
|
192
|
+
style: {
|
|
193
|
+
border: { fg: 'yellow' },
|
|
194
|
+
label: { fg: 'white' },
|
|
195
|
+
},
|
|
196
|
+
hidden: !this.showFilterPane,
|
|
197
|
+
scrollable: true,
|
|
198
|
+
content: this.generateFilterContent(),
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
createStatisticsBox() {
|
|
202
|
+
this.statisticsBox = blessed.box({
|
|
203
|
+
parent: this.container,
|
|
204
|
+
top: '71%',
|
|
205
|
+
left: this.showDetailsPane ? '60%' : (this.showFilterPane ? '0%' : '0%'),
|
|
206
|
+
width: this.showDetailsPane ? '40%' : '100%',
|
|
207
|
+
height: '14%',
|
|
208
|
+
label: ' Alert Statistics ',
|
|
209
|
+
border: { type: 'line' },
|
|
210
|
+
style: {
|
|
211
|
+
border: { fg: 'magenta' },
|
|
212
|
+
label: { fg: 'white' },
|
|
213
|
+
},
|
|
214
|
+
hidden: !this.showStatisticsPane,
|
|
215
|
+
content: 'Loading statistics...',
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
createActionBar() {
|
|
219
|
+
this.actionBar = blessed.box({
|
|
220
|
+
parent: this.container,
|
|
221
|
+
top: '86%',
|
|
222
|
+
left: 0,
|
|
223
|
+
width: '100%',
|
|
224
|
+
height: '14%',
|
|
225
|
+
label: ' Actions ',
|
|
226
|
+
border: { type: 'line' },
|
|
227
|
+
style: {
|
|
228
|
+
border: { fg: 'white' },
|
|
229
|
+
label: { fg: 'white' },
|
|
230
|
+
},
|
|
231
|
+
content: this.generateActionBarContent(),
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
updateLayout() {
|
|
235
|
+
if (!this.alertList || !this.detailsBox || !this.filterBox || !this.statisticsBox)
|
|
236
|
+
return;
|
|
237
|
+
this.alertList.width = this.showDetailsPane ? '60%' : '100%';
|
|
238
|
+
this.alertList.height = (this.showFilterPane || this.showStatisticsPane) ? '70%' : '85%';
|
|
239
|
+
this.detailsBox.hidden = !this.showDetailsPane;
|
|
240
|
+
this.detailsBox.height = (this.showFilterPane || this.showStatisticsPane) ? '70%' : '85%';
|
|
241
|
+
this.filterBox.hidden = !this.showFilterPane;
|
|
242
|
+
this.filterBox.width = this.showDetailsPane ? '60%' : '100%';
|
|
243
|
+
this.statisticsBox.hidden = !this.showStatisticsPane;
|
|
244
|
+
if (this.showStatisticsPane) {
|
|
245
|
+
if (this.showDetailsPane) {
|
|
246
|
+
this.statisticsBox.left = '60%';
|
|
247
|
+
this.statisticsBox.width = '40%';
|
|
248
|
+
}
|
|
249
|
+
else if (this.showFilterPane) {
|
|
250
|
+
this.statisticsBox.left = '0%';
|
|
251
|
+
this.statisticsBox.top = '71%';
|
|
252
|
+
this.statisticsBox.width = '100%';
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
this.statisticsBox.left = '0%';
|
|
256
|
+
this.statisticsBox.width = '100%';
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
bindKeyboardEvents() {
|
|
261
|
+
if (!this.alertList)
|
|
262
|
+
return;
|
|
263
|
+
this.alertList.on('select', (_item, index) => {
|
|
264
|
+
this.selectedAlertIndex = index;
|
|
265
|
+
this.updateDetailsPane();
|
|
266
|
+
});
|
|
267
|
+
this.alertList.key(['up', 'k'], () => {
|
|
268
|
+
this.alertList.up(1);
|
|
269
|
+
this.selectedAlertIndex = Math.max(0, this.selectedAlertIndex - 1);
|
|
270
|
+
this.updateDetailsPane();
|
|
271
|
+
});
|
|
272
|
+
this.alertList.key(['down', 'j'], () => {
|
|
273
|
+
this.alertList.down(1);
|
|
274
|
+
this.selectedAlertIndex = Math.min(this.filteredAlerts.length - 1, this.selectedAlertIndex + 1);
|
|
275
|
+
this.updateDetailsPane();
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
bindMouseEvents() {
|
|
279
|
+
if (!this.alertList)
|
|
280
|
+
return;
|
|
281
|
+
this.alertList.on('click', () => {
|
|
282
|
+
this.updateDetailsPane();
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
handleCustomKeyboard(event) {
|
|
286
|
+
switch (event.key) {
|
|
287
|
+
case 'a':
|
|
288
|
+
this.acknowledgeSelectedAlert();
|
|
289
|
+
return true;
|
|
290
|
+
case 'r':
|
|
291
|
+
this.resolveSelectedAlert();
|
|
292
|
+
return true;
|
|
293
|
+
case 'i':
|
|
294
|
+
this.ignoreSelectedAlert();
|
|
295
|
+
return true;
|
|
296
|
+
case 'n':
|
|
297
|
+
this.addNotesToSelected();
|
|
298
|
+
return true;
|
|
299
|
+
case 'A':
|
|
300
|
+
this.acknowledgeAllFiltered();
|
|
301
|
+
return true;
|
|
302
|
+
case 'S':
|
|
303
|
+
this.resolveAllFiltered();
|
|
304
|
+
return true;
|
|
305
|
+
case 'd':
|
|
306
|
+
this.toggleDetailsPane();
|
|
307
|
+
return true;
|
|
308
|
+
case 'f':
|
|
309
|
+
this.toggleFilterPane();
|
|
310
|
+
return true;
|
|
311
|
+
case 's':
|
|
312
|
+
this.toggleStatisticsPane();
|
|
313
|
+
return true;
|
|
314
|
+
case 'c':
|
|
315
|
+
this.clearAllAlerts();
|
|
316
|
+
return true;
|
|
317
|
+
case 'x':
|
|
318
|
+
this.deleteSelectedAlert();
|
|
319
|
+
return true;
|
|
320
|
+
case 'R':
|
|
321
|
+
this.refreshAlerts();
|
|
322
|
+
return true;
|
|
323
|
+
case '1':
|
|
324
|
+
case '2':
|
|
325
|
+
case '3':
|
|
326
|
+
case '4':
|
|
327
|
+
case '5':
|
|
328
|
+
this.jumpToAlert(parseInt(event.key) - 1);
|
|
329
|
+
return true;
|
|
330
|
+
default:
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
generateActionBarContent() {
|
|
335
|
+
return [
|
|
336
|
+
'{bold}Alert Actions:{/bold}',
|
|
337
|
+
'[a]ck [r]esolve [i]gnore [n]otes [d]etails [f]ilter',
|
|
338
|
+
'[A]ck All [S]olve All [c]lear [x]delete [R]efresh',
|
|
339
|
+
'1-5: Jump to alert [s]tats [Esc]Close',
|
|
340
|
+
].join('\n');
|
|
341
|
+
}
|
|
342
|
+
generateFilterContent() {
|
|
343
|
+
const activeFilters = [];
|
|
344
|
+
if (this.currentFilter.levels?.length) {
|
|
345
|
+
activeFilters.push(`Levels: ${this.currentFilter.levels.join(', ')}`);
|
|
346
|
+
}
|
|
347
|
+
if (this.currentFilter.types?.length) {
|
|
348
|
+
activeFilters.push(`Types: ${this.currentFilter.types.join(', ')}`);
|
|
349
|
+
}
|
|
350
|
+
if (this.currentFilter.statuses?.length) {
|
|
351
|
+
activeFilters.push(`Status: ${this.currentFilter.statuses.join(', ')}`);
|
|
352
|
+
}
|
|
353
|
+
if (this.currentFilter.searchText) {
|
|
354
|
+
activeFilters.push(`Search: "${this.currentFilter.searchText}"`);
|
|
355
|
+
}
|
|
356
|
+
return activeFilters.length > 0
|
|
357
|
+
? `Active Filters:\n${activeFilters.join('\n')}`
|
|
358
|
+
: 'No active filters';
|
|
359
|
+
}
|
|
360
|
+
formatAlertForList(alert, index) {
|
|
361
|
+
const icon = this.levelIcons[alert.level];
|
|
362
|
+
const typeIcon = this.typeIcons[alert.type];
|
|
363
|
+
const timestamp = this.formatTimestamp(alert.timestamp);
|
|
364
|
+
const ackStatus = alert.acknowledged ? '✓' : ' ';
|
|
365
|
+
if (this.panelConfig.compactMode) {
|
|
366
|
+
return `${icon} ${alert.title} (${alert.source})`;
|
|
367
|
+
}
|
|
368
|
+
const parts = [];
|
|
369
|
+
if (this.panelConfig.showIds) {
|
|
370
|
+
parts.push(`[${index + 1}]`);
|
|
371
|
+
}
|
|
372
|
+
parts.push(`${icon}${typeIcon}`);
|
|
373
|
+
parts.push(ackStatus);
|
|
374
|
+
if (this.panelConfig.showTimestamps) {
|
|
375
|
+
parts.push(`[${timestamp}]`);
|
|
376
|
+
}
|
|
377
|
+
parts.push(alert.title);
|
|
378
|
+
if (this.panelConfig.showSources) {
|
|
379
|
+
parts.push(`(${alert.source})`);
|
|
380
|
+
}
|
|
381
|
+
return parts.join(' ');
|
|
382
|
+
}
|
|
383
|
+
formatTimestamp(timestamp) {
|
|
384
|
+
const date = new Date(timestamp);
|
|
385
|
+
if (this.panelConfig.timeFormat === 'relative') {
|
|
386
|
+
const now = Date.now();
|
|
387
|
+
const diff = now - timestamp;
|
|
388
|
+
if (diff < 60000) {
|
|
389
|
+
return `${Math.floor(diff / 1000)}s ago`;
|
|
390
|
+
}
|
|
391
|
+
else if (diff < 3600000) {
|
|
392
|
+
return `${Math.floor(diff / 60000)}m ago`;
|
|
393
|
+
}
|
|
394
|
+
else if (diff < 86400000) {
|
|
395
|
+
return `${Math.floor(diff / 3600000)}h ago`;
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
return `${Math.floor(diff / 86400000)}d ago`;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
return date.toLocaleTimeString();
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
updateAlertList() {
|
|
406
|
+
if (!this.alertList)
|
|
407
|
+
return;
|
|
408
|
+
const items = this.filteredAlerts.map((alert, index) => this.formatAlertForList(alert, index));
|
|
409
|
+
this.alertList.setItems(items);
|
|
410
|
+
if (this.panelConfig.autoScroll && items.length > 0) {
|
|
411
|
+
this.alertList.select(items.length - 1);
|
|
412
|
+
this.selectedAlertIndex = items.length - 1;
|
|
413
|
+
}
|
|
414
|
+
const totalCount = this.alerts.length;
|
|
415
|
+
const filteredCount = this.filteredAlerts.length;
|
|
416
|
+
const label = totalCount === filteredCount
|
|
417
|
+
? ` Alerts (${totalCount}) `
|
|
418
|
+
: ` Alerts (${filteredCount}/${totalCount}) `;
|
|
419
|
+
this.alertList.setLabel(label);
|
|
420
|
+
}
|
|
421
|
+
updateDetailsPane() {
|
|
422
|
+
if (!this.detailsBox || !this.showDetailsPane)
|
|
423
|
+
return;
|
|
424
|
+
const selectedAlert = this.filteredAlerts[this.selectedAlertIndex];
|
|
425
|
+
if (!selectedAlert) {
|
|
426
|
+
this.detailsBox.setContent('No alert selected');
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
const content = this.formatAlertDetails(selectedAlert);
|
|
430
|
+
this.detailsBox.setContent(content);
|
|
431
|
+
}
|
|
432
|
+
formatAlertDetails(alert) {
|
|
433
|
+
const lines = [];
|
|
434
|
+
lines.push(`{bold}Alert Details{/bold}`);
|
|
435
|
+
lines.push('');
|
|
436
|
+
lines.push(`ID: ${alert.id}`);
|
|
437
|
+
lines.push(`Level: ${this.levelIcons[alert.level]} ${alert.level.toUpperCase()}`);
|
|
438
|
+
lines.push(`Type: ${this.typeIcons[alert.type]} ${alert.type.toUpperCase()}`);
|
|
439
|
+
lines.push(`Status: ${alert.status.toUpperCase()}`);
|
|
440
|
+
lines.push('');
|
|
441
|
+
lines.push(`{bold}Title:{/bold} ${alert.title}`);
|
|
442
|
+
lines.push('');
|
|
443
|
+
lines.push(`{bold}Message:{/bold}`);
|
|
444
|
+
lines.push(alert.message);
|
|
445
|
+
lines.push('');
|
|
446
|
+
lines.push(`{bold}Source:{/bold} ${alert.source}`);
|
|
447
|
+
if (alert.channelId) {
|
|
448
|
+
lines.push(`{bold}Channel:{/bold} ${alert.channelId}`);
|
|
449
|
+
}
|
|
450
|
+
lines.push('');
|
|
451
|
+
lines.push(`{bold}Created:{/bold} ${new Date(alert.timestamp).toLocaleString()}`);
|
|
452
|
+
if (alert.acknowledged) {
|
|
453
|
+
lines.push(`{bold}Acknowledged:{/bold} ${alert.acknowledgedAt ? new Date(alert.acknowledgedAt).toLocaleString() : 'Yes'}`);
|
|
454
|
+
if (alert.acknowledgedBy) {
|
|
455
|
+
lines.push(`{bold}Acknowledged By:{/bold} ${alert.acknowledgedBy}`);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (alert.resolvedAt) {
|
|
459
|
+
lines.push(`{bold}Resolved:{/bold} ${new Date(alert.resolvedAt).toLocaleString()}`);
|
|
460
|
+
}
|
|
461
|
+
if (alert.notes) {
|
|
462
|
+
lines.push('');
|
|
463
|
+
lines.push(`{bold}Notes:{/bold}`);
|
|
464
|
+
lines.push(alert.notes);
|
|
465
|
+
}
|
|
466
|
+
if (alert.metadata && Object.keys(alert.metadata).length > 0) {
|
|
467
|
+
lines.push('');
|
|
468
|
+
lines.push(`{bold}Metadata:{/bold}`);
|
|
469
|
+
Object.entries(alert.metadata).forEach(([key, value]) => {
|
|
470
|
+
lines.push(` ${key}: ${JSON.stringify(value)}`);
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
return lines.join('\n');
|
|
474
|
+
}
|
|
475
|
+
applyFilter() {
|
|
476
|
+
this.filteredAlerts = this.alerts.filter(alert => {
|
|
477
|
+
if (this.currentFilter.levels?.length && !this.currentFilter.levels.includes(alert.level)) {
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
if (this.currentFilter.types?.length && !this.currentFilter.types.includes(alert.type)) {
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
if (this.currentFilter.statuses?.length && !this.currentFilter.statuses.includes(alert.status)) {
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
if (this.currentFilter.sources?.length && !this.currentFilter.sources.includes(alert.source)) {
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
if (this.currentFilter.channelIds?.length && !this.currentFilter.channelIds.includes(alert.channelId || '')) {
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
492
|
+
if (this.currentFilter.timeRange) {
|
|
493
|
+
if (alert.timestamp < this.currentFilter.timeRange.start ||
|
|
494
|
+
alert.timestamp > this.currentFilter.timeRange.end) {
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
if (this.currentFilter.searchText) {
|
|
499
|
+
const searchText = this.currentFilter.searchText.toLowerCase();
|
|
500
|
+
return alert.title.toLowerCase().includes(searchText) ||
|
|
501
|
+
alert.message.toLowerCase().includes(searchText) ||
|
|
502
|
+
alert.source.toLowerCase().includes(searchText);
|
|
503
|
+
}
|
|
504
|
+
if (this.currentFilter.acknowledgedOnly && !alert.acknowledged) {
|
|
505
|
+
return false;
|
|
506
|
+
}
|
|
507
|
+
if (this.currentFilter.unacknowledgedOnly && alert.acknowledged) {
|
|
508
|
+
return false;
|
|
509
|
+
}
|
|
510
|
+
return true;
|
|
511
|
+
});
|
|
512
|
+
if (this.currentGrouping) {
|
|
513
|
+
this.applyGrouping();
|
|
514
|
+
}
|
|
515
|
+
this.filteredAlerts.sort((a, b) => b.timestamp - a.timestamp);
|
|
516
|
+
}
|
|
517
|
+
applyGrouping() {
|
|
518
|
+
if (!this.currentGrouping)
|
|
519
|
+
return;
|
|
520
|
+
const groups = new Map();
|
|
521
|
+
this.filteredAlerts.forEach(alert => {
|
|
522
|
+
const groupKey = alert[this.currentGrouping.field];
|
|
523
|
+
if (!groups.has(groupKey)) {
|
|
524
|
+
groups.set(groupKey, []);
|
|
525
|
+
}
|
|
526
|
+
groups.get(groupKey).push(alert);
|
|
527
|
+
});
|
|
528
|
+
this.filteredAlerts = [];
|
|
529
|
+
Array.from(groups.entries()).forEach(([, groupAlerts]) => {
|
|
530
|
+
groupAlerts.sort((a, b) => {
|
|
531
|
+
const aVal = a[this.currentGrouping.field];
|
|
532
|
+
const bVal = b[this.currentGrouping.field];
|
|
533
|
+
if (aVal === undefined && bVal === undefined)
|
|
534
|
+
return 0;
|
|
535
|
+
if (aVal === undefined)
|
|
536
|
+
return 1;
|
|
537
|
+
if (bVal === undefined)
|
|
538
|
+
return -1;
|
|
539
|
+
return this.currentGrouping.sortOrder === 'asc' ?
|
|
540
|
+
(aVal < bVal ? -1 : 1) : (aVal > bVal ? -1 : 1);
|
|
541
|
+
});
|
|
542
|
+
const limitedGroup = this.currentGrouping.maxPerGroup
|
|
543
|
+
? groupAlerts.slice(0, this.currentGrouping.maxPerGroup)
|
|
544
|
+
: groupAlerts;
|
|
545
|
+
this.filteredAlerts.push(...limitedGroup);
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
toggleDetailsPane() {
|
|
549
|
+
this.showDetailsPane = !this.showDetailsPane;
|
|
550
|
+
this.updateLayout();
|
|
551
|
+
this.updateDetailsPane();
|
|
552
|
+
this.throttledRender();
|
|
553
|
+
}
|
|
554
|
+
toggleFilterPane() {
|
|
555
|
+
this.showFilterPane = !this.showFilterPane;
|
|
556
|
+
this.updateLayout();
|
|
557
|
+
if (this.filterBox) {
|
|
558
|
+
this.filterBox.setContent(this.generateFilterContent());
|
|
559
|
+
}
|
|
560
|
+
this.throttledRender();
|
|
561
|
+
}
|
|
562
|
+
toggleStatisticsPane() {
|
|
563
|
+
this.showStatisticsPane = !this.showStatisticsPane;
|
|
564
|
+
this.updateLayout();
|
|
565
|
+
this.updateStatistics();
|
|
566
|
+
this.throttledRender();
|
|
567
|
+
}
|
|
568
|
+
updateStatistics() {
|
|
569
|
+
if (!this.statisticsBox || !this.showStatisticsPane)
|
|
570
|
+
return;
|
|
571
|
+
const stats = this.calculateStatistics();
|
|
572
|
+
const content = this.formatStatistics(stats);
|
|
573
|
+
this.statisticsBox.setContent(content);
|
|
574
|
+
}
|
|
575
|
+
calculateStatistics() {
|
|
576
|
+
const stats = {
|
|
577
|
+
total: this.alerts.length,
|
|
578
|
+
byLevel: { info: 0, warning: 0, error: 0, critical: 0 },
|
|
579
|
+
byType: { system: 0, stream: 0, channel: 0, network: 0 },
|
|
580
|
+
byStatus: { active: 0, acknowledged: 0, resolved: 0, ignored: 0 },
|
|
581
|
+
bySource: {},
|
|
582
|
+
last24Hours: 0,
|
|
583
|
+
mostFrequentType: 'system',
|
|
584
|
+
};
|
|
585
|
+
const now = Date.now();
|
|
586
|
+
const last24Hours = now - (24 * 60 * 60 * 1000);
|
|
587
|
+
const ackTimes = [];
|
|
588
|
+
const resolveTimes = [];
|
|
589
|
+
this.alerts.forEach(alert => {
|
|
590
|
+
stats.byLevel[alert.level]++;
|
|
591
|
+
stats.byType[alert.type]++;
|
|
592
|
+
stats.byStatus[alert.status]++;
|
|
593
|
+
stats.bySource[alert.source] = (stats.bySource[alert.source] || 0) + 1;
|
|
594
|
+
if (alert.timestamp >= last24Hours) {
|
|
595
|
+
stats.last24Hours++;
|
|
596
|
+
}
|
|
597
|
+
if (alert.acknowledged && alert.acknowledgedAt) {
|
|
598
|
+
ackTimes.push(alert.acknowledgedAt - alert.timestamp);
|
|
599
|
+
}
|
|
600
|
+
if (alert.resolvedAt) {
|
|
601
|
+
resolveTimes.push(alert.resolvedAt - alert.timestamp);
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
const typeEntries = Object.entries(stats.byType);
|
|
605
|
+
stats.mostFrequentType = typeEntries.reduce((a, b) => a[1] > b[1] ? a : b)[0];
|
|
606
|
+
if (ackTimes.length > 0) {
|
|
607
|
+
stats.avgTimeToAck = ackTimes.reduce((a, b) => a + b, 0) / ackTimes.length;
|
|
608
|
+
}
|
|
609
|
+
if (resolveTimes.length > 0) {
|
|
610
|
+
stats.avgTimeToResolve = resolveTimes.reduce((a, b) => a + b, 0) / resolveTimes.length;
|
|
611
|
+
}
|
|
612
|
+
return stats;
|
|
613
|
+
}
|
|
614
|
+
formatStatistics(stats) {
|
|
615
|
+
const lines = [];
|
|
616
|
+
lines.push(`{bold}Alert Statistics{/bold}`);
|
|
617
|
+
lines.push('');
|
|
618
|
+
lines.push(`Total Alerts: ${stats.total}`);
|
|
619
|
+
lines.push(`Last 24h: ${stats.last24Hours}`);
|
|
620
|
+
lines.push('');
|
|
621
|
+
lines.push(`{bold}By Level:{/bold}`);
|
|
622
|
+
Object.entries(stats.byLevel).forEach(([level, count]) => {
|
|
623
|
+
if (count > 0) {
|
|
624
|
+
const icon = this.levelIcons[level];
|
|
625
|
+
lines.push(` ${icon} ${level}: ${count}`);
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
lines.push('');
|
|
629
|
+
lines.push(`{bold}By Type:{/bold}`);
|
|
630
|
+
Object.entries(stats.byType).forEach(([type, count]) => {
|
|
631
|
+
if (count > 0) {
|
|
632
|
+
const icon = this.typeIcons[type];
|
|
633
|
+
lines.push(` ${icon} ${type}: ${count}`);
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
lines.push('');
|
|
637
|
+
lines.push(`{bold}By Status:{/bold}`);
|
|
638
|
+
Object.entries(stats.byStatus).forEach(([status, count]) => {
|
|
639
|
+
if (count > 0) {
|
|
640
|
+
lines.push(` ${status}: ${count}`);
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
if (stats.avgTimeToAck) {
|
|
644
|
+
lines.push('');
|
|
645
|
+
lines.push(`Avg Ack Time: ${Math.round(stats.avgTimeToAck / 1000)}s`);
|
|
646
|
+
}
|
|
647
|
+
if (stats.avgTimeToResolve) {
|
|
648
|
+
lines.push(`Avg Resolve Time: ${Math.round(stats.avgTimeToResolve / 60000)}m`);
|
|
649
|
+
}
|
|
650
|
+
return lines.join('\n');
|
|
651
|
+
}
|
|
652
|
+
acknowledgeSelectedAlert() {
|
|
653
|
+
const alert = this.filteredAlerts[this.selectedAlertIndex];
|
|
654
|
+
if (!alert || alert.acknowledged)
|
|
655
|
+
return;
|
|
656
|
+
this.acknowledgeAlert(alert.id);
|
|
657
|
+
}
|
|
658
|
+
ignoreSelectedAlert() {
|
|
659
|
+
const alert = this.filteredAlerts[this.selectedAlertIndex];
|
|
660
|
+
if (!alert)
|
|
661
|
+
return;
|
|
662
|
+
this.ignoreAlert(alert.id);
|
|
663
|
+
}
|
|
664
|
+
addNotesToSelected() {
|
|
665
|
+
const alert = this.filteredAlerts[this.selectedAlertIndex];
|
|
666
|
+
if (!alert)
|
|
667
|
+
return;
|
|
668
|
+
this.emit('alert:request-notes', { alertId: alert.id, alert });
|
|
669
|
+
}
|
|
670
|
+
jumpToAlert(index) {
|
|
671
|
+
if (index >= 0 && index < this.filteredAlerts.length) {
|
|
672
|
+
this.selectAlert(index);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
resolveSelectedAlert() {
|
|
676
|
+
const alert = this.filteredAlerts[this.selectedAlertIndex];
|
|
677
|
+
if (!alert)
|
|
678
|
+
return;
|
|
679
|
+
this.resolveAlert(alert.id);
|
|
680
|
+
}
|
|
681
|
+
deleteSelectedAlert() {
|
|
682
|
+
const alert = this.filteredAlerts[this.selectedAlertIndex];
|
|
683
|
+
if (!alert)
|
|
684
|
+
return;
|
|
685
|
+
this.deleteAlert(alert.id);
|
|
686
|
+
}
|
|
687
|
+
clearAllAlerts() {
|
|
688
|
+
this.alerts = [];
|
|
689
|
+
this.applyFilter();
|
|
690
|
+
this.updateAlertList();
|
|
691
|
+
this.updateDetailsPane();
|
|
692
|
+
this.updateStatistics();
|
|
693
|
+
this.throttledRender();
|
|
694
|
+
this.emit('alert:cleared', { timestamp: Date.now() });
|
|
695
|
+
}
|
|
696
|
+
refreshAlerts() {
|
|
697
|
+
this.emit('alert:refresh', { timestamp: Date.now() });
|
|
698
|
+
}
|
|
699
|
+
addAlert(alert) {
|
|
700
|
+
this.alerts.unshift(alert);
|
|
701
|
+
if (this.alerts.length > this.panelConfig.maxDisplayItems) {
|
|
702
|
+
this.alerts = this.alerts.slice(0, this.panelConfig.maxDisplayItems);
|
|
703
|
+
}
|
|
704
|
+
this.applyFilter();
|
|
705
|
+
this.updateAlertList();
|
|
706
|
+
this.updateDetailsPane();
|
|
707
|
+
this.updateStatistics();
|
|
708
|
+
this.throttledRender();
|
|
709
|
+
}
|
|
710
|
+
deleteAlert(alertId) {
|
|
711
|
+
const index = this.alerts.findIndex(a => a.id === alertId);
|
|
712
|
+
if (index === -1)
|
|
713
|
+
return false;
|
|
714
|
+
this.alerts.splice(index, 1);
|
|
715
|
+
this.applyFilter();
|
|
716
|
+
this.updateAlertList();
|
|
717
|
+
this.updateDetailsPane();
|
|
718
|
+
this.updateStatistics();
|
|
719
|
+
this.throttledRender();
|
|
720
|
+
this.emit('alert:deleted', { alertId, timestamp: Date.now() });
|
|
721
|
+
return true;
|
|
722
|
+
}
|
|
723
|
+
setFilter(filter) {
|
|
724
|
+
this.currentFilter = { ...filter };
|
|
725
|
+
this.applyFilter();
|
|
726
|
+
this.updateAlertList();
|
|
727
|
+
this.updateDetailsPane();
|
|
728
|
+
this.updateStatistics();
|
|
729
|
+
if (this.filterBox) {
|
|
730
|
+
this.filterBox.setContent(this.generateFilterContent());
|
|
731
|
+
}
|
|
732
|
+
this.throttledRender();
|
|
733
|
+
}
|
|
734
|
+
setGrouping(grouping) {
|
|
735
|
+
this.currentGrouping = grouping;
|
|
736
|
+
this.applyFilter();
|
|
737
|
+
this.updateAlertList();
|
|
738
|
+
this.updateDetailsPane();
|
|
739
|
+
this.throttledRender();
|
|
740
|
+
}
|
|
741
|
+
getAlerts() {
|
|
742
|
+
return [...this.alerts];
|
|
743
|
+
}
|
|
744
|
+
getFilteredAlerts() {
|
|
745
|
+
return [...this.filteredAlerts];
|
|
746
|
+
}
|
|
747
|
+
getStatistics() {
|
|
748
|
+
return this.calculateStatistics();
|
|
749
|
+
}
|
|
750
|
+
acknowledgeCurrentAlert(user) {
|
|
751
|
+
const alert = this.getSelectedAlert();
|
|
752
|
+
if (!alert)
|
|
753
|
+
return false;
|
|
754
|
+
return this.acknowledgeAlert(alert.id, user);
|
|
755
|
+
}
|
|
756
|
+
acknowledgeAlert(alertId, user) {
|
|
757
|
+
return this.acknowledgeAlertInternal(alertId, user, true);
|
|
758
|
+
}
|
|
759
|
+
resolveCurrentAlert(user) {
|
|
760
|
+
const alert = this.getSelectedAlert();
|
|
761
|
+
if (!alert)
|
|
762
|
+
return false;
|
|
763
|
+
return this.resolveAlert(alert.id, user);
|
|
764
|
+
}
|
|
765
|
+
resolveAlert(alertId, user) {
|
|
766
|
+
return this.resolveAlertInternal(alertId, user, true);
|
|
767
|
+
}
|
|
768
|
+
ignoreCurrentAlert(user) {
|
|
769
|
+
const alert = this.getSelectedAlert();
|
|
770
|
+
if (!alert)
|
|
771
|
+
return false;
|
|
772
|
+
return this.ignoreAlert(alert.id, user);
|
|
773
|
+
}
|
|
774
|
+
ignoreAlert(alertId, user) {
|
|
775
|
+
const alert = this.alerts.find(a => a.id === alertId);
|
|
776
|
+
if (!alert || alert.status === 'ignored')
|
|
777
|
+
return false;
|
|
778
|
+
alert.status = 'ignored';
|
|
779
|
+
alert.acknowledgedAt = Date.now();
|
|
780
|
+
if (user) {
|
|
781
|
+
alert.acknowledgedBy = user;
|
|
782
|
+
}
|
|
783
|
+
this.applyFilter();
|
|
784
|
+
this.updateAlertList();
|
|
785
|
+
this.updateDetailsPane();
|
|
786
|
+
this.updateStatistics();
|
|
787
|
+
this.throttledRender();
|
|
788
|
+
this.emit('alert:ignored', { alertId, alert, user });
|
|
789
|
+
return true;
|
|
790
|
+
}
|
|
791
|
+
acknowledgeBatch(alertIds, user) {
|
|
792
|
+
const result = { success: [], failed: [] };
|
|
793
|
+
alertIds.forEach(alertId => {
|
|
794
|
+
if (this.acknowledgeAlertInternal(alertId, user, false)) {
|
|
795
|
+
result.success.push(alertId);
|
|
796
|
+
}
|
|
797
|
+
else {
|
|
798
|
+
result.failed.push(alertId);
|
|
799
|
+
}
|
|
800
|
+
});
|
|
801
|
+
this.applyFilter();
|
|
802
|
+
this.updateAlertList();
|
|
803
|
+
this.updateDetailsPane();
|
|
804
|
+
this.updateStatistics();
|
|
805
|
+
this.throttledRender();
|
|
806
|
+
this.emit('alert:batch-acknowledged', { success: result.success, failed: result.failed, user });
|
|
807
|
+
return result;
|
|
808
|
+
}
|
|
809
|
+
resolveBatch(alertIds, user) {
|
|
810
|
+
const result = { success: [], failed: [] };
|
|
811
|
+
alertIds.forEach(alertId => {
|
|
812
|
+
if (this.resolveAlertInternal(alertId, user, false)) {
|
|
813
|
+
result.success.push(alertId);
|
|
814
|
+
}
|
|
815
|
+
else {
|
|
816
|
+
result.failed.push(alertId);
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
this.applyFilter();
|
|
820
|
+
this.updateAlertList();
|
|
821
|
+
this.updateDetailsPane();
|
|
822
|
+
this.updateStatistics();
|
|
823
|
+
this.throttledRender();
|
|
824
|
+
this.emit('alert:batch-resolved', { success: result.success, failed: result.failed, user });
|
|
825
|
+
return result;
|
|
826
|
+
}
|
|
827
|
+
acknowledgeAllFiltered(user) {
|
|
828
|
+
const alertIds = this.filteredAlerts
|
|
829
|
+
.filter(alert => !alert.acknowledged)
|
|
830
|
+
.map(alert => alert.id);
|
|
831
|
+
const result = this.acknowledgeBatch(alertIds, user);
|
|
832
|
+
return result.success.length;
|
|
833
|
+
}
|
|
834
|
+
resolveAllFiltered(user) {
|
|
835
|
+
const alertIds = this.filteredAlerts
|
|
836
|
+
.filter(alert => alert.status === 'active' || alert.status === 'acknowledged')
|
|
837
|
+
.map(alert => alert.id);
|
|
838
|
+
const result = this.resolveBatch(alertIds, user);
|
|
839
|
+
return result.success.length;
|
|
840
|
+
}
|
|
841
|
+
addAlertNotes(alertId, notes, user) {
|
|
842
|
+
const alert = this.alerts.find(a => a.id === alertId);
|
|
843
|
+
if (!alert)
|
|
844
|
+
return false;
|
|
845
|
+
const timestamp = new Date().toISOString();
|
|
846
|
+
const noteEntry = user ? `[${timestamp}] ${user}: ${notes}` : `[${timestamp}] ${notes}`;
|
|
847
|
+
if (alert.notes) {
|
|
848
|
+
alert.notes += '\n' + noteEntry;
|
|
849
|
+
}
|
|
850
|
+
else {
|
|
851
|
+
alert.notes = noteEntry;
|
|
852
|
+
}
|
|
853
|
+
this.updateDetailsPane();
|
|
854
|
+
this.throttledRender();
|
|
855
|
+
this.emit('alert:notes-added', { alertId, alert, notes, user });
|
|
856
|
+
return true;
|
|
857
|
+
}
|
|
858
|
+
getSelectedAlert() {
|
|
859
|
+
if (this.selectedAlertIndex >= 0 && this.selectedAlertIndex < this.filteredAlerts.length) {
|
|
860
|
+
return this.filteredAlerts[this.selectedAlertIndex] || null;
|
|
861
|
+
}
|
|
862
|
+
return null;
|
|
863
|
+
}
|
|
864
|
+
selectAlert(index) {
|
|
865
|
+
if (index >= 0 && index < this.filteredAlerts.length) {
|
|
866
|
+
this.selectedAlertIndex = index;
|
|
867
|
+
if (this.alertList) {
|
|
868
|
+
this.alertList.select(index);
|
|
869
|
+
}
|
|
870
|
+
this.updateDetailsPane();
|
|
871
|
+
this.throttledRender();
|
|
872
|
+
return true;
|
|
873
|
+
}
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
selectAlertById(alertId) {
|
|
877
|
+
const index = this.filteredAlerts.findIndex(alert => alert.id === alertId);
|
|
878
|
+
if (index !== -1) {
|
|
879
|
+
return this.selectAlert(index);
|
|
880
|
+
}
|
|
881
|
+
return false;
|
|
882
|
+
}
|
|
883
|
+
acknowledgeAlertInternal(alertId, user, shouldUpdate = true) {
|
|
884
|
+
const alert = this.alerts.find(a => a.id === alertId);
|
|
885
|
+
if (!alert || alert.acknowledged)
|
|
886
|
+
return false;
|
|
887
|
+
alert.acknowledged = true;
|
|
888
|
+
alert.acknowledgedAt = Date.now();
|
|
889
|
+
if (user) {
|
|
890
|
+
alert.acknowledgedBy = user;
|
|
891
|
+
}
|
|
892
|
+
if (alert.status === 'active') {
|
|
893
|
+
alert.status = 'acknowledged';
|
|
894
|
+
}
|
|
895
|
+
if (shouldUpdate) {
|
|
896
|
+
this.applyFilter();
|
|
897
|
+
this.updateAlertList();
|
|
898
|
+
this.updateDetailsPane();
|
|
899
|
+
this.updateStatistics();
|
|
900
|
+
this.throttledRender();
|
|
901
|
+
this.emit('alert:acknowledged', { alertId, alert, user });
|
|
902
|
+
}
|
|
903
|
+
return true;
|
|
904
|
+
}
|
|
905
|
+
resolveAlertInternal(alertId, user, shouldUpdate = true) {
|
|
906
|
+
const alert = this.alerts.find(a => a.id === alertId);
|
|
907
|
+
if (!alert || alert.status === 'resolved')
|
|
908
|
+
return false;
|
|
909
|
+
alert.status = 'resolved';
|
|
910
|
+
alert.resolvedAt = Date.now();
|
|
911
|
+
if (!alert.acknowledged) {
|
|
912
|
+
alert.acknowledged = true;
|
|
913
|
+
alert.acknowledgedAt = Date.now();
|
|
914
|
+
if (user) {
|
|
915
|
+
alert.acknowledgedBy = user;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
if (shouldUpdate) {
|
|
919
|
+
this.applyFilter();
|
|
920
|
+
this.updateAlertList();
|
|
921
|
+
this.updateDetailsPane();
|
|
922
|
+
this.updateStatistics();
|
|
923
|
+
this.throttledRender();
|
|
924
|
+
this.emit('alert:resolved', { alertId, alert, user });
|
|
925
|
+
}
|
|
926
|
+
return true;
|
|
927
|
+
}
|
|
928
|
+
handleNewAlert(data) {
|
|
929
|
+
this.addAlert(data.alert);
|
|
930
|
+
}
|
|
931
|
+
handleAlertAcknowledged(data) {
|
|
932
|
+
this.acknowledgeAlertInternal(data.alertId, data.user, false);
|
|
933
|
+
}
|
|
934
|
+
handleAlertResolved(data) {
|
|
935
|
+
this.resolveAlertInternal(data.alertId, undefined, false);
|
|
936
|
+
}
|
|
937
|
+
handleAlertUpdated(data) {
|
|
938
|
+
const index = this.alerts.findIndex(a => a.id === data.alert.id);
|
|
939
|
+
if (index !== -1) {
|
|
940
|
+
this.alerts[index] = data.alert;
|
|
941
|
+
this.applyFilter();
|
|
942
|
+
this.updateAlertList();
|
|
943
|
+
this.updateDetailsPane();
|
|
944
|
+
this.updateStatistics();
|
|
945
|
+
this.throttledRender();
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
handleFilterChanged(data) {
|
|
949
|
+
this.setFilter(data.filter);
|
|
950
|
+
}
|
|
951
|
+
handleClearAlerts() {
|
|
952
|
+
this.clearAllAlerts();
|
|
953
|
+
}
|
|
954
|
+
render() {
|
|
955
|
+
if (this.isDestroyed)
|
|
956
|
+
return;
|
|
957
|
+
try {
|
|
958
|
+
this.updateAlertList();
|
|
959
|
+
this.updateDetailsPane();
|
|
960
|
+
this.updateStatistics();
|
|
961
|
+
const currentScreen = getScreen();
|
|
962
|
+
if (currentScreen && currentScreen.render) {
|
|
963
|
+
currentScreen.render();
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
catch (error) {
|
|
967
|
+
this.handleError(error instanceof Error ? error : new Error('Render failed'));
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
update(data) {
|
|
971
|
+
if (this.isDestroyed)
|
|
972
|
+
return;
|
|
973
|
+
try {
|
|
974
|
+
if (data === null || data === undefined) {
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
if (data.alerts && Array.isArray(data.alerts)) {
|
|
978
|
+
this.alerts = data.alerts;
|
|
979
|
+
this.applyFilter();
|
|
980
|
+
}
|
|
981
|
+
if (data.filter && typeof data.filter === 'object') {
|
|
982
|
+
this.setFilter(data.filter);
|
|
983
|
+
}
|
|
984
|
+
if (data.grouping) {
|
|
985
|
+
this.setGrouping(data.grouping);
|
|
986
|
+
}
|
|
987
|
+
this.updateState({ data, lastUpdate: new Date() });
|
|
988
|
+
this.throttledRender();
|
|
989
|
+
}
|
|
990
|
+
catch (error) {
|
|
991
|
+
this.handleError(error instanceof Error ? error : new Error('Update failed'));
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
destroy() {
|
|
995
|
+
this.alerts = [];
|
|
996
|
+
this.filteredAlerts = [];
|
|
997
|
+
super.destroy();
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
exports.AlertPanel = AlertPanel;
|
|
1001
|
+
//# sourceMappingURL=alert.panel.js.map
|