OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_connect_element; | 5 library vm_connect_element; |
6 | 6 |
7 import 'dart:html'; | 7 import 'dart:html'; |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'package:observatory/models.dart' as M; | 10 import 'package:observatory/models.dart' as M; |
11 import 'package:observatory/src/elements/helpers/tag.dart'; | 11 import 'package:observatory/src/elements/helpers/tag.dart'; |
12 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 12 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
13 import 'package:observatory/src/elements/nav/bar.dart'; | 13 import 'package:observatory/src/elements/nav/bar.dart'; |
14 import 'package:observatory/src/elements/nav/notify.dart'; | 14 import 'package:observatory/src/elements/nav/notify.dart'; |
15 import 'package:observatory/src/elements/nav/top_menu.dart'; | 15 import 'package:observatory/src/elements/nav/top_menu.dart'; |
16 import 'package:observatory/src/elements/view_footer.dart'; | 16 import 'package:observatory/src/elements/view_footer.dart'; |
17 import 'package:observatory/src/elements/vm_connect_target.dart'; | 17 import 'package:observatory/src/elements/vm_connect_target.dart'; |
18 | 18 |
19 class VMConnectElement extends HtmlElement implements Renderable{ | 19 class VMConnectElement extends HtmlElement implements Renderable { |
20 static const tag = const Tag<VMConnectElement>('vm-connect', | 20 static const tag = const Tag<VMConnectElement>('vm-connect', |
21 dependencies: const [NavBarElement.tag, | 21 dependencies: const [NavBarElement.tag, |
22 NavTopMenuElement.tag, | 22 NavTopMenuElement.tag, |
23 NavNotifyElement.tag, | 23 NavNotifyElement.tag, |
24 ViewFooterElement.tag, | 24 ViewFooterElement.tag, |
25 VMConnectTargetElement.tag]); | 25 VMConnectTargetElement.tag]); |
26 | 26 |
27 RenderingScheduler _r; | 27 RenderingScheduler _r; |
28 | 28 |
29 Stream<RenderedEvent<VMConnectElement>> get onRendered => _r.onRendered; | 29 Stream<RenderedEvent<VMConnectElement>> get onRendered => _r.onRendered; |
(...skipping 30 matching lines...) Expand all Loading... |
60 _targetsSubscription = _targets.onChange.listen((_) => _r.dirty()); | 60 _targetsSubscription = _targets.onChange.listen((_) => _r.dirty()); |
61 } | 61 } |
62 | 62 |
63 @override | 63 @override |
64 void detached() { | 64 void detached() { |
65 super.detached(); children = []; _r.disable(notify: true); | 65 super.detached(); children = []; _r.disable(notify: true); |
66 _targetsSubscription.cancel(); _targetsSubscription = null; | 66 _targetsSubscription.cancel(); _targetsSubscription = null; |
67 } | 67 } |
68 | 68 |
69 void render() { | 69 void render() { |
| 70 final host = window.location.hostname; |
| 71 final port = window.location.port; |
70 children = [ | 72 children = [ |
71 new NavBarElement(queue: _r.queue) | 73 new NavBarElement(queue: _r.queue) |
72 ..children = [ | 74 ..children = [ |
73 new NavTopMenuElement(last: true, queue: _r.queue), | 75 new NavTopMenuElement(last: true, queue: _r.queue), |
74 new NavNotifyElement(_notifications, queue: _r.queue) | 76 new NavNotifyElement(_notifications, queue: _r.queue) |
75 ], | 77 ], |
76 new DivElement() | 78 new DivElement() |
77 ..classes = ['content-centered'] | 79 ..classes = ['content-centered'] |
78 ..children = [ | 80 ..children = [ |
79 new HeadingElement.h1()..text = 'Connect to a Dart VM', | 81 new HeadingElement.h1()..text = 'Connect to a Dart VM', |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 new DivElement() | 120 new DivElement() |
119 ..classes = ['flex-item-40-percent'] | 121 ..classes = ['flex-item-40-percent'] |
120 ..children = [ | 122 ..children = [ |
121 new HeadingElement.h2()..text = 'Crash dump', | 123 new HeadingElement.h2()..text = 'Crash dump', |
122 new BRElement(), | 124 new BRElement(), |
123 _createCrushDumpLoader(), | 125 _createCrushDumpLoader(), |
124 new BRElement(), new BRElement(), | 126 new BRElement(), new BRElement(), |
125 new PreElement() | 127 new PreElement() |
126 ..classes = ['well'] | 128 ..classes = ['well'] |
127 ..text = 'Request a crash dump with:\n' | 129 ..text = 'Request a crash dump with:\n' |
128 '\'curl localhost:8181/_getCrashDump > dump.json\'', | 130 '\'curl $host:$port/_getCrashDump > dump.json\'', |
129 new HRElement() | 131 new HRElement() |
130 ] | 132 ] |
131 ], | 133 ], |
132 ], | 134 ], |
133 new ViewFooterElement(queue: _r.queue) | 135 new ViewFooterElement(queue: _r.queue) |
134 ]; | 136 ]; |
135 } | 137 } |
136 | 138 |
137 TextInputElement _createAddressBox() { | 139 TextInputElement _createAddressBox() { |
138 var textbox = new TextInputElement() | 140 var textbox = new TextInputElement() |
(...skipping 29 matching lines...) Expand all Loading... |
168 void _connect(TargetEvent e) => _targets.setCurrent(e.target); | 170 void _connect(TargetEvent e) => _targets.setCurrent(e.target); |
169 void _delete(TargetEvent e) => _targets.delete(e.target); | 171 void _delete(TargetEvent e) => _targets.delete(e.target); |
170 | 172 |
171 static String _normalizeStandaloneAddress(String networkAddress) { | 173 static String _normalizeStandaloneAddress(String networkAddress) { |
172 if (networkAddress.startsWith('ws://')) { | 174 if (networkAddress.startsWith('ws://')) { |
173 return networkAddress; | 175 return networkAddress; |
174 } | 176 } |
175 return 'ws://${networkAddress}/ws'; | 177 return 'ws://${networkAddress}/ws'; |
176 } | 178 } |
177 } | 179 } |
OLD | NEW |