polyv-live-cli
Version:
CLI tool for managing PolyV live streaming services.
79 lines • 2.58 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.StatusComponentFactory = exports.StatusComponent = void 0;
const blessed_1 = __importDefault(require("blessed"));
const base_component_1 = require("./base.component");
class StatusComponent extends base_component_1.BaseComponent {
constructor(config, eventBus) {
super(config, eventBus);
}
createWidget() {
this.statusBox = blessed_1.default.box({
top: this.config.position.y,
left: this.config.position.x,
width: this.config.position.width,
height: this.config.position.height,
content: 'PolyV Monitoring Dashboard\nStatus: Starting...',
tags: true,
border: {
type: 'line',
},
style: {
fg: 'white',
bg: 'black',
border: {
fg: 'cyan',
},
},
label: ' Status ',
});
this.widget = this.statusBox;
}
render() {
if (this.isDestroyed || !this.widget)
return;
try {
this.widget.screen?.render();
}
catch (error) {
this.handleError(error instanceof Error ? error : new Error('Render error'));
}
}
update(data) {
if (this.isDestroyed || !this.statusBox)
return;
try {
const statusText = this.formatStatus(data);
this.statusBox.setContent(statusText);
this.render();
this.updateState({ lastUpdate: new Date() });
}
catch (error) {
this.handleError(error instanceof Error ? error : new Error('Update error'));
}
}
formatStatus(data) {
const lines = [
'PolyV Monitoring Dashboard',
'',
`Status: ${data?.status || 'Running'}`,
`Uptime: ${data?.uptime || '0s'}`,
`Layout: ${data?.layout || 'default'}`,
`Components: ${data?.components || '0'}`,
'',
'Press ? for help, q to quit',
];
return lines.join('\n');
}
}
exports.StatusComponent = StatusComponent;
exports.StatusComponentFactory = {
type: 'status',
create: (config, eventBus) => {
return new StatusComponent(config, eventBus);
},
};
//# sourceMappingURL=status.component.js.map