Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: runtime/observatory/lib/src/elements/isolate_reconnect.dart

Issue 2202973002: Converted Observatory isolate-reconnect element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 isolate_reconnect_element; 5 library isolate_riconnect_element;
6 6
7 import 'package:polymer/polymer.dart'; 7 import 'dart:html';
8 import 'observatory_element.dart'; 8 import 'dart:async';
9 import 'package:observatory/models.dart' as M;
10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
11 import 'package:observatory/src/elements/helpers/tag.dart';
12 import 'package:observatory/src/elements/helpers/uris.dart';
13 import 'package:observatory/src/elements/nav/bar.dart';
14 import 'package:observatory/src/elements/nav/notify.dart';
15 import 'package:observatory/src/elements/nav/top_menu.dart';
16 import 'package:observatory/src/elements/view_footer.dart';
9 17
10 @CustomTag('isolate-reconnect') 18 class IsolateReconnectElement extends HtmlElement implements Renderable{
11 class IsolateReconnectElement extends ObservatoryElement { 19 static const tag = const Tag<IsolateReconnectElement>('isolate-reconnect',
20 dependencies: const [NavBarElement.tag,
21 NavTopMenuElement.tag,
22 NavNotifyElement.tag]);
23
24 RenderingScheduler _r;
25
26 Stream<RenderedEvent<IsolateReconnectElement>> get onRendered =>
27 _r.onRendered;
28
29 M.VM _vm;
30 String _missing;
31 Uri _uri;
32 Stream<M.VMUpdateEvent> _vmUpdates;
33 StreamSubscription _subscription;
34
35 M.VM get vm => _vm;
36 String get missing => _missing;
37 Uri get uri => _uri;
38
39 set missing(String value) => _missing = _r.checkAndReact(_missing, value);
40 set uri(Uri value) => _uri = _r.checkAndReact(_uri, value);
41
42 M.NotificationRepository _notifications;
43 factory IsolateReconnectElement(M.VM vm, Stream<M.VMUpdateEvent> vmUpdates,
44 M.NotificationRepository notifications, {String missing: '',
45 Uri uri, RenderingQueue queue}) {
46 assert(vm != null);
47 assert(vmUpdates != null);
48 assert(missing != null);
49 assert(notifications != null);
50 IsolateReconnectElement e = document.createElement(tag.name);
51 e._r = new RenderingScheduler(e, queue: queue);
52 e._vm = vm;
53 e._vmUpdates = vmUpdates;
54 e._missing = missing;
55 e._uri = uri ?? new Uri();
56 e._notifications = notifications;
57 return e;
58 }
59
12 IsolateReconnectElement.created() : super.created(); 60 IsolateReconnectElement.created() : super.created();
13 61
14 get missingIsolateId { 62 @override
63 void attached() {
64 super.attached();
65 _r.enable();
66 _subscription = _vmUpdates.listen((e) => _r.dirty());
67 }
68
69 @override
70 void detached() {
71 super.detached();
72 children = [];
73 _r.disable(notify: true);
74 _subscription.cancel();
75 }
76
77 void render() {
78 children = [
79 new NavBarElement(queue: _r.queue)
80 ..children = [
81 new NavTopMenuElement(last: true, queue: _r.queue),
82 new NavNotifyElement(_notifications, queue: _r.queue)
83 ],
84 new DivElement()
85 ..classes = ['content-centered']
86 ..children = [
87 new HeadingElement.h1()..text = 'Isolate $_missing no longer exists',
88 new BRElement(), new HRElement(),
89 new DivElement()..classes = ['memberList']
90 ..children = (_vm.isolates.map((isolate) {
91 final query = new Map.from(_uri.queryParameters);
92 query['isolateId'] = isolate.id;
93 final href = new Uri(path: _uri.path, queryParameters: query);
94 return new DivElement()..classes = ['memberItem', 'doubleSpaced']
95 ..children = [
96 new SpanElement()..text = 'Continue in ',
97 new AnchorElement(href: '#$href')
98 ..text = '${isolate.id} (${isolate.name})'
99 ];
100 }).toList()..add(
101 new DivElement()..classes = ['memberItem', 'doubleSpaced']
102 ..children = [
103 new SpanElement()..text = 'Go to ',
104 new AnchorElement(href: Uris.vm())
105 ..text = 'isolates summary',
106 ]
107 ))
108 ],
109 new ViewFooterElement(queue: _r.queue)
110 ];
111 }
112
113 /*get missingIsolateId {
Cutch 2016/08/02 13:51:11 delete commented out code
cbernaschina 2016/08/02 15:53:07 Done.
15 return app.locationManager.uri.queryParameters['originalIsolateId']; 114 return app.locationManager.uri.queryParameters['originalIsolateId'];
16 } 115 }
17 116
18 linkToContinueIn(isolate) { 117 linkToContinueIn(isolate) {
19 var parameters = new Map.from(app.locationManager.uri.queryParameters); 118 var parameters = new Map.from(app.locationManager.uri.queryParameters);
20 parameters['isolateId'] = isolate.id; 119 parameters['isolateId'] = isolate.id;
21 parameters.remove('originalIsolateId'); 120 parameters.remove('originalIsolateId');
22 var path = parameters.remove('originalPath'); 121 var path = parameters.remove('originalPath');
23 path = "/$path"; 122 path = "/$path";
24 var generatedUri = new Uri(path: path, queryParameters: parameters); 123 var generatedUri = new Uri(path: path, queryParameters: parameters);
25 return app.locationManager.makeLink(generatedUri.toString()); 124 return app.locationManager.makeLink(generatedUri.toString());
26 } 125 }*/
27 } 126 }
127
128 /*<polymer-element name="isolate-reconnect">
Cutch 2016/08/02 13:51:11 delete commented out code
cbernaschina 2016/08/02 15:53:07 Done.
129 <template>
130 <link rel="stylesheet" href="css/shared.css">
131 <style>
132 .doubleSpaced {
133 line-height: 2em;
134 }
135 </style>
136
137 <nav-bar>
138 <top-nav-menu last="{{ true }}"></top-nav-menu>
139 <nav-notify notifications="{{ app.notifications }}"></nav-notify>
140 </nav-bar>
141
142 <div class="content-centered">
143 <h1 class="doubleSpaced">Isolate {{ missingIsolateId }} no longer exists</ h1>
144 <div class="memberList">
145 <template repeat="{{ i in app.vm.isolates }}">
146 <div class="memberItem doubleSpaced">
147 Continue in <a _href="{{ linkToContinueIn(i) }}">{{ i.id }} ({{ i.n ame }})</a>
148 </div>
149 </template>
150 <div class="memberItem doubleSpaced">
151 Go to <a _href="{{ gotoLink('/vm') }}">isolates summary</a>
152 </div>
153 </div>
154 </div>
155 </template>
156 </polymer-element>*/
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/css/shared.css ('k') | runtime/observatory/lib/src/elements/isolate_reconnect.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698