Skip to content

Commit f772a5c

Browse files
committed
Merge branch 'event-changes'
2 parents 583c0f0 + 4d63b57 commit f772a5c

File tree

14 files changed

+68
-132
lines changed

14 files changed

+68
-132
lines changed

CHANGELOG.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
# 3.0.0-beta3 (unreleased)
2-
3-
### Bug fixes
4-
* **Postgres**: Fixed page render crash when using postgres, fixes [#4558](https://github.com/grafana/grafana/issues/4558)
5-
* **Table panel**: Fixed table panel bug when trying to show annotations in table panel, fixes [#4563](https://github.com/grafana/grafana/issues/4563)
6-
* **App Config**: Fixed app config issue showing content of other app config, fixes [#4575](https://github.com/grafana/grafana/issues/4575)
7-
* **Graph Panel**: Fixed legend option max not updating, fixes [#4601](https://github.com/grafana/grafana/issues/4601)
8-
* **Graph Panel**: Fixed issue where newly added graph panels shared same axes config, fixes [#4582](https://github.com/grafana/grafana/issues/4582)
9-
10-
# 3.0.0-beta2 (2016-04-04)
1+
# 3.0.0-beta2 (unreleased)
112

123
### New Features (introduces since 3.0-beta1)
134
* **Preferences**: Set home dashboard on user and org level, closes [#1678](https://github.com/grafana/grafana/issues/1678)
@@ -18,9 +9,8 @@
189
* **Dashboard**: Fixed dashboard panel layout for mobile devices, fixes [#4529](https://github.com/grafana/grafana/issues/4529)
1910
* **Table Panel**: Fixed issue with table panel sort, fixes [#4532](https://github.com/grafana/grafana/issues/4532)
2011
* **Page Load Crash**: A Datasource with null jsonData would make Grafana fail to load page, fixes [#4536](https://github.com/grafana/grafana/issues/4536)
21-
* **Metrics tab**: Fix for missing datasource name in datasource selector, fixes [#4540](https://github.com/grafana/grafana/issues/4540)
12+
* **Metrics tab**: Fix for missing datasource name in datasource selector, fixes [#4541](https://github.com/grafana/grafana/issues/4540)
2213
* **Graph**: Fix legend in table mode with series on right-y axis, fixes [#4551](https://github.com/grafana/grafana/issues/4551), [#1145](https://github.com/grafana/grafana/issues/1145)
23-
* **Password**: Password reset link/page did not work, fixes [#4542](https://github.com/grafana/grafana/issues/4542)
2414

2515
# 3.0.0-beta1 (2016-03-31)
2616

package.json

Lines changed: 2 additions & 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
},
@@ -68,6 +67,7 @@
6867
},
6968
"license": "Apache-2.0",
7069
"dependencies": {
70+
"eventemitter3": "^1.2.0",
7171
"grunt-jscs": "~1.5.x",
7272
"grunt-sass-lint": "^0.1.0",
7373
"grunt-sync": "^0.4.1",

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/core/utils/emitter.ts

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
///<reference path="../../headers/common.d.ts" />
22

3-
import {Subject} from 'vendor/npm/rxjs/Subject';
3+
import EventEmitter from 'eventemitter3';
44

55
var hasOwnProp = {}.hasOwnProperty;
66

@@ -9,48 +9,27 @@ function createName(name) {
99
}
1010

1111
export class Emitter {
12-
subjects: any;
12+
emitter: any;
1313

1414
constructor() {
15-
this.subjects = {};
15+
this.emitter = new EventEmitter();
1616
}
1717

1818
emit(name, data?) {
19-
var fnName = createName(name);
20-
this.subjects[fnName] || (this.subjects[fnName] = new Subject());
21-
this.subjects[fnName].next(data);
19+
this.emitter.emit(name, data);
2220
}
2321

2422
on(name, handler, scope?) {
25-
var fnName = createName(name);
26-
this.subjects[fnName] || (this.subjects[fnName] = new Subject());
27-
var subscription = this.subjects[fnName].subscribe(handler);
23+
this.emitter.on(name, handler);
2824

2925
if (scope) {
3026
scope.$on('$destroy', function() {
31-
subscription.unsubscribe();
27+
this.emitter.off(name, handler);
3228
});
3329
}
34-
35-
return subscription;
36-
};
37-
38-
off(name, handler) {
39-
var fnName = createName(name);
40-
if (this.subjects[fnName]) {
41-
this.subjects[fnName].dispose();
42-
delete this.subjects[fnName];
43-
}
4430
}
4531

46-
dispose() {
47-
var subjects = this.subjects;
48-
for (var prop in subjects) {
49-
if (hasOwnProp.call(subjects, prop)) {
50-
subjects[prop].dispose();
51-
}
52-
}
53-
54-
this.subjects = {};
32+
off(name, handler) {
33+
this.emitter.off(name, handler);
5534
}
5635
}

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: 6 additions & 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

@@ -48,3 +47,8 @@ declare module 'tether-drop' {
4847
var config: any;
4948
export default config;
5049
}
50+
51+
declare module 'eventemitter3' {
52+
var config: any;
53+
export default config;
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/app/system.conf.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ System.config({
44
paths: {
55
'remarkable': 'vendor/npm/remarkable/dist/remarkable.js',
66
'tether': 'vendor/npm/tether/dist/js/tether.js',
7+
'eventemitter3': 'vendor/npm/eventemitter3/index.js',
78
'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js',
89
'moment': 'vendor/moment.js',
910
"jquery": "vendor/jquery/dist/jquery.js",
@@ -55,5 +56,9 @@ System.config({
5556
deps: ['jquery'],
5657
exports: 'angular',
5758
},
59+
'vendor/npm/eventemitter3/index.js': {
60+
format: 'cjs',
61+
exports: 'EventEmitter'
62+
},
5863
}
5964
});

public/sass/utils/_utils.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ button.close {
5252
.pull-right {
5353
float: right !important;
5454
}
55+
5556
.pull-left {
5657
float: left !important;
5758
}

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.only('should handle errors', () => {
28+
var events = new Emitter();
29+
var sub1Called = 0;
30+
var sub2Called = 0;
31+
32+
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(2);
45+
expect(sub2Called).to.be(0);
46+
});
47+
});
2848
});
2949

3050

public/test/test-main.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
baseURL: '/base/',
1111
defaultJSExtensions: true,
1212
paths: {
13+
'eventemitter3': 'vendor/npm/eventemitter3/index.js',
1314
'tether': 'vendor/npm/tether/dist/js/tether.js',
1415
'tether-drop': 'vendor/npm/tether-drop/dist/js/drop.js',
1516
'moment': 'vendor/moment.js',
@@ -58,7 +59,11 @@
5859
'vendor/angular-mocks/angular-mocks.js': {
5960
format: 'global',
6061
deps: ['angular'],
61-
}
62+
},
63+
'vendor/npm/eventemitter3/index.js': {
64+
format: 'cjs',
65+
exports: 'EventEmitter'
66+
},
6267
}
6368
});
6469

tasks/options/copy.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ module.exports = function(config) {
1919
cwd: './node_modules',
2020
expand: true,
2121
src: [
22-
'angular2/bundles/*.js',
23-
'angular2/*.d.ts',
24-
'angular2/typings/**/*',
25-
'angular2/manual_typings/**/*',
22+
'eventemitter3/*.js',
2623
'systemjs/dist/*.js',
2724
'es6-promise/**/*',
2825
'es6-shim/*.js',

0 commit comments

Comments
 (0)