├── .editorconfig
├── .gitignore
├── .npmignore
├── .vscode
└── settings.json
├── README.md
├── angular.json
├── assets
├── angular-progress-bar-50.PNG
└── angular-progress-bar.png
├── e2e
├── protractor.conf.js
├── src
│ ├── app.e2e-spec.ts
│ └── app.po.ts
└── tsconfig.e2e.json
├── package.json
├── projects
└── angular-progress-bar
│ ├── LICENSE
│ ├── karma.conf.js
│ ├── ng-package.json
│ ├── ng-package.prod.json
│ ├── package.json
│ ├── src
│ ├── lib
│ │ ├── angular-progress-bar.component.spec.ts
│ │ ├── angular-progress-bar.component.ts
│ │ └── angular-progress-bar.module.ts
│ ├── public_api.ts
│ └── test.ts
│ ├── tsconfig.lib.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── src
├── app
│ ├── app.component.css
│ ├── app.component.html
│ ├── app.component.spec.ts
│ ├── app.component.ts
│ └── app.module.ts
├── assets
│ └── .gitkeep
├── browserslist
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.html
├── main.ts
├── polyfills.ts
├── styles.css
├── test.ts
├── tsconfig.app.json
├── tsconfig.spec.json
└── tslint.json
├── tsconfig.json
└── tslint.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | node_modules/
3 | package-lock.json
4 | src/**/*.js
5 | src/**/*.d.ts
6 | src/**/*.js.map
7 | src/*.module.js
8 | src/*.module.js.map
9 | src/**/*.metadata.json
10 | bundles
11 | src/index.ngsummary.json
12 | src/progress-bar.module.ngfactory.ts
13 | src/progress-bar.module.ngsummary.json
14 | src/progress-bar/progress-bar.ngfactory.ts
15 | src/progress-bar/progress-bar.ngsummary.json
16 | bundles/
17 | dist/
18 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | ./assets/*
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "markdown.extension.toc.updateOnSave": true,
3 | "markdown.extension.toc.githubCompatibility": true,
4 | "markdown.extension.preview.autoShowPreviewToSide": true,
5 | "spellright.language": [
6 | "en"
7 | ],
8 | "spellright.documentTypes": [
9 | "markdown",
10 | "latex",
11 | "plaintext"
12 | ]
13 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
Angular Progress Bar
3 |
4 |
5 |
6 |
7 |
8 |
9 | ## Toc
10 | - [Toc](#toc)
11 | - [Introduction](#introduction)
12 | - [Online demo](#online-demo)
13 | - [Appearance](#appearance)
14 | - [Basic](#basic)
15 | - [Grey](#grey)
16 | - [Installation](#installation)
17 | - [How to use](#how-to-use)
18 | - [Classic way](#classic-way)
19 | - [Color degraded way](#color-degraded-way)
20 | - [Disable display of percentage](#disable-display-of-percentage)
21 |
22 | ## Introduction ##
23 |
24 | Angular progress bar is a component available from Angular 2, 4, 5, 6, 7, 8, 9 and Ionic 2, 3, 4, and 5.
25 |
26 | This component allow you to manage a progress visually
27 |
28 | ## Online demo ##
29 |
30 | You can find a demo at https://angular-progress-bar-demo.stackblitz.io
31 | ## Appearance ##
32 |
33 | ### Basic ###
34 |
35 |
36 | ### Grey ###
37 |
38 |
39 | ## Installation ##
40 |
41 | Type the following command to install the package:
42 |
43 | ```shell
44 | npm install angular-progress-bar@latest --save
45 | ```
46 |
47 | Then you need to import it into your app modules
48 |
49 | ```typescript
50 | import {ProgressBarModule} from "angular-progress-bar"
51 |
52 | @NgModule({
53 | imports: [
54 | ProgressBarModule
55 | ]
56 | })
57 | ```
58 |
59 |
60 | ## How to use ##
61 |
62 | ### Classic way ###
63 |
64 | By this way, progress property will be the value shown in the progress bar, and color property will be the color displayed
65 |
66 | ```html
67 |
68 |
69 | ```
70 |
71 | ### Color degraded way ###
72 |
73 | By this way, progress property will be the value shown in the progress bar, but color-degraded property must be binded ton an object.
74 |
75 | This object, must contains a key value made be a string that represent a percent, and the value must be an hexadecimal color
76 |
77 | in the example show below, from 0 to 15 percent the color will be #00cbcb then from 16 to 25 percent the color will be #f9c3d3 and then from 25 to the end the color will be #fd8c8e
78 |
79 | ```html
80 |
81 |
82 | ```
83 |
84 | ### Disable display of percentage ###
85 |
86 | You can disable display of percentage by using disable-percentage property
87 |
88 | ```html
89 |
90 |
91 | ```
92 |
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "angular-workspace": {
7 | "root": "",
8 | "sourceRoot": "src",
9 | "projectType": "application",
10 | "prefix": "app",
11 | "schematics": {},
12 | "architect": {
13 | "build": {
14 | "builder": "@angular-devkit/build-angular:browser",
15 | "options": {
16 | "outputPath": "dist/angular-workspace",
17 | "index": "src/index.html",
18 | "main": "src/main.ts",
19 | "polyfills": "src/polyfills.ts",
20 | "tsConfig": "src/tsconfig.app.json",
21 | "assets": [
22 | "src/favicon.ico",
23 | "src/assets"
24 | ],
25 | "styles": [
26 | "src/styles.css"
27 | ],
28 | "scripts": []
29 | },
30 | "configurations": {
31 | "production": {
32 | "fileReplacements": [
33 | {
34 | "replace": "src/environments/environment.ts",
35 | "with": "src/environments/environment.prod.ts"
36 | }
37 | ],
38 | "optimization": true,
39 | "outputHashing": "all",
40 | "sourceMap": false,
41 | "extractCss": true,
42 | "namedChunks": false,
43 | "aot": true,
44 | "extractLicenses": true,
45 | "vendorChunk": false,
46 | "buildOptimizer": true
47 | }
48 | }
49 | },
50 | "serve": {
51 | "builder": "@angular-devkit/build-angular:dev-server",
52 | "options": {
53 | "browserTarget": "angular-workspace:build"
54 | },
55 | "configurations": {
56 | "production": {
57 | "browserTarget": "angular-workspace:build:production"
58 | }
59 | }
60 | },
61 | "extract-i18n": {
62 | "builder": "@angular-devkit/build-angular:extract-i18n",
63 | "options": {
64 | "browserTarget": "angular-workspace:build"
65 | }
66 | },
67 | "test": {
68 | "builder": "@angular-devkit/build-angular:karma",
69 | "options": {
70 | "main": "src/test.ts",
71 | "polyfills": "src/polyfills.ts",
72 | "tsConfig": "src/tsconfig.spec.json",
73 | "karmaConfig": "src/karma.conf.js",
74 | "styles": [
75 | "src/styles.css"
76 | ],
77 | "scripts": [],
78 | "assets": [
79 | "src/favicon.ico",
80 | "src/assets"
81 | ]
82 | }
83 | },
84 | "lint": {
85 | "builder": "@angular-devkit/build-angular:tslint",
86 | "options": {
87 | "tsConfig": [
88 | "src/tsconfig.app.json",
89 | "src/tsconfig.spec.json"
90 | ],
91 | "exclude": [
92 | "**/node_modules/**"
93 | ]
94 | }
95 | }
96 | }
97 | },
98 | "angular-workspace-e2e": {
99 | "root": "e2e/",
100 | "projectType": "application",
101 | "architect": {
102 | "e2e": {
103 | "builder": "@angular-devkit/build-angular:protractor",
104 | "options": {
105 | "protractorConfig": "e2e/protractor.conf.js",
106 | "devServerTarget": "angular-workspace:serve"
107 | },
108 | "configurations": {
109 | "production": {
110 | "devServerTarget": "angular-workspace:serve:production"
111 | }
112 | }
113 | },
114 | "lint": {
115 | "builder": "@angular-devkit/build-angular:tslint",
116 | "options": {
117 | "tsConfig": "e2e/tsconfig.e2e.json",
118 | "exclude": [
119 | "**/node_modules/**"
120 | ]
121 | }
122 | }
123 | }
124 | },
125 | "angular-progress-bar": {
126 | "root": "projects/angular-progress-bar",
127 | "sourceRoot": "projects/angular-progress-bar/src",
128 | "projectType": "library",
129 | "prefix": "lib",
130 | "architect": {
131 | "build": {
132 | "builder": "@angular-devkit/build-ng-packagr:build",
133 | "options": {
134 | "tsConfig": "projects/angular-progress-bar/tsconfig.lib.json",
135 | "project": "projects/angular-progress-bar/ng-package.json"
136 | },
137 | "configurations": {
138 | "production": {
139 | "project": "projects/angular-progress-bar/ng-package.prod.json"
140 | }
141 | }
142 | },
143 | "test": {
144 | "builder": "@angular-devkit/build-angular:karma",
145 | "options": {
146 | "main": "projects/angular-progress-bar/src/test.ts",
147 | "tsConfig": "projects/angular-progress-bar/tsconfig.spec.json",
148 | "karmaConfig": "projects/angular-progress-bar/karma.conf.js"
149 | }
150 | },
151 | "lint": {
152 | "builder": "@angular-devkit/build-angular:tslint",
153 | "options": {
154 | "tsConfig": [
155 | "projects/angular-progress-bar/tsconfig.lib.json",
156 | "projects/angular-progress-bar/tsconfig.spec.json"
157 | ],
158 | "exclude": [
159 | "**/node_modules/**"
160 | ]
161 | }
162 | }
163 | }
164 | }
165 | },
166 | "defaultProject": "angular-workspace"
167 | }
--------------------------------------------------------------------------------
/assets/angular-progress-bar-50.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlesGrimont/angular-progress-bar/fa75cb8892b17cb06bbd09b0c6baf7da561f90a7/assets/angular-progress-bar-50.PNG
--------------------------------------------------------------------------------
/assets/angular-progress-bar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlesGrimont/angular-progress-bar/fa75cb8892b17cb06bbd09b0c6baf7da561f90a7/assets/angular-progress-bar.png
--------------------------------------------------------------------------------
/e2e/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './src/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | onPrepare() {
23 | require('ts-node').register({
24 | project: require('path').join(__dirname, './tsconfig.e2e.json')
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
--------------------------------------------------------------------------------
/e2e/src/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 |
3 | describe('workspace-project App', () => {
4 | let page: AppPage;
5 |
6 | beforeEach(() => {
7 | page = new AppPage();
8 | });
9 |
10 | it('should display welcome message', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('Welcome to angular-workspace!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/e2e/src/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class AppPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "jasminewd2",
10 | "node"
11 | ]
12 | }
13 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-workspace",
3 | "version": "0.1.0",
4 | "scripts": {
5 | "ng": "ng",
6 | "start": "ng serve",
7 | "build": "ng build",
8 | "test": "ng test",
9 | "lint": "ng lint",
10 | "e2e": "ng e2e"
11 | },
12 | "keywords": [
13 | "angular",
14 | "angular2",
15 | "angular 2",
16 | "angular4",
17 | "angular5",
18 | "angular 5",
19 | "Ionic",
20 | "Ionic 2",
21 | "Ionic2",
22 | "Ionic 3",
23 | "Ionic3",
24 | "progress bar",
25 | "angular progress bar",
26 | "ionic progress bar"
27 | ],
28 | "private": true,
29 | "dependencies": {
30 | "@angular/animations": "^7.1.0",
31 | "@angular/common": "^7.1.0",
32 | "@angular/compiler": "^7.1.0",
33 | "@angular/core": "^7.1.0",
34 | "@angular/forms": "^7.1.0",
35 | "@angular/http": "^7.1.0",
36 | "@angular/platform-browser": "^7.1.0",
37 | "@angular/platform-browser-dynamic": "^7.1.0",
38 | "@angular/platform-server": "^7.1.0",
39 | "@angular/router": "^7.1.0",
40 | "core-js": "^2.5.7",
41 | "rxjs": "^6.3.3",
42 | "rxjs-compat": "^6.3.3",
43 | "zone.js": "^0.8.26"
44 | },
45 | "devDependencies": {
46 | "@angular-devkit/build-angular": "^0.11.0",
47 | "@angular-devkit/build-ng-packagr": "~0.7.0",
48 | "@angular/cli": "^7.1.0",
49 | "@angular/compiler-cli": "^7.1.0",
50 | "@angular/language-service": "^7.1.0",
51 | "@types/jasmine": "^3.3.0",
52 | "@types/jasminewd2": "~2.0.3",
53 | "@types/node": "^10.12.10",
54 | "codelyzer": "^4.5.0",
55 | "jasmine-core": "^3.3.0",
56 | "jasmine-spec-reporter": "^4.2.1",
57 | "karma": "^3.1.1",
58 | "karma-chrome-launcher": "^2.2.0",
59 | "karma-cli": "^1.0.1",
60 | "karma-coverage-istanbul-reporter": "~2.0.0",
61 | "karma-jasmine": "^2.0.1",
62 | "karma-jasmine-html-reporter": "^1.4.0",
63 | "ng-packagr": "^4.4.0",
64 | "protractor": "^5.4.1",
65 | "rxjs-tslint": "^0.1.6",
66 | "ts-node": "~5.0.1",
67 | "tsickle": ">=0.29.0",
68 | "tslib": "^1.9.0",
69 | "tslint": "^5.11.0",
70 | "typescript": "^3.1.6",
71 | "webpack": "^4.26.1"
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/projects/angular-progress-bar/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Charles GRIMONT
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/projects/angular-progress-bar/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/1.0/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular-devkit/build-angular'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular-devkit/build-angular/plugins/karma')
14 | ],
15 | client: {
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | coverageIstanbulReporter: {
19 | dir: require('path').join(__dirname, '../../coverage'),
20 | reports: ['html', 'lcovonly'],
21 | fixWebpackSourcePaths: true
22 | },
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false
30 | });
31 | };
32 |
--------------------------------------------------------------------------------
/projects/angular-progress-bar/ng-package.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3 | "dest": "../../dist/angular-progress-bar",
4 | "deleteDestPath": false,
5 | "lib": {
6 | "entryFile": "src/public_api.ts"
7 | }
8 | }
--------------------------------------------------------------------------------
/projects/angular-progress-bar/ng-package.prod.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3 | "dest": "../../dist/angular-progress-bar",
4 | "lib": {
5 | "entryFile": "src/public_api.ts"
6 | }
7 | }
--------------------------------------------------------------------------------
/projects/angular-progress-bar/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular-progress-bar",
3 | "version": "1.0.11",
4 | "description": "An angular progress-bar",
5 | "author": "Charles GRIMONT",
6 | "license": "MIT",
7 | "homepage": "https://github.com/CharlesGrimont/angular-progress-bar#readme",
8 | "keywords": [
9 | "angular",
10 | "angular2",
11 | "angular 2",
12 | "angular4",
13 | "angular5",
14 | "angular 5",
15 | "Ionic",
16 | "Ionic 2",
17 | "Ionic2",
18 | "Ionic 3",
19 | "Ionic3",
20 | "progress bar",
21 | "angular progress bar",
22 | "ionic progress bar"
23 | ],
24 | "peerDependencies": {
25 | "@angular/common": "^6.0.0-rc.0 || ^6.0.0 || ^7.1.0",
26 | "@angular/core": "^6.0.0-rc.0 || ^6.0.0 || ^7.1.0"
27 | }
28 | }
--------------------------------------------------------------------------------
/projects/angular-progress-bar/src/lib/angular-progress-bar.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { ProgressBarComponent } from './angular-progress-bar.component';
4 |
5 | describe('AngularProgressBarComponent', () => {
6 | let component: ProgressBarComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ ProgressBarComponent ]
12 |
13 | })
14 | .compileComponents();
15 | }));
16 |
17 | beforeEach(() => {
18 | fixture = TestBed.createComponent(ProgressBarComponent);
19 | component = fixture.componentInstance;
20 | component.progress = "0";
21 | fixture.detectChanges();
22 | });
23 |
24 | it('should create', () => {
25 | expect(component).toBeTruthy();
26 | });
27 |
28 | it('should have a default color', () => {
29 | expect(component.color).toBe("#488aff");
30 | });
31 |
32 | it('should have a progress', () => {
33 | expect(component.progress).toBe("0");
34 | });
35 |
36 | it('should have a degraded color', () => {
37 | component.degraded = {'0': '#00cbcb', '15': '#f9c3d3', '25': '#fd8c8e'};
38 | fixture.detectChanges();
39 | for(var val = 0; val <16; val++){
40 | expect(component.whichColor(val +"")).toBe('#00cbcb');
41 | }
42 | for(var val = 16; val <26; val++){
43 | expect(component.whichColor(val +"")).toBe('#f9c3d3');
44 | }
45 | for(var val = 26; val <101; val++){
46 | expect(component.whichColor(val +"")).toBe('#fd8c8e');
47 | }
48 | });
49 | });
50 |
--------------------------------------------------------------------------------
/projects/angular-progress-bar/src/lib/angular-progress-bar.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, Input } from '@angular/core';
2 |
3 | @Component({
4 | selector:
5 | 'progress-bar',
6 | styles: [`
7 | .progress-outer {
8 | width: 96%;
9 | margin: 10px 2%;
10 | padding: 3px;
11 | background-color: #f4f4f4;
12 | border: 1px solid #dcdcdc;
13 | color: #fff;
14 | border-radius: 20px;
15 | text-align: center;
16 | }
17 | .progress-inner {
18 | min-width: 15%;
19 | min-height:18px;
20 | white-space: nowrap;
21 | overflow: hidden;
22 | padding: 0px;
23 | border-radius: 20px;
24 | `],
25 | template:
26 | `
27 |
28 |
29 |
30 | {{whichProgress(progress)}}%
31 |
32 |
33 | {{whichProgress(progress)}}
34 |
35 |
36 |
37 | `
38 | })
39 | export class ProgressBarComponent {
40 |
41 | /** Inputs **/
42 | @Input('progress') progress: string;
43 | @Input('color') color: string;
44 | @Input('color-degraded') degraded: any;
45 | @Input('disable-percentage') disabledP: boolean;
46 |
47 |
48 | constructor() {
49 | // Default color
50 | this.color = "#488aff";
51 | this.disabledP = false;
52 | }
53 |
54 | /**
55 | * Returns a color for a certain percent
56 | * @param percent The current progress
57 | */
58 | whichColor(percent: string){
59 | // Get all entries index as an array
60 | let k: Array = Object.keys(this.degraded);
61 | // Convert string to number
62 | k.forEach((e, i) => k[i] = +e);
63 | // Sort them by value
64 | k = k.sort((a, b) => a - b);
65 | // Percent as number
66 | let p = +percent
67 | // Set last by default as the first occurrence
68 | let last = k[0];
69 | // Foreach keys
70 | for(let val of k){
71 | // if current val is < than percent
72 | if(val < p){
73 | last = val;
74 | }
75 | // if val >= percent then the val that we could show has been reached
76 | else if(val >= p -1){
77 | return this.degraded[last];
78 | }
79 | }
80 | // if its the last one return the last
81 | return this.degraded[last];
82 | }
83 |
84 | whichProgress(progress: string){
85 | try{
86 | return Math.round(+progress * 100) / 100;
87 | }
88 | catch{
89 | return progress;
90 | }
91 | }
92 | }
--------------------------------------------------------------------------------
/projects/angular-progress-bar/src/lib/angular-progress-bar.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { ProgressBarComponent } from './angular-progress-bar.component';
3 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
4 | import { CommonModule } from "@angular/common";
5 |
6 | @NgModule({
7 | imports: [
8 | CommonModule
9 | ],
10 | declarations: [ProgressBarComponent],
11 | exports: [ProgressBarComponent],
12 | schemas: [CUSTOM_ELEMENTS_SCHEMA]
13 | })
14 | export class ProgressBarModule { }
--------------------------------------------------------------------------------
/projects/angular-progress-bar/src/public_api.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Public API Surface of angular-progress-bar
3 | */
4 |
5 | export * from './lib/angular-progress-bar.component';
6 | export * from './lib/angular-progress-bar.module';
7 |
--------------------------------------------------------------------------------
/projects/angular-progress-bar/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'core-js/es7/reflect';
4 | import 'zone.js/dist/zone';
5 | import 'zone.js/dist/zone-testing';
6 | import { getTestBed } from '@angular/core/testing';
7 | import {
8 | BrowserDynamicTestingModule,
9 | platformBrowserDynamicTesting
10 | } from '@angular/platform-browser-dynamic/testing';
11 |
12 | declare const require: any;
13 |
14 | // First, initialize the Angular testing environment.
15 | getTestBed().initTestEnvironment(
16 | BrowserDynamicTestingModule,
17 | platformBrowserDynamicTesting()
18 | );
19 | // Then we find all the tests.
20 | const context = require.context('./', true, /\.spec\.ts$/);
21 | // And load the modules.
22 | context.keys().map(context);
23 |
--------------------------------------------------------------------------------
/projects/angular-progress-bar/tsconfig.lib.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../out-tsc/lib",
5 | "target": "es2015",
6 | "module": "es2015",
7 | "moduleResolution": "node",
8 | "declaration": true,
9 | "sourceMap": true,
10 | "inlineSources": true,
11 | "emitDecoratorMetadata": true,
12 | "experimentalDecorators": true,
13 | "importHelpers": true,
14 | "types": [],
15 | "lib": [
16 | "dom",
17 | "es2015"
18 | ]
19 | },
20 | "angularCompilerOptions": {
21 | "annotateForClosureCompiler": true,
22 | "skipTemplateCodegen": true,
23 | "strictMetadataEmit": true,
24 | "fullTemplateTypeCheck": true,
25 | "strictInjectionParameters": true,
26 | "flatModuleId": "AUTOGENERATED",
27 | "flatModuleOutFile": "AUTOGENERATED"
28 | },
29 | "exclude": [
30 | "src/test.ts",
31 | "**/*.spec.ts"
32 | ]
33 | }
34 |
--------------------------------------------------------------------------------
/projects/angular-progress-bar/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../out-tsc/spec",
5 | "types": [
6 | "jasmine",
7 | "node"
8 | ]
9 | },
10 | "files": [
11 | "src/test.ts"
12 | ],
13 | "include": [
14 | "**/*.spec.ts",
15 | "**/*.d.ts"
16 | ]
17 | }
18 |
--------------------------------------------------------------------------------
/projects/angular-progress-bar/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "lib",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "lib",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlesGrimont/angular-progress-bar/fa75cb8892b17cb06bbd09b0c6baf7da561f90a7/src/app/app.component.css
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Welcome to {{ title }}!
5 |
6 |

