| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'dart:html'; |
| 6 import 'dart:async'; |
| 7 import 'package:observatory/app.dart'; |
| 8 import 'package:observatory/service.dart'; |
| 9 import 'package:observatory/src/elements/helpers/tag.dart'; |
| 10 import 'package:observatory/src/elements/shims/binding.dart'; |
| 11 import 'package:observatory/src/elements/isolate/shared_summary.dart'; |
| 12 |
| 13 @bindable |
| 14 class IsolateSharedSummaryElementWrapper extends HtmlElement { |
| 15 static const binder = const Binder<IsolateSharedSummaryElementWrapper>(const { |
| 16 'isolate': #isolate |
| 17 }); |
| 18 |
| 19 static const tag = |
| 20 const Tag<IsolateSharedSummaryElementWrapper>('isolate-shared-summary'); |
| 21 |
| 22 IsolateSharedSummaryElementWrapper.created() : super.created() { |
| 23 binder.registerCallback(this); |
| 24 createShadowRoot(); |
| 25 render(); |
| 26 } |
| 27 |
| 28 Isolate _isolate; |
| 29 StreamSubscription _subscription; |
| 30 |
| 31 Isolate get isolate => _isolate; |
| 32 |
| 33 void set isolate(Isolate value) { |
| 34 _isolate = value; |
| 35 _detached(); |
| 36 _attached(); |
| 37 } |
| 38 |
| 39 @override |
| 40 void attached() { |
| 41 super.attached(); |
| 42 _attached(); |
| 43 } |
| 44 |
| 45 @override |
| 46 void detached() { |
| 47 super.detached(); |
| 48 _detached(); |
| 49 } |
| 50 |
| 51 void _attached() { |
| 52 if (_isolate != null) { |
| 53 _subscription = _isolate.changes.listen((_) { render(); }); |
| 54 } |
| 55 render(); |
| 56 } |
| 57 |
| 58 void _detached() { |
| 59 _subscription?.cancel(); |
| 60 _subscription = null; |
| 61 } |
| 62 |
| 63 void render() { |
| 64 if (_isolate == null) { |
| 65 return; |
| 66 } |
| 67 shadowRoot.children = [ |
| 68 new StyleElement() |
| 69 ..text = ''' |
| 70 a[href] { |
| 71 color: #0489c3; |
| 72 text-decoration: none; |
| 73 } |
| 74 a[href]:hover { |
| 75 text-decoration: underline; |
| 76 } |
| 77 .memberList { |
| 78 display: table; |
| 79 } |
| 80 .memberItem { |
| 81 display: table-row; |
| 82 } |
| 83 .memberName, .memberValue { |
| 84 display: table-cell; |
| 85 vertical-align: top; |
| 86 padding: 3px 0 3px 1em; |
| 87 font: 400 14px 'Montserrat', sans-serif; |
| 88 } |
| 89 isolate-shared-summary-wrapped { |
| 90 display: block; |
| 91 height: 300px; |
| 92 position: relative; |
| 93 } |
| 94 isolate-shared-summary-wrapped > .menu { |
| 95 float: right; |
| 96 top: 0; |
| 97 right: 0; |
| 98 } |
| 99 isolate-shared-summary-wrapped > isolate-counter-chart { |
| 100 position: absolute; |
| 101 left: 0; |
| 102 top: 0; |
| 103 right: 230px; |
| 104 clear: both; |
| 105 } |
| 106 isolate-shared-summary-wrapped .errorBox { |
| 107 background-color: #f5f5f5; |
| 108 border: 1px solid #ccc; |
| 109 padding: 2em; |
| 110 font-family: consolas, courier, monospace; |
| 111 font-size: 1em; |
| 112 line-height: 1.2em; |
| 113 white-space: pre; |
| 114 } |
| 115 isolate-counter-chart { |
| 116 display: block; |
| 117 position: relative; |
| 118 height: 300px; |
| 119 min-width: 350px; |
| 120 } |
| 121 isolate-counter-chart > div.host { |
| 122 position: absolute; |
| 123 left: 0; |
| 124 bottom: 20px; |
| 125 top: 5px; |
| 126 right: 250px; |
| 127 } |
| 128 isolate-counter-chart > div.legend { |
| 129 position: absolute; |
| 130 width: 250px; |
| 131 top: 0; |
| 132 right: 0; |
| 133 bottom: 0; |
| 134 overflow-y: auto; |
| 135 } |
| 136 .type-pie-rdr > .chart-legend-color { |
| 137 border-radius: 6px; |
| 138 } |
| 139 .chart-legend-row, .chart-legend-more { |
| 140 width: 100%; |
| 141 display: flex; |
| 142 font-size: 14px; |
| 143 margin-bottom: 16px; |
| 144 position: relative; |
| 145 cursor: default; |
| 146 } |
| 147 .chart-legend-row:hover, .chart-legend-more:hover { |
| 148 font-weight: bold; |
| 149 } |
| 150 .chart-legend-color, .chart-legend-more-color { |
| 151 width: 12px; |
| 152 height: 12px; |
| 153 margin: auto 8px; |
| 154 border-radius: 2px; |
| 155 } |
| 156 .chart-legend-label { |
| 157 overflow: hidden; |
| 158 text-overflow: ellipsis; |
| 159 max-width: 120px; |
| 160 flex: 1; |
| 161 } |
| 162 ''', |
| 163 new IsolateSharedSummaryElement(_isolate, |
| 164 queue: ObservatoryApplication.app.queue) |
| 165 ]; |
| 166 } |
| 167 } |
| OLD | NEW |