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