mirror of
https://github.com/grafana/grafana.git
synced 2025-02-09 23:16:16 -06:00
refactoring(): fixing event things
This commit is contained in:
parent
b8baeac860
commit
44cf66d7ff
@ -10,7 +10,6 @@
|
||||
"url": "http://github.com/grafana/grafana.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"angular2": "2.0.0-beta.12",
|
||||
"zone.js": "^0.6.6",
|
||||
"autoprefixer": "^6.3.3",
|
||||
"es6-promise": "^3.0.2",
|
||||
@ -54,7 +53,7 @@
|
||||
"mocha": "2.3.4",
|
||||
"phantomjs-prebuilt": "^2.1.3",
|
||||
"reflect-metadata": "0.1.2",
|
||||
"rxjs": "5.0.0-beta.2",
|
||||
"rxjs": "5.0.0-beta.4",
|
||||
"sass-lint": "^1.5.0",
|
||||
"systemjs": "0.19.24"
|
||||
},
|
||||
|
@ -170,7 +170,7 @@ export default class TimeSeries {
|
||||
}
|
||||
|
||||
isMsResolutionNeeded() {
|
||||
for (var i = 0; i<this.datapoints.length; i++) {
|
||||
for (var i = 0; i < this.datapoints.length; i++) {
|
||||
if (this.datapoints[i][0] !== null) {
|
||||
var timestamp = this.datapoints[i][0].toString();
|
||||
if (timestamp.length === 13 && (timestamp % 1000) !== 0) {
|
||||
|
@ -272,7 +272,9 @@ function (angular, _, kbn) {
|
||||
}
|
||||
|
||||
for (i = 0; i < metricNames.length; i++) {
|
||||
var value = metricNames[i].text;
|
||||
var item = metricNames[i];
|
||||
var value = item.value || item.text;
|
||||
var text = item.text || item.value;
|
||||
|
||||
if (regex) {
|
||||
matches = regex.exec(value);
|
||||
@ -282,12 +284,11 @@ function (angular, _, kbn) {
|
||||
}
|
||||
}
|
||||
|
||||
options[value] = value;
|
||||
options[value] = {text: text, value: value};
|
||||
}
|
||||
|
||||
return _.map(_.keys(options).sort(), function(key) {
|
||||
var option = { text: key, value: key };
|
||||
return option;
|
||||
return options[key];
|
||||
});
|
||||
};
|
||||
|
||||
|
3
public/app/headers/common.d.ts
vendored
3
public/app/headers/common.d.ts
vendored
@ -1,5 +1,4 @@
|
||||
///<reference path="../../vendor/npm/angular2/typings/es6-promise/es6-promise.d.ts" />
|
||||
///<reference path="../../vendor/npm/angular2/typings/es6-collections/es6-collections.d.ts" />
|
||||
/// <reference path="./es6-shim/es6-shim.d.ts" />
|
||||
|
||||
declare var System: any;
|
||||
|
||||
|
73
public/app/headers/es6-promise/es6-promise.d.ts
vendored
73
public/app/headers/es6-promise/es6-promise.d.ts
vendored
@ -1,73 +0,0 @@
|
||||
// Type definitions for es6-promise
|
||||
// Project: https://github.com/jakearchibald/ES6-Promise
|
||||
// Definitions by: François de Campredon <https://github.com/fdecampredon/>, vvakame <https://github.com/vvakame>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface Thenable<R> {
|
||||
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
|
||||
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
|
||||
}
|
||||
|
||||
declare class Promise<R> implements Thenable<R> {
|
||||
/**
|
||||
* If you call resolve in the body of the callback passed to the constructor,
|
||||
* your promise is fulfilled with result object passed to resolve.
|
||||
* If you call reject your promise is rejected with the object passed to resolve.
|
||||
* For consistency and debugging (eg stack traces), obj should be an instanceof Error.
|
||||
* Any errors thrown in the constructor callback will be implicitly passed to reject().
|
||||
*/
|
||||
constructor(callback: (resolve : (value?: R | Thenable<R>) => void, reject: (error?: any) => void) => void);
|
||||
|
||||
/**
|
||||
* onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
|
||||
* Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
|
||||
* Both callbacks have a single parameter , the fulfillment value or rejection reason.
|
||||
* "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
|
||||
* If an error is thrown in the callback, the returned promise rejects with that error.
|
||||
*
|
||||
* @param onFulfilled called when/if "promise" resolves
|
||||
* @param onRejected called when/if "promise" rejects
|
||||
*/
|
||||
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Promise<U>;
|
||||
then<U>(onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => void): Promise<U>;
|
||||
|
||||
/**
|
||||
* Sugar for promise.then(undefined, onRejected)
|
||||
*
|
||||
* @param onRejected called when/if "promise" rejects
|
||||
*/
|
||||
catch<U>(onRejected?: (error: any) => U | Thenable<U>): Promise<U>;
|
||||
}
|
||||
|
||||
declare module Promise {
|
||||
/**
|
||||
* Make a new promise from the thenable.
|
||||
* A thenable is promise-like in as far as it has a "then" method.
|
||||
*/
|
||||
function resolve<R>(value?: R | Thenable<R>): Promise<R>;
|
||||
|
||||
/**
|
||||
* Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error
|
||||
*/
|
||||
function reject(error: any): Promise<any>;
|
||||
|
||||
/**
|
||||
* Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
|
||||
* the array passed to all can be a mixture of promise-like objects and other objects.
|
||||
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
|
||||
*/
|
||||
function all<R>(promises: (R | Thenable<R>)[]): Promise<R[]>;
|
||||
|
||||
/**
|
||||
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
|
||||
*/
|
||||
function race<R>(promises: (R | Thenable<R>)[]): Promise<R>;
|
||||
}
|
||||
|
||||
declare module 'es6-promise' {
|
||||
var foo: typeof Promise; // Temp variable to reference Promise in local context
|
||||
module rsvp {
|
||||
export var Promise: typeof foo;
|
||||
}
|
||||
export = rsvp;
|
||||
}
|
8
public/app/headers/es6-shim/es6-shim.d.ts
vendored
8
public/app/headers/es6-shim/es6-shim.d.ts
vendored
@ -1,7 +1,9 @@
|
||||
// Generated by typings
|
||||
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/es6-shim/es6-shim.d.ts
|
||||
// Type definitions for es6-shim v0.31.2
|
||||
// Project: https://github.com/paulmillr/es6-shim
|
||||
// Definitions by: Ron Buckton <http://github.com/rbuckton>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare type PropertyKey = string | number | symbol;
|
||||
|
||||
@ -621,7 +623,7 @@ interface WeakSetConstructor {
|
||||
|
||||
declare var WeakSet: WeakSetConstructor;
|
||||
|
||||
declare module Reflect {
|
||||
declare namespace Reflect {
|
||||
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
|
||||
function construct(target: Function, argumentsList: ArrayLike<any>): any;
|
||||
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
|
||||
@ -649,7 +651,7 @@ declare module "es6-shim" {
|
||||
var WeakMap: WeakMapConstructor;
|
||||
var WeakSet: WeakSetConstructor;
|
||||
var Promise: PromiseConstructor;
|
||||
module Reflect {
|
||||
namespace Reflect {
|
||||
function apply(target: Function, thisArgument: any, argumentsList: ArrayLike<any>): any;
|
||||
function construct(target: Function, argumentsList: ArrayLike<any>): any;
|
||||
function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean;
|
||||
|
@ -216,6 +216,11 @@ class GraphCtrl extends MetricsPanelCtrl {
|
||||
}
|
||||
|
||||
series.applySeriesOverrides(this.panel.seriesOverrides);
|
||||
|
||||
if (seriesData.unit) {
|
||||
this.panel.yaxes[series.yaxis-1].format = seriesData.unit;
|
||||
}
|
||||
|
||||
return series;
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,28 @@ describe("Emitter", () => {
|
||||
expect(sub1Called).to.be(true);
|
||||
expect(sub2Called).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle errors', () => {
|
||||
var events = new Emitter();
|
||||
var sub1Called = 0;
|
||||
var sub2Called = 0;
|
||||
|
||||
var sub1 = events.on('test', () => {
|
||||
sub1Called++;
|
||||
throw "hello";
|
||||
});
|
||||
|
||||
events.on('test', () => {
|
||||
sub2Called++;
|
||||
});
|
||||
|
||||
try { events.emit('test', null); } catch (_) { }
|
||||
try { events.emit('test', null); } catch (_) {}
|
||||
|
||||
expect(sub1Called).to.be(1);
|
||||
expect(sub2Called).to.be(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user