From 44cf66d7ffc3269cf3ffbe5d09e0751f401b3476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 7 Apr 2016 19:23:20 -0400 Subject: [PATCH] refactoring(): fixing event things --- package.json | 3 +- public/app/core/time_series2.ts | 2 +- .../features/templating/templateValuesSrv.js | 9 ++- public/app/headers/common.d.ts | 3 +- .../app/headers/es6-promise/es6-promise.d.ts | 73 ------------------- public/app/headers/es6-shim/es6-shim.d.ts | 8 +- public/app/plugins/panel/graph/module.ts | 5 ++ public/test/core/utils/emitter_specs.ts | 22 +++++- 8 files changed, 39 insertions(+), 86 deletions(-) delete mode 100644 public/app/headers/es6-promise/es6-promise.d.ts diff --git a/package.json b/package.json index b245bf540da..60467015be0 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/public/app/core/time_series2.ts b/public/app/core/time_series2.ts index f5fcf5bd50c..e0a3dd47b4e 100644 --- a/public/app/core/time_series2.ts +++ b/public/app/core/time_series2.ts @@ -170,7 +170,7 @@ export default class TimeSeries { } isMsResolutionNeeded() { - for (var i = 0; i -/// +/// declare var System: any; diff --git a/public/app/headers/es6-promise/es6-promise.d.ts b/public/app/headers/es6-promise/es6-promise.d.ts deleted file mode 100644 index 86c82273a0d..00000000000 --- a/public/app/headers/es6-promise/es6-promise.d.ts +++ /dev/null @@ -1,73 +0,0 @@ -// Type definitions for es6-promise -// Project: https://github.com/jakearchibald/ES6-Promise -// Definitions by: François de Campredon , vvakame -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -interface Thenable { - then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; - then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Thenable; -} - -declare class Promise implements Thenable { - /** - * 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) => 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(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Promise; - then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Promise; - - /** - * Sugar for promise.then(undefined, onRejected) - * - * @param onRejected called when/if "promise" rejects - */ - catch(onRejected?: (error: any) => U | Thenable): Promise; -} - -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(value?: R | Thenable): Promise; - - /** - * 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; - - /** - * 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(promises: (R | Thenable)[]): Promise; - - /** - * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. - */ - function race(promises: (R | Thenable)[]): Promise; -} - -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; -} diff --git a/public/app/headers/es6-shim/es6-shim.d.ts b/public/app/headers/es6-shim/es6-shim.d.ts index 41f22997af5..265c19e08f9 100644 --- a/public/app/headers/es6-shim/es6-shim.d.ts +++ b/public/app/headers/es6-shim/es6-shim.d.ts @@ -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 -// 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; function construct(target: Function, argumentsList: ArrayLike): 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; function construct(target: Function, argumentsList: ArrayLike): any; function defineProperty(target: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index a430be98662..aeb2aa5765a 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -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; } diff --git a/public/test/core/utils/emitter_specs.ts b/public/test/core/utils/emitter_specs.ts index 6ab5f80fa0e..9bf94030274 100644 --- a/public/test/core/utils/emitter_specs.ts +++ b/public/test/core/utils/emitter_specs.ts @@ -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); + }); + }); });