source_route 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,257 +0,0 @@
1
- doctype html
2
- html
3
- head
4
- title Source Route Result
5
- link rel="stylesheet" href="https://cdn.rawgit.com/Urigo/angular-spinkit/master/build/angular-spinkit.min.css"
6
- link rel="stylesheet" href="https://cdn.rawgit.com/mohsen1/json-formatter/master/dist/json-formatter.css"
7
- link rel="stylesheet" href="http://oss.maxcdn.com/semantic-ui/2.1.7/semantic.min.css"
8
-
9
- script async=true src="http://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.0/lodash.js"
10
- script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"
11
- script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.6/angular.min.js"
12
- script async=true src="http://oss.maxcdn.com/semantic-ui/2.1.7/semantic.min.js"
13
-
14
- css:
15
- .call-level-0 {}
16
- .item.trace.call-level-1 { padding-left: 50px }
17
- .item.trace.call-level-2 { padding-left: 100px }
18
- .item.trace.call-level-3 { padding-left: 150px }
19
- .item.trace.call-level-4 { padding-left: 200px }
20
- .item.trace.call-level-5 { padding-left: 250px }
21
- .item.trace.call-level-6 { padding-left: 300px }
22
- .item.trace.call-level-7 { padding-left: 300px }
23
- .tree-level {
24
- display: flex;
25
- align-items: center;
26
- justify-content: space-around;
27
- }
28
- // level more than 7 seems not reasonable
29
-
30
- body(ng-app="SourceRoute" ng-controller="MainCtrl" ng-cloak)
31
-
32
- .ui.menu.pointing.stackable.attached
33
- .ui.container
34
- .item
35
- a.navbar-brand(href="#" ng-click="::resetTraceFilter()") ALL
36
- .item(ng-repeat="event in tpEvents" ng-class="{active: event == traceFilter.event}")
37
- a(href="#" ng-click="traceFilter.event = event" ng-bind="::event")
38
- .item
39
- .ui.buttons
40
- button.ui.labeled.icon.button.olive(ng-click="outlineTrace()" ng-class="{loading: outlineTraceLoading}")
41
- i.angle.double.right.icon
42
- span OutLine
43
- .or
44
- button.ui.right.labeled.icon.button.green(ng-click="expandAllTrace()" ng-class="{loading: expandAllTraceLoading}")
45
- i.angle.double.down.icon
46
- span Expand
47
- .right.menu
48
- .item
49
- span Trace Count
50
- .ui.teal.left.pointing.label(ng-bind="currentCounter()")
51
-
52
- .ui.container
53
- .row
54
- / .ui.relaxed.items(ng-class="{{traceFilter.event}}")
55
- .ui.segment.tree-level(ng-repeat="level in lengthLevel")
56
- .item.trace(ng-repeat="trace in traces | filter:{parent_length: level, event: traceFilter.event}" ng-class="callLevelClass(trace)" ng-controller="TpTraceCtrl")
57
- .content(ng-init="showMoreDetail = false")
58
- .ui.segment.left.floated.padded
59
- .header
60
- span(ng-bind="::tpSelfList[trace.tp_self_refer]")
61
- i.circle.icon.grey(style="font-size: 0.3em")
62
- span.method-value(ng-bind="::trace.method_id")
63
- / workaround for return_value is 'false' and return_value always to be string when existed
64
- .meta(ng-if="trace.hasOwnProperty('return_value')")
65
- i.icon.pointing.right.small
66
- json-formatter(open="1" json="::trace.return_value" style="display: inline-block")
67
- .description
68
- .ui.vertical.buttons.basic
69
- button.ui.labeled.icon.button(ng-show="::containsDetail(trace)" ng-click="showMoreDetail = !showMoreDetail")
70
- i.browser.icon
71
- span Details
72
- button.ui.labeled.icon.button(ng-if="::hasChild()" ng-click="toggleChild()" ng-class="{loading: togglingChild}")
73
- i.icon.angle.down(ng-show="trace.childOpened")
74
- i.icon.angle.right(ng-hide="trace.childOpened")
75
- span Child
76
- pulse-spinner(ng-show="togglingChild")
77
-
78
- .details.right.floated(ng-if="showMoreDetail")
79
- .ui.segments(style="border-color: blue")
80
- .ui.segment(ng-if="::trace.params_var")
81
- .ui.teal.right.ribbon.label Parameters
82
- json-formatter(open="1" json="::trace.params_var")
83
- .ui.segment(ng-if="::trace.hasOwnProperty('return_value')")
84
- .ui.grey.right.ribbon.label Return Value
85
- json-formatter(json="::trace.return_value")
86
- .ui.segment(ng-if="::containsOtherAttrs(trace)")
87
- .ui.orange.right.ribbon.label Trace Attributes
88
- json-formatter(open="1" json="::plusTraceAttrs[trace.order_id]")
89
- .ui.segment(ng-if="::trace.local_var")
90
- .ui.teal.right.ribbon.label Local Variables
91
- json-formatter(open="1" json="::trace.local_var")
92
- .ui.segment(ng-if="::trace.instance_var")
93
- .ui.blue.right.ribbon.label Instance Variables
94
- json-formatter(open="1" json="::trace.instance_var")
95
-
96
- script src="https://cdn.rawgit.com/Urigo/angular-spinkit/master/build/angular-spinkit.min.js"
97
- script src="https://cdn.rawgit.com/mohsen1/json-formatter/master/dist/json-formatter.js"
98
- // script async src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-sanitize.js"
99
-
100
- javascript:
101
- sourceRoute = angular.module('SourceRoute', ['jsonFormatter', 'angular-spinkit'])
102
- sourceRoute.controller('MainCtrl', function($scope, $filter, $timeout) {
103
-
104
- // setup different color on menu item may not be a good solution
105
- // $scope.menuColorList = ['yellow', 'olive', 'green', 'teal', 'violet', 'purple', 'brown']
106
- $scope.trimString = function(str, length) {
107
- return str.length > length ? str.substring(0, length - 3) + '...' : str;
108
- }
109
-
110
- $scope.traces = angular.element("#trace-data").data('trace')
111
- $scope.tpSelfList = angular.element("#trace-data").data('tp-self-caches')
112
- $scope.tpEvents = angular.element("#trace-data").data('tp-events')
113
- $scope.childParentFilter = { hide_trace_ids: [] }
114
-
115
- $scope.lengthLevel = $scope.traces.reduce(function(pre, cur) {
116
- if (_.includes(pre, cur.parent_length)) {
117
- // return pre; // do nothing
118
- } else {
119
- pre.push(cur.parent_length)
120
- }
121
- return pre;
122
- }, []);
123
-
124
- $scope.childParentFilterFn = function(trace) {
125
- if (!trace.hasOwnProperty('parent_ids')) {
126
- return true;
127
- }
128
- if (trace.parent_ids.length == 0) {
129
- return true;
130
- } else {
131
- var shared_hide_parents = _.intersection(trace.parent_ids, $scope.childParentFilter.hide_trace_ids);
132
- if (shared_hide_parents.length > 0 ) {
133
- return false;
134
- }
135
- }
136
- return true;
137
- }
138
-
139
- $scope.expandAllTrace = function() {
140
- $scope.expandAllTraceLoading = true
141
- $timeout(function() {
142
- _.each($scope.traces, function(trace) { trace.childOpened = true; });
143
- $scope.childParentFilter.hide_trace_ids = [];
144
- $scope.expandAllTraceLoading = false
145
- $scope.expandAllTraceLoading = false
146
- }, 100)
147
- }
148
-
149
- $scope.outlineTrace = function() {
150
- $scope.outlineTraceLoading = true
151
- $scope.childParentFilter.hide_trace_ids = [];
152
- _.chain($scope.traces).filter({parent_length: 0, event: $scope.traceFilter.event})
153
- .each(function(trace) {
154
- trace.childOpened = false;
155
- $scope.childParentFilter.hide_trace_ids.push(trace.order_id) }
156
- ).value()
157
- $scope.outlineTraceLoading = false
158
- }
159
-
160
- $scope.traceFilter = {event: $scope.tpEvents[0]}
161
- if ($scope.tpEvents.length == 1 && angular.isUndefined($scope.traces[0].event)) {
162
- _.each($scope.traces, function(trace) {
163
- trace.event = $scope.tpEvents[0]
164
- })
165
- }
166
-
167
- $scope.definedClasses = _.uniq(_.map($scope.traces, 'defined_class'))
168
-
169
- $scope.callLevelClass = function(trace) {
170
- if (trace.parent_length > 7) {
171
- return 'call-level-7';
172
- } else {
173
- return 'call-level-' + trace.parent_length;
174
- }
175
- }
176
-
177
- $scope.resetTraceFilter = function() {
178
- $scope.traceFilter = {};
179
- }
180
-
181
- $scope.currentCounter = function() {
182
- return $filter('filter')($scope.traces, $scope.traceFilter, true).length;
183
- }
184
-
185
- $scope.containsOtherAttrs = function(trace) {
186
- return trace.hasOwnProperty('path') || trace.hasOwnProperty('lineno')
187
- }
188
-
189
- $scope.containsDetail = function(trace) {
190
- return $scope.containsOtherAttrs(trace) || trace.hasOwnProperty('local_var') ||
191
- trace.hasOwnProperty('instance_var')
192
- }
193
-
194
- combinedAttrs = function(trace) {
195
- var attrs = {}
196
- if (trace.hasOwnProperty('lineno') && trace.hasOwnProperty('path')) {
197
- attrs.method_defined_on = trace.path + ":" + trace.lineno;
198
- } else if (trace.hasOwnProperty('path')) {
199
- attrs.method_defined_on = trace.path;
200
- }
201
- if (trace.hasOwnProperty('defined_class')) {
202
- attrs.method_defined_in = trace.defined_class;
203
- }
204
- return attrs;
205
- }
206
-
207
- $scope.plusTraceAttrs = _.map($scope.traces, combinedAttrs)
208
-
209
- $scope.outlineTrace();
210
- })
211
-
212
- sourceRoute.controller('TpTraceCtrl', function($scope, $timeout) {
213
-
214
- $scope.toggleChild = function() {
215
- $scope.togglingChild = true
216
- $timeout(function() {
217
- if ($scope.trace.childOpened) {
218
- $scope.hideChild();
219
- $scope.togglingChild = false
220
- } else {
221
- $scope.showChild();
222
- $scope.togglingChild = false
223
- }
224
- }, 0)
225
- }
226
-
227
- $scope.showChild = function() {
228
- $scope.trace.childOpened = true;
229
- _.pull($scope.childParentFilter.hide_trace_ids, $scope.trace.order_id);
230
- if ($scope.trace.direct_child_order_ids.length > 0) {
231
- $scope.childParentFilter.hide_trace_ids.push($scope.trace.direct_child_order_ids);
232
- $scope.childParentFilter.hide_trace_ids = _.chain($scope.childParentFilter.hide_trace_ids).flatten().uniq().value();
233
- }
234
- }
235
-
236
- $scope.hideChild = function() {
237
- $scope.trace.childOpened = false;
238
- $scope.childParentFilter.hide_trace_ids.push($scope.trace.order_id);
239
- if ($scope.trace.direct_child_order_ids.length > 0) {
240
- _.each($scope.trace.direct_child_order_ids, function(ele) {
241
- _.pull($scope.childParentFilter.hide_trace_ids, ele);
242
- });
243
- }
244
- }
245
-
246
- $scope.hasChild = function() {
247
- return _.find($scope.traces, function(trace) {
248
- return _.contains(trace.parent_ids, $scope.trace.order_id)
249
- });
250
- }
251
- })
252
-
253
- .data-collect
254
- / dont use local_trace_data.to_json, because ActiveSupport override it and can introduce unexpected crash for some data
255
- #trace-data(data-trace="#{jsonify_tp_result_chain}"
256
- data-tp-events="#{jsonify_events}"
257
- data-tp-self-caches="#{jsonify_tp_self_caches}")
@@ -1,12 +0,0 @@
1
- module Jsonify
2
-
3
- def self.dump(obj)
4
- if obj.respond_to? :stringify
5
- JSON.dump(obj.stringify)
6
- else
7
- # JSON.dump(obj.to_s)
8
- JSON.dump(obj.inspect)
9
- end
10
- end
11
-
12
- end