refactor(static): add base component types

This commit is contained in:
2026-09-10 10:28:12 +03:00
parent 6683b7b5b0
commit bed8d7af7b
13 changed files with 368 additions and 236 deletions
+4 -27
View File
@@ -1,34 +1,11 @@
import { DataStorage } from "../base/storage";
import { ScheduleChannelElement, ScheduleChannelGroupElement } from "./component";
import { DataManager } from "../base/manager";
import { ScheduleChannelList } from "./component";
import { Channel } from "./model";
export class ScheduleChannelManager {
loadChannels(selector: string) {
const channels = window.scheduleChannelStorage.getAll();
const container = document.querySelector(selector);
if (container) {
container.innerHTML = "";
if (channels.length > 0) {
const groupElement = new ScheduleChannelGroupElement();
groupElement.setAttribute("channels", JSON.stringify(channels));
container.append(groupElement);
}
for (const channel of channels) {
const element = new ScheduleChannelElement();
element.setAttribute("channel", JSON.stringify(channel));
element.setAttribute("removable", "");
container.appendChild(element);
}
}
}
}
declare global {
interface Window {
scheduleChannelStorage: DataStorage<Channel>;
scheduleChannelManager: ScheduleChannelManager;
scheduleChannelManager: DataManager<Channel>;
}
}
window.scheduleChannelStorage = new DataStorage("schedule:channels");
window.scheduleChannelManager = new ScheduleChannelManager();
window.scheduleChannelManager = new DataManager(ScheduleChannelList, "schedule:channels", "#storedChannels");