Deepanjan Roy | fd79a7d | 2018-07-24 13:26:55 -0400 | [diff] [blame] | 1 | // Copyright (C) 2018 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | import * as m from 'mithril'; |
| 16 | |
Isabelle Taylor | d99a5d7 | 2019-03-25 16:45:32 +0000 | [diff] [blame] | 17 | import {Actions} from '../common/actions'; |
Hector Dearman | 79549c5 | 2019-04-01 13:30:46 +0100 | [diff] [blame] | 18 | import {LogExists, LogExistsKey} from '../common/logs'; |
Primiano Tucci | 8afc06d | 2018-08-06 19:11:42 +0100 | [diff] [blame] | 19 | import {QueryResponse} from '../common/queries'; |
Primiano Tucci | f30cd9c | 2018-08-13 01:53:26 +0200 | [diff] [blame] | 20 | import {TimeSpan} from '../common/time'; |
Primiano Tucci | 8afc06d | 2018-08-06 19:11:42 +0100 | [diff] [blame] | 21 | |
Nicolò Mazzucato | 87943de | 2019-07-25 16:26:33 +0100 | [diff] [blame] | 22 | import {ChromeSliceDetailsPanel} from './chrome_slice_panel'; |
Hector Dearman | a89177f | 2018-10-04 15:42:59 +0100 | [diff] [blame] | 23 | import {copyToClipboard} from './clipboard'; |
Neda Topoljanac | 643dbaa | 2019-09-11 12:06:56 +0100 | [diff] [blame] | 24 | import {CounterDetailsPanel} from './counter_panel'; |
Hector Dearman | afa51b2 | 2018-12-11 16:38:30 +0000 | [diff] [blame] | 25 | import {DragGestureHandler} from './drag_gesture_handler'; |
Primiano Tucci | 8afc06d | 2018-08-06 19:11:42 +0100 | [diff] [blame] | 26 | import {globals} from './globals'; |
Neda Topoljanac | a20caba | 2019-09-17 12:41:35 +0100 | [diff] [blame] | 27 | import {HeapDumpDetailsPanel} from './heap_dump_panel'; |
Hector Dearman | 79549c5 | 2019-04-01 13:30:46 +0100 | [diff] [blame] | 28 | import {LogPanel} from './logs_panel'; |
Hector Dearman | ea002ea | 2019-01-21 11:43:45 +0000 | [diff] [blame] | 29 | import {NotesEditorPanel, NotesPanel} from './notes_panel'; |
Deepanjan Roy | 1f658fe | 2018-09-11 08:38:17 -0400 | [diff] [blame] | 30 | import {OverviewTimelinePanel} from './overview_timeline_panel'; |
Deepanjan Roy | fd79a7d | 2018-07-24 13:26:55 -0400 | [diff] [blame] | 31 | import {createPage} from './pages'; |
Michail Schwab | 405002c | 2018-07-26 13:19:10 -0400 | [diff] [blame] | 32 | import {PanAndZoomHandler} from './pan_and_zoom_handler'; |
Deepanjan Roy | 4fa0ecc | 2018-10-03 16:10:46 -0400 | [diff] [blame] | 33 | import {Panel} from './panel'; |
| 34 | import {AnyAttrsVnode, PanelContainer} from './panel_container'; |
Isabelle Taylor | d99a5d7 | 2019-03-25 16:45:32 +0000 | [diff] [blame] | 35 | import {SliceDetailsPanel} from './slice_panel'; |
| 36 | import {ThreadStatePanel} from './thread_state_panel'; |
Hector Dearman | 372ec60 | 2019-09-03 12:12:02 +0100 | [diff] [blame] | 37 | import {TickmarkPanel} from './tickmark_panel'; |
Deepanjan Roy | 1f658fe | 2018-09-11 08:38:17 -0400 | [diff] [blame] | 38 | import {TimeAxisPanel} from './time_axis_panel'; |
Hector Dearman | 3e82d68 | 2019-01-09 15:55:10 +0000 | [diff] [blame] | 39 | import {computeZoom} from './time_scale'; |
Isabelle Taylor | 8325c5a | 2019-02-13 13:38:17 +0000 | [diff] [blame] | 40 | import {TimeSelectionPanel} from './time_selection_panel'; |
Hector Dearman | ccb0b79 | 2019-01-22 13:19:41 +0000 | [diff] [blame] | 41 | import {TRACK_SHELL_WIDTH} from './track_constants'; |
Deepanjan Roy | 32ad0d7 | 2018-10-18 14:50:16 -0400 | [diff] [blame] | 42 | import {TrackGroupPanel} from './track_group_panel'; |
Deepanjan Roy | 1f658fe | 2018-09-11 08:38:17 -0400 | [diff] [blame] | 43 | import {TrackPanel} from './track_panel'; |
Kodi Obika | 9adb058 | 2019-06-12 09:36:03 -0700 | [diff] [blame] | 44 | import {VideoPanel} from './video_panel'; |
Deepanjan Roy | fd79a7d | 2018-07-24 13:26:55 -0400 | [diff] [blame] | 45 | |
Isabelle Taylor | ee67d1b | 2019-02-27 14:12:53 +0000 | [diff] [blame] | 46 | const DRAG_HANDLE_HEIGHT_PX = 28; |
Isabelle Taylor | b6257fc | 2019-02-19 13:13:32 +0000 | [diff] [blame] | 47 | const DEFAULT_DETAILS_HEIGHT_PX = 230 + DRAG_HANDLE_HEIGHT_PX; |
Isabelle Taylor | ee67d1b | 2019-02-27 14:12:53 +0000 | [diff] [blame] | 48 | const UP_ICON = 'keyboard_arrow_up'; |
| 49 | const DOWN_ICON = 'keyboard_arrow_down'; |
Isabelle Taylor | f57b24f | 2019-07-31 11:06:41 +0100 | [diff] [blame] | 50 | const SIDEBAR_WIDTH = 256; |
Primiano Tucci | 8afc06d | 2018-08-06 19:11:42 +0100 | [diff] [blame] | 51 | |
Hector Dearman | 79549c5 | 2019-04-01 13:30:46 +0100 | [diff] [blame] | 52 | function hasLogs(): boolean { |
| 53 | const data = globals.trackDataStore.get(LogExistsKey) as LogExists; |
| 54 | return data && data.exists; |
| 55 | } |
| 56 | |
Deepanjan Roy | 4fa0ecc | 2018-10-03 16:10:46 -0400 | [diff] [blame] | 57 | class QueryTable extends Panel { |
Primiano Tucci | 8afc06d | 2018-08-06 19:11:42 +0100 | [diff] [blame] | 58 | view() { |
| 59 | const resp = globals.queryResults.get('command') as QueryResponse; |
| 60 | if (resp === undefined) { |
| 61 | return m(''); |
| 62 | } |
| 63 | const cols = []; |
| 64 | for (const col of resp.columns) { |
| 65 | cols.push(m('td', col)); |
| 66 | } |
| 67 | const header = m('tr', cols); |
| 68 | |
| 69 | const rows = []; |
| 70 | for (let i = 0; i < resp.rows.length; i++) { |
| 71 | const cells = []; |
| 72 | for (const col of resp.columns) { |
| 73 | cells.push(m('td', resp.rows[i][col])); |
| 74 | } |
| 75 | rows.push(m('tr', cells)); |
| 76 | } |
| 77 | return m( |
| 78 | 'div', |
| 79 | m('header.overview', |
Hector Dearman | b1179f9 | 2019-01-08 16:18:56 +0000 | [diff] [blame] | 80 | `Query result - ${Math.round(resp.durationMs)} ms`, |
| 81 | m('span.code', resp.query), |
Hector Dearman | a89177f | 2018-10-04 15:42:59 +0100 | [diff] [blame] | 82 | resp.error ? null : |
Hector Dearman | b1179f9 | 2019-01-08 16:18:56 +0000 | [diff] [blame] | 83 | m('button.query-ctrl', |
Hector Dearman | a89177f | 2018-10-04 15:42:59 +0100 | [diff] [blame] | 84 | { |
| 85 | onclick: () => { |
| 86 | const lines: string[][] = []; |
| 87 | lines.push(resp.columns); |
| 88 | for (const row of resp.rows) { |
| 89 | const line = []; |
| 90 | for (const col of resp.columns) { |
| 91 | line.push(row[col].toString()); |
| 92 | } |
| 93 | lines.push(line); |
| 94 | } |
| 95 | copyToClipboard( |
| 96 | lines.map(line => line.join('\t')).join('\n')); |
| 97 | }, |
| 98 | }, |
Hector Dearman | b1179f9 | 2019-01-08 16:18:56 +0000 | [diff] [blame] | 99 | 'Copy as .tsv'), |
| 100 | m('button.query-ctrl', |
| 101 | { |
| 102 | onclick: () => { |
| 103 | globals.queryResults.delete('command'); |
| 104 | globals.rafScheduler.scheduleFullRedraw(); |
| 105 | } |
| 106 | }, |
| 107 | 'Close'), ), |
Primiano Tucci | 8afc06d | 2018-08-06 19:11:42 +0100 | [diff] [blame] | 108 | resp.error ? |
| 109 | m('.query-error', `SQL error: ${resp.error}`) : |
| 110 | m('table.query-table', m('thead', header), m('tbody', rows))); |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 111 | } |
Deepanjan Roy | 4fa0ecc | 2018-10-03 16:10:46 -0400 | [diff] [blame] | 112 | |
| 113 | renderCanvas() {} |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 114 | } |
Primiano Tucci | 8afc06d | 2018-08-06 19:11:42 +0100 | [diff] [blame] | 115 | |
Hector Dearman | afa51b2 | 2018-12-11 16:38:30 +0000 | [diff] [blame] | 116 | interface DragHandleAttrs { |
| 117 | height: number; |
| 118 | resize: (height: number) => void; |
| 119 | } |
| 120 | |
| 121 | class DragHandle implements m.ClassComponent<DragHandleAttrs> { |
| 122 | private dragStartHeight = 0; |
| 123 | private height = 0; |
Isabelle Taylor | ee67d1b | 2019-02-27 14:12:53 +0000 | [diff] [blame] | 124 | private resize: (height: number) => void = () => {}; |
Hector Dearman | 79549c5 | 2019-04-01 13:30:46 +0100 | [diff] [blame] | 125 | private isClosed = this.height <= DRAG_HANDLE_HEIGHT_PX; |
Hector Dearman | afa51b2 | 2018-12-11 16:38:30 +0000 | [diff] [blame] | 126 | |
| 127 | oncreate({dom, attrs}: m.CVnodeDOM<DragHandleAttrs>) { |
| 128 | this.resize = attrs.resize; |
| 129 | this.height = attrs.height; |
Isabelle Taylor | cc85061 | 2019-08-19 14:15:20 +0100 | [diff] [blame] | 130 | this.isClosed = this.height <= DRAG_HANDLE_HEIGHT_PX; |
Hector Dearman | afa51b2 | 2018-12-11 16:38:30 +0000 | [diff] [blame] | 131 | const elem = dom as HTMLElement; |
| 132 | new DragGestureHandler( |
| 133 | elem, |
| 134 | this.onDrag.bind(this), |
| 135 | this.onDragStart.bind(this), |
| 136 | this.onDragEnd.bind(this)); |
| 137 | } |
| 138 | |
| 139 | onupdate({attrs}: m.CVnodeDOM<DragHandleAttrs>) { |
| 140 | this.resize = attrs.resize; |
| 141 | this.height = attrs.height; |
Isabelle Taylor | cc85061 | 2019-08-19 14:15:20 +0100 | [diff] [blame] | 142 | this.isClosed = this.height <= DRAG_HANDLE_HEIGHT_PX; |
Hector Dearman | afa51b2 | 2018-12-11 16:38:30 +0000 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | onDrag(_x: number, y: number) { |
Isabelle Taylor | ee67d1b | 2019-02-27 14:12:53 +0000 | [diff] [blame] | 146 | const newHeight = this.dragStartHeight + (DRAG_HANDLE_HEIGHT_PX / 2) - y; |
| 147 | this.isClosed = Math.floor(newHeight) <= DRAG_HANDLE_HEIGHT_PX; |
| 148 | this.resize(Math.floor(newHeight)); |
Hector Dearman | afa51b2 | 2018-12-11 16:38:30 +0000 | [diff] [blame] | 149 | globals.rafScheduler.scheduleFullRedraw(); |
| 150 | } |
| 151 | |
| 152 | onDragStart(_x: number, _y: number) { |
| 153 | this.dragStartHeight = this.height; |
| 154 | } |
| 155 | |
| 156 | onDragEnd() {} |
| 157 | |
| 158 | view() { |
Isabelle Taylor | ee67d1b | 2019-02-27 14:12:53 +0000 | [diff] [blame] | 159 | const icon = this.isClosed ? UP_ICON : DOWN_ICON; |
| 160 | const title = this.isClosed ? 'Show panel' : 'Hide panel'; |
| 161 | return m( |
| 162 | '.handle', |
| 163 | m('.handle-title', 'Current Selection'), |
| 164 | m('i.material-icons', |
| 165 | { |
| 166 | onclick: () => { |
| 167 | if (this.height === DRAG_HANDLE_HEIGHT_PX) { |
| 168 | this.isClosed = false; |
| 169 | this.resize(DEFAULT_DETAILS_HEIGHT_PX); |
| 170 | } else { |
| 171 | this.isClosed = true; |
| 172 | this.resize(DRAG_HANDLE_HEIGHT_PX); |
| 173 | } |
| 174 | globals.rafScheduler.scheduleFullRedraw(); |
| 175 | }, |
| 176 | title |
| 177 | }, |
| 178 | icon)); |
Hector Dearman | afa51b2 | 2018-12-11 16:38:30 +0000 | [diff] [blame] | 179 | } |
| 180 | } |
| 181 | |
Deepanjan Roy | fd79a7d | 2018-07-24 13:26:55 -0400 | [diff] [blame] | 182 | /** |
| 183 | * Top-most level component for the viewer page. Holds tracks, brush timeline, |
| 184 | * panels, and everything else that's part of the main trace viewer page. |
| 185 | */ |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 186 | class TraceViewer implements m.ClassComponent { |
| 187 | private onResize: () => void = () => {}; |
| 188 | private zoomContent?: PanAndZoomHandler; |
Hector Dearman | 79549c5 | 2019-04-01 13:30:46 +0100 | [diff] [blame] | 189 | private detailsHeight = DRAG_HANDLE_HEIGHT_PX; |
Isabelle Taylor | 0733c8c | 2019-02-07 13:55:23 +0000 | [diff] [blame] | 190 | // Used to set details panel to default height on selection. |
Hector Dearman | 79549c5 | 2019-04-01 13:30:46 +0100 | [diff] [blame] | 191 | private showDetailsPanel = true; |
Isabelle Taylor | 8325c5a | 2019-02-13 13:38:17 +0000 | [diff] [blame] | 192 | // Used to prevent global deselection if a pan/drag select occurred. |
| 193 | private keepCurrentSelection = false; |
Hector Dearman | 59e9812 | 2018-08-13 14:21:38 +0100 | [diff] [blame] | 194 | |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 195 | oncreate(vnode: m.CVnodeDOM) { |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 196 | const frontendLocalState = globals.frontendLocalState; |
Deepanjan Roy | 1f658fe | 2018-09-11 08:38:17 -0400 | [diff] [blame] | 197 | const updateDimensions = () => { |
Michail Schwab | 405002c | 2018-07-26 13:19:10 -0400 | [diff] [blame] | 198 | const rect = vnode.dom.getBoundingClientRect(); |
Deepanjan Roy | 9d95a25 | 2018-08-09 10:10:19 -0400 | [diff] [blame] | 199 | frontendLocalState.timeScale.setLimitsPx( |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 200 | 0, rect.width - TRACK_SHELL_WIDTH); |
Michail Schwab | 405002c | 2018-07-26 13:19:10 -0400 | [diff] [blame] | 201 | }; |
| 202 | |
Deepanjan Roy | 1f658fe | 2018-09-11 08:38:17 -0400 | [diff] [blame] | 203 | updateDimensions(); |
| 204 | |
| 205 | // TODO: Do resize handling better. |
| 206 | this.onResize = () => { |
| 207 | updateDimensions(); |
| 208 | globals.rafScheduler.scheduleFullRedraw(); |
| 209 | }; |
Michail Schwab | 405002c | 2018-07-26 13:19:10 -0400 | [diff] [blame] | 210 | |
| 211 | // Once ResizeObservers are out, we can stop accessing the window here. |
| 212 | window.addEventListener('resize', this.onResize); |
| 213 | |
Michail Schwab | a52306a | 2018-07-31 13:40:52 -0400 | [diff] [blame] | 214 | const panZoomEl = |
Deepanjan Roy | abd79aa | 2018-08-28 07:29:15 -0400 | [diff] [blame] | 215 | vnode.dom.querySelector('.pan-and-zoom-content') as HTMLElement; |
Michail Schwab | a52306a | 2018-07-31 13:40:52 -0400 | [diff] [blame] | 216 | |
Michail Schwab | 405002c | 2018-07-26 13:19:10 -0400 | [diff] [blame] | 217 | this.zoomContent = new PanAndZoomHandler({ |
Michail Schwab | a52306a | 2018-07-31 13:40:52 -0400 | [diff] [blame] | 218 | element: panZoomEl, |
Isabelle Taylor | f57b24f | 2019-07-31 11:06:41 +0100 | [diff] [blame] | 219 | contentOffsetX: SIDEBAR_WIDTH, |
Michail Schwab | 405002c | 2018-07-26 13:19:10 -0400 | [diff] [blame] | 220 | onPanned: (pannedPx: number) => { |
Isabelle Taylor | 8325c5a | 2019-02-13 13:38:17 +0000 | [diff] [blame] | 221 | this.keepCurrentSelection = true; |
Primiano Tucci | e36ca63 | 2018-08-21 14:32:23 +0200 | [diff] [blame] | 222 | const traceTime = globals.state.traceTime; |
| 223 | const vizTime = globals.frontendLocalState.visibleWindowTime; |
| 224 | const origDelta = vizTime.duration; |
| 225 | const tDelta = frontendLocalState.timeScale.deltaPxToDuration(pannedPx); |
| 226 | let tStart = vizTime.start + tDelta; |
| 227 | let tEnd = vizTime.end + tDelta; |
| 228 | if (tStart < traceTime.startSec) { |
| 229 | tStart = traceTime.startSec; |
| 230 | tEnd = tStart + origDelta; |
| 231 | } else if (tEnd > traceTime.endSec) { |
| 232 | tEnd = traceTime.endSec; |
| 233 | tStart = tEnd - origDelta; |
Primiano Tucci | f30cd9c | 2018-08-13 01:53:26 +0200 | [diff] [blame] | 234 | } |
Primiano Tucci | e36ca63 | 2018-08-21 14:32:23 +0200 | [diff] [blame] | 235 | frontendLocalState.updateVisibleTime(new TimeSpan(tStart, tEnd)); |
Hector Dearman | 2ba1133 | 2018-10-18 14:32:43 +0100 | [diff] [blame] | 236 | globals.rafScheduler.scheduleRedraw(); |
Michail Schwab | 405002c | 2018-07-26 13:19:10 -0400 | [diff] [blame] | 237 | }, |
Hector Dearman | 3e82d68 | 2019-01-09 15:55:10 +0000 | [diff] [blame] | 238 | onZoomed: (zoomedPositionPx: number, zoomRatio: number) => { |
| 239 | // TODO(hjd): Avoid hardcoding TRACK_SHELL_WIDTH. |
| 240 | // TODO(hjd): Improve support for zooming in overview timeline. |
| 241 | const span = frontendLocalState.visibleWindowTime; |
| 242 | const scale = frontendLocalState.timeScale; |
| 243 | const zoomPx = zoomedPositionPx - TRACK_SHELL_WIDTH; |
| 244 | const newSpan = computeZoom(scale, span, 1 - zoomRatio, zoomPx); |
| 245 | frontendLocalState.updateVisibleTime(newSpan); |
| 246 | globals.rafScheduler.scheduleRedraw(); |
Isabelle Taylor | 8325c5a | 2019-02-13 13:38:17 +0000 | [diff] [blame] | 247 | }, |
| 248 | onDragSelect: (selectStartPx: number|null, selectEndPx: number) => { |
| 249 | if (!selectStartPx) return; |
| 250 | this.keepCurrentSelection = true; |
Isabelle Taylor | 1ae33bc | 2019-02-22 11:44:33 +0000 | [diff] [blame] | 251 | globals.frontendLocalState.setShowTimeSelectPreview(false); |
Isabelle Taylor | 8325c5a | 2019-02-13 13:38:17 +0000 | [diff] [blame] | 252 | const traceTime = globals.state.traceTime; |
| 253 | const scale = frontendLocalState.timeScale; |
| 254 | const startPx = Math.min(selectStartPx, selectEndPx); |
| 255 | const endPx = Math.max(selectStartPx, selectEndPx); |
| 256 | const startTs = Math.max(traceTime.startSec, |
| 257 | scale.pxToTime(startPx - TRACK_SHELL_WIDTH)); |
| 258 | const endTs = Math.min(traceTime.endSec, |
| 259 | scale.pxToTime(endPx - TRACK_SHELL_WIDTH)); |
Isabelle Taylor | 593ac3f | 2019-10-03 10:46:52 +0100 | [diff] [blame^] | 260 | globals.frontendLocalState.selectTimeRange(startTs, endTs); |
Isabelle Taylor | 8325c5a | 2019-02-13 13:38:17 +0000 | [diff] [blame] | 261 | globals.rafScheduler.scheduleRedraw(); |
Michail Schwab | 405002c | 2018-07-26 13:19:10 -0400 | [diff] [blame] | 262 | } |
Deepanjan Roy | fd79a7d | 2018-07-24 13:26:55 -0400 | [diff] [blame] | 263 | }); |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 264 | } |
Hector Dearman | 59e9812 | 2018-08-13 14:21:38 +0100 | [diff] [blame] | 265 | |
Michail Schwab | 405002c | 2018-07-26 13:19:10 -0400 | [diff] [blame] | 266 | onremove() { |
| 267 | window.removeEventListener('resize', this.onResize); |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 268 | if (this.zoomContent) this.zoomContent.shutdown(); |
| 269 | } |
Hector Dearman | 59e9812 | 2018-08-13 14:21:38 +0100 | [diff] [blame] | 270 | |
Michail Schwab | 405002c | 2018-07-26 13:19:10 -0400 | [diff] [blame] | 271 | view() { |
Deepanjan Roy | 4fa0ecc | 2018-10-03 16:10:46 -0400 | [diff] [blame] | 272 | const scrollingPanels: AnyAttrsVnode[] = |
Hector Dearman | 9189b6b | 2019-02-27 14:58:51 +0000 | [diff] [blame] | 273 | globals.state.scrollingTracks.map(id => m(TrackPanel, {key: id, id})); |
Deepanjan Roy | 32ad0d7 | 2018-10-18 14:50:16 -0400 | [diff] [blame] | 274 | |
| 275 | for (const group of Object.values(globals.state.trackGroups)) { |
| 276 | scrollingPanels.push(m(TrackGroupPanel, { |
| 277 | trackGroupId: group.id, |
| 278 | key: `trackgroup-${group.id}`, |
| 279 | })); |
| 280 | if (group.collapsed) continue; |
| 281 | for (const trackId of group.tracks) { |
| 282 | scrollingPanels.push(m(TrackPanel, { |
| 283 | key: `track-${group.id}-${trackId}`, |
| 284 | id: trackId, |
| 285 | })); |
| 286 | } |
| 287 | } |
Isabelle Taylor | 1acfa2b | 2019-05-17 17:26:40 +0100 | [diff] [blame] | 288 | scrollingPanels.unshift(m(QueryTable, {key: 'query'})); |
Deepanjan Roy | 4fa0ecc | 2018-10-03 16:10:46 -0400 | [diff] [blame] | 289 | |
Hector Dearman | ea002ea | 2019-01-21 11:43:45 +0000 | [diff] [blame] | 290 | const detailsPanels: AnyAttrsVnode[] = []; |
Isabelle Taylor | ee67d1b | 2019-02-27 14:12:53 +0000 | [diff] [blame] | 291 | const curSelection = globals.state.currentSelection; |
| 292 | if (curSelection) { |
Isabelle Taylor | ee67d1b | 2019-02-27 14:12:53 +0000 | [diff] [blame] | 293 | switch (curSelection.kind) { |
Isabelle Taylor | 9a4afc6 | 2019-02-06 11:54:36 +0000 | [diff] [blame] | 294 | case 'NOTE': |
| 295 | detailsPanels.push(m(NotesEditorPanel, { |
| 296 | key: 'notes', |
Isabelle Taylor | ee67d1b | 2019-02-27 14:12:53 +0000 | [diff] [blame] | 297 | id: curSelection.id, |
Isabelle Taylor | 9a4afc6 | 2019-02-06 11:54:36 +0000 | [diff] [blame] | 298 | })); |
| 299 | break; |
| 300 | case 'SLICE': |
| 301 | detailsPanels.push(m(SliceDetailsPanel, { |
| 302 | key: 'slice', |
Isabelle Taylor | ee67d1b | 2019-02-27 14:12:53 +0000 | [diff] [blame] | 303 | utid: curSelection.utid, |
Isabelle Taylor | 9a4afc6 | 2019-02-06 11:54:36 +0000 | [diff] [blame] | 304 | })); |
| 305 | break; |
Neda Topoljanac | 643dbaa | 2019-09-11 12:06:56 +0100 | [diff] [blame] | 306 | case 'COUNTER': |
| 307 | detailsPanels.push(m(CounterDetailsPanel, { |
| 308 | key: 'counter', |
| 309 | })); |
| 310 | break; |
Neda Topoljanac | a20caba | 2019-09-17 12:41:35 +0100 | [diff] [blame] | 311 | case 'HEAP_DUMP': |
Neda Topoljanac | 3928801 | 2019-09-25 15:25:01 +0100 | [diff] [blame] | 312 | detailsPanels.push(m(HeapDumpDetailsPanel, {key: 'heap_dump'})); |
Neda Topoljanac | a20caba | 2019-09-17 12:41:35 +0100 | [diff] [blame] | 313 | break; |
Nicolò Mazzucato | 87943de | 2019-07-25 16:26:33 +0100 | [diff] [blame] | 314 | case 'CHROME_SLICE': |
| 315 | detailsPanels.push(m(ChromeSliceDetailsPanel)); |
| 316 | break; |
Isabelle Taylor | d99a5d7 | 2019-03-25 16:45:32 +0000 | [diff] [blame] | 317 | case 'THREAD_STATE': |
| 318 | detailsPanels.push(m(ThreadStatePanel, { |
| 319 | key: 'thread_state', |
| 320 | ts: curSelection.ts, |
| 321 | dur: curSelection.dur, |
| 322 | utid: curSelection.utid, |
Isabelle Taylor | 9d3b994 | 2019-09-03 13:18:19 +0100 | [diff] [blame] | 323 | state: curSelection.state, |
| 324 | cpu: curSelection.cpu |
Isabelle Taylor | d99a5d7 | 2019-03-25 16:45:32 +0000 | [diff] [blame] | 325 | })); |
| 326 | break; |
Isabelle Taylor | 9a4afc6 | 2019-02-06 11:54:36 +0000 | [diff] [blame] | 327 | default: |
| 328 | break; |
| 329 | } |
Hector Dearman | 79549c5 | 2019-04-01 13:30:46 +0100 | [diff] [blame] | 330 | } else if (hasLogs()) { |
| 331 | detailsPanels.push(m(LogPanel, {})); |
Isabelle Taylor | b9222c3 | 2019-01-31 10:58:37 +0000 | [diff] [blame] | 332 | } |
| 333 | |
Isabelle Taylor | cc85061 | 2019-08-19 14:15:20 +0100 | [diff] [blame] | 334 | const wasShowing = this.showDetailsPanel; |
Hector Dearman | 79549c5 | 2019-04-01 13:30:46 +0100 | [diff] [blame] | 335 | this.showDetailsPanel = detailsPanels.length > 0; |
Isabelle Taylor | cc85061 | 2019-08-19 14:15:20 +0100 | [diff] [blame] | 336 | // Pop up details panel on first selection. |
| 337 | if (!wasShowing && this.showDetailsPanel && |
| 338 | this.detailsHeight === DRAG_HANDLE_HEIGHT_PX) { |
| 339 | this.detailsHeight = DEFAULT_DETAILS_HEIGHT_PX; |
| 340 | } |
Hector Dearman | 79549c5 | 2019-04-01 13:30:46 +0100 | [diff] [blame] | 341 | |
Michail Schwab | c834e48 | 2018-07-26 13:30:13 -0400 | [diff] [blame] | 342 | return m( |
Primiano Tucci | 8afc06d | 2018-08-06 19:11:42 +0100 | [diff] [blame] | 343 | '.page', |
Kodi Obika | 9adb058 | 2019-06-12 09:36:03 -0700 | [diff] [blame] | 344 | m('.split-panel', |
Isabelle Taylor | f41b7c7 | 2019-07-24 13:55:43 +0100 | [diff] [blame] | 345 | m('.pan-and-zoom-content', |
| 346 | { |
| 347 | onclick: () => { |
| 348 | // We don't want to deselect when panning/drag selecting. |
| 349 | if (this.keepCurrentSelection) { |
| 350 | this.keepCurrentSelection = false; |
| 351 | return; |
| 352 | } |
Isabelle Taylor | 061c871 | 2019-09-16 13:38:58 +0100 | [diff] [blame] | 353 | globals.makeSelection(Actions.deselect({})); |
Isabelle Taylor | ee67d1b | 2019-02-27 14:12:53 +0000 | [diff] [blame] | 354 | } |
Isabelle Taylor | f41b7c7 | 2019-07-24 13:55:43 +0100 | [diff] [blame] | 355 | }, |
| 356 | m('.pinned-panel-container', m(PanelContainer, { |
| 357 | doesScroll: false, |
| 358 | panels: [ |
| 359 | m(OverviewTimelinePanel, {key: 'overview'}), |
| 360 | m(TimeAxisPanel, {key: 'timeaxis'}), |
| 361 | m(TimeSelectionPanel, {key: 'timeselection'}), |
| 362 | m(NotesPanel, {key: 'notes'}), |
Hector Dearman | 372ec60 | 2019-09-03 12:12:02 +0100 | [diff] [blame] | 363 | m(TickmarkPanel, {key: 'searchTickmarks'}), |
Isabelle Taylor | f41b7c7 | 2019-07-24 13:55:43 +0100 | [diff] [blame] | 364 | ...globals.state.pinnedTracks.map( |
| 365 | id => m(TrackPanel, {key: id, id})), |
| 366 | ], |
| 367 | kind: 'OVERVIEW', |
| 368 | })), |
| 369 | m('.scrolling-panel-container', m(PanelContainer, { |
| 370 | doesScroll: true, |
| 371 | panels: scrollingPanels, |
| 372 | kind: 'TRACKS', |
| 373 | }))), |
| 374 | m('.video-panel', |
| 375 | (globals.state.videoEnabled && globals.state.video != null) ? |
| 376 | m(VideoPanel) : |
| 377 | null)), |
Hector Dearman | afa51b2 | 2018-12-11 16:38:30 +0000 | [diff] [blame] | 378 | m('.details-content', |
Isabelle Taylor | ee67d1b | 2019-02-27 14:12:53 +0000 | [diff] [blame] | 379 | { |
| 380 | style: { |
| 381 | height: `${this.detailsHeight}px`, |
Hector Dearman | 79549c5 | 2019-04-01 13:30:46 +0100 | [diff] [blame] | 382 | display: this.showDetailsPanel ? null : 'none' |
Isabelle Taylor | ee67d1b | 2019-02-27 14:12:53 +0000 | [diff] [blame] | 383 | } |
| 384 | }, |
Hector Dearman | afa51b2 | 2018-12-11 16:38:30 +0000 | [diff] [blame] | 385 | m(DragHandle, { |
| 386 | resize: (height: number) => { |
| 387 | this.detailsHeight = Math.max(height, DRAG_HANDLE_HEIGHT_PX); |
| 388 | }, |
| 389 | height: this.detailsHeight, |
Hector Dearman | ea002ea | 2019-01-21 11:43:45 +0000 | [diff] [blame] | 390 | }), |
Isabelle Taylor | ee67d1b | 2019-02-27 14:12:53 +0000 | [diff] [blame] | 391 | m('.details-panel-container', |
Isabelle Taylor | f41b7c7 | 2019-07-24 13:55:43 +0100 | [diff] [blame] | 392 | m(PanelContainer, |
| 393 | {doesScroll: true, panels: detailsPanels, kind: 'DETAILS'})))); |
Deepanjan Roy | 97f6324 | 2018-09-20 15:32:01 -0400 | [diff] [blame] | 394 | } |
| 395 | } |
Deepanjan Roy | fd79a7d | 2018-07-24 13:26:55 -0400 | [diff] [blame] | 396 | |
| 397 | export const ViewerPage = createPage({ |
| 398 | view() { |
| 399 | return m(TraceViewer); |
| 400 | } |
Hector Dearman | 64484b9 | 2018-07-30 16:14:43 +0100 | [diff] [blame] | 401 | }); |