7 |
8 | Here are some links to help you start:
9 |
10 | -
11 |
12 |
13 | -
14 |
15 |
16 | -
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { AppComponent } from './app.component';
3 | describe('AppComponent', () => {
4 | beforeEach(async(() => {
5 | TestBed.configureTestingModule({
6 | declarations: [
7 | AppComponent
8 | ],
9 | }).compileComponents();
10 | }));
11 | it('should create the app', async(() => {
12 | const fixture = TestBed.createComponent(AppComponent);
13 | const app = fixture.debugElement.componentInstance;
14 | expect(app).toBeTruthy();
15 | }));
16 | it(`should have as title 'angular-workspace'`, async(() => {
17 | const fixture = TestBed.createComponent(AppComponent);
18 | const app = fixture.debugElement.componentInstance;
19 | expect(app.title).toEqual('angular-workspace');
20 | }));
21 | it('should render title in a h1 tag', async(() => {
22 | const fixture = TestBed.createComponent(AppComponent);
23 | fixture.detectChanges();
24 | const compiled = fixture.debugElement.nativeElement;
25 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to angular-workspace!');
26 | }));
27 | });
28 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.css']
7 | })
8 | export class AppComponent {
9 | title = 'angular-workspace';
10 | }
11 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 |
4 | import { AppComponent } from './app.component';
5 |
6 | import {ProgressBarModule} from "angular-progress-bar"
7 |
8 | @NgModule({
9 | declarations: [
10 | AppComponent
11 | ],
12 | imports: [
13 | BrowserModule,
14 | ProgressBarModule
15 | ],
16 | providers: [],
17 | bootstrap: [AppComponent]
18 | })
19 | export class AppModule { }
20 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlesGrimont/angular-progress-bar/fa75cb8892b17cb06bbd09b0c6baf7da561f90a7/src/assets/.gitkeep
--------------------------------------------------------------------------------
/src/browserslist:
--------------------------------------------------------------------------------
1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
2 | # For additional information regarding the format and rule options, please see:
3 | # https://github.com/browserslist/browserslist#queries
4 | # For IE 9-11 support, please uncomment the last line of the file and adjust as needed
5 | > 0.5%
6 | last 2 versions
7 | Firefox ESR
8 | not dead
9 | # IE 9-11
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build ---prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false
7 | };
8 |
9 | /*
10 | * In development mode, to ignore zone related error stack frames such as
11 | * `zone.run`, `zoneDelegate.invokeTask` for easier debugging, you can
12 | * import the following file, but please comment it out in production mode
13 | * because it will have performance impact when throw error
14 | */
15 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
16 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CharlesGrimont/angular-progress-bar/fa75cb8892b17cb06bbd09b0c6baf7da561f90a7/src/favicon.ico
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | AngularWorkspace
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule)
12 | .catch(err => console.log(err));
13 |
--------------------------------------------------------------------------------
/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/
22 | // import 'core-js/es6/symbol';
23 | // import 'core-js/es6/object';
24 | // import 'core-js/es6/function';
25 | // import 'core-js/es6/parse-int';
26 | // import 'core-js/es6/parse-float';
27 | // import 'core-js/es6/number';
28 | // import 'core-js/es6/math';
29 | // import 'core-js/es6/string';
30 | // import 'core-js/es6/date';
31 | // import 'core-js/es6/array';
32 | // import 'core-js/es6/regexp';
33 | // import 'core-js/es6/map';
34 | // import 'core-js/es6/weak-map';
35 | // import 'core-js/es6/set';
36 |
37 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
38 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
39 |
40 | /** IE10 and IE11 requires the following for the Reflect API. */
41 | // import 'core-js/es6/reflect';
42 |
43 |
44 | /** Evergreen browsers require these. **/
45 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
46 | import 'core-js/es7/reflect';
47 |
48 |
49 | /**
50 | * Web Animations `@angular/platform-browser/animations`
51 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
52 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
53 | **/
54 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
55 |
56 | /**
57 | * By default, zone.js will patch all possible macroTask and DomEvents
58 | * user can disable parts of macroTask/DomEvents patch by setting following flags
59 | */
60 |
61 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
62 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
63 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
64 |
65 | /*
66 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
67 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
68 | */
69 | // (window as any).__Zone_enable_cross_context_check = true;
70 |
71 | /***************************************************************************************************
72 | * Zone JS is required by default for Angular itself.
73 | */
74 | import 'zone.js/dist/zone'; // Included with Angular CLI.
75 |
76 |
77 |
78 | /***************************************************************************************************
79 | * APPLICATION IMPORTS
80 | */
81 |
--------------------------------------------------------------------------------
/src/styles.css:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/src/test.ts:
--------------------------------------------------------------------------------
1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2 |
3 | import 'zone.js/dist/zone-testing';
4 | import { getTestBed } from '@angular/core/testing';
5 | import {
6 | BrowserDynamicTestingModule,
7 | platformBrowserDynamicTesting
8 | } from '@angular/platform-browser-dynamic/testing';
9 |
10 | declare const require: any;
11 |
12 | // First, initialize the Angular testing environment.
13 | getTestBed().initTestEnvironment(
14 | BrowserDynamicTestingModule,
15 | platformBrowserDynamicTesting()
16 | );
17 | // Then we find all the tests.
18 | const context = require.context('./', true, /\.spec\.ts$/);
19 | // And load the modules.
20 | context.keys().map(context);
21 |
--------------------------------------------------------------------------------
/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "types": []
6 | },
7 | "exclude": [
8 | "src/test.ts",
9 | "**/*.spec.ts"
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "types": [
6 | "jasmine",
7 | "node"
8 | ]
9 | },
10 | "files": [
11 | "test.ts",
12 | "polyfills.ts"
13 | ],
14 | "include": [
15 | "**/*.spec.ts",
16 | "**/*.d.ts"
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/src/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "app",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "app",
14 | "kebab-case"
15 | ]
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "baseUrl": "./",
5 | "outDir": "./dist/out-tsc",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "module": "es2015",
9 | "moduleResolution": "node",
10 | "emitDecoratorMetadata": true,
11 | "experimentalDecorators": true,
12 | "target": "es5",
13 | "typeRoots": [
14 | "node_modules/@types"
15 | ],
16 | "lib": [
17 | "es2017",
18 | "dom"
19 | ],
20 | "paths": {
21 | "angular-progress-bar": [
22 | "dist/angular-progress-bar"
23 | ],
24 | "angular-progress-bar/*": [
25 | "dist/angular-progress-bar/*"
26 | ]
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "arrow-return-shorthand": true,
7 | "callable-types": true,
8 | "class-name": true,
9 | "comment-format": [
10 | true,
11 | "check-space"
12 | ],
13 | "curly": true,
14 | "deprecation": {
15 | "severity": "warn"
16 | },
17 | "eofline": true,
18 | "forin": true,
19 | "import-blacklist": [
20 | true,
21 | "rxjs/Rx"
22 | ],
23 | "import-spacing": true,
24 | "indent": [
25 | true,
26 | "spaces"
27 | ],
28 | "interface-over-type-literal": true,
29 | "label-position": true,
30 | "max-line-length": [
31 | true,
32 | 140
33 | ],
34 | "member-access": false,
35 | "member-ordering": [
36 | true,
37 | {
38 | "order": [
39 | "static-field",
40 | "instance-field",
41 | "static-method",
42 | "instance-method"
43 | ]
44 | }
45 | ],
46 | "no-arg": true,
47 | "no-bitwise": true,
48 | "no-console": [
49 | true,
50 | "debug",
51 | "info",
52 | "time",
53 | "timeEnd",
54 | "trace"
55 | ],
56 | "no-construct": true,
57 | "no-debugger": true,
58 | "no-duplicate-super": true,
59 | "no-empty": false,
60 | "no-empty-interface": true,
61 | "no-eval": true,
62 | "no-inferrable-types": [
63 | true,
64 | "ignore-params"
65 | ],
66 | "no-misused-new": true,
67 | "no-non-null-assertion": true,
68 | "no-shadowed-variable": true,
69 | "no-string-literal": false,
70 | "no-string-throw": true,
71 | "no-switch-case-fall-through": true,
72 | "no-trailing-whitespace": true,
73 | "no-unnecessary-initializer": true,
74 | "no-unused-expression": true,
75 | "no-use-before-declare": true,
76 | "no-var-keyword": true,
77 | "object-literal-sort-keys": false,
78 | "one-line": [
79 | true,
80 | "check-open-brace",
81 | "check-catch",
82 | "check-else",
83 | "check-whitespace"
84 | ],
85 | "prefer-const": true,
86 | "quotemark": [
87 | true,
88 | "single"
89 | ],
90 | "radix": true,
91 | "semicolon": [
92 | true,
93 | "always"
94 | ],
95 | "triple-equals": [
96 | true,
97 | "allow-null-check"
98 | ],
99 | "typedef-whitespace": [
100 | true,
101 | {
102 | "call-signature": "nospace",
103 | "index-signature": "nospace",
104 | "parameter": "nospace",
105 | "property-declaration": "nospace",
106 | "variable-declaration": "nospace"
107 | }
108 | ],
109 | "unified-signatures": true,
110 | "variable-name": false,
111 | "whitespace": [
112 | true,
113 | "check-branch",
114 | "check-decl",
115 | "check-operator",
116 | "check-separator",
117 | "check-type"
118 | ],
119 | "no-output-on-prefix": true,
120 | "use-input-property-decorator": true,
121 | "use-output-property-decorator": true,
122 | "use-host-property-decorator": true,
123 | "no-input-rename": true,
124 | "no-output-rename": true,
125 | "use-life-cycle-interface": true,
126 | "use-pipe-transform-interface": true,
127 | "component-class-suffix": true,
128 | "directive-class-suffix": true
129 | }
130 | }
131 |
--------------------------------------------------------------------------------