| 1 |
<script lang="ts"> |
| 2 |
import type Session from "../lib/model/Session"; |
| 3 |
import CogIcon from './CogIcon.svelte'; |
| 4 |
import Logo from './Logo.svelte'; |
| 5 |
import {viewOptions} from '../lib/settings' |
| 6 |
import ViewOptions from "./ViewOptions.svelte"; |
| 7 |
import { htmlForStringWithWBRAtSlashes } from "../lib/utils"; |
| 8 |
|
| 9 |
export let session: Session; |
| 10 |
|
| 11 |
const startTime = new Date(session.startTime*1000).toLocaleString(undefined, {dateStyle: 'long', timeStyle: 'medium'}) |
| 12 |
const cpuUtilisation = session.cpuTime / session.duration |
| 13 |
|
| 14 |
let viewOptionsVisible = false |
| 15 |
|
| 16 |
function viewOptionsButtonClicked(event: MouseEvent) { |
| 17 |
viewOptionsVisible = !viewOptionsVisible |
| 18 |
} |
| 19 |
</script> |
| 20 |
|
| 21 |
<div class="header"> |
| 22 |
<div class="margins"> |
| 23 |
<div class="row"> |
| 24 |
<div class="logo"> |
| 25 |
<Logo /> |
| 26 |
</div> |
| 27 |
<div class="layout"> |
| 28 |
<div class="target-description"> |
| 29 |
{@html htmlForStringWithWBRAtSlashes(session.target_description)} |
| 30 |
</div> |
| 31 |
<div class="metrics"> |
| 32 |
<div class="metric date"> |
| 33 |
<span class="metric-label">Recorded:</span> |
| 34 |
<span class="metric-value">{startTime}</span> |
| 35 |
</div> |
| 36 |
<br> |
| 37 |
<div class="metric"> |
| 38 |
<span class="metric-label">Samples:</span> |
| 39 |
<span class="metric-value">{session.sampleCount}</span> |
| 40 |
</div> |
| 41 |
<div class="metric"> |
| 42 |
<span class="metric-label">CPU utilization:</span> |
| 43 |
<span class="metric-value">{(cpuUtilisation * 100).toFixed(0)}%</span> |
| 44 |
</div> |
| 45 |
</div> |
| 46 |
<div class="view-options"> |
| 47 |
<div class="toggle"> |
| 48 |
View: |
| 49 |
<label> |
| 50 |
<input type="radio" bind:group={$viewOptions.viewMode} value="call-stack"> |
| 51 |
Call stack |
| 52 |
</label> |
| 53 |
<label> |
| 54 |
<input type="radio" bind:group={$viewOptions.viewMode} value="timeline"> |
| 55 |
Timeline |
| 56 |
</label> |
| 57 |
</div> |
| 58 |
<div class="spacer" style="flex: 1"></div> |
| 59 |
<div class="button-container"> |
| 60 |
<button on:click|preventDefault|stopPropagation={viewOptionsButtonClicked} class="js-view-options-button"> |
| 61 |
<CogIcon /> |
| 62 |
View options |
| 63 |
</button> |
| 64 |
{#if viewOptionsVisible} |
| 65 |
<ViewOptions on:close={() => viewOptionsVisible = false}/> |
| 66 |
{/if} |
| 67 |
</div> |
| 68 |
</div> |
| 69 |
</div> |
| 70 |
</div> |
| 71 |
</div> |
| 72 |
</div> |
| 73 |
|
| 74 |
<style lang="scss"> |
| 75 |
.header { |
| 76 |
background: #292f32; |
| 77 |
font-size: 14px; |
| 78 |
padding: 9px 0; |
| 79 |
} |
| 80 |
.row { |
| 81 |
display: flex; |
| 82 |
align-items: center; |
| 83 |
gap: 10px; |
| 84 |
} |
| 85 |
.logo { |
| 86 |
margin: 0 -6px; |
| 87 |
margin-right: -3px; |
| 88 |
} |
| 89 |
.layout { |
| 90 |
flex: 1; |
| 91 |
display: grid; |
| 92 |
gap: 0 10px; |
| 93 |
grid-template-columns: auto minmax(auto, max-content); |
| 94 |
} |
| 95 |
@media (max-width: 800px) { |
| 96 |
.layout { |
| 97 |
grid-template-columns: 1fr; |
| 98 |
} |
| 99 |
} |
| 100 |
.target-description { |
| 101 |
font-weight: 600; |
| 102 |
margin-bottom: 1px; |
| 103 |
} |
| 104 |
.view-options { |
| 105 |
display: flex; |
| 106 |
flex-wrap: wrap; |
| 107 |
// margin-top: 2px; |
| 108 |
label { |
| 109 |
margin: 0 5px; |
| 110 |
white-space: nowrap; |
| 111 |
} |
| 112 |
} |
| 113 |
.metrics { |
| 114 |
grid-row: span 2; |
| 115 |
/* grid-gap: 1px 10px; */ |
| 116 |
text-align: right; |
| 117 |
align-items: end; |
| 118 |
min-width: min-content; |
| 119 |
} |
| 120 |
@media (max-width: 800px) { |
| 121 |
.metrics { |
| 122 |
text-align: left; |
| 123 |
br { |
| 124 |
display: none; |
| 125 |
} |
| 126 |
} |
| 127 |
} |
| 128 |
.metric { |
| 129 |
display: inline-block; |
| 130 |
white-space: nowrap; |
| 131 |
margin-left: 2px; |
| 132 |
} |
| 133 |
@media (max-width: 800px) { |
| 134 |
.metric { |
| 135 |
margin-left: 0; |
| 136 |
margin-right: 2px; |
| 137 |
} |
| 138 |
} |
| 139 |
|
| 140 |
.metric-label { |
| 141 |
font-weight: 600; |
| 142 |
color: rgba(255, 255, 255, 0.6); |
| 143 |
} |
| 144 |
.metric-value { |
| 145 |
color: rgba(255, 255, 255, 0.4); |
| 146 |
} |
| 147 |
input[type=radio] { |
| 148 |
// width: 10px; |
| 149 |
// height: 10px; |
| 150 |
// border: 1px solid currentColor; |
| 151 |
// background-color: transparent; |
| 152 |
vertical-align: -8%; |
| 153 |
} |
| 154 |
.button-container { |
| 155 |
// display: flex; |
| 156 |
position: relative; |
| 157 |
} |
| 158 |
button { |
| 159 |
$bg: #5C6063; |
| 160 |
background: $bg; |
| 161 |
border-radius: 6px; |
| 162 |
font: inherit; |
| 163 |
font-size: calc(12em/14); |
| 164 |
color: inherit; |
| 165 |
border: none; |
| 166 |
cursor: pointer; |
| 167 |
|
| 168 |
&:hover { |
| 169 |
background: lighten($color: $bg, $amount: 3); |
| 170 |
} |
| 171 |
&:active { |
| 172 |
background: darken($color: $bg, $amount: 3); |
| 173 |
} |
| 174 |
} |
| 175 |
</style> |