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 isolate_summary_element; | 5 library isolate_summary_element; |
6 | 6 |
| 7 import 'dart:async'; |
| 8 import 'dart:html'; |
| 9 import 'observatory_element.dart'; |
| 10 import 'package:observatory/app.dart'; |
7 import 'package:observatory/service.dart'; | 11 import 'package:observatory/service.dart'; |
| 12 import 'package:logging/logging.dart'; |
8 import 'package:polymer/polymer.dart'; | 13 import 'package:polymer/polymer.dart'; |
9 import 'observatory_element.dart'; | |
10 | 14 |
11 @CustomTag('isolate-summary') | 15 @CustomTag('isolate-summary') |
12 class IsolateSummaryElement extends ObservatoryElement { | 16 class IsolateSummaryElement extends ObservatoryElement { |
13 IsolateSummaryElement.created() : super.created(); | 17 IsolateSummaryElement.created() : super.created(); |
| 18 |
14 @published Isolate isolate; | 19 @published Isolate isolate; |
15 } | 20 } |
| 21 |
| 22 @CustomTag('isolate-run-state') |
| 23 class IsolateRunStateElement extends ObservatoryElement { |
| 24 IsolateRunStateElement.created() : super.created(); |
| 25 |
| 26 @published Isolate isolate; |
| 27 |
| 28 Future pause(_) { |
| 29 return isolate.get("debug/pause").then((result) { |
| 30 // TODO(turnidge): Instead of asserting here, handle errors |
| 31 // properly. |
| 32 assert(result.serviceType == 'Success'); |
| 33 return isolate.reload(); |
| 34 }); |
| 35 } |
| 36 |
| 37 Future resume(_) { |
| 38 return isolate.get("debug/resume").then((result) { |
| 39 // TODO(turnidge): Instead of asserting here, handle errors |
| 40 // properly. |
| 41 assert(result.serviceType == 'Success'); |
| 42 return isolate.reload(); |
| 43 }); |
| 44 } |
| 45 } |
| 46 |
| 47 @CustomTag('isolate-location') |
| 48 class IsolateLocationElement extends ObservatoryElement { |
| 49 IsolateLocationElement.created() : super.created(); |
| 50 |
| 51 @published Isolate isolate; |
| 52 } |
| 53 |
| 54 @CustomTag('isolate-shared-summary') |
| 55 class IsolateSharedSummaryElement extends ObservatoryElement { |
| 56 IsolateSharedSummaryElement.created() : super.created(); |
| 57 |
| 58 @published Isolate isolate; |
| 59 } |
| 60 |
| 61 class CounterChart { |
| 62 var _table = new DataTable(); |
| 63 var _chart; |
| 64 |
| 65 void update(Map counters) { |
| 66 if (_table.columns == 0) { |
| 67 // Initialize. |
| 68 _table.addColumn('string', 'Name'); |
| 69 _table.addColumn('number', 'Value'); |
| 70 } |
| 71 _table.clearRows(); |
| 72 for (var key in counters.keys) { |
| 73 var value = double.parse(counters[key].split('%')[0]); |
| 74 _table.addRow([key, value]); |
| 75 } |
| 76 } |
| 77 |
| 78 void draw(var element) { |
| 79 if (_chart == null) { |
| 80 assert(element != null); |
| 81 _chart = new Chart('PieChart', element); |
| 82 } |
| 83 _chart.draw(_table); |
| 84 } |
| 85 } |
| 86 |
| 87 @CustomTag('isolate-counter-chart') |
| 88 class IsolateCounterChartElement extends ObservatoryElement { |
| 89 IsolateCounterChartElement.created() : super.created(); |
| 90 |
| 91 @published ObservableMap counters; |
| 92 CounterChart chart = new CounterChart(); |
| 93 |
| 94 void countersChanged(oldValue) { |
| 95 if (counters == null) { |
| 96 return; |
| 97 } |
| 98 chart.update(counters); |
| 99 var element = shadowRoot.querySelector('#counterPieChart'); |
| 100 if (element != null) { |
| 101 chart.draw(element); |
| 102 } |
| 103 } |
| 104 } |
| 105 |
| 106 |
| 107 |
OLD | NEW |