-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelvue.js
193 lines (193 loc) · 5.96 KB
/
elvue.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// Generated by LiveScript 1.3.1
/*
* ELVUE - Reports for ELMAH Error Logs
* Copyright (c) 2011 Atif Aziz. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function(){
var id, $, formatSimpleErrorTypeName, app;
id = function(it){
return it;
};
$ == null && ($ = function(it){
return angular.element(
typeof it === 'string' ? document.querySelector(it) : it);
});
formatSimpleErrorTypeName = function(name){
var m, last;
m = name.match(/^([a-z0-9]+\.)+?([a-z0-9]*exception)$/i);
switch (false) {
case m != null:
return name;
default:
last = m.pop();
return last.slice(0, -'exception'.length) || last;
}
};
app = angular.module('app', ['angularMoment']).constant('angularMomentConfig', {
preprocess: 'utc'
});
app.directive('googleChart', function(){
return {
restrict: 'A',
link: function($scope, $elem, $attr){
var ngModel, options, chart;
ngModel = $scope[$attr.ngModel];
if (ngModel == null) {
return;
}
options = {};
if (ngModel.title) {
options.title = ngModel.title;
}
chart = new google.visualization[$attr.googleChart]($elem[0]);
chart.draw(ngModel.dataTable, options);
return $scope.$watch($attr.ngModel + "", function(){
return chart.draw(ngModel.dataTable, ngModel.config);
}, true);
}
};
});
app.directive('elmahDownload', function(){
return {
restrict: 'A',
link: function($scope, $elem, $attr){
(function(src, id){
var callback;
if (src == null) {
return;
}
callback = 'onerrors' + id;
$($elem).attr('src', src.replace(/=CALLBACK(?=&|$)/, "=parent." + encodeURIComponent(callback)));
window[callback] == null && (window[callback] = function(data){
$scope.$apply(function(){
if (typeof $scope.onerrors == 'function') {
$scope.onerrors(data);
}
});
});
}.call(this, $scope.src, $scope.$id));
}
};
});
app.controller('page', new Array('$scope', 'config', function($scope, config){
var x$, dt, y$, errors, byType, label;
x$ = dt = new google.visualization.DataTable();
x$.addColumn('string', 'Error');
x$.addColumn('number', 'Count');
$scope.gc = {
dataTable: dt,
config: {
is3D: true,
width: 500,
height: 333,
chartArea: {
left: 10,
top: 10,
width: '90%',
height: '90%'
}
}
};
$scope.src = (function(src, limit){
return (src + "?format=html-jsonp&callback=CALLBACK") + (limit > 0 ? "&limit=" + limit : '');
}.call(this, config.src || 'elmah.axd/download', +config.limit));
y$ = $scope;
y$.callbackCount = 0;
y$.loadedCount = 0;
y$.totalCount = 0;
y$.errors = errors = [];
y$.byType = byType = {};
y$.sort = function(key){
if (key === this.sortKey) {
this.sortDescending = !this.sortDescending;
} else {
this.sortKey = key;
this.sortDescending = key !== 'type';
}
};
y$.sort('count');
label = function(labeling){
labeling == null && (labeling = config.labeling);
switch (false) {
case typeof labeling !== 'function':
return labeling;
case labeling !== 'words':
return function(type){
return $.trim(type.replace(/([a-z])([A-Z])/g, '$1 $2')).toLowerCase();
};
default:
return id;
}
}();
return $scope.onerrors = function(data){
var i$, ref$, len$, err, type, entry, ref1$, h;
$scope.callbackCount++;
$scope.totalCount = data.total;
$scope.loadedCount += data.errors.length;
for (i$ = 0, len$ = (ref$ = data.errors).length; i$ < len$; ++i$) {
err = ref$[i$];
type = label(formatSimpleErrorTypeName(
err.type), err);
if ((entry = byType[type]) == null) {
errors.push(entry = byType[type] = {
type: type,
type$: err.type,
count: 0,
i: errors.length,
time: new Date(Date.parse(err.time)),
time$: err.time.replace(/\.\d{1,3}Z$/, 'Z'),
href: (ref1$ = (fn$())[0]) != null ? ref1$.href : void 8
});
dt.addRows(1);
dt.setValue(entry.i, 0, type);
}
dt.setValue(entry.i, 1, ++entry.count);
}
function fn$(){
var i$, ref$, len$, results$ = [];
for (i$ = 0, len$ = (ref$ = err.hrefs).length; i$ < len$; ++i$) {
h = ref$[i$];
if ((h != null ? h.href : void 8) != null && h.type === 'text/html') {
results$.push(h);
}
}
return results$;
}
};
}));
google.setOnLoadCallback(function(config){
var ref$;
config == null && (config = (ref$ = this.config) != null
? ref$
: {});
return function(){
var location, ref$;
if (config.title) {
document.title = config.title;
} else {
location = window.location;
if ((ref$ = location.protocol) === 'http:' || ref$ === 'https:') {
document.title += " for \u201c" + location.hostname + "\u201d";
}
}
$('h1').text(document.title);
app.value('config', config);
angular.bootstrap(document.body, ['app']);
};
}());
google.load('visualization', '1', {
packages: ['corechart']
});
}).call(this);