├── src
├── assets
│ ├── .gitkeep
│ └── img
│ │ ├── desktop.ini
│ │ ├── boat_01.jpeg
│ │ ├── boat_02.jpeg
│ │ ├── boat_03.jpeg
│ │ ├── boat_04.jpeg
│ │ ├── boat_05.jpeg
│ │ ├── camping_04.jpg
│ │ ├── camping_06.jpg
│ │ ├── camping_01.jpeg
│ │ ├── camping_02.jpeg
│ │ ├── camping_03.jpeg
│ │ ├── camping_05.jpeg
│ │ ├── camping_07.jpeg
│ │ ├── library_01.jpeg
│ │ ├── library_02.jpeg
│ │ ├── library_03.jpeg
│ │ ├── library_04.jpeg
│ │ └── library_05.jpeg
├── app
│ ├── image
│ │ ├── image.component.css
│ │ ├── image.component.html
│ │ ├── image.component.ts
│ │ ├── image-detail.component.html
│ │ ├── shared
│ │ │ ├── filter.pipe.ts
│ │ │ └── image.service.ts
│ │ ├── image-detail.component.css
│ │ ├── image-detail.component.ts
│ │ └── image.component.spec.ts
│ ├── app.component.html
│ ├── app.component.css
│ ├── app.component.ts
│ ├── gallery
│ │ ├── gallery.component.css
│ │ ├── gallery.component.ts
│ │ ├── gallery.component.spec.ts
│ │ └── gallery.component.html
│ ├── navbar
│ │ ├── navbar.component.css
│ │ ├── navbar.component.ts
│ │ ├── navbar.component.html
│ │ └── navbar.component.spec.ts
│ ├── app.component.spec.ts
│ └── app.module.ts
├── favicon.ico
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── typings.d.ts
├── tsconfig.app.json
├── styles.css
├── main.ts
├── tsconfig.spec.json
├── routes.ts
├── index.html
├── test.ts
└── polyfills.ts
├── e2e
├── tsconfig.e2e.json
├── app.po.ts
└── app.e2e-spec.ts
├── .editorconfig
├── server.js
├── tsconfig.json
├── README.md
├── .gitignore
├── protractor.conf.js
├── LICENSE
├── .angular-cli.json
├── karma.conf.js
├── package.json
└── tslint.json
/src/assets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/image/image.component.css:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/app/image/image.component.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/assets/img/desktop.ini:
--------------------------------------------------------------------------------
1 | [ViewState]
2 | Mode=
3 | Vid=
4 | FolderType=Pictures
5 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/favicon.ico
--------------------------------------------------------------------------------
/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/src/assets/img/boat_01.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/boat_01.jpeg
--------------------------------------------------------------------------------
/src/assets/img/boat_02.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/boat_02.jpeg
--------------------------------------------------------------------------------
/src/assets/img/boat_03.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/boat_03.jpeg
--------------------------------------------------------------------------------
/src/assets/img/boat_04.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/boat_04.jpeg
--------------------------------------------------------------------------------
/src/assets/img/boat_05.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/boat_05.jpeg
--------------------------------------------------------------------------------
/src/assets/img/camping_04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/camping_04.jpg
--------------------------------------------------------------------------------
/src/assets/img/camping_06.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/camping_06.jpg
--------------------------------------------------------------------------------
/src/assets/img/camping_01.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/camping_01.jpeg
--------------------------------------------------------------------------------
/src/assets/img/camping_02.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/camping_02.jpeg
--------------------------------------------------------------------------------
/src/assets/img/camping_03.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/camping_03.jpeg
--------------------------------------------------------------------------------
/src/assets/img/camping_05.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/camping_05.jpeg
--------------------------------------------------------------------------------
/src/assets/img/camping_07.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/camping_07.jpeg
--------------------------------------------------------------------------------
/src/assets/img/library_01.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/library_01.jpeg
--------------------------------------------------------------------------------
/src/assets/img/library_02.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/library_02.jpeg
--------------------------------------------------------------------------------
/src/assets/img/library_03.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/library_03.jpeg
--------------------------------------------------------------------------------
/src/assets/img/library_04.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/library_04.jpeg
--------------------------------------------------------------------------------
/src/assets/img/library_05.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesdoyle/ng-gallery/HEAD/src/assets/img/library_05.jpeg
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/src/typings.d.ts:
--------------------------------------------------------------------------------
1 | /* SystemJS module definition */
2 | declare var module: NodeModule;
3 | interface NodeModule {
4 | id: string;
5 | }
6 |
--------------------------------------------------------------------------------
/src/app/app.component.css:
--------------------------------------------------------------------------------
1 | body{
2 | background: rgb(68,0,163);
3 | background: linear-gradient(to bottom, rgba(68,0,163,1) 1%,rgba(27,35,63,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
4 | }
5 |
--------------------------------------------------------------------------------
/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/e2e",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "types": [
8 | "jasmine",
9 | "node"
10 | ]
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, by, element } from 'protractor';
2 |
3 | export class GalleryPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/app",
5 | "module": "es2015",
6 | "baseUrl": "",
7 | "types": []
8 | },
9 | "exclude": [
10 | "test.ts",
11 | "**/*.spec.ts"
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/src/styles.css:
--------------------------------------------------------------------------------
1 | body{
2 | font-family: 'Lato', sans-serif;
3 | color: #ccc;
4 | background-color: #efefef;
5 | }
6 |
7 | .main-content{
8 | padding-top: 60px;
9 | color: #333;
10 | }
11 |
12 | h1 h2 h3 h4 h5{
13 | font-family: 'Monteserrat', sans-serif;
14 | color: #333;
15 | }
16 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { ImageService } from './image/shared/image.service';
3 |
4 | @Component({
5 | selector: 'app-root',
6 | templateUrl: './app.component.html',
7 | styleUrls: ['./app.component.css']
8 | })
9 | export class AppComponent {
10 | title = 'Photo Gallery';
11 | }
12 |
--------------------------------------------------------------------------------
/src/app/image/image.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-image',
5 | templateUrl: './image.component.html',
6 | styleUrls: ['./image.component.css']
7 | })
8 | export class ImageComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/server.js:
--------------------------------------------------------------------------------
1 | const express = require('express');
2 | const app = express();
3 | app.use(express.static(__dirname + '/dist'));
4 | app.listen(process.env.PORT || 8080);
5 | const path = require('path');
6 | app.get('/*', function(req, res){
7 | res.sendFile(path.join(__dirname + '/dist/index.html'));
8 | });
9 | console.log('Server listening on port 8080');
10 |
11 |
--------------------------------------------------------------------------------
/src/app/gallery/gallery.component.css:
--------------------------------------------------------------------------------
1 | ul { padding:0; width:1200px; margin:20px auto}
2 | li { display:inline;}
3 | .tn{
4 | margin:6px 6px;
5 | border: 4px solid #eee;
6 | box-shadow:#555 1px 1px 8px 1px;
7 | cursor: pointer
8 | }
9 | .modal-content {
10 | width: 1200px !important;
11 | }
12 |
13 | h1, h2{
14 | margin-bottom: 20px;
15 | }
16 |
--------------------------------------------------------------------------------
/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { GalleryPage } from './app.po';
2 |
3 | describe('gallery App', () => {
4 | let page: GalleryPage;
5 |
6 | beforeEach(() => {
7 | page = new GalleryPage();
8 | });
9 |
10 | it('should display message saying app works', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('app works!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic().bootstrapModule(AppModule);
12 |
--------------------------------------------------------------------------------
/src/app/image/image-detail.component.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 | {{image.caption}}
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/app/image/shared/filter.pipe.ts:
--------------------------------------------------------------------------------
1 | import { Pipe, PipeTransform } from '@angular/core'
2 |
3 | @Pipe({name: 'imageFilter'})
4 | export class ImageFilterPipe implements PipeTransform {
5 | transform(items: any[], criteria: string): any {
6 | if(criteria === 'all'){ return items } else
7 | return items.filter(item =>{
8 | return item.category === criteria;
9 | });
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../out-tsc/spec",
5 | "module": "commonjs",
6 | "target": "es5",
7 | "baseUrl": "",
8 | "types": [
9 | "jasmine",
10 | "node"
11 | ]
12 | },
13 | "files": [
14 | "test.ts"
15 | ],
16 | "include": [
17 | "**/*.spec.ts",
18 | "**/*.d.ts"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/src/app/navbar/navbar.component.css:
--------------------------------------------------------------------------------
1 | nav{
2 | font-family: 'Lato', sans-serif;
3 | background-color: #424242;
4 | }
5 |
6 | .logo{
7 | color: #fff;
8 | font-family: 'cabin', sans-serif;
9 | font-size: 1.5em;
10 | }
11 |
12 | ul.nav a{
13 | transition:0.3s ease;
14 | }
15 |
16 | ul.nav a:hover{
17 | color: #fff;
18 | background-color: #0D47A1;
19 | }
20 |
21 | .active>a{
22 | background-color: #616161;
23 | }
24 |
--------------------------------------------------------------------------------
/src/routes.ts:
--------------------------------------------------------------------------------
1 | import { Routes } from "@angular/router"
2 | import { GalleryComponent } from "./app/gallery/gallery.component"
3 | import { ImageDetailComponent } from "./app/image/image-detail.component"
4 |
5 | export const appRoutes:Routes = [
6 | { path: "gallery", component: GalleryComponent },
7 | { path: "image/:id", component: ImageDetailComponent },
8 | { path: "", redirectTo: "/gallery", pathMatch: 'full' },
9 | ]
10 |
--------------------------------------------------------------------------------
/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/app/navbar/navbar.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-navbar',
5 | templateUrl: './navbar.component.html',
6 | styleUrls: ['./navbar.component.css']
7 | })
8 | export class NavbarComponent implements OnInit {
9 | title = 'Gallery';
10 |
11 | filterBoats(){
12 | console.log("Boats!")
13 | }
14 |
15 | constructor() { }
16 |
17 | ngOnInit() {
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "outDir": "./dist/out-tsc",
5 | "baseUrl": "src",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "moduleResolution": "node",
9 | "emitDecoratorMetadata": true,
10 | "experimentalDecorators": true,
11 | "target": "es5",
12 | "typeRoots": [
13 | "node_modules/@types"
14 | ],
15 | "lib": [
16 | "es2016",
17 | "dom"
18 | ]
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Gallery
2 |
3 | A simplistic photo gallery app built using Angular 4.
4 | I created this application as a learning exercise and made a YouTube video showing how I built it.
5 | You can check that video out here: https://youtu.be/V5-CIZTLyvw
6 |
7 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.3.
8 |
9 | ## Development server
10 |
11 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
12 |
--------------------------------------------------------------------------------
/src/app/image/image-detail.component.css:
--------------------------------------------------------------------------------
1 |
2 | .img-container{
3 | margin:24px;
4 | box-shadow:#555 1px 2px 8px 1px;
5 | min-height: 660px;
6 | min-width: 900px;
7 | background-position: center;
8 | background-repeat: no-repeat;
9 | align-content: center;
10 | }
11 |
12 | #caption{
13 | font-size: 1.5em;
14 | font-family: "Montserrat", sans-serif;
15 | padding: 18px;
16 | color: #222;
17 | background-color: #f5f5f5;
18 | border: 1px solid #bbb;
19 | width: 900px;
20 | }
21 |
22 | .caption-row{
23 | padding: 24px;
24 | text-align: center;
25 | }
26 |
--------------------------------------------------------------------------------
/src/app/image/image-detail.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { ImageService } from './shared/image.service';
3 | import { ActivatedRoute } from '@angular/router'
4 |
5 | @Component({
6 | templateUrl: './image-detail.component.html',
7 | styleUrls: ['./image-detail.component.css']
8 | })
9 | export class ImageDetailComponent {
10 | image:any
11 |
12 | constructor(private imageService: ImageService,
13 | private route: ActivatedRoute) { }
14 |
15 | ngOnInit(){
16 | this.image = this.imageService.getImage(
17 | +this.route.snapshot.params['id']
18 | )
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/app/navbar/navbar.component.html:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
--------------------------------------------------------------------------------
/.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 |
44 | # local files
45 |
--------------------------------------------------------------------------------
/src/app/gallery/gallery.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit, Input, OnChanges } from '@angular/core';
2 | import { ImageService } from '../image/shared/image.service';
3 |
4 | @Component({
5 | selector: 'app-gallery',
6 | templateUrl: './gallery.component.html',
7 | styleUrls: ['./gallery.component.css']
8 | })
9 |
10 | export class GalleryComponent implements OnChanges {
11 | images:any[];
12 | filterBy?: string = 'all'
13 | visibleImages:any[] = [];
14 |
15 | constructor(private imageService: ImageService) {
16 | console.log(this.filterBy)
17 | this.visibleImages = this.imageService.getImages();
18 | }
19 |
20 | ngOnChanges() {
21 | this.visibleImages = this.imageService.getImages();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/app/image/image.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { ImageComponent } from './image.component';
4 |
5 | describe('ImageComponent', () => {
6 | let component: ImageComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ ImageComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(ImageComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should be created', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/navbar/navbar.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { NavbarComponent } from './navbar.component';
4 |
5 | describe('NavbarComponent', () => {
6 | let component: NavbarComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ NavbarComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(NavbarComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should be created', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/app/gallery/gallery.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { GalleryComponent } from './gallery.component';
4 |
5 | describe('GalleryComponent', () => {
6 | let component: GalleryComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ GalleryComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(GalleryComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should be created', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Gallery
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/app/gallery/gallery.component.html:
--------------------------------------------------------------------------------
1 |
2 |
Travel Photos
3 |
4 |
5 |
6 |
7 |
14 |
15 |
--------------------------------------------------------------------------------
/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 | beforeLaunch: function() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | },
27 | onPrepare() {
28 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
29 | }
30 | };
31 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Wes Doyle
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 |
3 | import { AppComponent } from './app.component';
4 |
5 | describe('AppComponent', () => {
6 | beforeEach(async(() => {
7 | TestBed.configureTestingModule({
8 | declarations: [
9 | AppComponent
10 | ],
11 | }).compileComponents();
12 | }));
13 |
14 | it('should create the app', async(() => {
15 | const fixture = TestBed.createComponent(AppComponent);
16 | const app = fixture.debugElement.componentInstance;
17 | expect(app).toBeTruthy();
18 | }));
19 |
20 | it(`should have as title 'app works!'`, async(() => {
21 | const fixture = TestBed.createComponent(AppComponent);
22 | const app = fixture.debugElement.componentInstance;
23 | expect(app.title).toEqual('app works!');
24 | }));
25 |
26 | it('should render title in a h1 tag', async(() => {
27 | const fixture = TestBed.createComponent(AppComponent);
28 | fixture.detectChanges();
29 | const compiled = fixture.debugElement.nativeElement;
30 | expect(compiled.querySelector('h1').textContent).toContain('app works!');
31 | }));
32 | });
33 |
--------------------------------------------------------------------------------
/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 var __karma__: any;
17 | declare var 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/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { FormsModule } from '@angular/forms';
4 | import { HttpModule } from '@angular/http';
5 | import { RouterModule } from '@angular/router';
6 |
7 | import { ImageService } from './image/shared/image.service';
8 | import { ImageFilterPipe } from './image/shared/filter.pipe';
9 | import { AppComponent } from './app.component';
10 | import { GalleryComponent } from './gallery/gallery.component';
11 | import { ImageComponent } from './image/image.component';
12 | import { ImageDetailComponent } from './image/image-detail.component';
13 | import { NavbarComponent } from './navbar/navbar.component';
14 | import { appRoutes } from '../routes'
15 |
16 | @NgModule({
17 | declarations: [
18 | AppComponent,
19 | GalleryComponent,
20 | ImageComponent,
21 | NavbarComponent,
22 | ImageDetailComponent,
23 | ImageFilterPipe
24 | ],
25 | imports: [
26 | BrowserModule,
27 | FormsModule,
28 | HttpModule,
29 | RouterModule.forRoot(appRoutes)
30 | ],
31 | providers: [ImageService, ImageFilterPipe],
32 | bootstrap: [AppComponent]
33 | })
34 | export class AppModule { }
35 |
--------------------------------------------------------------------------------
/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "gallery"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "polyfills": "polyfills.ts",
17 | "test": "test.ts",
18 | "tsconfig": "tsconfig.app.json",
19 | "testTsconfig": "tsconfig.spec.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css"
23 | ],
24 | "scripts": [],
25 | "environmentSource": "environments/environment.ts",
26 | "environments": {
27 | "dev": "environments/environment.ts",
28 | "prod": "environments/environment.prod.ts"
29 | }
30 | }
31 | ],
32 | "e2e": {
33 | "protractor": {
34 | "config": "./protractor.conf.js"
35 | }
36 | },
37 | "lint": [
38 | {
39 | "project": "src/tsconfig.app.json"
40 | },
41 | {
42 | "project": "src/tsconfig.spec.json"
43 | },
44 | {
45 | "project": "e2e/tsconfig.e2e.json"
46 | }
47 | ],
48 | "test": {
49 | "karma": {
50 | "config": "./karma.conf.js"
51 | }
52 | },
53 | "defaults": {
54 | "styleExt": "css",
55 | "component": {}
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/0.13/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
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/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | files: [
19 | { pattern: './src/test.ts', watched: false }
20 | ],
21 | preprocessors: {
22 | './src/test.ts': ['@angular/cli']
23 | },
24 | mime: {
25 | 'text/x-typescript': ['ts','tsx']
26 | },
27 | coverageIstanbulReporter: {
28 | reports: [ 'html', 'lcovonly' ],
29 | fixWebpackSourcePaths: true
30 | },
31 | angularCli: {
32 | environment: 'dev'
33 | },
34 | reporters: config.angularCli && config.angularCli.codeCoverage
35 | ? ['progress', 'coverage-istanbul']
36 | : ['progress', 'kjhtml'],
37 | port: 9876,
38 | colors: true,
39 | logLevel: config.LOG_INFO,
40 | autoWatch: true,
41 | browsers: ['Chrome'],
42 | singleRun: false
43 | });
44 | };
45 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gallery",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "angular-cli": {},
6 | "scripts": {
7 | "ng": "ng",
8 | "start": "node server.js",
9 | "build": "ng build",
10 | "test": "ng test",
11 | "lint": "ng lint",
12 | "e2e": "ng e2e",
13 | "postinstall": "ng build --aot --target=production"
14 | },
15 | "private": true,
16 | "dependencies": {
17 | "@angular/cli": "1.0.4",
18 | "@angular/common": "^4.0.0",
19 | "@angular/compiler": "^4.0.0",
20 | "@angular/compiler-cli": "^4.0.0",
21 | "@angular/core": "^4.0.0",
22 | "@angular/forms": "^4.0.0",
23 | "@angular/http": "^4.0.0",
24 | "@angular/platform-browser": "^4.0.0",
25 | "@angular/platform-browser-dynamic": "^4.0.0",
26 | "@angular/router": "^4.0.0",
27 | "bootstrap": "^3.3.7",
28 | "core-js": "^2.4.1",
29 | "express": "^4.15.3",
30 | "ng2-bootstrap": "^1.6.3",
31 | "rxjs": "^5.1.0",
32 | "tslint": "~4.5.0",
33 | "typescript": "~2.2.0",
34 | "zone.js": "^0.8.4"
35 | },
36 | "devDependencies": {
37 | "@types/jasmine": "2.5.38",
38 | "@types/node": "~6.0.60",
39 | "codelyzer": "~2.0.0",
40 | "jasmine-core": "~2.5.2",
41 | "jasmine-spec-reporter": "~3.2.0",
42 | "karma": "~1.4.1",
43 | "karma-chrome-launcher": "~2.1.1",
44 | "karma-cli": "~1.0.1",
45 | "karma-jasmine": "~1.1.0",
46 | "karma-jasmine-html-reporter": "^0.2.2",
47 | "karma-coverage-istanbul-reporter": "^0.2.0",
48 | "protractor": "~5.1.0",
49 | "ts-node": "~2.0.0"
50 | },
51 | "engines": {
52 | "node": "6.10.3",
53 | "npm": "3.10.10"
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/app/image/shared/image.service.ts:
--------------------------------------------------------------------------------
1 | import { Injectable } from '@angular/core'
2 |
3 | @Injectable()
4 | export class ImageService{
5 | visibleImages = [];
6 |
7 | getImages(){
8 | return this.visibleImages = IMAGES.slice(0);
9 | }
10 |
11 | getImage(id: number){
12 | return IMAGES.slice(0).find(image => image.id == id)
13 | }
14 | }
15 |
16 | const IMAGES =[
17 | {"id":1, "category": "boats", "caption": "View from the boat", "url":"assets/img/boat_01.jpeg"},
18 | {"id":2, "category": "boats", "caption": "Sailing the coast", "url":"assets/img/boat_02.jpeg"},
19 | {"id":3, "category": "boats", "caption": "The water was nice", "url":"assets/img/boat_03.jpeg"},
20 | {"id":4, "category": "boats", "caption": "Cool water cavern", "url":"assets/img/boat_04.jpeg"},
21 | {"id":5, "category": "boats", "caption": "Sunset at the docks", "url":"assets/img/boat_05.jpeg"},
22 | {"id":6, "category": "camping", "caption": "Camping Trip '17'", "url":"assets/img/camping_01.jpeg"},
23 | {"id":7, "category": "camping", "caption": "Kim and Jessie", "url":"assets/img/camping_02.jpeg"},
24 | {"id":8, "category": "camping", "caption": "View from the top", "url":"assets/img/camping_03.jpeg"},
25 | {"id":9, "category": "camping", "caption": "On the trail", "url":"assets/img/camping_04.jpg"},
26 | {"id":10, "category": "camping", "caption": "Our camping spot", "url":"assets/img/camping_05.jpeg"},
27 | {"id":11, "category": "camping", "caption": "RV Life", "url":"assets/img/camping_06.jpg"},
28 | {"id":12, "category": "camping", "caption": "Hiking trip 2017", "url":"assets/img/camping_07.jpeg"},
29 | {"id":13, "category": "library", "caption": "Big library", "url":"assets/img/library_01.jpeg"},
30 | {"id":14, "category": "library", "caption": "Stacks", "url":"assets/img/library_02.jpeg"},
31 | {"id":15, "category": "library", "caption": "Saturday afternoon", "url":"assets/img/library_03.jpeg"},
32 | {"id":16, "category": "library", "caption": "Local library", "url":"assets/img/library_04.jpeg"},
33 | {"id":17, "category": "library", "caption": "Nice library", "url":"assets/img/library_05.jpeg"}
34 | ]
35 |
--------------------------------------------------------------------------------
/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/set';
35 |
36 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
37 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
38 |
39 | /** IE10 and IE11 requires the following to support `@angular/animation`. */
40 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
41 |
42 |
43 | /** Evergreen browsers require these. **/
44 | import 'core-js/es6/reflect';
45 | import 'core-js/es7/reflect';
46 |
47 |
48 | /** ALL Firefox browsers require the following to support `@angular/animation`. **/
49 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
50 |
51 |
52 |
53 | /***************************************************************************************************
54 | * Zone JS is required by Angular itself.
55 | */
56 | import 'zone.js/dist/zone'; // Included with Angular CLI.
57 |
58 |
59 |
60 | /***************************************************************************************************
61 | * APPLICATION IMPORTS
62 | */
63 |
64 | /**
65 | * Date, currency, decimal and percent pipes.
66 | * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
67 | */
68 | // import 'intl'; // Run `npm install --save intl`.
69 | /**
70 | * Need to import at least one locale-data with intl.
71 | */
72 | // import 'intl/locale-data/jsonp/en';
73 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/codelyzer"
4 | ],
5 | "rules": {
6 | "callable-types": true,
7 | "class-name": true,
8 | "comment-format": [
9 | true,
10 | "check-space"
11 | ],
12 | "curly": true,
13 | "eofline": true,
14 | "forin": true,
15 | "import-blacklist": [
16 | true,
17 | "rxjs"
18 | ],
19 | "import-spacing": true,
20 | "indent": [
21 | true,
22 | "spaces"
23 | ],
24 | "interface-over-type-literal": true,
25 | "label-position": true,
26 | "max-line-length": [
27 | true,
28 | 140
29 | ],
30 | "member-access": false,
31 | "member-ordering": [
32 | true,
33 | "static-before-instance",
34 | "variables-before-functions"
35 | ],
36 | "no-arg": true,
37 | "no-bitwise": true,
38 | "no-console": [
39 | true,
40 | "debug",
41 | "info",
42 | "time",
43 | "timeEnd",
44 | "trace"
45 | ],
46 | "no-construct": true,
47 | "no-debugger": true,
48 | "no-empty": false,
49 | "no-empty-interface": true,
50 | "no-eval": true,
51 | "no-inferrable-types": [
52 | true,
53 | "ignore-params"
54 | ],
55 | "no-shadowed-variable": true,
56 | "no-string-literal": false,
57 | "no-string-throw": true,
58 | "no-switch-case-fall-through": true,
59 | "no-trailing-whitespace": true,
60 | "no-unused-expression": true,
61 | "no-use-before-declare": true,
62 | "no-var-keyword": true,
63 | "object-literal-sort-keys": false,
64 | "one-line": [
65 | true,
66 | "check-open-brace",
67 | "check-catch",
68 | "check-else",
69 | "check-whitespace"
70 | ],
71 | "prefer-const": true,
72 | "quotemark": [
73 | true,
74 | "single"
75 | ],
76 | "radix": true,
77 | "semicolon": [
78 | "always"
79 | ],
80 | "triple-equals": [
81 | true,
82 | "allow-null-check"
83 | ],
84 | "typedef-whitespace": [
85 | true,
86 | {
87 | "call-signature": "nospace",
88 | "index-signature": "nospace",
89 | "parameter": "nospace",
90 | "property-declaration": "nospace",
91 | "variable-declaration": "nospace"
92 | }
93 | ],
94 | "typeof-compare": true,
95 | "unified-signatures": true,
96 | "variable-name": false,
97 | "whitespace": [
98 | true,
99 | "check-branch",
100 | "check-decl",
101 | "check-operator",
102 | "check-separator",
103 | "check-type"
104 | ],
105 | "directive-selector": [
106 | true,
107 | "attribute",
108 | "app",
109 | "camelCase"
110 | ],
111 | "component-selector": [
112 | true,
113 | "element",
114 | "app",
115 | "kebab-case"
116 | ],
117 | "use-input-property-decorator": true,
118 | "use-output-property-decorator": true,
119 | "use-host-property-decorator": true,
120 | "no-input-rename": true,
121 | "no-output-rename": true,
122 | "use-life-cycle-interface": true,
123 | "use-pipe-transform-interface": true,
124 | "component-class-suffix": true,
125 | "directive-class-suffix": true,
126 | "no-access-missing-member": true,
127 | "templates-use-public": true,
128 | "invoke-injectable": true
129 | }
130 | }
131 |
--------------------------------------------------------------------------------