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 flag_list_element; | 5 library flag_list_element; |
6 | 6 |
7 import 'dart:html'; | 7 import 'dart:html'; |
8 import 'dart:async'; | 8 import 'dart:async'; |
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'; |
| 11 import 'package:observatory/src/elements/helpers/nav_menu.dart'; |
10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 12 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
11 import 'package:observatory/src/elements/helpers/tag.dart'; | 13 import 'package:observatory/src/elements/helpers/tag.dart'; |
12 import 'package:observatory/src/elements/helpers/uris.dart'; | 14 import 'package:observatory/src/elements/helpers/uris.dart'; |
13 import 'package:observatory/src/elements/nav/bar.dart'; | |
14 import 'package:observatory/src/elements/nav/menu.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 | 20 |
21 class FlagListElement extends HtmlElement implements Renderable { | 21 class FlagListElement extends HtmlElement implements Renderable { |
22 static const tag = const Tag<FlagListElement>('flag-list', | 22 static const tag = const Tag<FlagListElement>('flag-list', |
23 dependencies: const [NavBarElement.tag, | 23 dependencies: const [NavNotifyElement.tag, |
24 NavMenuElement.tag, | |
25 NavNotifyElement.tag, | |
26 NavRefreshElement.tag, | 24 NavRefreshElement.tag, |
27 NavTopMenuElement.tag, | 25 NavTopMenuElement.tag, |
28 NavVMMenuElement.tag, | 26 NavVMMenuElement.tag, |
29 ViewFooterElement.tag,]); | 27 ViewFooterElement.tag,]); |
30 | 28 |
31 RenderingScheduler _r; | 29 RenderingScheduler _r; |
32 | 30 |
33 Stream<RenderedEvent<FlagListElement>> get onRendered => _r.onRendered; | 31 Stream<RenderedEvent<FlagListElement>> get onRendered => _r.onRendered; |
34 | 32 |
35 M.VMRef _vm; | 33 M.VMRef _vm; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 content.add(new BRElement()); | 91 content.add(new BRElement()); |
94 | 92 |
95 if (unmodified.isEmpty) { | 93 if (unmodified.isEmpty) { |
96 content.add(new HeadingElement.h2()..text = 'None'); | 94 content.add(new HeadingElement.h2()..text = 'None'); |
97 } else { | 95 } else { |
98 content.addAll(unmodified.expand(_renderFlag)); | 96 content.addAll(unmodified.expand(_renderFlag)); |
99 } | 97 } |
100 } | 98 } |
101 | 99 |
102 children = [ | 100 children = [ |
103 new NavBarElement(queue: _r.queue) | 101 navBar([ |
104 ..children = [ | 102 new NavTopMenuElement(queue: _r.queue), |
105 new NavTopMenuElement(queue: _r.queue), | 103 new NavVMMenuElement(_vm, _events, queue: _r.queue), |
106 new NavVMMenuElement(_vm, _events, queue: _r.queue), | 104 navMenu('flags'), |
107 new NavMenuElement('flags', link: Uris.flags(), last: true, | 105 new NavRefreshElement(queue: _r.queue) |
108 queue: _r.queue), | 106 ..onRefresh.listen((e) async { |
109 new NavRefreshElement(queue: _r.queue) | 107 e.element.disabled = true; |
110 ..onRefresh.listen((e) async { | 108 try { |
111 e.element.disabled = true; | 109 await _refresh(); |
112 try { | 110 } finally { |
113 await _refresh(); | 111 e.element.disabled = false; |
114 } finally { | 112 } |
115 e.element.disabled = false; | 113 }), |
116 } | 114 new NavNotifyElement(_notifications, queue: _r.queue) |
117 }), | 115 ]), |
118 new NavNotifyElement(_notifications, queue: _r.queue) | |
119 ], | |
120 new DivElement() | 116 new DivElement() |
121 ..classes = ['content-centered'] | 117 ..classes = ['content-centered'] |
122 ..children = content, | 118 ..children = content, |
123 new ViewFooterElement(queue: _r.queue) | 119 new ViewFooterElement(queue: _r.queue) |
124 ]; | 120 ]; |
125 } | 121 } |
126 | 122 |
127 Future _refresh() { | 123 Future _refresh() { |
128 return _repository.list().then((flags) { | 124 return _repository.list().then((flags) { |
129 _flags = flags; | 125 _flags = flags; |
(...skipping 14 matching lines...) Expand all Loading... |
144 new SpanElement()..classes = ['name'] | 140 new SpanElement()..classes = ['name'] |
145 ..text = flag.name, | 141 ..text = flag.name, |
146 new SpanElement()..text = '=', | 142 new SpanElement()..text = '=', |
147 new SpanElement()..classes = ['value'] | 143 new SpanElement()..classes = ['value'] |
148 ..text = flag.valueAsString ?? 'NULL' | 144 ..text = flag.valueAsString ?? 'NULL' |
149 ], | 145 ], |
150 new BRElement(), | 146 new BRElement(), |
151 ]; | 147 ]; |
152 } | 148 } |
153 } | 149 } |
OLD | NEW |