├── .editorconfig
├── .gitignore
├── LICENSE
├── README.md
├── angular.json
├── e2e
├── protractor.conf.js
├── src
│ ├── app.e2e-spec.ts
│ └── app.po.ts
└── tsconfig.e2e.json
├── package.json
├── server
└── index.js
├── src
├── app
│ ├── add-todo
│ │ ├── add-todo.component.css
│ │ ├── add-todo.component.html
│ │ ├── add-todo.component.spec.ts
│ │ └── add-todo.component.ts
│ ├── app.component.css
│ ├── app.component.html
│ ├── app.component.scss
│ ├── app.component.spec.ts
│ ├── app.component.ts
│ ├── app.module.ts
│ ├── app.routes.ts
│ ├── core
│ │ ├── core.module.ts
│ │ ├── spinner-overlay
│ │ │ ├── spinner-overlay.component.html
│ │ │ ├── spinner-overlay.component.scss
│ │ │ ├── spinner-overlay.component.spec.ts
│ │ │ ├── spinner-overlay.component.ts
│ │ │ ├── spinner-overlay.module.ts
│ │ │ ├── spinner-overlay.service.spec.ts
│ │ │ └── spinner-overlay.service.ts
│ │ └── todo-list
│ │ │ ├── todo-list.service.spec.ts
│ │ │ └── todo-list.service.ts
│ ├── footer
│ │ ├── footer.component.css
│ │ ├── footer.component.html
│ │ ├── footer.component.spec.ts
│ │ └── footer.component.ts
│ ├── navbar
│ │ ├── navbar.component.css
│ │ ├── navbar.component.html
│ │ ├── navbar.component.spec.ts
│ │ └── navbar.component.ts
│ ├── shared
│ │ ├── invalid-date.directive.ts
│ │ ├── models
│ │ │ ├── guid.ts
│ │ │ └── todo-item.ts
│ │ ├── shared.module.ts
│ │ ├── spinner-overlay-wrapper
│ │ │ ├── spinner-overlay-wrapper.component.html
│ │ │ ├── spinner-overlay-wrapper.component.scss
│ │ │ ├── spinner-overlay-wrapper.component.spec.ts
│ │ │ ├── spinner-overlay-wrapper.component.ts
│ │ │ └── spinner-overlay-wrapper.module.ts
│ │ └── spinner
│ │ │ ├── spinner.component.html
│ │ │ ├── spinner.component.scss
│ │ │ ├── spinner.component.spec.ts
│ │ │ ├── spinner.component.ts
│ │ │ └── spinner.module.ts
│ ├── todo-item
│ │ ├── todo-item.component.css
│ │ ├── todo-item.component.html
│ │ ├── todo-item.component.spec.ts
│ │ └── todo-item.component.ts
│ ├── todo-list-completed
│ │ ├── todo-list-completed.component.css
│ │ ├── todo-list-completed.component.html
│ │ ├── todo-list-completed.component.spec.ts
│ │ └── todo-list-completed.component.ts
│ └── todo-list
│ │ ├── todo-list.component.css
│ │ ├── todo-list.component.html
│ │ ├── todo-list.component.spec.ts
│ │ └── todo-list.component.ts
├── assets
│ └── .gitkeep
├── browserslist
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.html
├── karma.conf.js
├── main.ts
├── polyfills.ts
├── styles.scss
├── styles
│ └── spinner.scss
├── test.ts
├── tsconfig.app.json
├── tsconfig.spec.json
└── tslint.json
├── tsconfig.json
├── tslint.json
└── yarn.lock
/.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 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 | /out-tsc
7 |
8 | # dependencies
9 | /node_modules
10 |
11 | # IDEs and editors
12 | /.idea
13 | .project
14 | .classpath
15 | .c9/
16 | *.launch
17 | .settings/
18 | *.sublime-workspace
19 |
20 | # IDE - VSCode
21 | .vscode/*
22 | !.vscode/settings.json
23 | !.vscode/tasks.json
24 | !.vscode/launch.json
25 | !.vscode/extensions.json
26 |
27 | # misc
28 | /.sass-cache
29 | /connect.lock
30 | /coverage
31 | /libpeerconnection.log
32 | npm-debug.log
33 | yarn-error.log
34 | testem.log
35 | /typings
36 |
37 | # System Files
38 | .DS_Store
39 | Thumbs.db
40 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Christian Lüdemann
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SpinnersDemo
2 |
3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.1.1.
4 |
5 | ## Development server
6 |
7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8 |
9 | ## Code scaffolding
10 |
11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12 |
13 | ## Build
14 |
15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
16 |
17 | ## Running unit tests
18 |
19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20 |
21 | ## Running end-to-end tests
22 |
23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24 |
25 | ## Further help
26 |
27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
28 |
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "spinners-demo": {
7 | "root": "",
8 | "sourceRoot": "src",
9 | "projectType": "application",
10 | "prefix": "app",
11 | "schematics": {
12 | "@schematics/angular:component": {
13 | "styleext": "scss"
14 | }
15 | },
16 | "architect": {
17 | "build": {
18 | "builder": "@angular-devkit/build-angular:browser",
19 | "options": {
20 | "outputPath": "dist/spinners-demo",
21 | "index": "src/index.html",
22 | "main": "src/main.ts",
23 | "polyfills": "src/polyfills.ts",
24 | "tsConfig": "src/tsconfig.app.json",
25 | "assets": [
26 | "src/favicon.ico",
27 | "src/assets"
28 | ],
29 | "styles": [
30 | "src/styles.scss"
31 | ],
32 | "scripts": []
33 | },
34 | "configurations": {
35 | "production": {
36 | "fileReplacements": [
37 | {
38 | "replace": "src/environments/environment.ts",
39 | "with": "src/environments/environment.prod.ts"
40 | }
41 | ],
42 | "optimization": true,
43 | "outputHashing": "all",
44 | "sourceMap": false,
45 | "extractCss": true,
46 | "namedChunks": false,
47 | "aot": true,
48 | "extractLicenses": true,
49 | "vendorChunk": false,
50 | "buildOptimizer": true
51 | }
52 | }
53 | },
54 | "serve": {
55 | "builder": "@angular-devkit/build-angular:dev-server",
56 | "options": {
57 | "browserTarget": "spinners-demo:build"
58 | },
59 | "configurations": {
60 | "production": {
61 | "browserTarget": "spinners-demo:build:production"
62 | }
63 | }
64 | },
65 | "extract-i18n": {
66 | "builder": "@angular-devkit/build-angular:extract-i18n",
67 | "options": {
68 | "browserTarget": "spinners-demo:build"
69 | }
70 | },
71 | "test": {
72 | "builder": "@angular-devkit/build-angular:karma",
73 | "options": {
74 | "main": "src/test.ts",
75 | "polyfills": "src/polyfills.ts",
76 | "tsConfig": "src/tsconfig.spec.json",
77 | "karmaConfig": "src/karma.conf.js",
78 | "styles": [
79 | "src/styles.scss"
80 | ],
81 | "scripts": [],
82 | "assets": [
83 | "src/favicon.ico",
84 | "src/assets"
85 | ]
86 | }
87 | },
88 | "lint": {
89 | "builder": "@angular-devkit/build-angular:tslint",
90 | "options": {
91 | "tsConfig": [
92 | "src/tsconfig.app.json",
93 | "src/tsconfig.spec.json"
94 | ],
95 | "exclude": [
96 | "**/node_modules/**"
97 | ]
98 | }
99 | }
100 | }
101 | },
102 | "spinners-demo-e2e": {
103 | "root": "e2e/",
104 | "projectType": "application",
105 | "architect": {
106 | "e2e": {
107 | "builder": "@angular-devkit/build-angular:protractor",
108 | "options": {
109 | "protractorConfig": "e2e/protractor.conf.js",
110 | "devServerTarget": "spinners-demo:serve"
111 | },
112 | "configurations": {
113 | "production": {
114 | "devServerTarget": "spinners-demo:serve:production"
115 | }
116 | }
117 | },
118 | "lint": {
119 | "builder": "@angular-devkit/build-angular:tslint",
120 | "options": {
121 | "tsConfig": "e2e/tsconfig.e2e.json",
122 | "exclude": [
123 | "**/node_modules/**"
124 | ]
125 | }
126 | }
127 | }
128 | }
129 | },
130 | "defaultProject": "spinners-demo"
131 | }
--------------------------------------------------------------------------------
/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 spinners-demo!');
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": "spinners-demo",
3 | "version": "0.0.0",
4 | "scripts": {
5 | "ng": "ng",
6 | "start": "nodemon server | ng serve",
7 | "build": "ng build --prod",
8 | "test": "ng test --sourcemaps false",
9 | "lint": "ng lint",
10 | "e2e": "ng e2e"
11 | },
12 | "private": true,
13 | "dependencies": {
14 | "@angular/animations": "^6.1.0",
15 | "@angular/cdk": "^6.4.1",
16 | "@angular/common": "^6.1.0",
17 | "@angular/compiler": "^6.1.0",
18 | "@angular/core": "^6.1.0",
19 | "@angular/forms": "^6.1.0",
20 | "@angular/http": "^6.1.0",
21 | "@angular/platform-browser": "^6.1.0",
22 | "@angular/platform-browser-dynamic": "^6.1.0",
23 | "@angular/router": "^6.1.0",
24 | "@ng-bootstrap/ng-bootstrap": "^2.2.1",
25 | "bootstrap": "^4.0.0",
26 | "core-js": "^2.5.4",
27 | "cors": "^2.8.4",
28 | "rxjs": "^6.0.0",
29 | "zone.js": "~0.8.26"
30 | },
31 | "devDependencies": {
32 | "@angular-devkit/build-angular": "~0.7.0",
33 | "@angular/cli": "~6.1.1",
34 | "@angular/compiler-cli": "^6.1.0",
35 | "@angular/language-service": "^6.1.0",
36 | "@types/jasmine": "~2.8.6",
37 | "@types/jasminewd2": "~2.0.3",
38 | "@types/node": "~8.9.4",
39 | "codelyzer": "~4.2.1",
40 | "jasmine-core": "~2.99.1",
41 | "jasmine-spec-reporter": "~4.2.1",
42 | "karma": "~1.7.1",
43 | "karma-chrome-launcher": "~2.2.0",
44 | "karma-coverage-istanbul-reporter": "~2.0.0",
45 | "karma-jasmine": "~1.1.1",
46 | "karma-jasmine-html-reporter": "^0.2.2",
47 | "nodemon": "^1.17.1",
48 | "protractor": "~5.3.0",
49 | "ts-node": "~5.0.1",
50 | "tslint": "~5.9.1",
51 | "typescript": "~2.7.2"
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/server/index.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | var cors = require('cors')
3 | var app = express();
4 |
5 | app.use(cors());
6 |
7 | app.get('/todo-list', (req, res) => {
8 |
9 | const todoList = [
10 | {id: 'task1', title: 'Buy Milk', description: 'Remember to buy milk'},
11 | {id: 'task2', title: 'Go to the gym', description: 'Remember to work out'}
12 | ];
13 | return res.json(todoList);
14 | });
15 |
16 | const port = 8080;
17 | app.listen(port, () => console.log(`Example app listening on port ${port}!`));
--------------------------------------------------------------------------------
/src/app/add-todo/add-todo.component.css:
--------------------------------------------------------------------------------
1 |
2 | .relative {
3 | position: relative;
4 | }
--------------------------------------------------------------------------------
/src/app/add-todo/add-todo.component.html:
--------------------------------------------------------------------------------
1 |
2 |
Add TODO
3 |
4 |
5 |
6 | Invalid form
7 |
8 |
26 |
--------------------------------------------------------------------------------
/src/app/add-todo/add-todo.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
2 | /* tslint:disable:no-unused-variable */
3 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
4 | import { By, BrowserModule } from '@angular/platform-browser';
5 | import { DebugElement } from '@angular/core';
6 |
7 | import { AddTodoComponent } from '@app/add-todo/add-todo.component';
8 | import { AppComponent } from '@app/app.component';
9 | import { NavbarComponent } from '@app/navbar/navbar.component';
10 | import { TodoListComponent } from '@app/todo-list/todo-list.component';
11 | import { TodoItemComponent } from '@app/todo-item/todo-item.component';
12 | import { FooterComponent } from '@app/footer/footer.component';
13 | import { TodoListCompletedComponent } from '@app/todo-list-completed/todo-list-completed.component';
14 | import { FormsModule } from '@angular/forms';
15 | import { CoreModule } from '@app/core/core.module';
16 | import { HttpClientModule } from '@angular/common/http';
17 | import { appRouterModule } from '@app/app.routes';
18 | import { APP_BASE_HREF } from '@angular/common';
19 |
20 | describe('AddTodoComponent', () => {
21 | let component: AddTodoComponent;
22 | let fixture: ComponentFixture;
23 |
24 | beforeEach(async(() => {
25 | TestBed.configureTestingModule({
26 | declarations: [
27 | AppComponent,
28 | NavbarComponent,
29 | TodoListComponent,
30 | TodoItemComponent,
31 | FooterComponent,
32 | AddTodoComponent,
33 | TodoListCompletedComponent,
34 | ],
35 | imports: [
36 | BrowserModule,
37 | NgbModule.forRoot(),
38 | FormsModule,
39 | CoreModule,
40 | HttpClientModule,
41 | appRouterModule
42 | ],
43 | providers: [{provide: APP_BASE_HREF, useValue : '/' }]
44 | })
45 | .compileComponents();
46 | }));
47 |
48 | beforeEach(() => {
49 | fixture = TestBed.createComponent(AddTodoComponent);
50 | component = fixture.componentInstance;
51 | fixture.detectChanges();
52 | });
53 |
54 | it('should create', () => {
55 | expect(component).toBeTruthy();
56 | });
57 | });
58 |
--------------------------------------------------------------------------------
/src/app/add-todo/add-todo.component.ts:
--------------------------------------------------------------------------------
1 | import { of } from 'rxjs';
2 | import { delay, first } from 'rxjs/operators';
3 | import { Component, OnInit, Input } from '@angular/core';
4 | import { NgForm } from '@angular/forms';
5 | import { TODOItem } from '@app/shared/models/todo-item';
6 | import { TodoListService } from '@app/core/todo-list/todo-list.service';
7 |
8 | @Component({
9 | selector: 'app-add-todo',
10 | templateUrl: './add-todo.component.html',
11 | styleUrls: ['./add-todo.component.css']
12 | })
13 | export class AddTodoComponent implements OnInit {
14 | private editingIndex = -1;
15 |
16 | public isLoading = false;
17 |
18 | private _currentTODO: TODOItem = new TODOItem('', '');
19 | public get currentTODO(): TODOItem {
20 | return this._currentTODO;
21 | }
22 | @Input()
23 | public set currentTODO(value: TODOItem) {
24 | this._currentTODO = Object.assign({}, value);
25 | this.editingIndex = this.todoListService.todoList.findIndex(
26 | todo => todo.id === value.id
27 | );
28 | }
29 |
30 | constructor(private todoListService: TodoListService) {}
31 |
32 | ngOnInit() {}
33 |
34 | save(form: NgForm) {
35 | if (!form.valid) {
36 | console.log('Invalid form!');
37 | // TODO: display form errors
38 | return;
39 | }
40 | this.isLoading = true;
41 | of(null)
42 | .pipe(
43 | delay(2000),
44 | first()
45 | )
46 | .subscribe(() => {
47 |
48 | this.isLoading = false;
49 | const currentTODOClone = Object.assign({}, this.currentTODO);
50 | if (this.isEditing()) {
51 | this.todoListService.todoList[this.editingIndex] = currentTODOClone;
52 | this.setAdding();
53 | } else {
54 | this.todoListService.todoList.push(currentTODOClone);
55 | this.currentTODO = new TODOItem('', '');
56 | }
57 | form.resetForm();
58 | });
59 | }
60 |
61 | private setAdding() {
62 | this.editingIndex = -1;
63 | }
64 |
65 | private isEditing() {
66 | return this.editingIndex !== -1;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lydemann/angular-spinners-demo/759495995ea503c11b5a3c12adb0686ddd69f85c/src/app/app.component.css
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/app/app.component.scss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lydemann/angular-spinners-demo/759495995ea503c11b5a3c12adb0686ddd69f85c/src/app/app.component.scss
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { AppComponent } from '@app/app.component';
3 | import { NavbarComponent } from '@app/navbar/navbar.component';
4 | import { TodoListComponent } from '@app/todo-list/todo-list.component';
5 | import { TodoItemComponent } from '@app/todo-item/todo-item.component';
6 | import { FooterComponent } from '@app/footer/footer.component';
7 | import { AddTodoComponent } from '@app/add-todo/add-todo.component';
8 | import { TodoListCompletedComponent } from '@app/todo-list-completed/todo-list-completed.component';
9 | import { BrowserModule } from '@angular/platform-browser';
10 | import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
11 | import { FormsModule } from '@angular/forms';
12 | import { CoreModule } from '@app/core/core.module';
13 | import { HttpClientModule } from '@angular/common/http';
14 | import { appRouterModule } from '@app/app.routes';
15 | import { APP_BASE_HREF } from '@angular/common';
16 | describe('AppComponent', () => {
17 | beforeEach(async(() => {
18 | TestBed.configureTestingModule({
19 | declarations: [
20 | AppComponent,
21 | NavbarComponent,
22 | TodoListComponent,
23 | TodoItemComponent,
24 | FooterComponent,
25 | AddTodoComponent,
26 | TodoListCompletedComponent,
27 | ],
28 | imports: [
29 | BrowserModule,
30 | NgbModule.forRoot(),
31 | FormsModule,
32 | CoreModule,
33 | HttpClientModule,
34 | appRouterModule
35 | ],
36 | providers: [{provide: APP_BASE_HREF, useValue : '/' }]
37 | }).compileComponents();
38 | }));
39 | it('should create the app', async(() => {
40 | const fixture = TestBed.createComponent(AppComponent);
41 | const app = fixture.debugElement.componentInstance;
42 | expect(app).toBeTruthy();
43 | }));
44 | });
45 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { SpinnerOverlayService } from '@app/core/spinner-overlay/spinner-overlay.service';
2 | import { Component } from '@angular/core';
3 |
4 | @Component({
5 | selector: 'app-root',
6 | templateUrl: './app.component.html',
7 | styleUrls: ['./app.component.css']
8 | })
9 | export class AppComponent {
10 |
11 | /**
12 | *
13 | */
14 | constructor() {
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { appRouterModule } from '@app/app.routes';
2 | import { BrowserModule } from '@angular/platform-browser';
3 | import { NgModule } from '@angular/core';
4 | import { HttpClientModule } from '@angular/common/http';
5 | import { FormsModule } from '@angular/forms';
6 | import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
7 |
8 | import { AppComponent } from '@app/app.component';
9 | import { NavbarComponent } from '@app/navbar/navbar.component';
10 | import { TodoListComponent } from '@app/todo-list/todo-list.component';
11 | import { TodoItemComponent } from '@app/todo-item/todo-item.component';
12 | import { FooterComponent } from '@app/footer/footer.component';
13 | import { AddTodoComponent } from '@app/add-todo/add-todo.component';
14 | import { CoreModule } from '@app/core/core.module';
15 | import { TodoListCompletedComponent } from '@app/todo-list-completed/todo-list-completed.component';
16 | import { SharedModule } from '@app/shared/shared.module';
17 |
18 |
19 | @NgModule({
20 | declarations: [
21 | AppComponent,
22 | NavbarComponent,
23 | TodoListComponent,
24 | TodoItemComponent,
25 | FooterComponent,
26 | AddTodoComponent,
27 | TodoListCompletedComponent
28 | ],
29 | imports: [
30 | BrowserModule,
31 | NgbModule.forRoot(),
32 | FormsModule,
33 | CoreModule,
34 | SharedModule,
35 | HttpClientModule,
36 | appRouterModule
37 | ],
38 | providers: [],
39 | bootstrap: [AppComponent]
40 | })
41 | export class AppModule { }
42 |
--------------------------------------------------------------------------------
/src/app/app.routes.ts:
--------------------------------------------------------------------------------
1 | import { Routes, RouterModule } from '@angular/router';
2 | import { TodoListComponent } from '@app/todo-list/todo-list.component';
3 | import { TodoListCompletedComponent } from '@app/todo-list-completed/todo-list-completed.component';
4 |
5 | export const rootPath = '';
6 | export const completedTodoPath = 'completed-todos';
7 |
8 | const appRoutes: Routes = [
9 | {
10 | path: rootPath,
11 | component: TodoListComponent,
12 | pathMatch: 'full'
13 | },
14 | {
15 | path: completedTodoPath,
16 | component: TodoListCompletedComponent
17 | },
18 | ];
19 |
20 | export const appRouterModule = RouterModule.forRoot(appRoutes);
21 |
--------------------------------------------------------------------------------
/src/app/core/core.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { OverlayModule } from '@angular/cdk/overlay';
3 | import { SpinnerOverlayModule } from '@app/core/spinner-overlay/spinner-overlay.module';
4 | import { TodoListService } from '@app/core/todo-list/todo-list.service';
5 |
6 | @NgModule({
7 | imports: [
8 | OverlayModule,
9 | SpinnerOverlayModule
10 | ],
11 | declarations: [],
12 | providers: [TodoListService]
13 | })
14 | export class CoreModule { }
15 |
--------------------------------------------------------------------------------
/src/app/core/spinner-overlay/spinner-overlay.component.html:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/src/app/core/spinner-overlay/spinner-overlay.component.scss:
--------------------------------------------------------------------------------
1 | .spinner-wrapper {
2 | position: fixed;
3 | width: 100%;
4 | height: 100%;
5 | display: flex;
6 | justify-content: center;
7 | align-items: center;
8 | top: 0;
9 | left: 0;
10 | background-color: rgba(255, 255, 255, 0.5);
11 | z-index: 998;
12 | app-spinner {
13 | width: 6rem;
14 | height: 6rem;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/app/core/spinner-overlay/spinner-overlay.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { SpinnerComponent } from '@app/shared/spinner/spinner.component';
4 | import { SpinnerOverlayComponent } from '@app/core/spinner-overlay/spinner-overlay.component';
5 |
6 | describe('SpinnerOverlayComponent', () => {
7 | let component: SpinnerOverlayComponent;
8 | let fixture: ComponentFixture;
9 |
10 | beforeEach(async(() => {
11 | TestBed.configureTestingModule({
12 | declarations: [SpinnerOverlayComponent, SpinnerComponent]
13 | }).compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(SpinnerOverlayComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/core/spinner-overlay/spinner-overlay.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, Input, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-spinner-overlay',
5 | templateUrl: './spinner-overlay.component.html',
6 | styleUrls: ['./spinner-overlay.component.scss']
7 | })
8 | export class SpinnerOverlayComponent implements OnInit {
9 | @Input() public message: string;
10 | constructor() {}
11 |
12 | public ngOnInit() {}
13 | }
14 |
--------------------------------------------------------------------------------
/src/app/core/spinner-overlay/spinner-overlay.module.ts:
--------------------------------------------------------------------------------
1 | import { CommonModule } from '@angular/common';
2 | import { NgModule } from '@angular/core';
3 | import { SpinnerOverlayService } from '@app/core/spinner-overlay/spinner-overlay.service';
4 | import { SpinnerOverlayComponent } from '@app/core/spinner-overlay/spinner-overlay.component';
5 | import { SpinnerModule } from '@app/shared/spinner/spinner.module';
6 |
7 | @NgModule({
8 | imports: [CommonModule, SpinnerModule],
9 | declarations: [SpinnerOverlayComponent],
10 | entryComponents: [SpinnerOverlayComponent],
11 | providers: [SpinnerOverlayService],
12 | exports: []
13 | })
14 | export class SpinnerOverlayModule {}
15 |
--------------------------------------------------------------------------------
/src/app/core/spinner-overlay/spinner-overlay.service.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 |
3 | import { Overlay } from '@angular/cdk/overlay';
4 | import { inject, TestBed } from '@angular/core/testing';
5 | import { SpinnerOverlayService } from '@app/core/spinner-overlay/spinner-overlay.service';
6 |
7 | describe('Service: SpinnerOverlay', () => {
8 | beforeEach(() => {
9 | TestBed.configureTestingModule({
10 | providers: [SpinnerOverlayService, Overlay]
11 | });
12 | });
13 |
14 | it(
15 | 'should ...',
16 | inject([SpinnerOverlayService], (service: SpinnerOverlayService) => {
17 | expect(service).toBeTruthy();
18 | })
19 | );
20 | });
21 |
--------------------------------------------------------------------------------
/src/app/core/spinner-overlay/spinner-overlay.service.ts:
--------------------------------------------------------------------------------
1 | import { Overlay, OverlayRef } from '@angular/cdk/overlay';
2 | import { ComponentPortal } from '@angular/cdk/portal';
3 | import { Injectable } from '@angular/core';
4 | import { SpinnerOverlayWrapperComponent } from '@app/shared/spinner-overlay-wrapper/spinner-overlay-wrapper.component';
5 | import { SpinnerOverlayComponent } from '@app/core/spinner-overlay/spinner-overlay.component';
6 |
7 | @Injectable({
8 | providedIn: 'root'
9 | })
10 | export class SpinnerOverlayService {
11 | private overlayRef: OverlayRef = null;
12 |
13 | constructor(private overlay: Overlay) {}
14 |
15 | public show(message = '') {
16 | // Returns an OverlayRef (which is a PortalHost)
17 |
18 | if (!this.overlayRef) {
19 | this.overlayRef = this.overlay.create();
20 | }
21 |
22 | // Create ComponentPortal that can be attached to a PortalHost
23 | const spinnerOverlayPortal = new ComponentPortal(SpinnerOverlayComponent);
24 |
25 | // run in async context for triggering "tick", thus avoid ExpressionChangedAfterItHasBeenCheckedError
26 | setTimeout(() => {
27 | const component = this.overlayRef.attach(spinnerOverlayPortal); // Attach ComponentPortal to PortalHost
28 |
29 | // TODO: set message
30 | // component.instance.message = message;
31 | });
32 | }
33 |
34 | public hide() {
35 | if (!!this.overlayRef) {
36 | this.overlayRef.detach();
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/app/core/todo-list/todo-list.service.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 |
3 | import { TestBed, async, inject } from '@angular/core/testing';
4 | import { TodoListService } from '@app/core/todo-list/todo-list.service';
5 | import { HttpClientModule, HttpClient } from '@angular/common/http';
6 | import { TODOItem } from '../shared/models/todo-item';
7 | import { Observable } from 'rxjs/Observable';
8 | import { of } from 'rxjs/observable/of';
9 |
10 | describe('Service: TodoList', () => {
11 | let todoListService: TodoListService;
12 | const httpClientSpy: jasmine.SpyObj = jasmine.createSpyObj('httpClient', ['get']);
13 | httpClientSpy.get.and.returnValue(of([new TODOItem('Buy Milk', 'Lala')]));
14 | beforeEach(() => {
15 | TestBed.configureTestingModule({
16 | providers: [TodoListService,
17 | {
18 | provide: HttpClient,
19 | useValue: httpClientSpy
20 | }]
21 | });
22 | });
23 |
24 |
25 | beforeEach(inject([TodoListService], (service: TodoListService) => {
26 | todoListService = service;
27 | }));
28 |
29 | it('should be defined', () => {
30 | expect(todoListService).toBeTruthy();
31 | });
32 |
33 | it('should make a http get request', () => {
34 |
35 | expect(httpClientSpy.get).toHaveBeenCalled();
36 | expect(todoListService.todoList.length).toBe(1);
37 | });
38 | });
39 |
--------------------------------------------------------------------------------
/src/app/core/todo-list/todo-list.service.ts:
--------------------------------------------------------------------------------
1 | import { of } from 'rxjs';
2 | import { delay } from 'rxjs/operators';
3 | import { Injectable } from '@angular/core';
4 | import { TODOItem } from '@app/shared/models/todo-item';
5 | import { HttpClient } from '@angular/common/http';
6 |
7 | @Injectable()
8 | export class TodoListService {
9 |
10 | public todoList: TODOItem[] = [];
11 | private todoListUrl = '//localhost:8080/todo-list';
12 |
13 | constructor(httpClient: HttpClient) {
14 | httpClient.get>(this.todoListUrl).subscribe(data => {
15 | this.todoList = data;
16 | });
17 | }
18 |
19 | public addTodo(todo: TODOItem) {
20 | return of(null).pipe(delay(2000));
21 | }
22 |
23 | public updateTodo(todo: TODOItem) {
24 | return of(null).pipe(delay(2000));
25 | }
26 |
27 | public deleteTodo(id: string) {
28 | return of(null).pipe(delay(2000));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/app/footer/footer.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lydemann/angular-spinners-demo/759495995ea503c11b5a3c12adb0686ddd69f85c/src/app/footer/footer.component.css
--------------------------------------------------------------------------------
/src/app/footer/footer.component.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/app/footer/footer.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { FooterComponent } from '@app/footer/footer.component';
7 |
8 | describe('FooterComponent', () => {
9 | let component: FooterComponent;
10 | let fixture: ComponentFixture;
11 |
12 | beforeEach(async(() => {
13 | TestBed.configureTestingModule({
14 | declarations: [ FooterComponent ]
15 | })
16 | .compileComponents();
17 | }));
18 |
19 | beforeEach(() => {
20 | fixture = TestBed.createComponent(FooterComponent);
21 | component = fixture.componentInstance;
22 | fixture.detectChanges();
23 | });
24 |
25 | it('should create', () => {
26 | expect(component).toBeTruthy();
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/src/app/footer/footer.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-footer',
5 | templateUrl: './footer.component.html',
6 | styleUrls: ['./footer.component.css']
7 | })
8 | export class FooterComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/navbar/navbar.component.css:
--------------------------------------------------------------------------------
1 | .nav-active {
2 | background-color: #dae0e5;
3 | }
4 |
5 | a:hover {
6 | background-color: #eef4f9
7 | }
--------------------------------------------------------------------------------
/src/app/navbar/navbar.component.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/navbar/navbar.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { appRouterModule } from '@app/app.routes';
2 | /* tslint:disable:no-unused-variable */
3 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
4 | import { By, BrowserModule } from '@angular/platform-browser';
5 | import { DebugElement } from '@angular/core';
6 |
7 | import { NavbarComponent } from '@app/navbar/navbar.component';
8 | import { RouterModule } from '@angular/router';
9 | import { APP_BASE_HREF } from '@angular/common';
10 | import { TodoListComponent } from '@app/todo-list/todo-list.component';
11 | import { TodoListCompletedComponent } from '@app/todo-list-completed/todo-list-completed.component';
12 | import { TodoItemComponent } from '@app/todo-item/todo-item.component';
13 | import { AddTodoComponent } from '@app/add-todo/add-todo.component';
14 | import { AppComponent } from '@app/app.component';
15 | import { FooterComponent } from '@app/footer/footer.component';
16 | import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
17 | import { FormsModule } from '@angular/forms';
18 | import { CoreModule } from '@app/core/core.module';
19 | import { HttpClientModule } from '@angular/common/http';
20 |
21 | describe('NavbarComponent', () => {
22 | let component: NavbarComponent;
23 | let fixture: ComponentFixture;
24 |
25 | beforeEach(async(() => {
26 | TestBed.configureTestingModule({
27 | declarations: [
28 | AppComponent,
29 | NavbarComponent,
30 | TodoListComponent,
31 | TodoItemComponent,
32 | FooterComponent,
33 | AddTodoComponent,
34 | TodoListCompletedComponent,
35 | ],
36 | imports: [
37 | BrowserModule,
38 | NgbModule.forRoot(),
39 | FormsModule,
40 | CoreModule,
41 | HttpClientModule,
42 | appRouterModule
43 | ],
44 | providers: [{provide: APP_BASE_HREF, useValue : '/' }]
45 | })
46 | .compileComponents();
47 | }));
48 |
49 | beforeEach(() => {
50 | fixture = TestBed.createComponent(NavbarComponent);
51 | component = fixture.componentInstance;
52 | fixture.detectChanges();
53 | });
54 |
55 | it('should create', () => {
56 | expect(component).toBeTruthy();
57 | });
58 | });
59 |
--------------------------------------------------------------------------------
/src/app/navbar/navbar.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-navbar',
5 | templateUrl: './navbar.component.html',
6 | styleUrls: ['./navbar.component.css']
7 | })
8 | export class NavbarComponent implements OnInit {
9 |
10 | title = 'TODO app';
11 |
12 | constructor() { }
13 |
14 | ngOnInit() {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/app/shared/invalid-date.directive.ts:
--------------------------------------------------------------------------------
1 | import { ValidatorFn, AbstractControl, NG_VALIDATORS, Validator } from '@angular/forms';
2 | import { Directive, Input } from '@angular/core';
3 |
4 | export function InvalidDateValidator(): ValidatorFn {
5 | return (control: AbstractControl): { [key: string]: any } => {
6 | const date = new Date(control.value);
7 | const invalidDate = !control.value || date.getMonth === undefined;
8 | return invalidDate ? { 'invalidDate': { value: control.value } } : null;
9 | };
10 | }
11 |
12 | @Directive({
13 | selector: '[appInvalidDate]',
14 | providers: [{ provide: NG_VALIDATORS, useExisting: InvalidDateValidatorDirective, multi: true }]
15 | })
16 | export class InvalidDateValidatorDirective implements Validator {
17 | // tslint:disable-next-line:no-input-rename
18 | @Input('appInvalidDate') invalidDate: string;
19 | validate(control: AbstractControl): { [key: string]: any } {
20 | return this.invalidDate ? InvalidDateValidator()(control)
21 | : null;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/app/shared/models/guid.ts:
--------------------------------------------------------------------------------
1 |
2 | /*tslint:disable:no-bitwise*/
3 | // Class for creating Guids: https://github.com/Steve-Fenton/TypeScriptUtilities/blob/master/Guid
4 |
5 | export class Guid {
6 | static newGuid() {
7 | return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
8 | const r = Math.random() * 16, v = c === 'x' ? r : (r & 0x3 | 0x8);
9 | return v.toString(16);
10 | });
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/app/shared/models/todo-item.ts:
--------------------------------------------------------------------------------
1 | import { Guid } from '@app/shared/models/guid';
2 |
3 | export class TODOItem {
4 |
5 | constructor(title: string, description: string, dueDate: string = null) {
6 | this.id = Guid.newGuid();
7 | this.title = title;
8 | this.description = description;
9 | this.dueDate = dueDate;
10 | }
11 |
12 | id: string;
13 | title: string;
14 | description: string;
15 | dueDate?: string;
16 | completed?: boolean;
17 | }
18 |
--------------------------------------------------------------------------------
/src/app/shared/shared.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 | import { InvalidDateValidatorDirective } from '@app/shared/invalid-date.directive';
4 | import { SpinnerModule } from '@app/shared/spinner/spinner.module';
5 | import { SpinnerOverlayWrapperModule } from '@app/shared/spinner-overlay-wrapper/spinner-overlay-wrapper.module';
6 |
7 | @NgModule({
8 | imports: [
9 | CommonModule,
10 | SpinnerModule,
11 | SpinnerOverlayWrapperModule
12 | ],
13 | declarations: [
14 | InvalidDateValidatorDirective,
15 | ],
16 | exports: [InvalidDateValidatorDirective,
17 | SpinnerModule, SpinnerOverlayWrapperModule]
18 | })
19 | export class SharedModule { }
20 |
--------------------------------------------------------------------------------
/src/app/shared/spinner-overlay-wrapper/spinner-overlay-wrapper.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
{{message | translate}}
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/app/shared/spinner-overlay-wrapper/spinner-overlay-wrapper.component.scss:
--------------------------------------------------------------------------------
1 | .wrapper {
2 | width: 100%;
3 | height: 100%;
4 | }
5 |
6 | .overlay {
7 | position: absolute;
8 | z-index: 1002;
9 | background-color: rgba(255, 255, 255, 0.5);
10 | width: 100%;
11 | height: 100%;
12 | }
13 |
14 | .spinner-wrapper {
15 | display: flex;
16 | justify-content: center;
17 | justify-items: center;
18 | }
19 |
--------------------------------------------------------------------------------
/src/app/shared/spinner-overlay-wrapper/spinner-overlay-wrapper.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { SpinnerOverlayWrapperComponent } from '@app/shared/spinner-overlay-wrapper/spinner-overlay-wrapper.component';
7 |
8 | describe('SpinnerOverlayWrapperComponent', () => {
9 | let component: SpinnerOverlayWrapperComponent;
10 | let fixture: ComponentFixture;
11 |
12 | beforeEach(async(() => {
13 | TestBed.configureTestingModule({
14 | declarations: [ SpinnerOverlayWrapperComponent ]
15 | })
16 | .compileComponents();
17 | }));
18 |
19 | beforeEach(() => {
20 | fixture = TestBed.createComponent(SpinnerOverlayWrapperComponent);
21 | component = fixture.componentInstance;
22 | fixture.detectChanges();
23 | });
24 |
25 | it('should create', () => {
26 | expect(component).toBeTruthy();
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/src/app/shared/spinner-overlay-wrapper/spinner-overlay-wrapper.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, Input, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-spinner-overlay-wrapper',
5 | templateUrl: './spinner-overlay-wrapper.component.html',
6 | styleUrls: ['./spinner-overlay-wrapper.component.scss']
7 | })
8 | export class SpinnerOverlayWrapperComponent implements OnInit {
9 |
10 | @Input() public readonly showSpinner = false;
11 | @Input() public readonly message: string = 'Loading...';
12 |
13 | constructor() { }
14 |
15 | ngOnInit() {
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/app/shared/spinner-overlay-wrapper/spinner-overlay-wrapper.module.ts:
--------------------------------------------------------------------------------
1 | import { SpinnerModule } from '@app/shared/spinner/spinner.module';
2 | import { NgModule } from '@angular/core';
3 | import { SpinnerOverlayWrapperComponent } from '@app/shared/spinner-overlay-wrapper/spinner-overlay-wrapper.component';
4 |
5 | @NgModule({
6 | imports: [SpinnerModule],
7 | declarations: [SpinnerOverlayWrapperComponent],
8 | exports: [SpinnerOverlayWrapperComponent]
9 | })
10 | export class SpinnerOverlayWrapperModule {
11 | }
12 |
--------------------------------------------------------------------------------
/src/app/shared/spinner/spinner.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | {{message}}
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/app/shared/spinner/spinner.component.scss:
--------------------------------------------------------------------------------
1 | @import "~styles/spinner";
--------------------------------------------------------------------------------
/src/app/shared/spinner/spinner.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { SpinnerComponent } from '@app/shared/spinner/spinner.component';
7 |
8 | describe('SpinnerComponent', () => {
9 | let component: SpinnerComponent;
10 | let fixture: ComponentFixture;
11 |
12 | beforeEach(async(() => {
13 | TestBed.configureTestingModule({
14 | declarations: [ SpinnerComponent ]
15 | })
16 | .compileComponents();
17 | }));
18 |
19 | beforeEach(() => {
20 | fixture = TestBed.createComponent(SpinnerComponent);
21 | component = fixture.componentInstance;
22 | fixture.detectChanges();
23 | });
24 |
25 | it('should create', () => {
26 | expect(component).toBeTruthy();
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/src/app/shared/spinner/spinner.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-spinner',
5 | templateUrl: './spinner.component.html',
6 | styleUrls: ['./spinner.component.scss']
7 | })
8 | export class SpinnerComponent implements OnInit {
9 |
10 | @Input() message = '';
11 |
12 | constructor() { }
13 |
14 | ngOnInit() {
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/app/shared/spinner/spinner.module.ts:
--------------------------------------------------------------------------------
1 | import { CommonModule } from '@angular/common';
2 | import { NgModule } from '@angular/core';
3 | import { SpinnerComponent } from '@app/shared/spinner/spinner.component';
4 |
5 | @NgModule({
6 | imports: [CommonModule],
7 | declarations: [SpinnerComponent],
8 | exports: [SpinnerComponent]
9 | })
10 | export class SpinnerModule {
11 | }
12 |
--------------------------------------------------------------------------------
/src/app/todo-item/todo-item.component.css:
--------------------------------------------------------------------------------
1 | .bg-completed {
2 | background-color: #85cc95;
3 | }
4 |
--------------------------------------------------------------------------------
/src/app/todo-item/todo-item.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
{{todoItem.title}}
5 |
{{todoItem.description}}
6 |
7 | Due date:
8 | {{todoItem.dueDate}}
9 |
10 |
11 |
12 |
13 |
14 |
17 |
20 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/app/todo-item/todo-item.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By, BrowserModule } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { TodoItemComponent } from '@app/todo-item/todo-item.component';
7 | import { AppComponent } from '@app/app.component';
8 | import { NavbarComponent } from '@app/navbar/navbar.component';
9 | import { TodoListComponent } from '@app/todo-list/todo-list.component';
10 | import { FooterComponent } from '@app/footer/footer.component';
11 | import { AddTodoComponent } from '@app/add-todo/add-todo.component';
12 | import { TodoListCompletedComponent } from '@app/todo-list-completed/todo-list-completed.component';
13 | import { FormsModule } from '@angular/forms';
14 | import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
15 | import { CoreModule } from '@app/core/core.module';
16 | import { appRouterModule, rootPath } from '@app/app.routes';
17 | import { HttpClientModule } from '@angular/common/http';
18 | import { APP_BASE_HREF } from '@angular/common';
19 | import { TodoListService } from '@app/core/todo-list/todo-list.service';
20 | import { TODOItem } from '@app/shared/models/todo-item';
21 |
22 | describe('TodoItemComponent', () => {
23 | let component: TodoItemComponent;
24 | let fixture: ComponentFixture;
25 |
26 | beforeEach(async(() => {
27 | TestBed.configureTestingModule({
28 | declarations: [
29 | AppComponent,
30 | NavbarComponent,
31 | TodoListComponent,
32 | TodoItemComponent,
33 | FooterComponent,
34 | AddTodoComponent,
35 | TodoListCompletedComponent,
36 | ],
37 | imports: [
38 | BrowserModule,
39 | NgbModule.forRoot(),
40 | FormsModule,
41 | appRouterModule
42 | ],
43 | providers: [
44 | {provide: APP_BASE_HREF, useValue : rootPath },
45 | {
46 | provide: TodoListService,
47 | useValue: {todoList: [new TODOItem('Buy milk', 'Remember to buy milk')]}
48 | }
49 | ]
50 | })
51 | .compileComponents();
52 | }));
53 |
54 | beforeEach(() => {
55 | fixture = TestBed.createComponent(TodoItemComponent);
56 | component = fixture.componentInstance;
57 | fixture.detectChanges();
58 | });
59 |
60 | it('should create', () => {
61 | expect(component).toBeTruthy();
62 | });
63 | });
64 |
--------------------------------------------------------------------------------
/src/app/todo-item/todo-item.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
2 | import { TODOItem } from '@app/shared/models/todo-item';
3 |
4 | @Component({
5 | selector: 'app-todo-item',
6 | templateUrl: './todo-item.component.html',
7 | styleUrls: ['./todo-item.component.css']
8 | })
9 | export class TodoItemComponent implements OnInit {
10 |
11 | @Input() public todoItem: TODOItem;
12 | @Input() public readOnlyTODO: boolean;
13 | @Output() public todoDelete = new EventEmitter();
14 | @Output() public todoEdit = new EventEmitter();
15 |
16 | constructor() { }
17 |
18 | ngOnInit() {
19 | }
20 |
21 | public completeClick() {
22 | this.todoItem.completed = !this.todoItem.completed;
23 | }
24 |
25 | public deleteClick() {
26 | this.todoDelete.emit(this.todoItem.id);
27 | }
28 |
29 | public editClick() {
30 | this.todoEdit.emit(this.todoItem);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/app/todo-list-completed/todo-list-completed.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lydemann/angular-spinners-demo/759495995ea503c11b5a3c12adb0686ddd69f85c/src/app/todo-list-completed/todo-list-completed.component.css
--------------------------------------------------------------------------------
/src/app/todo-list-completed/todo-list-completed.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
TODO list
4 |
5 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/app/todo-list-completed/todo-list-completed.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By, BrowserModule } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { TodoListCompletedComponent } from '@app/todo-list-completed/todo-list-completed.component';
7 | import { AppModule } from '@app/app.module';
8 | import { AppComponent } from '@app/app.component';
9 | import { NavbarComponent } from '@app/navbar/navbar.component';
10 | import { TodoListComponent } from '@app/todo-list/todo-list.component';
11 | import { TodoItemComponent } from '@app/todo-item/todo-item.component';
12 | import { FooterComponent } from '@app/footer/footer.component';
13 | import { AddTodoComponent } from '@app/add-todo/add-todo.component';
14 | import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
15 | import { FormsModule } from '@angular/forms';
16 | import { appRouterModule, completedTodoPath } from '@app/app.routes';
17 | import { APP_BASE_HREF } from '@angular/common';
18 | import { TodoListService } from '@app/core/todo-list/todo-list.service';
19 | import { TODOItem } from '@app/shared/models/todo-item';
20 |
21 | describe('TodoListCompletedComponent', () => {
22 | let component: TodoListCompletedComponent;
23 | let fixture: ComponentFixture;
24 |
25 | beforeEach(async(() => {
26 |
27 | const todo1 = new TODOItem('Buy milk', 'Remember to buy milk');
28 | todo1.completed = true;
29 | const todoList = [
30 | todo1,
31 | new TODOItem('Buy flowers', 'Remember to buy flowers'),
32 | ];
33 |
34 | TestBed.configureTestingModule({
35 | declarations: [
36 | AppComponent,
37 | NavbarComponent,
38 | TodoListComponent,
39 | TodoItemComponent,
40 | FooterComponent,
41 | AddTodoComponent,
42 | TodoListCompletedComponent,
43 | ],
44 | imports: [
45 | BrowserModule,
46 | NgbModule.forRoot(),
47 | FormsModule,
48 | appRouterModule
49 | ],
50 | providers: [
51 | {provide: APP_BASE_HREF, useValue : completedTodoPath },
52 | {
53 | provide: TodoListService,
54 | useValue: {
55 | todoList: todoList
56 | }
57 | }
58 | ]
59 | })
60 | .compileComponents();
61 | }));
62 |
63 | beforeEach(() => {
64 | fixture = TestBed.createComponent(TodoListCompletedComponent);
65 | component = fixture.componentInstance;
66 | fixture.detectChanges();
67 | });
68 |
69 | it('should create', () => {
70 | expect(component).toBeTruthy();
71 | });
72 |
73 | it('should have one completed TODO item', () => {
74 | expect(component.todoList.length).toBe(1);
75 | });
76 | });
77 |
--------------------------------------------------------------------------------
/src/app/todo-list-completed/todo-list-completed.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { TodoListService } from '@app/core/todo-list/todo-list.service';
3 |
4 | @Component({
5 | selector: 'app-todo-list-completed',
6 | templateUrl: './todo-list-completed.component.html',
7 | styleUrls: ['./todo-list-completed.component.css']
8 | })
9 | export class TodoListCompletedComponent {
10 |
11 | constructor(private todoListService: TodoListService) { }
12 |
13 | get todoList() {
14 | return this.todoListService.todoList.filter(todo => todo.completed);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/app/todo-list/todo-list.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lydemann/angular-spinners-demo/759495995ea503c11b5a3c12adb0686ddd69f85c/src/app/todo-list/todo-list.component.css
--------------------------------------------------------------------------------
/src/app/todo-list/todo-list.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
TODO list
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/app/todo-list/todo-list.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By, BrowserModule } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { TodoListComponent } from '@app/todo-list/todo-list.component';
7 | import { AppModule } from '@app/app.module';
8 | import { AppComponent } from '@app/app.component';
9 | import { NavbarComponent } from '@app/navbar/navbar.component';
10 | import { TodoItemComponent } from '@app/todo-item/todo-item.component';
11 | import { FooterComponent } from '@app/footer/footer.component';
12 | import { AddTodoComponent } from '@app/add-todo/add-todo.component';
13 | import { TodoListCompletedComponent } from '@app/todo-list-completed/todo-list-completed.component';
14 | import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
15 | import { FormsModule } from '@angular/forms';
16 | import { CoreModule } from '@app/core/core.module';
17 | import { HttpClientModule } from '@angular/common/http';
18 | import { appRouterModule } from '@app/app.routes';
19 | import { APP_BASE_HREF } from '@angular/common';
20 | import { TodoListService } from '@app/core/todo-list/todo-list.service';
21 | import { TODOItem } from '@app/shared/models/todo-item';
22 |
23 | describe('TodoListComponent', () => {
24 | let component: TodoListComponent;
25 | let fixture: ComponentFixture;
26 |
27 | beforeEach(async(() => {
28 |
29 | const todo1 = new TODOItem('Buy milk', 'Remember to buy milk');
30 | todo1.completed = true;
31 | const todoList = [
32 | todo1,
33 | new TODOItem('Buy flowers', 'Remember to buy flowers'),
34 | ];
35 |
36 | TestBed.configureTestingModule({
37 | declarations: [
38 | AppComponent,
39 | NavbarComponent,
40 | TodoListComponent,
41 | TodoItemComponent,
42 | FooterComponent,
43 | AddTodoComponent,
44 | TodoListCompletedComponent,
45 | ],
46 | imports: [
47 | BrowserModule,
48 | NgbModule.forRoot(),
49 | FormsModule,
50 | HttpClientModule,
51 | appRouterModule
52 | ],
53 | providers: [{provide: APP_BASE_HREF, useValue : '/' },
54 | {
55 | provide: TodoListService,
56 | useValue: {todoList: todoList}
57 | }
58 | ]
59 | })
60 | .compileComponents();
61 | }));
62 |
63 | beforeEach(() => {
64 | fixture = TestBed.createComponent(TodoListComponent);
65 | component = fixture.componentInstance;
66 | fixture.detectChanges();
67 | });
68 |
69 | it('should create', () => {
70 | expect(component).toBeTruthy();
71 | });
72 |
73 | it('should have two completed TODO item', () => {
74 | expect(component.todoList.length).toBe(2);
75 | });
76 | });
77 |
--------------------------------------------------------------------------------
/src/app/todo-list/todo-list.component.ts:
--------------------------------------------------------------------------------
1 | import { TODOItem } from '@app/shared/models/todo-item';
2 | import { TodoListService } from '@app/core/todo-list/todo-list.service';
3 | import { Component } from '@angular/core';
4 |
5 | @Component({
6 | selector: 'app-todo-list',
7 | templateUrl: './todo-list.component.html',
8 | styleUrls: ['./todo-list.component.css']
9 | })
10 | export class TodoListComponent {
11 |
12 | currentTODO: TODOItem = new TODOItem('', '');
13 |
14 | constructor(private todoListService: TodoListService) { }
15 |
16 | get todoList() {
17 | return this.todoListService.todoList;
18 | }
19 |
20 | deleteTodo(id: string) {
21 |
22 | const deleteIndex = this.todoListService.todoList.findIndex(todo => todo.id === id);
23 | this.todoListService.todoList.splice(deleteIndex, 1);
24 | }
25 |
26 | editTodo(todoItem: TODOItem) {
27 | this.currentTODO = todoItem;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lydemann/angular-spinners-demo/759495995ea503c11b5a3c12adb0686ddd69f85c/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/lydemann/angular-spinners-demo/759495995ea503c11b5a3c12adb0686ddd69f85c/src/favicon.ico
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SpinnersDemo
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/src/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 | };
--------------------------------------------------------------------------------
/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.scss:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
3 | /* Bootstrap */
4 | @import '~bootstrap/scss/bootstrap';
5 |
6 | @import "styles/spinner";
7 |
8 |
--------------------------------------------------------------------------------
/src/styles/spinner.scss:
--------------------------------------------------------------------------------
1 | #loader {
2 | bottom: 0;
3 | height: 175px;
4 | left: 0;
5 | margin: auto;
6 | position: absolute;
7 | right: 0;
8 | top: 0;
9 | width: 175px;
10 | }
11 |
12 | #loader {
13 | bottom: 0;
14 | height: 175px;
15 | left: 0;
16 | margin: auto;
17 | position: absolute;
18 | right: 0;
19 | top: 0;
20 | width: 175px;
21 | }
22 |
23 | #loader .dot {
24 | bottom: 0;
25 | height: 100%;
26 | left: 0;
27 | margin: auto;
28 | position: absolute;
29 | right: 0;
30 | top: 0;
31 | width: 87.5px;
32 | }
33 |
34 | #loader .dot::before {
35 | border-radius: 100%;
36 | content: "";
37 | height: 87.5px;
38 | left: 0;
39 | position: absolute;
40 | right: 0;
41 | top: 0;
42 | transform: scale(0);
43 | width: 87.5px;
44 | }
45 |
46 | #loader .dot:nth-child(7n+1) {
47 | transform: rotate(45deg);
48 | }
49 |
50 | #loader .dot:nth-child(7n+1)::before {
51 | animation: 0.8s linear 0.1s normal none infinite running load;
52 | background: #00ff80 none repeat scroll 0 0;
53 | }
54 |
55 | #loader .dot:nth-child(7n+2) {
56 | transform: rotate(90deg);
57 | }
58 |
59 | #loader .dot:nth-child(7n+2)::before {
60 | animation: 0.8s linear 0.2s normal none infinite running load;
61 | background: #00ffea none repeat scroll 0 0;
62 | }
63 |
64 | #loader .dot:nth-child(7n+3) {
65 | transform: rotate(135deg);
66 | }
67 |
68 | #loader .dot:nth-child(7n+3)::before {
69 | animation: 0.8s linear 0.3s normal none infinite running load;
70 | background: #00aaff none repeat scroll 0 0;
71 | }
72 |
73 | #loader .dot:nth-child(7n+4) {
74 | transform: rotate(180deg);
75 | }
76 |
77 | #loader .dot:nth-child(7n+4)::before {
78 | animation: 0.8s linear 0.4s normal none infinite running load;
79 | background: #0040ff none repeat scroll 0 0;
80 | }
81 |
82 | #loader .dot:nth-child(7n+5) {
83 | transform: rotate(225deg);
84 | }
85 |
86 | #loader .dot:nth-child(7n+5)::before {
87 | animation: 0.8s linear 0.5s normal none infinite running load;
88 | background: #2a00ff none repeat scroll 0 0;
89 | }
90 |
91 | #loader .dot:nth-child(7n+6) {
92 | transform: rotate(270deg);
93 | }
94 |
95 | #loader .dot:nth-child(7n+6)::before {
96 | animation: 0.8s linear 0.6s normal none infinite running load;
97 | background: #9500ff none repeat scroll 0 0;
98 | }
99 |
100 | #loader .dot:nth-child(7n+7) {
101 | transform: rotate(315deg);
102 | }
103 |
104 | #loader .dot:nth-child(7n+7)::before {
105 | animation: 0.8s linear 0.7s normal none infinite running load;
106 | background: magenta none repeat scroll 0 0;
107 | }
108 |
109 | #loader .dot:nth-child(7n+8) {
110 | transform: rotate(360deg);
111 | }
112 |
113 | #loader .dot:nth-child(7n+8)::before {
114 | animation: 0.8s linear 0.8s normal none infinite running load;
115 | background: #ff0095 none repeat scroll 0 0;
116 | }
117 |
118 | #loader .loading {
119 | background-position: 50% 50%;
120 | background-repeat: no-repeat;
121 | bottom: -40px;
122 | height: 20px;
123 | left: 0;
124 | position: absolute;
125 | right: 0;
126 | width: 180px;
127 | }
128 |
129 | @keyframes load {
130 | 100% {
131 | opacity: 0;
132 | transform: scale(1);
133 | }
134 | }
135 |
136 | @keyframes load {
137 | 100% {
138 | opacity: 0;
139 | transform: scale(1);
140 | }
141 | }
142 |
143 | .spinner-message {
144 | text-align: center;
145 | }
146 |
--------------------------------------------------------------------------------
/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 | "outDir": "./dist/out-tsc",
5 | "sourceMap": true,
6 | "declaration": false,
7 | "module": "es2015",
8 | "baseUrl": "src",
9 | "paths": {
10 | "@app/*": ["app/*"]
11 | },
12 | "moduleResolution": "node",
13 | "emitDecoratorMetadata": true,
14 | "experimentalDecorators": true,
15 | "target": "es5",
16 | "typeRoots": [
17 | "node_modules/@types"
18 | ],
19 | "lib": [
20 | "es2017",
21 | "dom"
22 | ]
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------