|
1 | 1 | <!-- |
2 | | - - Copyright 2014-2018 the original author or authors. |
| 2 | + - Copyright 2014-2019 the original author or authors. |
3 | 3 | - |
4 | 4 | - Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | - you may not use this file except in compliance with the License. |
|
32 | 32 | <span v-text="thread.threadName" /> |
33 | 33 | </td> |
34 | 34 | <td class="threads__timeline"> |
35 | | - <svg :id="`thread-${thread.threadId}`" height="26px" /> |
| 35 | + <svg :id="`thread-${thread.threadId}`" height="32px" /> |
36 | 36 | </td> |
37 | 37 | </tr> |
38 | 38 | <tr :key="`${thread.threadId}-detail`" |
|
49 | 49 | <td v-text="thread.threadName" /> |
50 | 50 | </tr> |
51 | 51 | <template v-if="getThreadDetails(thread) !== null"> |
52 | | - <tr> |
53 | | - <td v-text="$t('instances.threaddump.thread_state')" /> |
54 | | - <td v-text="getThreadDetails(thread).threadState" /> |
55 | | - </tr> |
| 52 | + <tr> |
| 53 | + <td v-text="$t('instances.threaddump.thread_state')" /> |
| 54 | + <td v-text="getThreadDetails(thread).threadState" /> |
| 55 | + </tr> |
56 | 56 | <tr> |
57 | 57 | <td v-text="$t('instances.threaddump.thread_details_blocked_count')" /> |
58 | 58 | <td v-text="getThreadDetails(thread).blockedCount" /> |
|
105 | 105 | </table> |
106 | 106 | </template> |
107 | 107 | <script> |
108 | | - import d3 from '@/utils/d3'; |
109 | | - import moment from 'moment'; |
110 | | - import threadTag from './thread-tag'; |
| 108 | + import d3 from '@/utils/d3'; |
| 109 | + import moment from 'moment'; |
| 110 | + import threadTag from './thread-tag'; |
111 | 111 |
|
112 | | - const maxPixelsPerSeconds = 15; |
| 112 | + const maxPixelsPerSeconds = 15; |
113 | 113 |
|
114 | 114 | export default { |
115 | 115 | props: { |
|
132 | 132 | }, |
133 | 133 | methods: { |
134 | 134 | getThreadDetails(thread) { |
135 | | - return thread.timeline.find(entry => entry.start === this.showDetails[thread.threadId + '-start']).details |
| 135 | + return thread.timeline.find(entry => entry.start === this.showDetails[thread.threadId]).details |
136 | 136 | }, |
137 | 137 | getTimeExtent(timelines) { |
138 | 138 | return Object.entries(timelines).map(([, value]) => value.timeline) |
|
146 | 146 | }), {start: Number.MAX_SAFE_INTEGER, end: Number.MIN_SAFE_INTEGER}); |
147 | 147 | }, |
148 | 148 | showThreadDetails({threadId, start}) { |
149 | | - if (this.showDetails[threadId + '-start']) { |
150 | | - d3.selectAll('#rect-threadid-' + threadId + '-start-' + this.showDetails[threadId + '-start']) |
151 | | - .attr('class', d => `thread--${d.threadState.toLowerCase()}`) |
| 149 | + const previousSelectedStart = this.showDetails[threadId]; |
| 150 | + if (previousSelectedStart) { |
| 151 | + d3.selectAll('#rect-threadid-' + threadId + '-start-' + previousSelectedStart) |
| 152 | + .attr('class', d => `thread thread--${d.threadState.toLowerCase()}`); |
152 | 153 | } |
153 | 154 |
|
154 | | - this.showDetails[threadId + '-start'] ? |
155 | | - this.$delete(this.showDetails, threadId + '-start') : this.$set(this.showDetails, threadId + '-start', start); |
156 | | - this.showDetails[threadId] ? this.$delete(this.showDetails, threadId) : |
157 | | - this.$set(this.showDetails, threadId, true); |
158 | | -
|
159 | | - d3.selectAll('#rect-threadid-' + threadId + '-start-' + start) |
160 | | - .attr('class', d => `thread--${d.threadState.toLowerCase()}${this.showDetails[threadId + '-start'] ? '_clicked' : ''}`) |
| 155 | + if (previousSelectedStart === start) { |
| 156 | + this.$delete(this.showDetails, threadId) |
| 157 | + } else { |
| 158 | + this.$set(this.showDetails, threadId, start); |
| 159 | + d3.selectAll('#rect-threadid-' + threadId + '-start-' + start) |
| 160 | + .attr('class', d => `thread thread--${d.threadState.toLowerCase()} thread--clicked`) |
| 161 | + } |
161 | 162 | }, |
162 | 163 | async drawTimelines(timelines) { |
163 | 164 | if (timelines) { |
|
185 | 186 | d.enter() |
186 | 187 | .append('rect') |
187 | 188 | .attr('id', 'rect-threadid-' + threadId + '-start-' + value.timeline[value.timeline.length - 1].start) |
188 | | - .attr('class', d => `thread--${d.threadState.toLowerCase()}`) |
| 189 | + .attr('class', d => `thread thread--${d.threadState.toLowerCase()}`) |
189 | 190 | .merge(d) |
190 | 191 | .attr('height', '2em') |
191 | 192 | .attr('x', d => x(d.start)) |
192 | 193 | .transition(150) |
193 | | - .attr('width', d => Math.max(x(d.end) - x(d.start), x(d.start + 500) - x(d.start))) |
| 194 | + .attr('width', d => Math.max(x(d.end) - x(d.start), x(d.start + 500) - x(d.start))); |
194 | 195 |
|
195 | 196 | d3.selectAll('#rect-threadid-' + threadId + '-start-' + value.timeline[value.timeline.length - 1].start) |
196 | | - .on("click", d => this.showThreadDetails({threadId: threadId, start: d.start})) |
| 197 | + .on('click', d => this.showThreadDetails({threadId: threadId, start: d.start})) |
197 | 198 | }); |
198 | 199 |
|
199 | 200 | this.lastEndPosition = x(end); |
|
255 | 256 | } |
256 | 257 |
|
257 | 258 | .thread { |
| 259 | + stroke: $black; |
| 260 | + stroke-width: 1px; |
| 261 | + stroke-opacity: .1; |
| 262 | +
|
258 | 263 | &--runnable { |
259 | 264 | fill: $success; |
260 | | - } |
261 | 265 |
|
262 | | - &--runnable_clicked { |
263 | | - fill: #157d39; |
| 266 | + &:hover, |
| 267 | + &.thread--clicked { |
| 268 | + fill: darken($success, 20%) |
| 269 | + } |
264 | 270 | } |
265 | 271 |
|
266 | | - &--timed_waiting, |
267 | 272 | &--waiting { |
268 | 273 | fill: $warning; |
| 274 | +
|
| 275 | + &:hover, |
| 276 | + &.thread--clicked { |
| 277 | + fill: darken($warning, 20%) |
| 278 | + } |
269 | 279 | } |
270 | 280 |
|
271 | | - &--timed_waiting_clicked, |
272 | | - &--waiting_clicked { |
273 | | - fill: #e5c64e; |
| 281 | + &--timed_waiting { |
| 282 | + fill: $warning; |
| 283 | +
|
| 284 | + &:hover, |
| 285 | + &.thread--clicked { |
| 286 | + fill: darken($warning, 20%) |
| 287 | + } |
274 | 288 | } |
275 | 289 |
|
276 | | - &--blocked, |
277 | | - &--blocked_clicked { |
| 290 | + &--blocked { |
278 | 291 | fill: $danger; |
| 292 | +
|
| 293 | + &:hover, |
| 294 | + &.thread--clicked { |
| 295 | + fill: darken($warning, 20%) |
| 296 | + } |
279 | 297 | } |
280 | 298 | } |
281 | 299 | </style> |
0 commit comments