| 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 nav_bar_element; | 5 library nav_bar_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'observatory_element.dart'; | 9 import 'observatory_element.dart'; |
| 10 import 'package:observatory/service.dart'; | 10 import 'package:observatory/service.dart'; |
| 11 import 'package:polymer/polymer.dart'; | 11 import 'package:polymer/polymer.dart'; |
| 12 | 12 |
| 13 | 13 |
| 14 @CustomTag('nav-bar') | 14 @CustomTag('nav-bar') |
| 15 class NavBarElement extends ObservatoryElement { | 15 class NavBarElement extends ObservatoryElement { |
| 16 @published bool showNotify = true; | 16 @published bool notifyOnPause = true; |
| 17 @published bool pad = true; | 17 @published bool pad = true; |
| 18 | 18 |
| 19 NavBarElement.created() : super.created(); | 19 NavBarElement.created() : super.created(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 @CustomTag('nav-menu') | 22 @CustomTag('nav-menu') |
| 23 class NavMenuElement extends ObservatoryElement { | 23 class NavMenuElement extends ObservatoryElement { |
| 24 @published String link = '#'; | 24 @published String link = '#'; |
| 25 @published String anchor = '---'; | 25 @published String anchor = '---'; |
| 26 @published bool last = false; | 26 @published bool last = false; |
| 27 | 27 |
| 28 NavMenuElement.created() : super.created(); | 28 NavMenuElement.created() : super.created(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 @CustomTag('nav-menu-item') | 31 @CustomTag('nav-menu-item') |
| 32 class NavMenuItemElement extends ObservatoryElement { | 32 class NavMenuItemElement extends ObservatoryElement { |
| 33 @published String link = '#'; | 33 @published String link = '#'; |
| 34 @published String anchor = '---'; | 34 @published String anchor = '---'; |
| 35 | 35 |
| 36 NavMenuItemElement.created() : super.created(); | 36 NavMenuItemElement.created() : super.created(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 typedef Future RefreshCallback(); |
| 40 |
| 39 @CustomTag('nav-refresh') | 41 @CustomTag('nav-refresh') |
| 40 class NavRefreshElement extends ObservatoryElement { | 42 class NavRefreshElement extends ObservatoryElement { |
| 41 @published var callback; | 43 @published RefreshCallback callback; |
| 42 @published bool active = false; | 44 @published bool active = false; |
| 43 @published String label = 'Refresh'; | 45 @published String label = 'Refresh'; |
| 44 | 46 |
| 45 NavRefreshElement.created() : super.created(); | 47 NavRefreshElement.created() : super.created(); |
| 46 | 48 |
| 47 void buttonClick(Event e, var detail, Node target) { | 49 void buttonClick(Event e, var detail, Node target) { |
| 48 if (active) { | 50 if (active) { |
| 49 return; | 51 return; |
| 50 } | 52 } |
| 51 active = true; | 53 active = true; |
| 52 if (callback != null) { | 54 if (callback != null) { |
| 53 callback(refreshDone); | 55 callback() |
| 56 .catchError(app.handleException) |
| 57 .whenComplete(refreshDone); |
| 54 } | 58 } |
| 55 } | 59 } |
| 56 | 60 |
| 57 void refreshDone() { | 61 void refreshDone() { |
| 58 active = false; | 62 active = false; |
| 59 } | 63 } |
| 60 } | 64 } |
| 61 | 65 |
| 62 @CustomTag('top-nav-menu') | 66 @CustomTag('top-nav-menu') |
| 63 class TopNavMenuElement extends ObservatoryElement { | 67 class TopNavMenuElement extends ObservatoryElement { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 93 @CustomTag('class-nav-menu') | 97 @CustomTag('class-nav-menu') |
| 94 class ClassNavMenuElement extends ObservatoryElement { | 98 class ClassNavMenuElement extends ObservatoryElement { |
| 95 @published Class cls; | 99 @published Class cls; |
| 96 @published bool last = false; | 100 @published bool last = false; |
| 97 | 101 |
| 98 ClassNavMenuElement.created() : super.created(); | 102 ClassNavMenuElement.created() : super.created(); |
| 99 } | 103 } |
| 100 | 104 |
| 101 @CustomTag('nav-notify') | 105 @CustomTag('nav-notify') |
| 102 class NavNotifyElement extends ObservatoryElement { | 106 class NavNotifyElement extends ObservatoryElement { |
| 103 @published ObservableList<ServiceEvent> events; | 107 @published ObservableList<Notification> notifications; |
| 108 @published bool notifyOnPause = true; |
| 104 | 109 |
| 105 NavNotifyElement.created() : super.created(); | 110 NavNotifyElement.created() : super.created(); |
| 106 } | 111 } |
| 107 | 112 |
| 108 @CustomTag('nav-notify-item') | 113 @CustomTag('nav-notify-event') |
| 109 class NavNotifyItemElement extends ObservatoryElement { | 114 class NavNotifyEventElement extends ObservatoryElement { |
| 110 @published ObservableList<ServiceEvent> events; | 115 @published ObservableList<Notification> notifications; |
| 116 @published Notification notification; |
| 111 @published ServiceEvent event; | 117 @published ServiceEvent event; |
| 118 @published bool notifyOnPause = true; |
| 112 | 119 |
| 113 Future resume(_) { | 120 void closeItem(MouseEvent e, var detail, Element target) { |
| 114 app.removePauseEvents(event.isolate); | 121 notifications.remove(notification); |
| 115 return event.isolate.resume(); | |
| 116 } | 122 } |
| 117 Future stepInto(_) { | 123 |
| 118 app.removePauseEvents(event.isolate); | 124 NavNotifyEventElement.created() : super.created(); |
| 119 return event.isolate.stepInto(); | 125 } |
| 126 |
| 127 @CustomTag('nav-notify-exception') |
| 128 class NavNotifyExceptionElement extends ObservatoryElement { |
| 129 @published ObservableList<Notification> notifications; |
| 130 @published Notification notification; |
| 131 @published var exception; |
| 132 @published var stacktrace; |
| 133 |
| 134 exceptionChanged() { |
| 135 notifyPropertyChange(#isNetworkError, true, false); |
| 136 notifyPropertyChange(#isUnexpectedError, true, false); |
| 120 } | 137 } |
| 121 Future stepOver(_) { | 138 |
| 122 app.removePauseEvents(event.isolate); | 139 @observable get isNetworkError { |
| 123 return event.isolate.stepOver(); | 140 return (exception is NetworkRpcException); |
| 124 } | 141 } |
| 125 Future stepOut(_) { | 142 |
| 126 app.removePauseEvents(event.isolate); | 143 @observable get isUnexpectedError { |
| 127 return event.isolate.stepOut(); | 144 return (exception is! NetworkRpcException); |
| 128 } | 145 } |
| 129 | 146 |
| 130 void closeItem(MouseEvent e, var detail, Element target) { | 147 void closeItem(MouseEvent e, var detail, Element target) { |
| 131 events.remove(event); | 148 notifications.remove(notification); |
| 132 } | 149 } |
| 133 | 150 |
| 134 NavNotifyItemElement.created() : super.created(); | 151 NavNotifyExceptionElement.created() : super.created(); |
| 135 } | 152 } |
| OLD | NEW |