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 error_view_element; | 5 library error_view_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'; |
10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 11 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/tag.dart'; |
12 import 'package:observatory/src/elements/nav/bar.dart'; | |
13 import 'package:observatory/src/elements/nav/notify.dart'; | 13 import 'package:observatory/src/elements/nav/notify.dart'; |
14 import 'package:observatory/src/elements/nav/top_menu.dart'; | 14 import 'package:observatory/src/elements/nav/top_menu.dart'; |
15 import 'package:observatory/src/elements/view_footer.dart'; | 15 import 'package:observatory/src/elements/view_footer.dart'; |
16 | 16 |
17 class ErrorViewElement extends HtmlElement implements Renderable{ | 17 class ErrorViewElement extends HtmlElement implements Renderable{ |
18 static const tag = const Tag<ErrorViewElement>('error-view', | 18 static const tag = const Tag<ErrorViewElement>('error-view', |
19 dependencies: const [NavBarElement.tag, | 19 dependencies: const [NavTopMenuElement.tag, |
20 NavTopMenuElement.tag, | |
21 NavNotifyElement.tag, | 20 NavNotifyElement.tag, |
22 ViewFooterElement.tag]); | 21 ViewFooterElement.tag]); |
23 | 22 |
24 RenderingScheduler _r; | 23 RenderingScheduler _r; |
25 | 24 |
26 Stream<RenderedEvent<ErrorViewElement>> get onRendered => | 25 Stream<RenderedEvent<ErrorViewElement>> get onRendered => |
27 _r.onRendered; | 26 _r.onRendered; |
28 | 27 |
29 M.Error _error; | 28 M.Error _error; |
30 M.NotificationRepository _notifications; | 29 M.NotificationRepository _notifications; |
(...skipping 22 matching lines...) Expand all Loading... |
53 | 52 |
54 @override | 53 @override |
55 void detached() { | 54 void detached() { |
56 super.detached(); | 55 super.detached(); |
57 children = []; | 56 children = []; |
58 _r.disable(notify: true); | 57 _r.disable(notify: true); |
59 } | 58 } |
60 | 59 |
61 void render() { | 60 void render() { |
62 children = [ | 61 children = [ |
63 new NavBarElement(queue: _r.queue) | 62 navBar([ |
64 ..children = [ | 63 new NavTopMenuElement(queue: _r.queue), |
65 new NavTopMenuElement(last: true, queue: _r.queue), | 64 new NavNotifyElement(_notifications, queue: _r.queue) |
66 new NavNotifyElement(_notifications, queue: _r.queue) | 65 ]), |
67 ], | |
68 new DivElement() | 66 new DivElement() |
69 ..classes = ['content-centered'] | 67 ..classes = ['content-centered'] |
70 ..children = [ | 68 ..children = [ |
71 new HeadingElement.h1() | 69 new HeadingElement.h1() |
72 ..text = 'Error: ${_kindToString(_error.kind)}', | 70 ..text = 'Error: ${_kindToString(_error.kind)}', |
73 new BRElement(), | 71 new BRElement(), |
74 new DivElement()..classes = ['well'] | 72 new DivElement()..classes = ['well'] |
75 ..children = [ | 73 ..children = [ |
76 new PreElement()..text = error.message | 74 new PreElement()..text = error.message |
77 ] | 75 ] |
78 ], | 76 ], |
79 new ViewFooterElement(queue: _r.queue) | 77 new ViewFooterElement(queue: _r.queue) |
80 ]; | 78 ]; |
81 } | 79 } |
82 | 80 |
83 static String _kindToString(M.ErrorKind kind) { | 81 static String _kindToString(M.ErrorKind kind) { |
84 switch(kind) { | 82 switch(kind) { |
85 case M.ErrorKind.unhandledException: | 83 case M.ErrorKind.unhandledException: |
86 return 'Unhandled Exception'; | 84 return 'Unhandled Exception'; |
87 case M.ErrorKind.languageError: | 85 case M.ErrorKind.languageError: |
88 return 'Language Error'; | 86 return 'Language Error'; |
89 case M.ErrorKind.internalError: | 87 case M.ErrorKind.internalError: |
90 return 'Internal Error'; | 88 return 'Internal Error'; |
91 case M.ErrorKind.terminationError: | 89 case M.ErrorKind.terminationError: |
92 return 'Termination Error'; | 90 return 'Termination Error'; |
93 } | 91 } |
94 throw new Exception('Unkown M.ErrorKind ($kind)'); | 92 throw new Exception('Unkown M.ErrorKind ($kind)'); |
95 } | 93 } |
96 } | 94 } |
OLD | NEW |