├── src
├── assets
│ └── .gitkeep
├── app
│ ├── app.component.scss
│ ├── form
│ │ ├── form.component.scss
│ │ ├── form.component.html
│ │ ├── recent-submissions
│ │ │ ├── recent-submissions.component.scss
│ │ │ ├── recent-submissions.component.html
│ │ │ ├── recent-submissions.component.spec.ts
│ │ │ └── recent-submissions.component.ts
│ │ ├── form.module.spec.ts
│ │ ├── new-submission
│ │ │ ├── new-submission.component.scss
│ │ │ ├── new-submission.component.html
│ │ │ ├── new-submission.component.ts
│ │ │ └── new-submission.component.spec.ts
│ │ ├── form.component.ts
│ │ ├── form-routing.module.ts
│ │ ├── form.component.spec.ts
│ │ └── form.module.ts
│ ├── admin
│ │ ├── admin.component.scss
│ │ ├── dashboard
│ │ │ ├── dashboard.component.scss
│ │ │ ├── dashboard.component.html
│ │ │ ├── dashboard.component.ts
│ │ │ └── dashboard.component.spec.ts
│ │ ├── admin.component.html
│ │ ├── admin.module.spec.ts
│ │ ├── admin.component.ts
│ │ ├── admin.module.ts
│ │ ├── admin.component.spec.ts
│ │ └── admin-routing.module.ts
│ ├── core
│ │ ├── login
│ │ │ ├── login.component.scss
│ │ │ ├── login.component.html
│ │ │ ├── login.component.ts
│ │ │ └── login.component.spec.ts
│ │ ├── not-found
│ │ │ ├── not-found.component.scss
│ │ │ ├── not-found.component.html
│ │ │ ├── not-found.component.ts
│ │ │ └── not-found.component.spec.ts
│ │ ├── header
│ │ │ ├── header.component.scss
│ │ │ ├── header.component.ts
│ │ │ ├── header.component.spec.ts
│ │ │ └── header.component.html
│ │ ├── core.module.spec.ts
│ │ ├── services
│ │ │ ├── auth-guard.service.spec.ts
│ │ │ ├── api-interceptor.service.spec.ts
│ │ │ ├── authentication.service.spec.ts
│ │ │ ├── api-interceptor.service.ts
│ │ │ ├── auth-guard.service.ts
│ │ │ └── authentication.service.ts
│ │ ├── core.module.ts
│ │ └── core-routing.module.ts
│ ├── app.component.html
│ ├── shared
│ │ ├── directives
│ │ │ ├── required-label.directive.spec.ts
│ │ │ └── required-label.directive.ts
│ │ ├── shared.module.spec.ts
│ │ └── shared.module.ts
│ ├── app.component.ts
│ ├── app.component.spec.ts
│ └── app.module.ts
├── favicon.ico
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── typings.d.ts
├── styles.scss
├── tsconfig.app.json
├── index.html
├── main.ts
├── tsconfig.spec.json
├── test.ts
└── polyfills.ts
├── e2e
├── app.e2e-spec.ts
├── app.po.ts
└── tsconfig.e2e.json
├── .editorconfig
├── tsconfig.json
├── .gitignore
├── protractor.conf.js
├── karma.conf.js
├── package.json
├── tslint.json
├── README.md
└── angular.json
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/app.component.scss:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/form/form.component.scss:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/admin/admin.component.scss:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/core/login/login.component.scss:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/admin/dashboard/dashboard.component.scss:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/core/not-found/not-found.component.scss:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/admin/admin.component.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/app/core/not-found/not-found.component.html:
--------------------------------------------------------------------------------
1 |
2 | not-found works!
3 |
4 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zaarheed/angular6-starter-multi-module/HEAD/src/favicon.ico
--------------------------------------------------------------------------------
/src/app/form/form.component.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true,
3 | apiBasePath: 'localhost:4201'
4 | };
5 |
--------------------------------------------------------------------------------
/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/src/app/form/recent-submissions/recent-submissions.component.scss:
--------------------------------------------------------------------------------
1 | table, th, td {
2 | border: 1px solid black;
3 | margin-top: 15px;
4 | padding: 5px;
5 | }
--------------------------------------------------------------------------------
/src/app/shared/directives/required-label.directive.spec.ts:
--------------------------------------------------------------------------------
1 | import { RequiredLabelDirective } from './required-label.directive';
2 |
3 | describe('RequiredLabelDirective', () => {
4 |
5 | });
6 |
--------------------------------------------------------------------------------
/src/styles.scss:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 | body {
3 | margin: 0;
4 | padding: 0;
5 | font-family: Verdana, Geneva, Tahoma, sans-serif;
6 | }
--------------------------------------------------------------------------------
/src/app/admin/dashboard/dashboard.component.html:
--------------------------------------------------------------------------------
1 |
2 | Welcome to the Admin dashboard!
3 |
4 |
5 | The Authentication Guard in the Core Module will only allow you access this route if you have logged in.
6 |
--------------------------------------------------------------------------------
/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AppPage } from './app.po';
2 |
3 | describe('angular6-starter-multi-module App', () => {
4 | let page: AppPage;
5 |
6 | beforeEach(() => {
7 | page = new AppPage();
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/src/app/core/header/header.component.scss:
--------------------------------------------------------------------------------
1 | div#header {
2 | width: 100%;
3 | background: #5d5d5d;
4 | padding: 15px;
5 | color: #ffffff;
6 |
7 | a {
8 | color: #ffffff;
9 | text-decoration: underline;
10 | margin-left: 7px;
11 | }
12 | }
--------------------------------------------------------------------------------
/src/app/core/core.module.spec.ts:
--------------------------------------------------------------------------------
1 | import { CoreModule } from './core.module';
2 |
3 | describe('CoreModule', () => {
4 | let coreModule: CoreModule;
5 |
6 | beforeEach(() => {
7 | coreModule = new CoreModule();
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/src/app/form/form.module.spec.ts:
--------------------------------------------------------------------------------
1 | import { FormModule } from './form.module';
2 |
3 | describe('FormModule', () => {
4 | let formModule: FormModule;
5 |
6 | beforeEach(() => {
7 | formModule = new FormModule();
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/src/app/admin/admin.module.spec.ts:
--------------------------------------------------------------------------------
1 | import { AdminModule } from './admin.module';
2 |
3 | describe('AdminModule', () => {
4 | let adminModule: AdminModule;
5 |
6 | beforeEach(() => {
7 | adminModule = new AdminModule();
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/e2e/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 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.scss']
7 | })
8 | export class AppComponent {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/app/shared/shared.module.spec.ts:
--------------------------------------------------------------------------------
1 | import { SharedModule } from './shared.module';
2 |
3 | describe('SharedModule', () => {
4 | let sharedModule: SharedModule;
5 |
6 | beforeEach(() => {
7 | sharedModule = new SharedModule();
8 | });
9 | });
10 |
--------------------------------------------------------------------------------
/src/app/form/new-submission/new-submission.component.scss:
--------------------------------------------------------------------------------
1 | form {
2 | margin-top: 15px;
3 | }
4 |
5 | label.required:before {
6 | content: "*";
7 | color: red;
8 | font-weight: 700;
9 | font-size: 20px;
10 | vertical-align: top;
11 | line-height: 1;
12 | }
--------------------------------------------------------------------------------
/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "baseUrl": "./",
6 | "module": "es2015",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "target": "es5",
8 | "types": [
9 | "jasmine",
10 | "jasminewd2",
11 | "node"
12 | ]
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/app/form/recent-submissions/recent-submissions.component.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | | Name |
4 | Email |
5 |
6 |
7 | | {{submission.name}} |
8 | {{submission.email}} |
9 |
10 |
--------------------------------------------------------------------------------
/src/app/form/form.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-form',
5 | templateUrl: './form.component.html',
6 | styleUrls: ['./form.component.scss']
7 | })
8 | export class FormComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/admin/admin.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-admin',
5 | templateUrl: './admin.component.html',
6 | styleUrls: ['./admin.component.scss']
7 | })
8 | export class AdminComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/core/services/auth-guard.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { AuthGuardService } from './auth-guard.service';
4 |
5 | describe('AuthGuardService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [AuthGuardService]
9 | });
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/src/app/admin/dashboard/dashboard.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-dashboard',
5 | templateUrl: './dashboard.component.html',
6 | styleUrls: ['./dashboard.component.scss']
7 | })
8 | export class DashboardComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Angular6StarterMultiModule
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/app/form/new-submission/new-submission.component.html:
--------------------------------------------------------------------------------
1 |
14 |
--------------------------------------------------------------------------------
/src/app/core/services/api-interceptor.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { ApiInterceptorService } from './api-interceptor.service';
4 |
5 | describe('ApiInterceptorService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [ApiInterceptorService]
9 | });
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/src/app/core/services/authentication.service.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, inject } from '@angular/core/testing';
2 |
3 | import { AuthenticationService } from './authentication.service';
4 |
5 | describe('AuthenticationService', () => {
6 | beforeEach(() => {
7 | TestBed.configureTestingModule({
8 | providers: [AuthenticationService]
9 | });
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/src/app/core/not-found/not-found.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-not-found',
5 | templateUrl: './not-found.component.html',
6 | styleUrls: ['./not-found.component.scss']
7 | })
8 | export class NotFoundComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/shared/directives/required-label.directive.ts:
--------------------------------------------------------------------------------
1 | import { Directive, ElementRef, Renderer2 } from '@angular/core';
2 |
3 | @Directive({
4 | selector: '[requiredLabel]'
5 | })
6 | export class RequiredLabelDirective {
7 |
8 | constructor(private element: ElementRef, private renderer: Renderer2) {
9 | this.renderer.addClass(this.element.nativeElement, "required");
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { AppComponent } from './app.component';
3 | describe('AppComponent', () => {
4 | beforeEach(async(() => {
5 | TestBed.configureTestingModule({
6 | declarations: [
7 | AppComponent
8 | ],
9 | }).compileComponents();
10 | }));
11 |
12 |
13 | });
14 |
--------------------------------------------------------------------------------
/src/app/form/form-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 | import { FormComponent } from './form.component';
4 |
5 | const routes: Routes = [
6 | { path: '', component: FormComponent }
7 | ];
8 |
9 | @NgModule({
10 | imports: [RouterModule.forChild(routes)],
11 | exports: [RouterModule]
12 | })
13 | export class FormRoutingModule { }
14 |
--------------------------------------------------------------------------------
/src/app/form/new-submission/new-submission.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-new-submission',
5 | templateUrl: './new-submission.component.html',
6 | styleUrls: ['./new-submission.component.scss']
7 | })
8 | export class NewSubmissionComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/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/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // The file contents for the current environment will overwrite these during build.
2 | // The build system defaults to the dev environment which uses `environment.ts`, but if you do
3 | // `ng build --env=prod` then `environment.prod.ts` will be used instead.
4 | // The list of which env maps to which file can be found in `.angular-cli.json`.
5 |
6 | export const environment = {
7 | production: false
8 | };
9 |
--------------------------------------------------------------------------------
/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "baseUrl": "./",
6 | "module": "commonjs",
7 | "target": "es5",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "files": [
14 | "test.ts",
15 | "polyfills.ts"
16 | ],
17 | "include": [
18 | "**/*.spec.ts",
19 | "**/*.d.ts"
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/src/app/shared/shared.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 | import { RequiredLabelDirective } from './directives/required-label.directive';
4 |
5 | @NgModule({
6 | imports: [
7 | CommonModule
8 | ],
9 | declarations: [RequiredLabelDirective],
10 | exports: [
11 | RequiredLabelDirective
12 | ]
13 | })
14 | export class SharedModule { }
15 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "outDir": "./dist/out-tsc",
5 | "sourceMap": true,
6 | "declaration": false,
7 | "moduleResolution": "node",
8 | "emitDecoratorMetadata": true,
9 | "experimentalDecorators": true,
10 | "target": "es5",
11 | "typeRoots": [
12 | "node_modules/@types"
13 | ],
14 | "lib": [
15 | "es2017",
16 | "dom"
17 | ]
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 |
4 | import { AppComponent } from './app.component';
5 | import { CoreModule } from './core/core.module';
6 |
7 | @NgModule({
8 | declarations: [
9 | AppComponent
10 | ],
11 | imports: [
12 | BrowserModule,
13 | CoreModule
14 | ],
15 | providers: [],
16 | bootstrap: [AppComponent]
17 | })
18 | export class AppModule { }
19 |
--------------------------------------------------------------------------------
/src/app/core/login/login.component.html:
--------------------------------------------------------------------------------
1 |
9 |
--------------------------------------------------------------------------------
/src/app/admin/admin.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 | import { AdminRoutingModule } from './admin-routing.module';
5 | import { AdminComponent } from './admin.component';
6 | import { DashboardComponent } from './dashboard/dashboard.component';
7 |
8 | @NgModule({
9 | imports: [
10 | CommonModule,
11 | AdminRoutingModule
12 | ],
13 | declarations: [AdminComponent, DashboardComponent]
14 | })
15 | export class AdminModule { }
16 |
--------------------------------------------------------------------------------
/src/app/core/header/header.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { AuthenticationService } from '../services/authentication.service';
3 |
4 | @Component({
5 | selector: 'app-header',
6 | templateUrl: './header.component.html',
7 | styleUrls: ['./header.component.scss']
8 | })
9 | export class HeaderComponent implements OnInit {
10 |
11 | constructor(private authentication: AuthenticationService) { }
12 |
13 | ngOnInit() {
14 | }
15 |
16 | logout() {
17 | this.authentication.logout();
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/app/admin/admin.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { AdminComponent } from './admin.component';
4 |
5 | describe('AdminComponent', () => {
6 | let component: AdminComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [AdminComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(AdminComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/src/app/core/login/login.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { AuthenticationService } from '../services/authentication.service';
3 | import { Router } from '@angular/router';
4 |
5 | @Component({
6 | selector: 'app-login',
7 | templateUrl: './login.component.html',
8 | styleUrls: ['./login.component.scss']
9 | })
10 | export class LoginComponent implements OnInit {
11 |
12 | constructor(private authentication: AuthenticationService, private router: Router) { }
13 |
14 | ngOnInit() {
15 | }
16 |
17 | login(username, password) {
18 | this.authentication.login(username, password);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/app/admin/dashboard/dashboard.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { DashboardComponent } from './dashboard.component';
4 |
5 | describe('DashboardComponent', () => {
6 | let component: DashboardComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [DashboardComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(DashboardComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/src/app/admin/admin-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 | import { AdminComponent } from './admin.component';
4 | import { DashboardComponent } from './dashboard/dashboard.component';
5 |
6 | const routes: Routes = [
7 | {
8 | path: '',
9 | redirectTo: 'dashboard',
10 | pathMatch: 'full'
11 | },
12 | {
13 | path: 'dashboard',
14 | component: AdminComponent,
15 | children: [
16 | { path: '', component: DashboardComponent }
17 | ]
18 | }
19 | ];
20 |
21 | @NgModule({
22 | imports: [RouterModule.forChild(routes)],
23 | exports: [RouterModule]
24 | })
25 | export class AdminRoutingModule { }
26 |
--------------------------------------------------------------------------------
/src/app/form/form.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { FormComponent } from './form.component';
4 |
5 | describe('FormComponent', () => {
6 | let component: FormComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [FormComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(FormComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/.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 | testem.log
34 | /typings
35 |
36 | # e2e
37 | /e2e/*.js
38 | /e2e/*.map
39 |
40 | # System Files
41 | .DS_Store
42 | Thumbs.db
43 |
--------------------------------------------------------------------------------
/src/app/core/login/login.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { LoginComponent } from './login.component';
4 |
5 | describe('LoginComponent', () => {
6 | let component: LoginComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [LoginComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(LoginComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/src/app/core/header/header.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { HeaderComponent } from './header.component';
4 |
5 | describe('HeaderComponent', () => {
6 | let component: HeaderComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [HeaderComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(HeaderComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/src/app/core/not-found/not-found.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { NotFoundComponent } from './not-found.component';
4 |
5 | describe('NotFoundComponent', () => {
6 | let component: NotFoundComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [NotFoundComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(NotFoundComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/src/app/form/form.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 | import { FormRoutingModule } from './form-routing.module';
5 | import { FormComponent } from './form.component';
6 | import { RecentSubmissionsComponent } from './recent-submissions/recent-submissions.component';
7 | import { NewSubmissionComponent } from './new-submission/new-submission.component';
8 | import { SharedModule } from '../shared/shared.module';
9 |
10 | @NgModule({
11 | imports: [
12 | CommonModule,
13 | FormRoutingModule,
14 | SharedModule
15 | ],
16 | declarations: [FormComponent, RecentSubmissionsComponent, NewSubmissionComponent]
17 | })
18 | export class FormModule { }
19 |
--------------------------------------------------------------------------------
/src/app/core/services/api-interceptor.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable, Injector } from '@angular/core';
2 | import { Router } from '@angular/router';
3 | import { HttpHandler, HttpRequest, HttpEvent, HttpResponse, HttpErrorResponse, HttpInterceptor } from "@angular/common/http";
4 | import { Observable } from 'rxjs/Rx';
5 | import { environment } from '../../../environments/environment';
6 | import { AuthenticationService } from './authentication.service';
7 |
8 | @Injectable()
9 | export class ApiInterceptorService {
10 |
11 | constructor(private injector: Injector, private router: Router) { }
12 |
13 | intercept(request: HttpRequest, next: HttpHandler): Observable> {
14 | return next.handle(request);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/app/core/header/header.component.html:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/src/app/form/new-submission/new-submission.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { NewSubmissionComponent } from './new-submission.component';
4 |
5 | describe('NewSubmissionComponent', () => {
6 | let component: NewSubmissionComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [NewSubmissionComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(NewSubmissionComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | });
23 |
--------------------------------------------------------------------------------
/src/app/form/recent-submissions/recent-submissions.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { RecentSubmissionsComponent } from './recent-submissions.component';
4 |
5 | describe('RecentSubmissionsComponent', () => {
6 | let component: RecentSubmissionsComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [RecentSubmissionsComponent]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(RecentSubmissionsComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/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 | './e2e/**/*.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: 'e2e/tsconfig.e2e.json'
25 | });
26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/src/app/core/core.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 |
4 | import { CoreRoutingModule } from './core-routing.module';
5 | import { LoginComponent } from './login/login.component';
6 | import { HeaderComponent } from './header/header.component';
7 | import { NotFoundComponent } from './not-found/not-found.component';
8 | import { RouterModule } from '@angular/router';
9 | import { AuthenticationService } from './services/authentication.service';
10 | import { AuthGuardService } from './services/auth-guard.service';
11 |
12 | @NgModule({
13 | imports: [
14 | CommonModule,
15 | CoreRoutingModule
16 | ],
17 | declarations: [LoginComponent, HeaderComponent, NotFoundComponent],
18 | exports: [
19 | RouterModule,
20 | HeaderComponent
21 | ],
22 | providers: [
23 | AuthenticationService,
24 | AuthGuardService
25 | ]
26 | })
27 | export class CoreModule { }
28 |
--------------------------------------------------------------------------------
/src/app/form/recent-submissions/recent-submissions.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-recent-submissions',
5 | templateUrl: './recent-submissions.component.html',
6 | styleUrls: ['./recent-submissions.component.scss']
7 | })
8 | export class RecentSubmissionsComponent implements OnInit {
9 | submissions: Array<{}>;
10 |
11 | constructor() { }
12 |
13 | ngOnInit() {
14 | this.initSubmissions();
15 | }
16 |
17 | initSubmissions() {
18 | this.submissions = [
19 | { name: 'John', email: 'john@angular6-starter-multi-module.com' },
20 | { name: 'Samantha', email: 'sam@angular6-starter-multi-module.com' },
21 | { name: 'Cassandra', email: 'cass@angular6-starter-multi-module.com' },
22 | { name: 'Taylor', email: 'taylor@angular6-starter-multi-module.com' },
23 | { name: 'Fatima', email: 'fatima@angular6-starter-multi-module.com' }
24 | ]
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/app/core/services/auth-guard.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { AuthenticationService } from './authentication.service';
3 | import { Router } from '@angular/router';
4 |
5 | @Injectable()
6 | export class AuthGuardService {
7 |
8 | constructor(private authentication: AuthenticationService, private router: Router) { }
9 |
10 | canActivate(): boolean | Promise {
11 | let token = this.authentication.getToken();
12 | let accessToken = this.authentication.getAccessToken();
13 |
14 | if (!token) {
15 | console.error("User is not authenticated.");
16 | this.redirectToLoginPage();
17 | return false;
18 | }
19 | else if (this.authentication.isAuthenticated()) {
20 | return true;
21 | }
22 | else {
23 | this.authentication.refreshToken();
24 | return true;
25 | }
26 | }
27 |
28 | redirectToLoginPage() {
29 | this.router.navigate(['/login']);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/app/core/core-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { Routes, RouterModule } from '@angular/router';
3 | import { NotFoundComponent } from './not-found/not-found.component';
4 | import { AuthGuardService } from './services/auth-guard.service';
5 | import { LoginComponent } from './login/login.component';
6 |
7 | const routes: Routes = [
8 | {
9 | path: '',
10 | redirectTo: 'form',
11 | pathMatch: 'full'
12 | },
13 | {
14 | path: 'login',
15 | component: LoginComponent
16 | },
17 | {
18 | path: 'admin',
19 | canActivate: [AuthGuardService],
20 | loadChildren: '../admin/admin.module#AdminModule'
21 | },
22 | {
23 | path: 'form',
24 | loadChildren: '../form/form.module#FormModule'
25 | },
26 | {
27 | path: '**',
28 | component: NotFoundComponent
29 | }
30 | ];
31 |
32 | @NgModule({
33 | imports: [RouterModule.forRoot(routes)],
34 | exports: [RouterModule]
35 | })
36 | export class CoreRoutingModule { }
37 |
--------------------------------------------------------------------------------
/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'), reports: [ 'html', 'lcovonly' ],
20 | fixWebpackSourcePaths: true
21 | },
22 |
23 | reporters: ['progress', 'kjhtml'],
24 | port: 9876,
25 | colors: true,
26 | logLevel: config.LOG_INFO,
27 | autoWatch: true,
28 | browsers: ['Chrome'],
29 | singleRun: false
30 | });
31 | };
32 |
--------------------------------------------------------------------------------
/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/long-stack-trace-zone';
4 | import 'zone.js/dist/proxy.js';
5 | import 'zone.js/dist/sync-test';
6 | import 'zone.js/dist/jasmine-patch';
7 | import 'zone.js/dist/async-test';
8 | import 'zone.js/dist/fake-async-test';
9 | import { getTestBed } from '@angular/core/testing';
10 | import {
11 | BrowserDynamicTestingModule,
12 | platformBrowserDynamicTesting
13 | } from '@angular/platform-browser-dynamic/testing';
14 |
15 | // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
16 | declare const __karma__: any;
17 | declare const require: any;
18 |
19 | // Prevent Karma from running prematurely.
20 | __karma__.loaded = function () { };
21 |
22 | // First, initialize the Angular testing environment.
23 | getTestBed().initTestEnvironment(
24 | BrowserDynamicTestingModule,
25 | platformBrowserDynamicTesting()
26 | );
27 | // Then we find all the tests.
28 | const context = require.context('./', true, /\.spec\.ts$/);
29 | // And load the modules.
30 | context.keys().map(context);
31 | // Finally, start Karma to run the tests.
32 | __karma__.start();
33 |
--------------------------------------------------------------------------------
/src/app/core/services/authentication.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core';
2 | import { Router } from '@angular/router';
3 |
4 | @Injectable()
5 | export class AuthenticationService {
6 | token = {
7 | refresh_token: 'refreshtokencode',
8 | exp: new Date((new Date().getDate() + 1)),
9 | access_token: {
10 | username: 'user',
11 | roles: ['Admin', 'RegisteredUser', 'Super User']
12 | }
13 | };
14 |
15 | tokenKey: string = "a6smm_utoken"
16 |
17 | constructor(private router: Router) { }
18 |
19 | login(username, password) {
20 | this.setToken(this.token);
21 | this.router.navigate(['admin', 'dashboard']);
22 | }
23 |
24 | logout() {
25 | this.removeToken();
26 | this.router.navigate(['login']);
27 | }
28 |
29 | getToken() {
30 | return JSON.parse(localStorage.getItem(this.tokenKey));
31 | }
32 |
33 | setToken(token) {
34 | localStorage.setItem(this.tokenKey, JSON.stringify(token));
35 | }
36 |
37 | getAccessToken() {
38 | return JSON.parse(localStorage.getItem(this.tokenKey))['access_token'];
39 | }
40 |
41 | isAuthenticated() {
42 | let token = localStorage.getItem(this.tokenKey);
43 |
44 | if (token) {
45 | return true;
46 | }
47 | else {
48 | return false;
49 | }
50 | }
51 |
52 | refreshToken() {
53 | this.token.exp = new Date((new Date().getDate() + 1));
54 | this.setToken(this.token);
55 | }
56 |
57 | removeToken() {
58 | localStorage.removeItem(this.tokenKey);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular6-starter-multi-module",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "start": "ng serve",
8 | "build": "ng build",
9 | "test": "ng test",
10 | "lint": "ng lint",
11 | "e2e": "ng e2e"
12 | },
13 | "private": true,
14 | "dependencies": {
15 | "@angular/animations": "^6.0.6",
16 | "@angular/common": "^6.0.6",
17 | "@angular/compiler": "^6.0.6",
18 | "@angular/core": "^6.0.6",
19 | "@angular/forms": "^6.0.6",
20 | "@angular/http": "^6.0.6",
21 | "@angular/platform-browser": "^6.0.6",
22 | "@angular/platform-browser-dynamic": "^6.0.6",
23 | "@angular/platform-server": "^6.0.6",
24 | "@angular/router": "^6.0.6",
25 | "angular-cli-ghpages": "^0.5.3",
26 | "core-js": "^2.4.1",
27 | "rxjs": "^6.2.1",
28 | "rxjs-compat": "^6.0.0-rc.0",
29 | "zone.js": "^0.8.26"
30 | },
31 | "devDependencies": {
32 | "@angular-devkit/build-angular": "~0.6.8",
33 | "@angular/cli": "^6.0.8",
34 | "@angular/compiler-cli": "^6.0.6",
35 | "@angular/language-service": "^6.0.6",
36 | "@types/jasmine": "~2.5.53",
37 | "@types/jasminewd2": "~2.0.2",
38 | "@types/node": "~6.0.60",
39 | "codelyzer": "^4.3.0",
40 | "jasmine-core": "~2.6.2",
41 | "jasmine-spec-reporter": "~4.1.0",
42 | "karma": "~1.7.0",
43 | "karma-chrome-launcher": "~2.1.1",
44 | "karma-cli": "~1.0.1",
45 | "karma-coverage-istanbul-reporter": "^1.2.1",
46 | "karma-jasmine": "~1.1.0",
47 | "karma-jasmine-html-reporter": "^0.2.2",
48 | "protractor": "~5.1.2",
49 | "ts-node": "~3.2.0",
50 | "tslint": "~5.7.0",
51 | "typescript": "2.7.2"
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/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 | * Required to support Web Animations `@angular/platform-browser/animations`.
51 | * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
52 | **/
53 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
54 |
55 |
56 |
57 | /***************************************************************************************************
58 | * Zone JS is required by Angular itself.
59 | */
60 | import 'zone.js/dist/zone'; // Included with Angular CLI.
61 |
62 |
63 |
64 | /***************************************************************************************************
65 | * APPLICATION IMPORTS
66 | */
67 |
68 | /**
69 | * Date, currency, decimal and percent pipes.
70 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
71 | */
72 | // import 'intl'; // Run `npm install --save intl`.
73 | /**
74 | * Need to import at least one locale-data with intl.
75 | */
76 | // import 'intl/locale-data/jsonp/en';
77 |
--------------------------------------------------------------------------------
/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 | "eofline": true,
15 | "forin": true,
16 | "import-blacklist": [
17 | true,
18 | "rxjs/Rx"
19 | ],
20 | "import-spacing": true,
21 | "indent": [
22 | true,
23 | "spaces"
24 | ],
25 | "interface-over-type-literal": true,
26 | "label-position": true,
27 | "max-line-length": [
28 | true,
29 | 140
30 | ],
31 | "member-access": false,
32 | "member-ordering": [
33 | true,
34 | {
35 | "order": [
36 | "static-field",
37 | "instance-field",
38 | "static-method",
39 | "instance-method"
40 | ]
41 | }
42 | ],
43 | "no-arg": true,
44 | "no-bitwise": true,
45 | "no-console": [
46 | true,
47 | "debug",
48 | "info",
49 | "time",
50 | "timeEnd",
51 | "trace"
52 | ],
53 | "no-construct": true,
54 | "no-debugger": true,
55 | "no-duplicate-super": true,
56 | "no-empty": false,
57 | "no-empty-interface": true,
58 | "no-eval": true,
59 | "no-inferrable-types": [
60 | true,
61 | "ignore-params"
62 | ],
63 | "no-misused-new": true,
64 | "no-non-null-assertion": true,
65 | "no-shadowed-variable": true,
66 | "no-string-literal": false,
67 | "no-string-throw": true,
68 | "no-switch-case-fall-through": true,
69 | "no-trailing-whitespace": true,
70 | "no-unnecessary-initializer": true,
71 | "no-unused-expression": true,
72 | "no-use-before-declare": true,
73 | "no-var-keyword": true,
74 | "object-literal-sort-keys": false,
75 | "one-line": [
76 | true,
77 | "check-open-brace",
78 | "check-catch",
79 | "check-else",
80 | "check-whitespace"
81 | ],
82 | "prefer-const": true,
83 | "quotemark": [
84 | true,
85 | "single"
86 | ],
87 | "radix": true,
88 | "semicolon": [
89 | true,
90 | "always"
91 | ],
92 | "triple-equals": [
93 | true,
94 | "allow-null-check"
95 | ],
96 | "typedef-whitespace": [
97 | true,
98 | {
99 | "call-signature": "nospace",
100 | "index-signature": "nospace",
101 | "parameter": "nospace",
102 | "property-declaration": "nospace",
103 | "variable-declaration": "nospace"
104 | }
105 | ],
106 | "typeof-compare": true,
107 | "unified-signatures": true,
108 | "variable-name": false,
109 | "whitespace": [
110 | true,
111 | "check-branch",
112 | "check-decl",
113 | "check-operator",
114 | "check-separator",
115 | "check-type"
116 | ],
117 | "directive-selector": [
118 | true,
119 | "attribute",
120 | "app",
121 | "camelCase"
122 | ],
123 | "component-selector": [
124 | true,
125 | "element",
126 | "app",
127 | "kebab-case"
128 | ],
129 | "use-input-property-decorator": true,
130 | "use-output-property-decorator": true,
131 | "use-host-property-decorator": true,
132 | "no-input-rename": true,
133 | "no-output-rename": true,
134 | "use-life-cycle-interface": true,
135 | "use-pipe-transform-interface": true,
136 | "component-class-suffix": true,
137 | "directive-class-suffix": true,
138 | "invoke-injectable": true
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Angular 6 Starter (Multi-module)
2 |
3 | A starter template for Angular 6 applications with multiple modules.
4 |
5 | ## Requirements
6 |
7 | - Angular CLI v6.0.8
8 | - Angular v6.0.6
9 | - Typescript v2.9.1
10 |
11 | # Demo
12 | View a demo of the application [here](https://zaarheed.github.io/angular6-starter-multi-module).
13 |
14 | You can run a local demo by cloning this repo, running `npm install`, `ng serve` and then pointing your browser to `http://localhost:4200`.
15 |
16 | # Documentation
17 | Read more about the architecture [here](https://www.technouz.com/4644/angular-5-app-structure-multiple-modules/).
18 |
19 | # Angular 5
20 | This is a copy, and improvement, of my [Angular 5 Multi Module Starter](https://github.com/zaarheed/angular5-starter-multi-module).
21 |
22 | ### FormModule
23 | The `FormModule` represents a publicly accessible module which is lazy-loaded when the application is executed. There is no authorization required to view any of the pages or components within the `FormModule`. In a real-world application, the `FormModule` can be replaced with the core of the website which can be accessed by anyone - such as the homepage.
24 |
25 | ### CoreModule
26 | The `CoreModule` drives the Angular application. It handles the API HTTP Interceptor, Authentication Guard and Authentication Service. In addition, the `CoreModule` holds the Login component, not-found component and the global Header component.
27 |
28 | #### HeaderComponent
29 |
30 | The `HeaderComponent` independently determines the route from the URL, and the permissions set in the User Authentication token, and then appropriately displays the links in the navigation bar.
31 |
32 | ### AdminModule
33 |
34 | The `AdminModule` represents a privately accessible module which is lazy-loaded only upon successful user authentication via the `LoginComponent` and `AuthenticationService` in the `CoreModule`. In a real-world application the `AdminModule` would be the registered-user dasboard. In this demo, you can use any username and password to login.
35 |
36 | ### SharedModule
37 |
38 | The `SharedModule` contains directives and components which may be used across multiple modules and areas of the application. A good example is the `RequiredLabelDirective` which adds an asterisk to an input label. This directive can be used all over the application including the `FormComponent` and `LoginComponent` which are in the `FormModule` and `CoreModule` respectively.
39 |
40 | For a more detailed explanation on the architectural decisions made in this design, [read this article](https://www.technouz.com/4644/angular-5-app-structure-multiple-modules/).
41 |
42 | # Features
43 | - Multi-module architecture using Angular CLI conventions
44 | - Core module, Shared module, 1x public module, 1x private module
45 | - HTTP/API interceptor example
46 | - Authentication guard example
47 | - Shared directive example
48 |
49 | The steps below will allow you to upgrade any projects based from this starter template:
50 |
51 | 1. Switch from `HttpModule` and the `Http` service to `HttpClientModule` and the `HttpClient` service.
52 |
53 | 2. Make sure you are using Node 8 or later.
54 |
55 | 3. Update your Angular CLI globally and locally, and migrate the configuration to the new `angular.json` format by running the following:
56 |
57 | ```
58 | npm install -g @angular/cli
59 | npm install @angular/cli
60 | ng update @angular/cli
61 | ```
62 |
63 | 4. Update all of your Angular framework packages to v6, and the correct version of RxJS and TypeScript.
64 |
65 | ```
66 | ng update @angular/core
67 | ````
68 |
69 | 5. Use `ng update` or your normal package manager tools to identify and update other dependencies.
70 |
71 | # Updating the demo
72 | 1. Install angular-cli-ghpages by running the command `npm install -g angular-cli-ghpages`
73 | 2. Build the Angular app and set the base-href by running the command: `ng build --prod --base-href "https://zaarheed.github.io/angular6-starter-multi-module"`
74 | 3. Deploy to GitHub.io by running the `angular-cli-ghpages` tool (shorthand: `ngh`)
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "angular6-starter-multi-module": {
7 | "root": "",
8 | "sourceRoot": "src",
9 | "projectType": "application",
10 | "architect": {
11 | "build": {
12 | "builder": "@angular-devkit/build-angular:browser",
13 | "options": {
14 | "outputPath": "dist",
15 | "index": "src/index.html",
16 | "main": "src/main.ts",
17 | "tsConfig": "src/tsconfig.app.json",
18 | "polyfills": "src/polyfills.ts",
19 | "assets": [
20 | "src/assets",
21 | "src/favicon.ico"
22 | ],
23 | "styles": [
24 | "src/styles.scss"
25 | ],
26 | "scripts": []
27 | },
28 | "configurations": {
29 | "production": {
30 | "optimization": true,
31 | "outputHashing": "all",
32 | "sourceMap": false,
33 | "extractCss": true,
34 | "namedChunks": false,
35 | "aot": true,
36 | "extractLicenses": true,
37 | "vendorChunk": false,
38 | "buildOptimizer": true,
39 | "fileReplacements": [
40 | {
41 | "replace": "src/environments/environment.ts",
42 | "with": "src/environments/environment.prod.ts"
43 | }
44 | ]
45 | }
46 | }
47 | },
48 | "serve": {
49 | "builder": "@angular-devkit/build-angular:dev-server",
50 | "options": {
51 | "browserTarget": "angular6-starter-multi-module:build"
52 | },
53 | "configurations": {
54 | "production": {
55 | "browserTarget": "angular6-starter-multi-module:build:production"
56 | }
57 | }
58 | },
59 | "extract-i18n": {
60 | "builder": "@angular-devkit/build-angular:extract-i18n",
61 | "options": {
62 | "browserTarget": "angular6-starter-multi-module:build"
63 | }
64 | },
65 | "test": {
66 | "builder": "@angular-devkit/build-angular:karma",
67 | "options": {
68 | "main": "src/test.ts",
69 | "karmaConfig": "./karma.conf.js",
70 | "polyfills": "src/polyfills.ts",
71 | "tsConfig": "src/tsconfig.spec.json",
72 | "scripts": [],
73 | "styles": [
74 | "src/styles.scss"
75 | ],
76 | "assets": [
77 | "src/assets",
78 | "src/favicon.ico"
79 | ]
80 | }
81 | },
82 | "lint": {
83 | "builder": "@angular-devkit/build-angular:tslint",
84 | "options": {
85 | "tsConfig": [
86 | "src/tsconfig.app.json",
87 | "src/tsconfig.spec.json"
88 | ],
89 | "exclude": [
90 | "**/node_modules/**"
91 | ]
92 | }
93 | }
94 | }
95 | },
96 | "angular6-starter-multi-module-e2e": {
97 | "root": "",
98 | "sourceRoot": "e2e",
99 | "projectType": "application",
100 | "architect": {
101 | "e2e": {
102 | "builder": "@angular-devkit/build-angular:protractor",
103 | "options": {
104 | "protractorConfig": "./protractor.conf.js",
105 | "devServerTarget": "angular6-starter-multi-module:serve"
106 | }
107 | },
108 | "lint": {
109 | "builder": "@angular-devkit/build-angular:tslint",
110 | "options": {
111 | "tsConfig": [
112 | "e2e/tsconfig.e2e.json"
113 | ],
114 | "exclude": [
115 | "**/node_modules/**"
116 | ]
117 | }
118 | }
119 | }
120 | }
121 | },
122 | "defaultProject": "angular6-starter-multi-module",
123 | "schematics": {
124 | "@schematics/angular:component": {
125 | "prefix": "app",
126 | "styleext": "scss"
127 | },
128 | "@schematics/angular:directive": {
129 | "prefix": "app"
130 | }
131 | }
132 | }
--------------------------------------------------------------------------------