OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015, 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 library timeline_page_element; | |
6 | |
7 import 'dart:async'; | |
8 import 'dart:convert'; | |
9 import 'dart:html'; | |
10 import 'observatory_element.dart'; | |
11 import 'package:observatory/app.dart'; | |
12 import 'package:observatory/service_html.dart'; | |
13 import 'package:polymer/polymer.dart'; | |
14 | |
15 | |
16 @CustomTag('timeline-page') | |
17 class TimelinePageElement extends ObservatoryElement { | |
18 TimelinePageElement.created() : super.created(); | |
19 | |
20 attached() { | |
rmacnak
2015/11/09 18:59:06
Weird spacing
Cutch
2015/11/10 15:59:24
Fixed here and elsewhere.
| |
21 super.attached(); | |
22 _resizeSubscription = window.onResize.listen((_) => _updateSize( )); | |
23 _updateSize(); | |
24 } | |
25 | |
26 detached() { | |
27 super.detached(); | |
28 if (_resizeSubscription != null) { | |
29 _resizeSubscription.cancel(); | |
30 } | |
31 } | |
32 | |
33 Future postMessage(String method) { | |
34 IFrameElement e = $['root']; | |
35 var message = { | |
36 'method': method, | |
37 'params': { | |
38 'vmAddress': (app.vm as WebSocketVM).target.networkAddress | |
39 } | |
40 }; | |
41 e.contentWindow.postMessage(JSON.encode(message), window.location.href); | |
42 return null; | |
43 } | |
44 | |
45 Future refresh() async { | |
46 return postMessage('refresh'); | |
47 } | |
48 | |
49 Future clear() async { | |
50 await app.vm.invokeRpc('_clearVMTimeline', {}); | |
51 return postMessage('clear'); | |
52 } | |
53 | |
54 Future recordOn() async { | |
55 return app.vm.invokeRpc('_setVMTimelineFlag', { | |
56 '_record': 'all', | |
57 }); | |
58 } | |
59 | |
60 Future recordOff() async { | |
61 return app.vm.invokeRpc('_setVMTimelineFlag', { | |
62 '_record': 'none', | |
63 }); | |
64 } | |
65 | |
66 _updateSize() { | |
67 IFrameElement e = $['root']; | |
68 final totalHeight = window.innerHeight; | |
69 final top = e.offset.top; | |
70 final bottomMargin = 32; | |
71 final mainHeight = totalHeight - top - bottomMargin; | |
72 e.style.setProperty('height', '${mainHeight}px'); | |
73 e.style.setProperty('width', '100%'); | |
74 } | |
75 | |
76 | |
77 StreamSubscription _resizeSubscription; | |
78 } | |
OLD | NEW |