|
| 1 | +class Graphic extends HTMLElement { |
| 2 | + connectedCallback() { |
| 3 | + // Called when the element is added to the DOM |
| 4 | + // Note: Don't paint any pixels at this point, wait for load() to be called |
| 5 | + } |
| 6 | + |
| 7 | + async load(params) { |
| 8 | + if (params.renderType !== "realtime") |
| 9 | + throw new Error("Only realtime rendering is supported by this graphic"); |
| 10 | + |
| 11 | + const elText = document.createElement("p"); |
| 12 | + elText.style.backgroundColor = "#ffffff"; |
| 13 | + elText.style.color = "#000000"; |
| 14 | + elText.style.display = "inline-block"; |
| 15 | + elText.style.padding = "10px"; |
| 16 | + elText.style.border = "1px solid #000000"; |
| 17 | + elText.innerHTML = "Hello world!"; |
| 18 | + this.appendChild(elText); |
| 19 | + |
| 20 | + // When everything is loaded we can return: |
| 21 | + return { |
| 22 | + statusCode: 200, |
| 23 | + }; |
| 24 | + } |
| 25 | + async dispose(_params) { |
| 26 | + this.innerHTML = ""; |
| 27 | + } |
| 28 | + async getStatus(_params) { |
| 29 | + return { |
| 30 | + statusCode: 200, |
| 31 | + status: { |
| 32 | + // nothing |
| 33 | + }, |
| 34 | + }; |
| 35 | + } |
| 36 | + async updateAction(_params) { |
| 37 | + // No actions are implemented in this minimal example |
| 38 | + } |
| 39 | + async playAction(_params) { |
| 40 | + // No actions are implemented in this minimal example |
| 41 | + } |
| 42 | + async stopAction(_params) { |
| 43 | + // No actions are implemented in this minimal example |
| 44 | + } |
| 45 | + async customAction(params) { |
| 46 | + // No actions are implemented in this minimal example |
| 47 | + } |
| 48 | + async goToTime(_payload) { |
| 49 | + throw new Error("Non-realtime not supported!"); |
| 50 | + } |
| 51 | + async setActionsSchedule(_payload) { |
| 52 | + throw new Error("Non-realtime not supported!"); |
| 53 | + } |
| 54 | +} |
| 55 | + |
| 56 | +export default Graphic; |
| 57 | + |
| 58 | +// Note: The renderer will render the component |
0 commit comments