Skip to content

Commit 44cf66d

Browse files
committed
refactoring(): fixing event things
1 parent b8baeac commit 44cf66d

File tree

8 files changed

+39
-86
lines changed

8 files changed

+39
-86
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"url": "http://github.com/grafana/grafana.git"
1111
},
1212
"devDependencies": {
13-
"angular2": "2.0.0-beta.12",
1413
"zone.js": "^0.6.6",
1514
"autoprefixer": "^6.3.3",
1615
"es6-promise": "^3.0.2",
@@ -54,7 +53,7 @@
5453
"mocha": "2.3.4",
5554
"phantomjs-prebuilt": "^2.1.3",
5655
"reflect-metadata": "0.1.2",
57-
"rxjs": "5.0.0-beta.2",
56+
"rxjs": "5.0.0-beta.4",
5857
"sass-lint": "^1.5.0",
5958
"systemjs": "0.19.24"
6059
},

public/app/core/time_series2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export default class TimeSeries {
170170
}
171171

172172
isMsResolutionNeeded() {
173-
for (var i = 0; i<this.datapoints.length; i++) {
173+
for (var i = 0; i < this.datapoints.length; i++) {
174174
if (this.datapoints[i][0] !== null) {
175175
var timestamp = this.datapoints[i][0].toString();
176176
if (timestamp.length === 13 && (timestamp % 1000) !== 0) {

public/app/features/templating/templateValuesSrv.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ function (angular, _, kbn) {
272272
}
273273

274274
for (i = 0; i < metricNames.length; i++) {
275-
var value = metricNames[i].text;
275+
var item = metricNames[i];
276+
var value = item.value || item.text;
277+
var text = item.text || item.value;
276278

277279
if (regex) {
278280
matches = regex.exec(value);
@@ -282,12 +284,11 @@ function (angular, _, kbn) {
282284
}
283285
}
284286

285-
options[value] = value;
287+
options[value] = {text: text, value: value};
286288
}
287289

288290
return _.map(_.keys(options).sort(), function(key) {
289-
var option = { text: key, value: key };
290-
return option;
291+
return options[key];
291292
});
292293
};
293294

public/app/headers/common.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
///<reference path="../../vendor/npm/angular2/typings/es6-promise/es6-promise.d.ts" />
2-
///<reference path="../../vendor/npm/angular2/typings/es6-collections/es6-collections.d.ts" />
1+
/// <reference path="./es6-shim/es6-shim.d.ts" />
32

43
declare var System: any;
54

public/app/headers/es6-promise/es6-promise.d.ts

Lines changed: 0 additions & 73 deletions
This file was deleted.

public/app/headers/es6-shim/es6-shim.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
// Generated by typings
2+
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/es6-shim/es6-shim.d.ts
13
// Type definitions for es6-shim v0.31.2
24
// Project: https://github.com/paulmillr/es6-shim
35
// Definitions by: Ron Buckton <http://github.com/rbuckton>
4-
// Definitions: https://github.com/borisyankov/DefinitelyTyped
6+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
57

68
declare type PropertyKey = string | number | symbol;
79

@@ -621,7 +623,7 @@ interface WeakSetConstructor {
621623

622624
declare var WeakSet: WeakSetConstructor;
623625

624-
declare module Reflect {
626+
declare namespace Reflect {
625627
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
626628
function construct(target: Function, argumentsList: ArrayLike<any>): any;
627629
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
@@ -649,7 +651,7 @@ declare module "es6-shim" {
649651
var WeakMap: WeakMapConstructor;
650652
var WeakSet: WeakSetConstructor;
651653
var Promise: PromiseConstructor;
652-
module Reflect {
654+
namespace Reflect {
653655
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
654656
function construct(target: Function, argumentsList: ArrayLike<any>): any;
655657
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;

public/app/plugins/panel/graph/module.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ class GraphCtrl extends MetricsPanelCtrl {
216216
}
217217

218218
series.applySeriesOverrides(this.panel.seriesOverrides);
219+
220+
if (seriesData.unit) {
221+
this.panel.yaxes[series.yaxis-1].format = seriesData.unit;
222+
}
223+
219224
return series;
220225
}
221226

public/test/core/utils/emitter_specs.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,28 @@ describe("Emitter", () => {
2323
expect(sub1Called).to.be(true);
2424
expect(sub2Called).to.be(true);
2525
});
26-
});
2726

27+
it('should handle errors', () => {
28+
var events = new Emitter();
29+
var sub1Called = 0;
30+
var sub2Called = 0;
31+
32+
var sub1 = events.on('test', () => {
33+
sub1Called++;
34+
throw "hello";
35+
});
36+
37+
events.on('test', () => {
38+
sub2Called++;
39+
});
40+
41+
try { events.emit('test', null); } catch (_) { }
42+
try { events.emit('test', null); } catch (_) {}
43+
44+
expect(sub1Called).to.be(1);
45+
expect(sub2Called).to.be(1);
46+
});
47+
});
2848
});
2949

3050

0 commit comments

Comments
 (0)