| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library vm_view_element; | 5 library vm_view_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'package:observatory/models.dart' as M; | 9 import 'package:observatory/models.dart' as M; |
| 10 import 'package:observatory/src/elements/helpers/nav_bar.dart'; | 10 import 'package:observatory/src/elements/helpers/nav_bar.dart'; |
| 11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
| 12 import 'package:observatory/src/elements/helpers/tag.dart'; | 12 import 'package:observatory/src/elements/helpers/tag.dart'; |
| 13 import 'package:observatory/src/elements/helpers/uris.dart'; | 13 import 'package:observatory/src/elements/helpers/uris.dart'; |
| 14 import 'package:observatory/src/elements/isolate/summary.dart'; | 14 import 'package:observatory/src/elements/isolate/summary.dart'; |
| 15 import 'package:observatory/src/elements/nav/notify.dart'; | 15 import 'package:observatory/src/elements/nav/notify.dart'; |
| 16 import 'package:observatory/src/elements/nav/refresh.dart'; | 16 import 'package:observatory/src/elements/nav/refresh.dart'; |
| 17 import 'package:observatory/src/elements/nav/top_menu.dart'; | 17 import 'package:observatory/src/elements/nav/top_menu.dart'; |
| 18 import 'package:observatory/src/elements/nav/vm_menu.dart'; | 18 import 'package:observatory/src/elements/nav/vm_menu.dart'; |
| 19 import 'package:observatory/src/elements/view_footer.dart'; | 19 import 'package:observatory/src/elements/view_footer.dart'; |
| 20 import 'package:observatory/utils.dart'; | 20 import 'package:observatory/utils.dart'; |
| 21 | 21 |
| 22 class VMViewElement extends HtmlElement implements Renderable { | 22 class VMViewElement extends HtmlElement implements Renderable { |
| 23 static const tag = const Tag<VMViewElement>('vm-view', | 23 static const tag = const Tag<VMViewElement>('vm-view', dependencies: const [ |
| 24 dependencies: const [ | 24 IsolateSummaryElement.tag, |
| 25 IsolateSummaryElement.tag, | 25 NavTopMenuElement.tag, |
| 26 NavTopMenuElement.tag, | 26 NavVMMenuElement.tag, |
| 27 NavVMMenuElement.tag, | 27 NavRefreshElement.tag, |
| 28 NavRefreshElement.tag, | 28 NavNotifyElement.tag, |
| 29 NavNotifyElement.tag, | 29 ViewFooterElement.tag |
| 30 ViewFooterElement.tag | 30 ]); |
| 31 ]); | |
| 32 | 31 |
| 33 RenderingScheduler<VMViewElement> _r; | 32 RenderingScheduler<VMViewElement> _r; |
| 34 | 33 |
| 35 Stream<RenderedEvent<VMViewElement>> get onRendered => _r.onRendered; | 34 Stream<RenderedEvent<VMViewElement>> get onRendered => _r.onRendered; |
| 36 | 35 |
| 37 M.VM _vm; | 36 M.VM _vm; |
| 38 M.EventRepository _events; | 37 M.EventRepository _events; |
| 39 M.NotificationRepository _notifications; | 38 M.NotificationRepository _notifications; |
| 40 M.IsolateRepository _isolates; | 39 M.IsolateRepository _isolates; |
| 41 M.ScriptRepository _scripts; | 40 M.ScriptRepository _scripts; |
| 42 StreamSubscription _vmSubscription; | 41 StreamSubscription _vmSubscription; |
| 43 StreamSubscription _startSubscription; | 42 StreamSubscription _startSubscription; |
| 44 StreamSubscription _exitSubscription; | 43 StreamSubscription _exitSubscription; |
| 45 | 44 |
| 46 M.VMRef get vm => _vm; | 45 M.VMRef get vm => _vm; |
| 47 M.NotificationRepository get notifications => _notifications; | 46 M.NotificationRepository get notifications => _notifications; |
| 48 | 47 |
| 49 factory VMViewElement(M.VM vm, M.EventRepository events, | 48 factory VMViewElement( |
| 50 M.NotificationRepository notifications, | 49 M.VM vm, |
| 51 M.IsolateRepository isolates, | 50 M.EventRepository events, |
| 52 M.ScriptRepository scripts, | 51 M.NotificationRepository notifications, |
| 53 {RenderingQueue queue}) { | 52 M.IsolateRepository isolates, |
| 53 M.ScriptRepository scripts, |
| 54 {RenderingQueue queue}) { |
| 54 assert(vm != null); | 55 assert(vm != null); |
| 55 assert(events != null); | 56 assert(events != null); |
| 56 assert(notifications != null); | 57 assert(notifications != null); |
| 57 VMViewElement e = document.createElement(tag.name); | 58 VMViewElement e = document.createElement(tag.name); |
| 58 e._r = new RenderingScheduler(e, queue: queue); | 59 e._r = new RenderingScheduler(e, queue: queue); |
| 59 e._vm = vm; | 60 e._vm = vm; |
| 60 e._events = events; | 61 e._events = events; |
| 61 e._notifications = notifications; | 62 e._notifications = notifications; |
| 62 e._isolates = isolates; | 63 e._isolates = isolates; |
| 63 e._scripts = scripts; | 64 e._scripts = scripts; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 89 } | 90 } |
| 90 | 91 |
| 91 void render() { | 92 void render() { |
| 92 final uptime = new DateTime.now().difference(_vm.startTime); | 93 final uptime = new DateTime.now().difference(_vm.startTime); |
| 93 final isolates = _vm.isolates.toList(); | 94 final isolates = _vm.isolates.toList(); |
| 94 children = [ | 95 children = [ |
| 95 navBar([ | 96 navBar([ |
| 96 new NavTopMenuElement(queue: _r.queue), | 97 new NavTopMenuElement(queue: _r.queue), |
| 97 new NavVMMenuElement(_vm, _events, queue: _r.queue), | 98 new NavVMMenuElement(_vm, _events, queue: _r.queue), |
| 98 new NavRefreshElement(queue: _r.queue) | 99 new NavRefreshElement(queue: _r.queue) |
| 99 ..onRefresh.listen((e) async { | 100 ..onRefresh.listen((e) async { |
| 100 e.element.disabled = true; | 101 e.element.disabled = true; |
| 101 _r.dirty(); | 102 _r.dirty(); |
| 102 }), | 103 }), |
| 103 new NavNotifyElement(_notifications, queue: _r.queue) | 104 new NavNotifyElement(_notifications, queue: _r.queue) |
| 104 ]), | 105 ]), |
| 105 new DivElement()..classes = ['content-centered-big'] | 106 new DivElement() |
| 107 ..classes = ['content-centered-big'] |
| 106 ..children = [ | 108 ..children = [ |
| 107 new HeadingElement.h1()..text = 'VM', | 109 new HeadingElement.h1()..text = 'VM', |
| 108 new HRElement(), | 110 new HRElement(), |
| 109 new DivElement()..classes = ['memberList'] | 111 new DivElement() |
| 112 ..classes = ['memberList'] |
| 110 ..children = [ | 113 ..children = [ |
| 111 new DivElement()..classes = ['memberItem'] | 114 new DivElement() |
| 115 ..classes = ['memberItem'] |
| 112 ..children = [ | 116 ..children = [ |
| 113 new DivElement()..classes = ['memberName'] | 117 new DivElement() |
| 118 ..classes = ['memberName'] |
| 114 ..text = 'name', | 119 ..text = 'name', |
| 115 new DivElement()..classes = ['memberValue'] | 120 new DivElement() |
| 121 ..classes = ['memberValue'] |
| 116 ..text = _vm.displayName | 122 ..text = _vm.displayName |
| 117 ], | 123 ], |
| 118 new DivElement()..classes = ['memberItem'] | 124 new DivElement() |
| 125 ..classes = ['memberItem'] |
| 119 ..children = [ | 126 ..children = [ |
| 120 new DivElement()..classes = ['memberName'] | 127 new DivElement() |
| 128 ..classes = ['memberName'] |
| 121 ..text = 'version', | 129 ..text = 'version', |
| 122 new DivElement()..classes = ['memberValue'] | 130 new DivElement() |
| 131 ..classes = ['memberValue'] |
| 123 ..text = _vm.version | 132 ..text = _vm.version |
| 124 ], | 133 ], |
| 125 new DivElement()..classes = ['memberItem'] | 134 new DivElement() |
| 135 ..classes = ['memberItem'] |
| 126 ..children = [ | 136 ..children = [ |
| 127 new DivElement()..classes = ['memberName'] | 137 new DivElement() |
| 138 ..classes = ['memberName'] |
| 128 ..text = 'started at', | 139 ..text = 'started at', |
| 129 new DivElement()..classes = ['memberValue'] | 140 new DivElement() |
| 141 ..classes = ['memberValue'] |
| 130 ..text = '${_vm.startTime}' | 142 ..text = '${_vm.startTime}' |
| 131 ], | 143 ], |
| 132 new DivElement()..classes = ['memberItem'] | 144 new DivElement() |
| 145 ..classes = ['memberItem'] |
| 133 ..children = [ | 146 ..children = [ |
| 134 new DivElement()..classes = ['memberName'] | 147 new DivElement() |
| 148 ..classes = ['memberName'] |
| 135 ..text = 'uptime', | 149 ..text = 'uptime', |
| 136 new DivElement()..classes = ['memberValue'] | 150 new DivElement() |
| 151 ..classes = ['memberValue'] |
| 137 ..text = '$uptime' | 152 ..text = '$uptime' |
| 138 ], | 153 ], |
| 139 new DivElement()..classes = ['memberItem'] | 154 new DivElement() |
| 155 ..classes = ['memberItem'] |
| 140 ..children = [ | 156 ..children = [ |
| 141 new DivElement()..classes = ['memberName'] | 157 new DivElement() |
| 158 ..classes = ['memberName'] |
| 142 ..text = 'refreshed at', | 159 ..text = 'refreshed at', |
| 143 new DivElement()..classes = ['memberValue'] | 160 new DivElement() |
| 161 ..classes = ['memberValue'] |
| 144 ..text = '${new DateTime.now()}' | 162 ..text = '${new DateTime.now()}' |
| 145 ], | 163 ], |
| 146 new DivElement()..classes = ['memberItem'] | 164 new DivElement() |
| 165 ..classes = ['memberItem'] |
| 147 ..children = [ | 166 ..children = [ |
| 148 new DivElement()..classes = ['memberName'] | 167 new DivElement() |
| 168 ..classes = ['memberName'] |
| 149 ..text = 'pid', | 169 ..text = 'pid', |
| 150 new DivElement()..classes = ['memberValue'] | 170 new DivElement() |
| 171 ..classes = ['memberValue'] |
| 151 ..text = '${_vm.pid}' | 172 ..text = '${_vm.pid}' |
| 152 ], | 173 ], |
| 153 new DivElement()..classes = ['memberItem'] | 174 new DivElement() |
| 175 ..classes = ['memberItem'] |
| 154 ..children = [ | 176 ..children = [ |
| 155 new DivElement()..classes = ['memberName'] | 177 new DivElement() |
| 178 ..classes = ['memberName'] |
| 156 ..text = 'peak memory', | 179 ..text = 'peak memory', |
| 157 new DivElement()..classes = ['memberValue'] | 180 new DivElement() |
| 181 ..classes = ['memberValue'] |
| 158 ..text = Utils.formatSize(_vm.maxRSS) | 182 ..text = Utils.formatSize(_vm.maxRSS) |
| 159 ], | 183 ], |
| 160 new BRElement(), | 184 new BRElement(), |
| 161 new DivElement()..classes = ['memberItem'] | 185 new DivElement() |
| 186 ..classes = ['memberItem'] |
| 162 ..children = [ | 187 ..children = [ |
| 163 new DivElement()..classes = ['memberName'] | 188 new DivElement() |
| 189 ..classes = ['memberName'] |
| 164 ..children = [ | 190 ..children = [ |
| 165 new SpanElement()..text = 'see ', | 191 new SpanElement()..text = 'see ', |
| 166 new AnchorElement(href: Uris.flags())..text = 'flags' | 192 new AnchorElement(href: Uris.flags())..text = 'flags' |
| 167 ], | 193 ], |
| 168 new DivElement()..classes = ['memberValue'] | 194 new DivElement() |
| 195 ..classes = ['memberValue'] |
| 169 ..children = [ | 196 ..children = [ |
| 170 new SpanElement()..text = 'view ', | 197 new SpanElement()..text = 'view ', |
| 171 new AnchorElement(href: Uris.timeline())..text = 'timeline
' | 198 new AnchorElement(href: Uris.timeline()) |
| 199 ..text = 'timeline' |
| 172 ] | 200 ] |
| 173 ] | 201 ] |
| 174 ], | 202 ], |
| 175 new BRElement(), | 203 new BRElement(), |
| 176 new HeadingElement.h1()..text = 'Isolates (${isolates.length})', | 204 new HeadingElement.h1()..text = 'Isolates (${isolates.length})', |
| 177 new HRElement(), | 205 new HRElement(), |
| 178 new UListElement()..classes = ['list-group'] | 206 new UListElement() |
| 179 ..children = isolates.expand((i) => [ | 207 ..classes = ['list-group'] |
| 180 new LIElement()..classes = ['list-group-item'] | 208 ..children = isolates |
| 181 ..children = [ | 209 .expand((i) => [ |
| 182 new IsolateSummaryElement(i, _isolates, _events, _scripts, | 210 new LIElement() |
| 183 queue: _r.queue) | 211 ..classes = ['list-group-item'] |
| 184 ], | 212 ..children = [ |
| 185 new HRElement() | 213 new IsolateSummaryElement( |
| 186 ]).toList(), | 214 i, _isolates, _events, _scripts, |
| 215 queue: _r.queue) |
| 216 ], |
| 217 new HRElement() |
| 218 ]) |
| 219 .toList(), |
| 187 new ViewFooterElement(queue: _r.queue) | 220 new ViewFooterElement(queue: _r.queue) |
| 188 ] | 221 ] |
| 189 ]; | 222 ]; |
| 190 } | 223 } |
| 191 } | 224 } |
| OLD | NEW |