diff --git a/.editorconfig b/.editorconfig
index 06dde11..6e87a00 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -9,5 +9,5 @@ insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
-max_line_length = 0
+max_line_length = off
trim_trailing_whitespace = false
diff --git a/.gitignore b/.gitignore
index 7c910e7..ce200cb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,7 @@
/.vscode
.project
.classpath
+.c9/
*.launch
.settings/
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ef0b5dc..be8f0fd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,17 @@
+
+# [1.2.0](https://github.com/TheDonDope/crudular/releases/tag/v1.2.0) (2016-11-26)
+
+[Full Changelog](https://github.com/TheDonDope/crudular/compare/v1.1.0...v1.2.0)
+
+### Features
+
+* **styleguide:** conform to styleguide rules ([d00cfcd](https://github.com/TheDonDope/crudular/commit/d00cfcd7cb815a65e77a5fda86a963c89f6c7ac3))
+* **angular-cli:** update to 1.0.0-beta.21 ([02f5de2](https://github.com/TheDonDope/crudular/commit/02f5de2e4f66b1c009875bc6e1dfc1f14e76796e))
+* **styleguide:** add styleguide document ([0339867](https://github.com/TheDonDope/crudular/commit/03398679c116d1cf9ce2d81fa72d35cc594e8c61))
+* **styleguide:** conform to 02-12 ([bdda04a](https://github.com/TheDonDope/crudular/commit/bdda04ad2ff4886da1482f19aa4d92674cc83066))
+* **angular-cli:** update to 1.0.0-beta.20-4 ([0c61fe5](https://github.com/TheDonDope/crudular/commit/0c61fe51b2940de09772ec4aac2463205cf096a6))
+
+
# [1.1.0](https://github.com/TheDonDope/crudular/releases/tag/v1.1.0) (2016-11-05)
@@ -5,9 +19,9 @@
### Features
-* **angular-cli:** update angular-cli d783393
-* **nginx:** provide nginx prod build f1a5690
-* **docker:** provide docker deployment 4cf1a60
+* **angular-cli:** update angular-cli ([d783393](https://github.com/TheDonDope/crudular/commit/d78339374bd7ac6ab8dcde34bba4b51d6a804628))
+* **nginx:** provide nginx prod build ([f1a5690](https://github.com/TheDonDope/crudular/commit/f1a5690f1f46c26a13f2c5e1e854bd736e89d868))
+* **docker:** provide docker deployment ([4cf1a60](https://github.com/TheDonDope/crudular/commit/4cf1a606e860fbd194c482abcf9e34fe723b1969))
@@ -16,10 +30,9 @@
### Features
-* **jwt:** provide login, home and shared module cb72080
-* **routing:** provide app routing module 57bc688
-* **styling:** configure bootstrap 6449ddd
-* **styling:** configure font-awesome 4c496bc
-
+* **jwt:** provide login, home and shared module ([cb72080](https://github.com/TheDonDope/crudular/commit/cb720805b182865ba7d0accb949206e77a80aacd))
+* **routing:** provide app routing module ([57bc688](https://github.com/TheDonDope/crudular/commit/57bc688e959876f7ecc78bfe84287dd34fefa321))
+* **styling:** configure font-awesome ([4c496bc](https://github.com/TheDonDope/crudular/commit/4c496bcaa6eb6254d44530f4cb692f4c6cfe2031))
+* **styling:** configure bootstrap ([6449ddd](https://github.com/TheDonDope/crudular/commit/6449ddd58200a49be4bcda6b0d260de33ac6cd05))
diff --git a/README.md b/README.md
index e38d6ee..27ca5fa 100644
--- a/README.md
+++ b/README.md
@@ -4,13 +4,13 @@
[![Angular Style Guide](https://mgechev.github.io/angular2-style-guide/images/badge.svg)](https://angular.io/styleguide)
-This project was generated with [angular-cli](https://github.com/angular/angular-cli) version 1.0.0-beta.19-3.
+This project was generated with [angular-cli](https://github.com/angular/angular-cli) version 1.0.0-beta.21.
-It uses the following npm packages (version numbers current as of 2016-10-10):
+It uses the following npm packages (version numbers current as of [2016-11-22](https://xkcd.com/1179/)):
-- [Bootstrap 4.0.0-alpha.4](https://www.npmjs.com/package/bootstrap): Used for the SCSS styling of the application
-- [Font-Awesome 4.6.3](https://www.npmjs.com/package/font-awesome): Used as the glyphicon font of the application
-- [Moment 2.15.1](https://www.npmjs.com/package/moment): Used for date/time manipulation *(Note: The npm package already includes the types for moment so you do not need to add it with `npm install @types/moment --save-dev`)*
+- [Bootstrap 4.0.0-alpha.5](https://www.npmjs.com/package/bootstrap): Used for the SCSS styling of the application
+- [Font-Awesome 4.7.0](https://www.npmjs.com/package/font-awesome): Used as the glyphicon font of the application
+- [Moment 2.17.0](https://www.npmjs.com/package/moment): Used for date/time manipulation *(Note: The npm package already includes the types for moment so you do not need to add it with `npm install @types/moment --save-dev`)*
It follows the [Official Angular Styleguide](https://angular.io/styleguide).
@@ -56,7 +56,7 @@ $ docker-compose build
$ docker-compose up -d
```
-Now open your browser at http://localhost:4200
+Now open your browser at [http://localhost:4200](http://localhost:4200)
### Production build and deployment
@@ -68,7 +68,7 @@ $ docker-compose -f docker-compose.production.yml up crudular-angular # Wait u
$ docker-compose -f docker-compose.production.yml up -d crudular-nginx # Start the nginx container in detached mode
```
-Now open your browser at http://localhost:8080
+Now open your browser at [http://localhost:8080](http://localhost:4200)
## Running unit tests
diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md
new file mode 100644
index 0000000..a931d6c
--- /dev/null
+++ b/STYLEGUIDE.md
@@ -0,0 +1,285 @@
+# Angular Styleguide conformity
+![Angular Styleguide](https://mgechev.github.io/angular2-style-guide/images/badge.svg)
+
+This document tracks the conformity to the different rules of the [Angular Styleguide](https://angular.io/styleguide).
+
+## Table of Contents
+
+1. [1. Single Responsibility](#single-responsibility)
+2. [2. Naming](#naming)
+3. [Coding Conventions](#coding-conventions)
+4. [App Structure](#app-structure)
+5. [Components](#components)
+6. [Directives](#directives)
+7. [Services](#services)
+8. [Data Services](#data-services)
+9. [Lifecycle Hooks](#lifecycle-hooks)
+10. [Appendix](#appendix)
+
+## 1. Single Responsibility
+
+### Rule of One [STYLE 01-01](https://angular.io/styleguide#01-01)
+
+- [X] **Do** define one thing (e.g. service or component) per file.
+- [X] **Consider** limiting files to 400 lines of code.
+
+### Small Functions [STYLE 01-02](https://angular.io/styleguide#01-02)
+
+- [X] **Do** define small functions.
+- [X] **Consider** limiting to no more than 75 lines.
+
+
+## 2. Naming
+
+### General Naming Guidelines [STYLE 02-01](https://angular.io/styleguide#02-01)
+
+- [X] **Do** use consistent names for all symbols.
+- [X] **Do** follow a pattern that describes the symbol's feature then its type. The recommended pattern is `feature.type.ts`.
+
+### Separate File Names with Dots and Dashes [STYLE 02-02](https://angular.io/styleguide#02-02)
+
+- [X] **Do** use dashes to separate words in the descriptive name.
+- [X] **Do** use dots to separate the descriptive name from the type.
+- [X] **Do** use consistent type names for all components following a pattern that describes the component's feature then its type. A recommended pattern is `feature.type.ts`.
+- [X] **Do** use conventional type names including `.service`, `.component`, `.pipe`, `.module`, `.directive`. Invent additional type names if you must but take care not to create too many.
+
+### Symbols and File Names [STYLE 02-03](https://angular.io/styleguide#02-03)
+
+- [X] **Do** use consistent names for all assets named after what they represent.
+- [X] **Do** use upper camel case for class names. Match the name of the symbol to the name of the file.
+- [X] **Do** append the symbol name with the conventional suffix for a thing of that type (e.g., `Component`, `Directive`, `Module`, `Pipe`, `Service`).
+- [X] **Do** give the filename the conventional suffix for a file of that type (e.g., `.component.ts`, `.directive.ts`, `.module.ts`, `.pipe.ts`, `.service.ts`).
+
+### Service Names [STYLE 02-04](https://angular.io/styleguide#02-04)
+
+- [X] **Do** use consistent names for all services named after their feature.
+- [X] **Do** use upper camel case for services.
+- [X] **Do** suffix services with `Service` when it is not clear what they are (e.g. when they are nouns).
+
+### Bootstrapping [STYLE 02-05](https://angular.io/styleguide#02-05)
+
+- [X] **Do** put bootstrapping and platform logic for the app in a file named `main.ts`.
+- [X] **Do** include error handling in the bootstrapping logic.
+- [X] ___Avoid___ putting app logic in the `main.ts`. Instead consider placing it in a component or service.
+
+
+## 3. Coding Conventions
+
+### Classes [STYLE 03-01](https://angular.io/styleguide#03-01)
+
+- [X] **Do** use upper camel case when naming classes.
+
+### Constants [STYLE 03-02](https://angular.io/styleguide#03-02)
+
+- [X] **Do** declare variables with `const` if their values should not change during the application lifetime.
+- [X] **Consider** spelling `const` variables in lower camel case.
+- [X] **Do** tolerate *existing* `const` variables that are spelled in `UPPER_SNAKE_CASE`.
+
+### Interfaces [STYLE 03-03](https://angular.io/styleguide#03-03)
+
+- [X] **Do** name an interface using upper camel case.
+- [X] **Consider** naming an interface without an `I` prefix.
+- [X] **Consider** using a class instead of an interface.
+
+### Properties and Methods [STYLE 03-04](https://angular.io/styleguide#03-04)
+
+- [X] **Do** use lower camel case to name properties and methods.
+- [X] ___Avoid___ prefixing private properties and methods with an underscore.
+
+### Import Line Spacing [STYLE 03-06](https://angular.io/styleguide#03-06)
+
+- [X] **Consider** leaving one empty line between third party imports and application imports.
+- [X] **Consider** listing import lines alphabetized by the module.
+- [X] **Consider** listing destructured imported assets alphabetically.
+
+
+## 4. App Structure
+
+### LIFT [STYLE 04-01](https://angular.io/styleguide#04-01)
+
+- [X] **Do** structure the app such that you can `L`ocate code quickly, `I`dentify the code at a glance, keep the `F`lattest structure you can, and `T`ry to be DRY.
+- [X] **Do** define the structure to follow these four basic guidelines, listed in order of importance.
+
+### Locate [STYLE 04-02](https://angular.io/styleguide#04-02)
+
+- [X] **Do** make locating code intuitive, simple and fast.
+
+### Identify [STYLE 04-03](https://angular.io/styleguide#04-03)
+
+- [X] **Do** name the file such that you instantly know what it contains and represents.
+- [X] **Do** be descriptive with file names and keep the contents of the file to exactly one component.
+- [X] ___Avoid___ files with multiple components, multiple services, or a mixture.
+
+### Flat [STYLE 04-04](https://angular.io/styleguide#04-04)
+
+- [X] **Do** keep a flat folder structure as long as possible.
+- [X] **Consider** creating sub-folders when a folder reaches seven or more files.
+- [X] **Consider** configuring the IDE to hide distracting, irrelevant files such as generated `.js` and `.js.map` files.
+
+### T-DRY (Try to be DRY) [STYLE 04-05](https://angular.io/styleguide#04-05)
+
+- [X] **Do** be DRY (Don't Repeat Yourself)
+- [X] **Avoid** being so DRY that you sacrifice readability.
+
+### Overall Structural Guidelines [STYLE 04-06](https://angular.io/styleguide#04-06)
+
+- [X] **Do** start small but keep in mind where the app is heading down the road.
+- [X] **Do** have a near term view of implementation and a long term vision.
+- [X] **Do** put all of the app's code in a folder named `app`.
+- [X] **Consider** creating a folder for a component when is has multiple accompanying files (`.ts`, `.html`, `.css` and `.spec`).
+
+### Folders-by-Feature Structure [STYLE 04-07](https://angular.io/styleguide#04-07)
+
+- [X] **Do** create folders named for the feature area they represent.
+- [X] **Do** create an Angular module for each feature area.
+
+### App Root Module [STYLE 04-08](https://angular.io/styleguide#04-08)
+
+- [X] **Do** create an Angular module in the app's root folder (e.g., in `/app`).
+- [X] **Consider** naming the root module `app.module.ts`.
+
+### Feature Modules [STYLE 04-09](https://angular.io/styleguide#04-09)
+
+- [X] **Do** create an Angular module for all distinct features in an application (e.g. `Heroes` feature).
+- [X] **Do** place the feature module in the same named folder as the feature area (.e.g `app/heroes`).
+- [X] **Do** name the feature module file reflecting the name of the feature area and folder (e.g. `app/heroes/heroes.module.ts`)
+- [X] **Do** name the feature module symbol reflecting the name of the feature area, folder, and file (e.g. `app/heroes/heroes.module.ts` defines `HeroesModule`)
+
+### Shared Feature Module [STYLE 04-10](https://angular.io/styleguide#04-10)
+
+- [X] **Do** create a feature module named `SharedModule` in a `shared` folder (e.g. `app/shared/shared.module.ts` defines `SharedModule`).
+- [X] **Do** put common components, directives and pipes that will be used throughout the application by other feature modules in the `SharedModule`, where those assets are expected to share a new instance of themselves (not singletons).
+- [X] **Do** import all modules required by the assets in the `SharedModule` (e.g. `CommonModule` and `FormsModule`).
+- [X] **Do** declare all components, directives, and pipes in the `SharedModule`.
+- [X] **Do** export all symbols from the `SharedModule` that other feature modules need to use.
+- [X] ___Avoid___ specifying app-wide singleton providers in a `SharedModule`. Intentional singletons are OK. Take care.
+
+### Core Feature Module [STYLE 04-11](https://angular.io/styleguide#04-11)
+
+- [X] **Do** collect single-use classes and hiding their gory details inside `CoreModule`. A simplified root `AppModule` imports `CoreModule` in its capacity as orchestrator of the application as a whole.
+- [X] **Do** create a feature module named `CoreModule` in a `core` folder (e.g. `app/core/core.module.ts` defines `CoreModule`).
+- [X] **Do** put a singleton service whose instance wil be shared throughout the application in the `CoreModule` (e.g. `ExceptionService` and `LoggerService`).
+- [X] **Do** import all modules required by the assets in the `CoreModule` (e.g. `CommonModule` and `FormsModule`).
+- [X] **Do** gather application-wide, single use components in the `CoreModule`. Import it once (in the `AppModule`) when the app starts and never import it anywhere else. (e.g. `NavComponent` and `SpinnerComponent`).
+- [X] ___Avoid___ importing the `CoreModule` anywhere except in the `AppModule`.
+- [X] **Do** export all symbols that from the `CoreModule` that the `AppModule` will import and make available for other feature modules to use.
+
+### Prevent Reimport of Core Module [STYLE 04-12](https://angular.io/styleguide#04-12)
+
+- [X] **Do** guard against reimporting of `CoreModule` and fail fast by adding guard logic.
+
+### Lazy Loaded Folders [STYLE 04-13](https://angular.io/styleguide#!#04-13)
+
+- [X] **Do** put the contents of lazy loaded features in a *lazy loaded folder*. A typical *lazy loaded folder* contains a *routing component*, its child components, and their related assets and modules.
+
+### Never Directly Import Lazy Loaded Folders [STYLE 04-14](https://angular.io/styleguide#!#04-14)
+
+- [X] ___Avoid___ allowing modules in sibling and parent folders to directly import a module in a *lazy loaded feature*.
+
+
+## 5. Components
+
+### Component Selector Naming [STYLE 05-02](https://angular.io/styleguide#!#05-02)
+
+- [X] **Do** use *dashed-case* or *kebab-case* for naming the element selectors of components.
+
+### Components as Elements [STYLE 05-03](https://angular.io/styleguide#!#05-03)
+
+- [X] **Do** define components as elements via the selector.
+
+### Extract Template and Styles to Their Own Files [STYLE 05-04](https://angular.io/styleguide#!#05-04)
+
+- [X] **Do** extract templates and styles into a separate file, when more than 3 lines.
+- [X] **Do** name the template file `[component-name].component.html`, where `[component-name]` is the component name.
+- [X] **Do** name the style file `[component-name].component.css`, where `[component-name]` is the component name.
+
+### Decorate Input and Output Properties Inline [STYLE 05-12](https://angular.io/styleguide#!#05-12)
+
+- [X] **Do** use `@Input` and `@Output` instead of the inputs and outputs properties of the `@Directive` and `@Component` decorators.
+- [X] **Do** place the `@Input()` or `@Output()` on the same line as the property they decorate.
+
+### Avoid Renaming Inputs and Outputs [STYLE 05-13](https://angular.io/styleguide#!#05-13)
+
+- [X] ___Avoid___ renaming inputs and outputs, when possible.
+
+### Member Sequence [STYLE 05-14](https://angular.io/styleguide#05-14)
+
+- [X] **Do** place properties up top followed by methods.
+- [X] **Do** place private members after public members, alphabetized.
+
+### Put Logic in Services [STYLE 05-15](https://angular.io/styleguide#05-15)
+
+- [X] **Do** limit logic in a component to only that required for the view. All other logic should be delegated to services.
+- [X] **Do** move reusable logic to services and keep components simple and focused on their intended purpose.
+
+### Don't Prefix Output Properties [STYLE 05-16](https://angular.io/styleguide#05-16)
+
+- [X] **Do** name events without the prefix `on`.
+- [X] **Do** name event handler methods with the prefix `on` followed by the event name.
+
+### Put Presentation Logic in the Component Class [STYLE 05-17](https://angular.io/styleguide#!#05-17)
+
+- [X] **Do** put presentation logic in the component class, and not in the template.
+
+
+## 6. Directives
+
+### Use Directives to Enhance an Existing Element [STYLE 06-01](https://angular.io/styleguide#06-01)
+
+- [X] **Do** use attribute directives when you have presentation logic without a template.
+
+### Use HostListener and HostBinding Class Decorators [STYLE 06-03](https://angular.io/styleguide#06-03)
+
+- [X] **Consider** preferring the `@HostListener` and `@HostBinding` to the host property of the `@Directive` and `@Component` decorators.
+- [X] **Do** be consistent in your choice.
+
+
+## 7. Services
+
+### Services are Singletons within an Injector [STYLE 07-01](https://angular.io/styleguide#07-01)
+
+- [X] **Do** use services as singletons within the same injector. Use them for sharing data and functionality.
+
+### Single Responsibility [STYLE 07-02](https://angular.io/styleguide#07-02)
+
+- [X] **Do** create services with a single responsibility that is encapsulated by its context.
+- [X] **Do** create a new service once the service begins to exceed that singular purpose.
+
+### Providing a Service [STYLE 07-03](https://angular.io/styleguide#07-03)
+
+- [X] **Do** provide services to the Angular injector at the top-most component where they will be shared.
+
+### Use the @Injectable() Class Decorator [STYLE 07-04](https://angular.io/styleguide#07-04)
+
+- [X] **Do** use the `@Injectable` class decorator instead of the `@Inject` parameter decorator when using types as tokens for the dependencies of a service.
+
+
+## 8. Data Services
+
+### Separate Data Calls [STYLE 08-01](https://angular.io/styleguide#08-01)
+
+- [X] **Do** refactor logic for making data operations and interacting with data to a service.
+- [X] **Do** make data services responsible for XHR calls, local storage, stashing in memory, or any other data operations.
+
+
+## 9. Lifecycle Hooks
+
+### Implement Lifecycle Hooks Interfaces [STYLE 09-01](https://angular.io/styleguide#09-01)
+
+- [X] **Do** implement the lifecycle hook interfaces.
+
+
+## 10. Appendix
+
+### Codelyzer [STYLE A-01](https://angular.io/styleguide#A-01)
+
+- [X] **Do** use [codelyzer](https://www.npmjs.com/package/codelyzer) to follow this guide.
+- [X] **Consider** adjusting the rules in codelyzer to suit your needs.
+
+### File Templates and Snippets [STYLE A-02](https://angular.io/styleguide#A-02)
+
+- [X] **Do** use file templates or snippets to help follow consistent styles and patterns. Here are templates and/or snippets for some of the web development editors and IDEs.
+- [X] **Consider** using [snippets](https://marketplace.visualstudio.com/items?itemName=johnpapa.Angular2) for [Visual Studio Code](https://code.visualstudio.com/) that follow these styles and guidelines.
+- [X] **Consider** using [snippets](https://atom.io/packages/angular-2-typescript-snippets) for [Atom](https://atom.io/) that follow these styles and guidelines.
+- [X] **Consider** using [snippets](https://github.com/orizens/sublime-angular2-snippets) for [Sublime Text](http://www.sublimetext.com/) that follow these styles and guidelines.
+- [X] **Consider** using [snippets](https://github.com/mhartington/vim-angular2-snippets) for [Vim](http://www.vim.org/) that follow these styles and guidelines.
diff --git a/angular-cli.json b/angular-cli.json
index 69aeb73..e8e05c0 100644
--- a/angular-cli.json
+++ b/angular-cli.json
@@ -1,6 +1,6 @@
{
"project": {
- "version": "1.0.0-beta.19-3",
+ "version": "1.0.0-beta.21",
"name": "crudular"
},
"apps": [
@@ -22,12 +22,7 @@
"../node_modules/bootstrap/scss/bootstrap.scss",
"../node_modules/font-awesome/scss/font-awesome.scss"
],
- "scripts": [
- "../node_modules/jquery/dist/jquery.js",
- "../node_modules/tether/dist/js/tether.js",
- "../node_modules/bootstrap/dist/js/bootstrap.js",
- "../node_modules/moment/moment.js"
- ],
+ "scripts": [],
"environments": {
"source": "environments/environment.ts",
"dev": "environments/environment.ts",
diff --git a/karma.conf.js b/karma.conf.js
index 864bcaf..1f2613a 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -17,6 +17,9 @@ module.exports = function (config) {
preprocessors: {
'./src/test.ts': ['angular-cli']
},
+ mime: {
+ 'text/x-typescript': ['ts','tsx']
+ },
remapIstanbulReporter: {
reports: {
html: 'coverage',
diff --git a/package.json b/package.json
index a2f520a..adddaa6 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "crudular",
- "version": "1.1.0",
+ "version": "1.2.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
@@ -15,28 +15,29 @@
},
"private": true,
"dependencies": {
- "@angular/common": "~2.1.0",
- "@angular/compiler": "~2.1.0",
- "@angular/core": "~2.1.0",
- "@angular/forms": "~2.1.0",
- "@angular/http": "~2.1.0",
- "@angular/platform-browser": "~2.1.0",
- "@angular/platform-browser-dynamic": "~2.1.0",
- "@angular/router": "~3.1.0",
- "bootstrap": "^4.0.0-alpha.4",
+ "@angular/common": "2.2.1",
+ "@angular/compiler": "2.2.1",
+ "@angular/core": "2.2.1",
+ "@angular/forms": "2.2.1",
+ "@angular/http": "2.2.1",
+ "@angular/platform-browser": "2.2.1",
+ "@angular/platform-browser-dynamic": "2.2.1",
+ "@angular/router": "3.2.1",
+ "bootstrap": "^4.0.0-alpha.5",
"core-js": "^2.4.1",
- "font-awesome": "^4.6.3",
- "moment": "^2.15.1",
+ "font-awesome": "^4.7.0",
+ "moment": "^2.17.0",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
},
"devDependencies": {
- "@types/jasmine": "^2.2.30",
+ "@angular/compiler-cli": "2.2.1",
+ "@types/jasmine": "2.5.38",
"@types/node": "^6.0.42",
- "angular-cli": "^1.0.0-beta.19-3",
- "codelyzer": "1.0.0-beta.1",
- "jasmine-core": "2.4.1",
+ "angular-cli": "1.0.0-beta.21",
+ "codelyzer": "~1.0.0-beta.3",
+ "jasmine-core": "2.5.2",
"jasmine-spec-reporter": "2.5.0",
"karma": "1.2.0",
"karma-chrome-launcher": "^2.0.0",
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
new file mode 100644
index 0000000..2da6506
--- /dev/null
+++ b/src/app/app-routing.module.ts
@@ -0,0 +1,11 @@
+import { NgModule } from '@angular/core';
+import { RouterModule } from '@angular/router';
+
+/**
+ * The AppRoutingModule provides all non-feature routes of the application.
+ */
+@NgModule({
+ imports: [RouterModule.forRoot([/* define app non-feature routes here */])],
+ exports: [RouterModule]
+})
+export class AppRoutingModule { }
diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts
index 1e13602..98c4ef4 100644
--- a/src/app/app.component.spec.ts
+++ b/src/app/app.component.spec.ts
@@ -3,7 +3,7 @@
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
-describe('App: Crudular', () => {
+describe('AppComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
@@ -13,21 +13,21 @@ describe('App: Crudular', () => {
});
it('should create the app', async(() => {
- let fixture = TestBed.createComponent(AppComponent);
- let app = fixture.debugElement.componentInstance;
+ const fixture = TestBed.createComponent(AppComponent);
+ const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
- it(`should have as title 'app works!'`, async(() => {
- let fixture = TestBed.createComponent(AppComponent);
- let app = fixture.debugElement.componentInstance;
+ it(`should have as title 'cru works!'`, async(() => {
+ const fixture = TestBed.createComponent(AppComponent);
+ const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('cru works!');
}));
it('should render title in a h1 tag', async(() => {
- let fixture = TestBed.createComponent(AppComponent);
+ const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
- let compiled = fixture.debugElement.nativeElement;
+ const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('cru works!');
}));
});
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index f819bd8..e2c124e 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -2,6 +2,9 @@ import { Component } from '@angular/core';
import { environment } from '../environments/environment';
+/**
+ * This class represents the root component of the application.
+ */
@Component({
selector: 'cru-root',
templateUrl: './app.component.html',
@@ -9,6 +12,10 @@ import { environment } from '../environments/environment';
})
export class AppComponent {
+ /**
+ * Creates an instance of the AppComponent class.
+ * @constructor
+ */
constructor() {
console.log(JSON.stringify(environment));
}
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index a713782..f322270 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -1,16 +1,19 @@
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
-import { RouterModule } from '@angular/router';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
+import { AppRoutingModule } from './app-routing.module';
+import { CoreModule } from './core/core.module';
import { HomeModule } from './home/home.module';
import { LoginModule } from './login/login.module';
import { SharedModule } from './shared/shared.module';
-import { AppRoutingModule } from './app.routing';
+/**
+ * The AppModule provides the root module of the application. It imports all existing feature modules.
+ */
@NgModule({
declarations: [AppComponent],
imports: [
@@ -22,12 +25,14 @@ import { AppRoutingModule } from './app.routing';
HttpModule,
// app.routing
AppRoutingModule,
- // shared/shared.module
- SharedModule,
+ // core/core.module
+ CoreModule,
// home/home.module
HomeModule,
// login/login.module
- LoginModule
+ LoginModule,
+ // shared/shared.module
+ SharedModule
],
providers: [],
bootstrap: [AppComponent]
diff --git a/src/app/app.routing.ts b/src/app/app.routing.ts
deleted file mode 100644
index 2cd4c9a..0000000
--- a/src/app/app.routing.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { NgModule } from '@angular/core';
-import { Routes, RouterModule } from '@angular/router';
-
-import { HomeRoutes } from './home/';
-import { LoginRoutes } from './login/';
-
-const AppRoutes: Routes = [
- ...HomeRoutes,
- ...LoginRoutes
-];
-
-/**
- * This module provides all the routes of the application. Any feature routes are imported through their respective
- * module and added to the `AppRoutes` array.
- */
-@NgModule({
- imports: [RouterModule.forRoot(AppRoutes)],
- exports: [RouterModule],
- providers: []
-})
-export class AppRoutingModule { }
diff --git a/src/app/shared/authentication/authentication.guard.ts b/src/app/core/authentication/authentication.guard.ts
similarity index 60%
rename from src/app/shared/authentication/authentication.guard.ts
rename to src/app/core/authentication/authentication.guard.ts
index 9a8c58c..a3d89dc 100644
--- a/src/app/shared/authentication/authentication.guard.ts
+++ b/src/app/core/authentication/authentication.guard.ts
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
-import { Router, CanActivate } from '@angular/router';
+import { CanActivate, Router } from '@angular/router';
/**
* This class implements a guard for routes that require successful authentication.
@@ -15,11 +15,10 @@ export class AuthenticationGuard implements CanActivate {
constructor(private router: Router) { }
/**
- * To protect routes from being accessible without previous authentication,
- * the `canActivate()` method checks if the LocalStorage contains a
- * `currentUser`, which equates to a user being logged in. Only then the
- * navigation will pass on to the requested route. Otherwise the user will be
- * redirected to the login view.
+ * To protect routes from being accessible without previous authentication, the `canActivate()` method checks if the
+ * LocalStorage contains a `currentUser`, which equates to a user being logged in. Only then the navigation will pass
+ * on to the requested route. Otherwise the user will be redirected to the login view.
+ * @return {boolean} `true` if a user is currently logged in, otherwise `false`.
*/
canActivate() {
if (localStorage.getItem('currentUser')) {
diff --git a/src/app/core/authentication/authentication.module.ts b/src/app/core/authentication/authentication.module.ts
new file mode 100644
index 0000000..6f7e3ec
--- /dev/null
+++ b/src/app/core/authentication/authentication.module.ts
@@ -0,0 +1,23 @@
+import { NgModule, ModuleWithProviders } from '@angular/core';
+
+import { AuthenticationGuard } from './authentication.guard';
+import { AuthenticationService } from './authentication.service';
+
+/**
+ * The AuthenticationModule provides the Authentication guard and Authentication service.
+ */
+@NgModule({ })
+export class AuthenticationModule {
+
+ /**
+ * Returns the wrapped AuthenticationModule also containing the providers.
+ * @return {ModuleWithProviders} The wrapped AuthenticationModule.
+ */
+ static forRoot(): ModuleWithProviders {
+ return {
+ ngModule: AuthenticationModule,
+ providers: [AuthenticationGuard, AuthenticationService]
+ };
+ }
+
+}
diff --git a/src/app/core/authentication/authentication.service.spec.ts b/src/app/core/authentication/authentication.service.spec.ts
new file mode 100644
index 0000000..ee4684b
--- /dev/null
+++ b/src/app/core/authentication/authentication.service.spec.ts
@@ -0,0 +1,17 @@
+/* tslint:disable:no-unused-variable */
+
+import { async, inject, TestBed } from '@angular/core/testing';
+
+import { AuthenticationService } from './authentication.service';
+
+describe('Service: Authentication', () => {
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [AuthenticationService]
+ });
+ });
+
+ it('should ...', inject([AuthenticationService], (service: AuthenticationService) => {
+ expect(service).toBeTruthy();
+ }));
+});
diff --git a/src/app/shared/authentication/authentication.service.ts b/src/app/core/authentication/authentication.service.ts
similarity index 90%
rename from src/app/shared/authentication/authentication.service.ts
rename to src/app/core/authentication/authentication.service.ts
index 765830e..078fde6 100644
--- a/src/app/shared/authentication/authentication.service.ts
+++ b/src/app/core/authentication/authentication.service.ts
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Headers, Http, RequestOptions, Response } from '@angular/http';
import { Observable } from 'rxjs';
-import 'rxjs/add/operator/map'
+import 'rxjs/add/operator/map';
import { environment } from '../../../environments/environment';
@@ -33,10 +33,11 @@ export class AuthenticationService {
* @return {boolean} `true` if the authorisation was successful, otherwise `false`.
*/
login(username: string, password: string): Observable {
- return this.http.post(this.baseUrl + 'users/sign_in.json', JSON.stringify({ user: { email: username, password: password }}), this.getRequestOptions())
+ const userJSON: string = JSON.stringify({ user: { email: username, password: password }});
+ return this.http.post(this.baseUrl + 'users/sign_in.json', userJSON, this.getRequestOptions())
.map((response: Response) => {
// login successful if there's a jwt token in the response
- let token = response.json() && response.json().token;
+ const token = response.json() && response.json().token;
if (token) {
// set token property
this.token = token;
diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts
new file mode 100644
index 0000000..e5a7ee4
--- /dev/null
+++ b/src/app/core/core.module.ts
@@ -0,0 +1,44 @@
+import { CommonModule } from '@angular/common';
+import { NgModule, Optional, SkipSelf } from '@angular/core';
+import { RouterModule } from '@angular/router';
+
+import { AuthenticationModule } from './authentication/authentication.module';
+import { LoggingService } from './logging/logging.service';
+import { NavigationModule } from './navigation/navigation.module';
+import { throwIfAlreadyLoaded } from './module-import.guard';
+
+/**
+ * The CoreModule provides all single-use components and singleton services of the application.
+ */
+@NgModule({
+ imports: [
+ // @angular/common
+ CommonModule,
+ // @angular/router
+ RouterModule,
+ // authentication/authentication.module
+ AuthenticationModule.forRoot(),
+ // navigation/navigation.module
+ NavigationModule
+ ],
+ exports: [
+ // authentication/authentication.module
+ AuthenticationModule,
+ // navigation/navigation.module
+ NavigationModule
+ ],
+ declarations: [],
+ providers: [LoggingService]
+})
+export class CoreModule {
+
+ /**
+ * Do guard against reimporting of CoreModule and fail fast by adding guard logic.
+ * @param {CoreModule} parentModule - the parent Module.
+ * @constructor
+ */
+ constructor( @Optional() @SkipSelf() parentModule: CoreModule) {
+ throwIfAlreadyLoaded(parentModule, 'CoreModule');
+ }
+
+}
diff --git a/src/app/core/logging/logging.service.spec.ts b/src/app/core/logging/logging.service.spec.ts
new file mode 100644
index 0000000..73c0699
--- /dev/null
+++ b/src/app/core/logging/logging.service.spec.ts
@@ -0,0 +1,17 @@
+/* tslint:disable:no-unused-variable */
+
+import { async, inject, TestBed } from '@angular/core/testing';
+
+import { LoggingService } from './logging.service';
+
+describe('Service: Logging', () => {
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [LoggingService]
+ });
+ });
+
+ it('should ...', inject([LoggingService], (service: LoggingService) => {
+ expect(service).toBeTruthy();
+ }));
+});
diff --git a/src/app/core/logging/logging.service.ts b/src/app/core/logging/logging.service.ts
new file mode 100644
index 0000000..ad56ba4
--- /dev/null
+++ b/src/app/core/logging/logging.service.ts
@@ -0,0 +1,14 @@
+import { Injectable } from '@angular/core';
+
+@Injectable()
+export class LoggingService {
+
+ log(msg: string) {
+ console.log(msg);
+ }
+
+ error(msg: string) {
+ console.error(msg);
+ }
+
+}
diff --git a/src/app/core/module-import.guard.ts b/src/app/core/module-import.guard.ts
new file mode 100644
index 0000000..445640c
--- /dev/null
+++ b/src/app/core/module-import.guard.ts
@@ -0,0 +1,5 @@
+export function throwIfAlreadyLoaded(parentModule: any, moduleName: string) {
+ if (parentModule) {
+ throw new Error(`${moduleName} has already been loaded. Import Core modules in the AppModule only.`);
+ }
+}
diff --git a/src/app/shared/navigation/navigation.component.html b/src/app/core/navigation/navigation.component.html
similarity index 100%
rename from src/app/shared/navigation/navigation.component.html
rename to src/app/core/navigation/navigation.component.html
diff --git a/src/app/shared/navigation/navigation.component.scss b/src/app/core/navigation/navigation.component.scss
similarity index 100%
rename from src/app/shared/navigation/navigation.component.scss
rename to src/app/core/navigation/navigation.component.scss
diff --git a/src/app/core/navigation/navigation.component.spec.ts b/src/app/core/navigation/navigation.component.spec.ts
new file mode 100644
index 0000000..bfe9656
--- /dev/null
+++ b/src/app/core/navigation/navigation.component.spec.ts
@@ -0,0 +1,29 @@
+/* tslint:disable:no-unused-variable */
+
+import { DebugElement } from '@angular/core';
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { By } from '@angular/platform-browser';
+
+import { NavigationComponent } from './navigation.component';
+
+describe('NavigationComponent', () => {
+ let component: NavigationComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ NavigationComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(NavigationComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/shared/navigation/navigation.component.ts b/src/app/core/navigation/navigation.component.ts
similarity index 76%
rename from src/app/shared/navigation/navigation.component.ts
rename to src/app/core/navigation/navigation.component.ts
index 4c0469c..6096baf 100644
--- a/src/app/shared/navigation/navigation.component.ts
+++ b/src/app/core/navigation/navigation.component.ts
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
-import { AuthenticationService } from '../authentication/';
+import { AuthenticationService } from '../authentication/authentication.service';
/**
* This class represents the navigation bar component.
@@ -14,13 +14,15 @@ export class NavigationComponent implements OnInit {
/**
* Creates a new NavigationComponent with the injected AuthenticationService.
- * @param {AuthenticationService} authorisationService - The injected AuthenticationService.
+ * @param {AuthenticationService} authenticationService - The injected AuthenticationService.
* @constructor
*/
constructor(private authenticationService: AuthenticationService) { }
- ngOnInit() {
- }
+ /**
+ * Lifecycle hook which is called after the component has initialized.
+ */
+ ngOnInit() { }
/**
* Returns if a user is currently logged in.
diff --git a/src/app/shared/navigation/navigation.module.ts b/src/app/core/navigation/navigation.module.ts
similarity index 86%
rename from src/app/shared/navigation/navigation.module.ts
rename to src/app/core/navigation/navigation.module.ts
index ffd9782..d59c7ee 100644
--- a/src/app/shared/navigation/navigation.module.ts
+++ b/src/app/core/navigation/navigation.module.ts
@@ -3,8 +3,7 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AuthenticationModule } from '../authentication/authentication.module';
-
-import { NavigationComponent } from './index';
+import { NavigationComponent } from './navigation.component';
@NgModule({
imports: [CommonModule, RouterModule, AuthenticationModule.forRoot()],
diff --git a/src/app/home/home-routing.module.ts b/src/app/home/home-routing.module.ts
new file mode 100644
index 0000000..7083761
--- /dev/null
+++ b/src/app/home/home-routing.module.ts
@@ -0,0 +1,18 @@
+import { NgModule } from '@angular/core';
+import { RouterModule } from '@angular/router';
+
+import { AuthenticationGuard } from '../core/authentication/authentication.guard';
+import { HomeComponent } from './home.component';
+
+/**
+ * The HomeRoutingModule provides the routes for the Home module.
+ */
+@NgModule({
+ imports: [
+ RouterModule.forChild([
+ { path: '', component: HomeComponent, canActivate: [AuthenticationGuard] }
+ ])
+ ],
+ exports: [RouterModule]
+})
+export class HomeRoutingModule { }
diff --git a/src/app/home/home.component.spec.ts b/src/app/home/home.component.spec.ts
index e7eae4d..3c85b78 100644
--- a/src/app/home/home.component.spec.ts
+++ b/src/app/home/home.component.spec.ts
@@ -1,11 +1,29 @@
/* tslint:disable:no-unused-variable */
-import { TestBed, async } from '@angular/core/testing';
+import { DebugElement } from '@angular/core';
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { By } from '@angular/platform-browser';
+
import { HomeComponent } from './home.component';
-describe('Component: Home', () => {
- it('should create an instance', () => {
- let component = new HomeComponent();
+describe('HomeComponent', () => {
+ let component: HomeComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ HomeComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(HomeComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
expect(component).toBeTruthy();
});
});
diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts
index 2a9c765..b789386 100644
--- a/src/app/home/home.component.ts
+++ b/src/app/home/home.component.ts
@@ -1,9 +1,9 @@
import { Component, OnInit } from '@angular/core';
-import { AuthenticationService } from '../shared/';
+import { AuthenticationService } from '../core/authentication/authentication.service';
/**
- * This class represents the lazy loaded HomeComponent.
+ * This class provides the Home component of the application.
*/
@Component({
selector: 'cru-home',
@@ -24,7 +24,7 @@ export class HomeComponent implements OnInit {
constructor(private authenticationService: AuthenticationService) { }
/**
- * Initialises the component.
+ * Lifecycle hook which is called after the component has initialized.
*/
ngOnInit() {
this.currentUser = JSON.parse(this.authenticationService.getCurrentUser());
diff --git a/src/app/home/home.module.ts b/src/app/home/home.module.ts
index 0f0e35e..8f1840f 100644
--- a/src/app/home/home.module.ts
+++ b/src/app/home/home.module.ts
@@ -2,10 +2,14 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { SharedModule } from '../shared/shared.module';
-import { HomeComponent } from './index';
+import { HomeRoutingModule } from './home-routing.module';
+import { HomeComponent } from './home.component';
+/**
+ * The LoginModule provides the Home component of the application.
+ */
@NgModule({
- imports: [CommonModule, SharedModule],
+ imports: [CommonModule, HomeRoutingModule, SharedModule],
declarations: [HomeComponent],
exports: [HomeComponent]
})
diff --git a/src/app/home/home.routing.ts b/src/app/home/home.routing.ts
deleted file mode 100644
index 870db93..0000000
--- a/src/app/home/home.routing.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Routes } from '@angular/router';
-
-import { AuthenticationGuard } from '../shared/';
-import { HomeComponent } from './home.component';
-
-export const HomeRoutes: Routes = [
- { path: '', component: HomeComponent, canActivate: [AuthenticationGuard] }
-];
diff --git a/src/app/home/index.ts b/src/app/home/index.ts
deleted file mode 100644
index b8072e7..0000000
--- a/src/app/home/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './home.component';
-export * from './home.routing';
diff --git a/src/app/index.ts b/src/app/index.ts
index 875bdb2..f42e29d 100644
--- a/src/app/index.ts
+++ b/src/app/index.ts
@@ -1,2 +1,5 @@
+/**
+ * This barrel file provides the exports for the App component and App module.
+ */
export * from './app.component';
export * from './app.module';
diff --git a/src/app/login/index.ts b/src/app/login/index.ts
deleted file mode 100644
index 892f85c..0000000
--- a/src/app/login/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './login.component';
-export * from './login.routing';
diff --git a/src/app/login/login-routing.module.ts b/src/app/login/login-routing.module.ts
new file mode 100644
index 0000000..4f1a592
--- /dev/null
+++ b/src/app/login/login-routing.module.ts
@@ -0,0 +1,17 @@
+import { NgModule } from '@angular/core';
+import { RouterModule } from '@angular/router';
+
+import { LoginComponent } from './login.component';
+
+/**
+ * The LoginRoutingModule provides the routes for the Login module.
+ */
+@NgModule({
+ imports: [
+ RouterModule.forChild([
+ { path: 'login', component: LoginComponent }
+ ])
+ ],
+ exports: [RouterModule]
+})
+export class LoginRoutingModule { }
diff --git a/src/app/login/login.component.spec.ts b/src/app/login/login.component.spec.ts
index d7ef9dc..384f06e 100644
--- a/src/app/login/login.component.spec.ts
+++ b/src/app/login/login.component.spec.ts
@@ -1,11 +1,29 @@
/* tslint:disable:no-unused-variable */
-import { TestBed, async } from '@angular/core/testing';
+import { DebugElement } from '@angular/core';
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { By } from '@angular/platform-browser';
+
import { LoginComponent } from './login.component';
-describe('Component: Login', () => {
- it('should create an instance', () => {
- let component = new LoginComponent();
+describe('LoginComponent', () => {
+ let component: LoginComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ LoginComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(LoginComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
expect(component).toBeTruthy();
});
});
diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts
index 96d19c9..e77eca2 100644
--- a/src/app/login/login.component.ts
+++ b/src/app/login/login.component.ts
@@ -1,10 +1,10 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
-import { AuthenticationService } from '../shared/';
+import { AuthenticationService } from '../core/authentication/authentication.service';
/**
- * This class represents the lazy loaded LoginComponent.
+ * This class provides the Login component of the application.
*/
@Component({
selector: 'cru-login',
@@ -26,7 +26,7 @@ export class LoginComponent implements OnInit {
constructor(private router: Router, private authenticationService: AuthenticationService) { }
/**
- * Initialises the component and resets the login status.
+ * Lifecycle hook which is called after the component has initialized.
*/
ngOnInit() {
this.authenticationService.logout();
@@ -40,7 +40,7 @@ export class LoginComponent implements OnInit {
this.authenticationService.login(this.user.username, this.user.password)
.subscribe(result => {
if (result === true) {
- this.router.navigate(['/']);
+ this.router.navigate(['']);
} else {
this.error = 'Username or password is incorrect';
this.loading = false;
diff --git a/src/app/login/login.module.ts b/src/app/login/login.module.ts
index 7dcec74..8d38a30 100644
--- a/src/app/login/login.module.ts
+++ b/src/app/login/login.module.ts
@@ -2,10 +2,14 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { SharedModule } from '../shared/shared.module';
-import { LoginComponent } from './index';
+import { LoginRoutingModule } from './login-routing.module';
+import { LoginComponent } from './login.component';
+/**
+ * The LoginModule provides the Login component of the application.
+ */
@NgModule({
- imports: [CommonModule, SharedModule],
+ imports: [CommonModule, LoginRoutingModule, SharedModule],
declarations: [LoginComponent],
exports: [LoginComponent]
})
diff --git a/src/app/login/login.routing.ts b/src/app/login/login.routing.ts
deleted file mode 100644
index ab20829..0000000
--- a/src/app/login/login.routing.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Routes } from '@angular/router';
-
-import { LoginComponent } from './login.component';
-
-export const LoginRoutes: Routes = [
- { path: 'login', component: LoginComponent }
-];
diff --git a/src/app/shared/authentication/authentication.module.ts b/src/app/shared/authentication/authentication.module.ts
deleted file mode 100644
index de28f2c..0000000
--- a/src/app/shared/authentication/authentication.module.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import { NgModule, ModuleWithProviders } from '@angular/core';
-
-import { AuthenticationGuard, AuthenticationService } from './index';
-
-/**
- * Do not specify providers for modules that might be imported by a lazy loaded module.
- */
-@NgModule({ })
-export class AuthenticationModule {
-
- static forRoot(): ModuleWithProviders {
- return {
- ngModule: AuthenticationModule,
- providers: [
- AuthenticationGuard, AuthenticationService
- ]
- };
- }
-
-}
diff --git a/src/app/shared/authentication/index.ts b/src/app/shared/authentication/index.ts
deleted file mode 100644
index ff53bf5..0000000
--- a/src/app/shared/authentication/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './authentication.guard';
-export * from './authentication.service';
diff --git a/src/app/shared/index.ts b/src/app/shared/index.ts
deleted file mode 100644
index 7d6c550..0000000
--- a/src/app/shared/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './authentication/';
-export * from './navigation/';
diff --git a/src/app/shared/navigation/index.ts b/src/app/shared/navigation/index.ts
deleted file mode 100644
index e7cdd0a..0000000
--- a/src/app/shared/navigation/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './navigation.component';
diff --git a/src/app/shared/navigation/navigation.component.spec.ts b/src/app/shared/navigation/navigation.component.spec.ts
deleted file mode 100644
index e8a26a2..0000000
--- a/src/app/shared/navigation/navigation.component.spec.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-/* tslint:disable:no-unused-variable */
-
-import { TestBed, async } from '@angular/core/testing';
-import { NavigationComponent } from './navigation.component';
-
-describe('Component: Navigation', () => {
- it('should create an instance', () => {
- let component = new NavigationComponent();
- expect(component).toBeTruthy();
- });
-});
diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts
index 46b86ab..f0ef25a 100644
--- a/src/app/shared/shared.module.ts
+++ b/src/app/shared/shared.module.ts
@@ -1,21 +1,19 @@
import { CommonModule } from '@angular/common';
-import { NgModule, ModuleWithProviders } from '@angular/core';
+import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
-import { AuthenticationModule } from './authentication/authentication.module';
-import { NavigationModule } from './navigation/navigation.module';
-
+/**
+ * The SharedModule provides all shared components, directives and pipes of the application.
+ */
@NgModule({
imports: [
// @angular/common
CommonModule,
+ // @angular/forms
+ FormsModule,
// @angular/router
- RouterModule,
- // authentication/authentication.module
- AuthenticationModule.forRoot(),
- // navigation/navigation.module
- NavigationModule
+ RouterModule
],
exports: [
// @angular/common
@@ -23,9 +21,7 @@ import { NavigationModule } from './navigation/navigation.module';
// @angular/forms
FormsModule,
// @angular/router
- RouterModule,
- // navigation/navigation.module
- NavigationModule
+ RouterModule
]
})
export class SharedModule { }
diff --git a/src/main.ts b/src/main.ts
index 5c3c520..c19ee64 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,7 +1,7 @@
import './polyfills.ts';
-import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
+import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { environment } from './environments/environment';
import { AppModule } from './app/';
diff --git a/src/test.ts b/src/test.ts
index 7727c8e..ae22663 100644
--- a/src/test.ts
+++ b/src/test.ts
@@ -6,6 +6,11 @@ import 'zone.js/dist/sync-test';
import 'zone.js/dist/jasmine-patch';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
+import { getTestBed } from '@angular/core/testing';
+import {
+ BrowserDynamicTestingModule,
+ platformBrowserDynamicTesting
+} from '@angular/platform-browser-dynamic/testing';
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
declare var __karma__: any;
@@ -14,21 +19,14 @@ declare var require: any;
// Prevent Karma from running prematurely.
__karma__.loaded = function () {};
-
-Promise.all([
- System.import('@angular/core/testing'),
- System.import('@angular/platform-browser-dynamic/testing')
-])
- // First, initialize the Angular testing environment.
- .then(([testing, testingBrowser]) => {
- testing.getTestBed().initTestEnvironment(
- testingBrowser.BrowserDynamicTestingModule,
- testingBrowser.platformBrowserDynamicTesting()
- );
- })
- // Then we find all the tests.
- .then(() => require.context('./', true, /\.spec\.ts/))
- // And load the modules.
- .then(context => context.keys().map(context))
- // Finally, start Karma to run the tests.
- .then(__karma__.start, __karma__.error);
+// First, initialize the Angular testing environment.
+getTestBed().initTestEnvironment(
+ BrowserDynamicTestingModule,
+ platformBrowserDynamicTesting()
+);
+// Then we find all the tests.
+const context = require.context('./', true, /\.spec\.ts/);
+// And load the modules.
+context.keys().map(context);
+// Finally, start Karma to run the tests.
+__karma__.start();
diff --git a/src/tsconfig.json b/src/tsconfig.json
index 9b4c84c..1cf713a 100644
--- a/src/tsconfig.json
+++ b/src/tsconfig.json
@@ -1,5 +1,6 @@
{
"compilerOptions": {
+ "baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
diff --git a/src/typings.d.ts b/src/typings.d.ts
index ed687ab..ea52695 100644
--- a/src/typings.d.ts
+++ b/src/typings.d.ts
@@ -1,4 +1,2 @@
// Typings reference file, you can add your own global typings here
// https://www.typescriptlang.org/docs/handbook/writing-declaration-files.html
-
-declare var System: any;