From b689c9a1ed67eeec6882eeafd91bd39cdbdb612c Mon Sep 17 00:00:00 2001 From: Murhaf Sousli Date: Wed, 25 Oct 2017 16:39:10 +0300 Subject: [PATCH] v2.1.1 fixes #88 --- CHANGELOG.md | 8 ++++++-- package.json | 2 +- rollup.config.js | 1 + src/components/progress-bar.component.ts | 17 +++++++++-------- src/components/progress.component.ts | 3 +-- src/models/progress.state.ts | 4 ++++ src/progressbar.ts | 1 + src/services/progress.service.ts | 10 +++++++++- tslint.json | 1 + 9 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 src/models/progress.state.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 54d3eca..ed44db3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,15 @@ # Changelog -## 2.1.0 +## 2.1.1 - Allow `` component to be destroyed, fixes [#27](https://github.com/MurhafSousli/ngx-progressbar/issues/27), [#28](https://github.com/MurhafSousli/ngx-progressbar/issues/28), [#33](https://github.com/MurhafSousli/ngx-progressbar/issues/33), [#41](https://github.com/MurhafSousli/ngx-progressbar/issues/41), [#81](https://github.com/MurhafSousli/ngx-progressbar/issues/81), [#82](https://github.com/MurhafSousli/ngx-progressbar/issues/82) in [#86](https://github.com/MurhafSousli/ngx-progressbar/issues/86) - + - Add `NgProgressState` interface for Progress state - **Breaking Changes**: `NgProgressService` has been renamed to `NgProgress` +## 2.1.0 + + **Broken Release** + ## 2.0.8 - fix: remove unused code in [#68](https://github.com/MurhafSousli/ngx-progressbar/issues/68) diff --git a/package.json b/package.json index ea2e287..5ac2dd7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-progressbar", - "version": "2.1.0", + "version": "2.1.1", "description": "A nanoscopic progress bar. Featuring realistic trickle animations to convince your users that something is happening!", "main": "./bundles/ngx-progressbar.umd.js", "module": "./modules/ngx-progressbar.es5.js", diff --git a/rollup.config.js b/rollup.config.js index 9543d62..6114bd6 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -7,6 +7,7 @@ const globals = { '@angular/http': 'ng.http', 'rxjs/Observable': 'Rx', 'rxjs/Subject': 'Rx', + 'rxjs/BehaviorSubject': 'Rx', 'rxjs/add/observable/timer': 'Rx.Observable', 'rxjs/add/operator/do': 'Rx.Observable.prototype', 'rxjs/add/operator/takeWhile': 'Rx.Observable.prototype', diff --git a/src/components/progress-bar.component.ts b/src/components/progress-bar.component.ts index 21df9cb..f871547 100644 --- a/src/components/progress-bar.component.ts +++ b/src/components/progress-bar.component.ts @@ -1,4 +1,5 @@ import { Component, Input, ChangeDetectionStrategy } from '@angular/core'; +import { NgProgressState } from '../models/progress.state'; @Component({ selector: 'ng-progress-bar', @@ -126,14 +127,14 @@ import { Component, Input, ChangeDetectionStrategy } from '@angular/core'; }) export class ProgressBarComponent { - @Input() state; - @Input() positionUsing; - @Input() ease; - @Input() speed; - @Input() showSpinner; - @Input() direction; - @Input() thick; - @Input() color; + @Input() state: NgProgressState; + @Input() positionUsing: string; + @Input() ease: string; + @Input() speed: number; + @Input() showSpinner: boolean; + @Input() direction: string; + @Input() thick: string; + @Input() color: string; /** Styles for progressbar */ barStyles() { diff --git a/src/components/progress.component.ts b/src/components/progress.component.ts index a15865f..7846541 100644 --- a/src/components/progress.component.ts +++ b/src/components/progress.component.ts @@ -14,7 +14,7 @@ import { NgProgress } from '../services/progress.service'; [direction]="direction" [color]="color" [thick]="thick" - [state]="progress.state | async" + [state]="ngProgress.state | async" >`, styles: [` :host { @@ -94,5 +94,4 @@ export class ProgressComponent implements OnChanges { } } } - } diff --git a/src/models/progress.state.ts b/src/models/progress.state.ts new file mode 100644 index 0000000..9027fcb --- /dev/null +++ b/src/models/progress.state.ts @@ -0,0 +1,4 @@ +export interface NgProgressState { + active: boolean; + value: number; +} diff --git a/src/progressbar.ts b/src/progressbar.ts index 0dfac75..2d09712 100644 --- a/src/progressbar.ts +++ b/src/progressbar.ts @@ -2,3 +2,4 @@ export { NgProgress } from './services/progress.service'; export { NgProgressBrowserXhr } from './services/browser-xhr.provider'; export { NgProgressInterceptor } from './services/interceptor.provider'; export { NgProgressModule } from './modules/progress.module'; +export { NgProgressState } from './models/progress.state'; diff --git a/src/services/progress.service.ts b/src/services/progress.service.ts index a43c64e..e8fecc6 100644 --- a/src/services/progress.service.ts +++ b/src/services/progress.service.ts @@ -1,5 +1,7 @@ import { Injectable } from '@angular/core'; import { Subject } from 'rxjs/Subject'; +import { NgProgressState } from '../models/progress.state'; +import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { Observable } from 'rxjs/Observable'; import 'rxjs/add/observable/timer'; @@ -21,8 +23,14 @@ const clamp = (n, min, max) => { @Injectable() export class NgProgress { + /** Initial state */ + initState: NgProgressState = { + active: false, + value: 0 + }; + /** Progress state */ - state = new Subject(); + state = new BehaviorSubject(this.initState); /** Trickling stream */ trickling = new Subject(); diff --git a/tslint.json b/tslint.json index 97c2fe3..1ac01d5 100644 --- a/tslint.json +++ b/tslint.json @@ -13,6 +13,7 @@ "no-forward-ref": true, "use-life-cycle-interface": true, "use-pipe-transform-interface": true, + "interface-name": false, "component-class-suffix": [ true, "Component"