|
| 1 | +import Canvas from '../../../../../src/component/Canvas.mjs'; |
| 2 | + |
| 3 | +/** |
| 4 | + * @class AgentOS.view.TimelineCanvas |
| 5 | + * @extends Neo.component.Canvas |
| 6 | + */ |
| 7 | +class TimelineCanvas extends Canvas { |
| 8 | + static config = { |
| 9 | + /** |
| 10 | + * @member {String} className='AgentOS.view.TimelineCanvas' |
| 11 | + * @protected |
| 12 | + */ |
| 13 | + className: 'AgentOS.view.TimelineCanvas', |
| 14 | + /** |
| 15 | + * @member {Object} _vdom |
| 16 | + */ |
| 17 | + _vdom: |
| 18 | + {tag: 'div', cls: ['neo-ticket-timeline-wrapper'], style: {width: '100%', height: '100%'}, cn: [ |
| 19 | + {tag: 'canvas', style: {width: '100%', height: '100%'}} |
| 20 | + ]} |
| 21 | + } |
| 22 | + |
| 23 | + /** |
| 24 | + * Triggered after the offscreenRegistered config got changed |
| 25 | + * @param {Boolean} value |
| 26 | + * @param {Boolean} oldValue |
| 27 | + * @protected |
| 28 | + */ |
| 29 | + async afterSetOffscreenRegistered(value, oldValue) { |
| 30 | + if (value) { |
| 31 | + let me = this; |
| 32 | + |
| 33 | + // Direct Remote Method Access call |
| 34 | + // The namespace AgentOS.canvas.Blackboard is auto-generated in this worker |
| 35 | + // by the RemoteMethodAccess mixin when the Canvas worker registers it. |
| 36 | + await Portal.canvas.TicketCanvas.initGraph({canvasId: me.getCanvasId(), windowId: me.windowId}); |
| 37 | + |
| 38 | + await me.updateSize() |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * Override to return the inner canvas ID |
| 44 | + */ |
| 45 | + getCanvasId() { |
| 46 | + return this.vdom.cn[0].id; |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * @param {Object} data |
| 51 | + */ |
| 52 | + onDomResize(data) { |
| 53 | + super.onDomResize(data); |
| 54 | + this.updateSize(data.contentRect) |
| 55 | + } |
| 56 | + |
| 57 | + async updateSize(rect) { |
| 58 | + let me = this; |
| 59 | + |
| 60 | + if (!rect || rect.width === 0 || rect.height === 0) { |
| 61 | + rect = await me.waitForDomRect({id: me.getCanvasId()}) |
| 62 | + } |
| 63 | + |
| 64 | + // todo |
| 65 | + await Portal.canvas.TicketCanvas.updateSize({width: rect.width, height: rect.height}) |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +export default Neo.setupClass(TimelineCanvas); |
0 commit comments