@@ -19,17 +20,20 @@
diff --git a/src/app/movie/movie.component.scss b/src/app/movie/movie.component.scss
index 00f9fe0..bb2931c 100644
--- a/src/app/movie/movie.component.scss
+++ b/src/app/movie/movie.component.scss
@@ -1,4 +1,4 @@
-@import 'variables';
+@import "variables";
:host {
display: flex;
@@ -6,7 +6,6 @@
flex-direction: column;
}
-
.ngmp-main-container {
display: flex;
justify-content: flex-start;
@@ -63,7 +62,7 @@
}
.ngmp-movie {
- margin-bottom: 1.8em;
+ margin-bottom: 1em;
flex-basis: 25%;
a {
@@ -82,9 +81,9 @@
}
img {
- -webkit-box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.5);
- -moz-box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.5);
- box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.5);
+ -webkit-box-shadow: 0px 0px 10px 0px $shadow;
+ -moz-box-shadow: 0px 0px 10px 0px $shadow;
+ box-shadow: 0px 0px 10px 0px $shadow;
}
}
@@ -94,13 +93,13 @@
}
.ngmp-movie-title,
- .ngmp-movie-rate {
- display: block;
- // margin-top: 0.3em;
+ .ngmp-movie-year {
+ text-decoration: none;
+ display: inline-block;
}
.ngmp-movie-title {
- color: $green;
+ color: $orange;
margin: 15px 0 5px 42px;
overflow: hidden;
white-space: nowrap;
@@ -108,19 +107,29 @@
width: 300px;
}
- .ngmp-movie-rate {
+ .ngmp-movie-year {
color: $grey;
margin: 0;
- margin-left: 42px;
+ margin-left: 34px;
+ }
+ .ngma-rateimg {
+ height: 16px;
+ position: relative;
+ width: 25px;
}
-
.ngmp-noimageposter {
-text-align: center;
+ text-align: center;
+ height: 100px;
+ }
+ .ngmp-noimage {
+ text-align: center;
+ height: 100px;
+ margin-right: 100px;
}
}
}
-@media only screen and (max-width : 48em) {
+@media only screen and (max-width: 48em) {
.main-container {
flex-direction: column;
@@ -172,3 +181,4 @@ text-align: center;
}
}
}
+
diff --git a/src/app/movie/movie.component.ts b/src/app/movie/movie.component.ts
index a8aea07..bd71631 100644
--- a/src/app/movie/movie.component.ts
+++ b/src/app/movie/movie.component.ts
@@ -1,9 +1,8 @@
import { Component, OnInit } from "@angular/core";
-import { Router, NavigationEnd } from '@angular/router';
+import { Router, NavigationEnd } from "@angular/router";
-import { Movie } from "./models/movie.models";
import { MovieService } from "./services/movie.services";
-
+import { Movie } from "./models/movie.models";
import { MOVIE_PROPS } from "../shared/constants";
@Component({
@@ -25,7 +24,6 @@ export class MovieComponent implements OnInit {
movieService.getMovies().subscribe(
(movies) => {
this.movies = movies;
- this.l("getMovies", movies);
this.loading = false;
},
(error) => (this.loading = false)
@@ -37,4 +35,13 @@ export class MovieComponent implements OnInit {
onSearch(movies: Movie[]) {
this.movies = movies;
}
+
+ onNavMenuChange(movies: Movie[]) {
+ console.log("onNavMenuChange", movies);
+ this.movies = movies;
+ }
+
+ showLoading(loading: boolean) {
+ this.loading = loading;
+ }
}
diff --git a/src/app/movie/movie.module.ts b/src/app/movie/movie.module.ts
index 5ea7545..91f2152 100644
--- a/src/app/movie/movie.module.ts
+++ b/src/app/movie/movie.module.ts
@@ -3,25 +3,28 @@ import { CommonModule } from "@angular/common";
import { FormsModule } from "@angular/forms";
import { RouterModule } from "@angular/router";
import { HttpClientModule } from "@angular/common/http";
-
+import { HttpClient } from "@angular/common/http";
import { MovieRoutingModule } from "./movie-routing.module";
+
import { MovieComponent } from "./movie.component";
-import { SearchBarComponent } from "../search-bar/search-bar.component";
import { LoaderComponent } from "../loader/loader.component";
+import { SearchBarComponent } from "../search-bar/search-bar.component";
import { MovieDetailComponent } from "../movie-detail/movie-detail.component";
import { NoDataComponent } from "../no-data/no-data.component";
+import { NavMenuComponent } from "../nav-menu/nav-menu.component";
import { MovieService } from "./services/movie.services";
@NgModule({
declarations: [
MovieComponent,
- SearchBarComponent,
LoaderComponent,
+ SearchBarComponent,
MovieDetailComponent,
- NoDataComponent
+ NoDataComponent,
+ NavMenuComponent
],
imports: [CommonModule, MovieRoutingModule, FormsModule, HttpClientModule],
- providers: [HttpClientModule, MovieService],
+ providers: [HttpClientModule, HttpClient, MovieService],
})
export class MovieModule {}
diff --git a/src/app/movie/services/movie.services.ts b/src/app/movie/services/movie.services.ts
index 95bdc85..d6fd825 100644
--- a/src/app/movie/services/movie.services.ts
+++ b/src/app/movie/services/movie.services.ts
@@ -15,7 +15,7 @@ export class MovieService {
constructor(private http: HttpClient) {}
getMovies() {
- var url: string = `${this.moviesEndpoint}&s=people`;
+ var url: string = `${this.moviesEndpoint}&s=avenger`;
return this.http.get(url).pipe(
map((res: any) => res.Search),
catchError(this.handleError("getMovies", []))
diff --git a/src/app/movie/services/movies.service.spec.ts b/src/app/movie/services/movies.service.spec.ts
new file mode 100644
index 0000000..ebf3315
--- /dev/null
+++ b/src/app/movie/services/movies.service.spec.ts
@@ -0,0 +1,48 @@
+import { TestBed, inject } from "@angular/core/testing";
+import {
+ HttpClientTestingModule,
+ HttpTestingController,
+} from "@angular/common/http/testing";
+
+import { API_CONIG } from "../../shared/constants";
+import { MovieService } from "./movie.services";
+import { dataSet1, dataSet2 } from "../test-data/sample-data";
+
+describe("Movie Service", () => {
+ let httpTestingController: HttpTestingController;
+ let service: MovieService;
+
+ const movies = [dataSet1, dataSet2];
+ const moviesEndpoint = `${API_CONIG.API_ENDPOINT}?apikey=${API_CONIG.API_KEY}`;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ imports: [HttpClientTestingModule],
+ providers: [MovieService],
+ });
+
+ httpTestingController = TestBed.get(HttpTestingController);
+ service = TestBed.get(MovieService);
+ });
+
+ describe("getMovies", () => {
+ it("should call get method to retrieve all movies initial time", () => {
+ service.getMovies().subscribe((movies) => {
+ expect(movies[1].Title).toEqual("The Avenger");
+ });
+ });
+ });
+
+ describe("getMovieById", () => {
+ it("should call get method to retrieve the movie by id", () => {
+ service.getMovieById(movies[0]["imdbID"]).subscribe((data:any) => {
+ expect(data['Title']).toEqual(movies[0].Title);
+ });
+
+ const req = httpTestingController.expectOne(`${moviesEndpoint}&i=${movies[0]["imdbID"]}&plot=full`);
+ // console.log(req);
+ // req.flush(movies[0]);
+ // httpTestingController.verify();
+ });
+ });
+});
diff --git a/src/app/movie/test-data/sample-data.ts b/src/app/movie/test-data/sample-data.ts
new file mode 100644
index 0000000..8bbb133
--- /dev/null
+++ b/src/app/movie/test-data/sample-data.ts
@@ -0,0 +1,16 @@
+export const dataSet1 = {
+ Poster:
+ "https://m.media-amazon.com/images/M/MV5BMTYzOTc2NzU3N15BMl5BanBnXkFtZTcwNjY3MDE3NQ@@._V1_SX300.jpg",
+ Title: "Captain America: The First Avenger",
+ Type: "movie",
+ Year: "2011",
+ imdbID: "tt0458339",
+};
+export const dataSet2 = {
+ Poster:
+ "https://m.media-amazon.com/images/M/MV5BNzU5YzM3MmEtNTE2MS00MzVjLWI5Y2EtNGU3M2YwMGYzMGQ0XkEyXkFqcGdeQXVyMDExMzA0Mw@@._V1_SX300.jpg",
+ Title: "The Avenger",
+ Type: "movie",
+ Year: "1960",
+ imdbID: "tt0054257",
+};
diff --git a/src/app/nav-menu/nav-menu-routing.module.ts b/src/app/nav-menu/nav-menu-routing.module.ts
new file mode 100644
index 0000000..1f151e1
--- /dev/null
+++ b/src/app/nav-menu/nav-menu-routing.module.ts
@@ -0,0 +1,11 @@
+import { NgModule } from '@angular/core';
+import { Routes, RouterModule } from '@angular/router';
+
+
+const routes: Routes = [];
+
+@NgModule({
+ imports: [RouterModule.forChild(routes)],
+ exports: [RouterModule]
+})
+export class NavMenuRoutingModule { }
diff --git a/src/app/nav-menu/nav-menu.component.html b/src/app/nav-menu/nav-menu.component.html
new file mode 100644
index 0000000..cb69d0c
--- /dev/null
+++ b/src/app/nav-menu/nav-menu.component.html
@@ -0,0 +1,13 @@
+
\ No newline at end of file
diff --git a/src/app/nav-menu/nav-menu.component.scss b/src/app/nav-menu/nav-menu.component.scss
new file mode 100644
index 0000000..9a4c3da
--- /dev/null
+++ b/src/app/nav-menu/nav-menu.component.scss
@@ -0,0 +1,64 @@
+@import "variables";
+
+.ngma-nav-bar-container {
+ width: 100%;
+ margin: 0 auto;
+
+ a {
+ color: $primary-title;
+ font-weight: 300;
+ letter-spacing: 2px;
+ text-decoration: none;
+ background: lighten($primary-color, 15);
+ padding: 20px 5px;
+ display: inline-block;
+ width: 100%;
+ text-align: center;
+
+ &:hover {
+ opacity: 0.7;
+ }
+
+ &.active {
+ opacity: 1;
+ background: $secondary-color;
+ }
+ }
+
+ .main {
+ }
+
+ .ngma-navigation {
+ ul {
+ border: 1px solid $primary-color-light;
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ }
+
+ li {
+ flex: 3;
+ }
+ }
+
+ @media all and (max-width: 1000px) {
+ .navigation {
+ ul {
+ flex-wrap: wrap;
+ }
+
+ li {
+ flex: 1 1 50%;
+ }
+ }
+ }
+
+ @media all and (max-width: 480px) {
+ .navigation {
+ li {
+ flex-basis: 100%;
+ }
+ }
+ }
+}
diff --git a/src/app/nav-menu/nav-menu.component.spec.ts b/src/app/nav-menu/nav-menu.component.spec.ts
new file mode 100644
index 0000000..c6e15c5
--- /dev/null
+++ b/src/app/nav-menu/nav-menu.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { NavMenuComponent } from './nav-menu.component';
+
+describe('NavMenuComponent', () => {
+ let component: NavMenuComponent;
+ let fixture: ComponentFixture
;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ NavMenuComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(NavMenuComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/nav-menu/nav-menu.component.ts b/src/app/nav-menu/nav-menu.component.ts
new file mode 100644
index 0000000..8a1eb97
--- /dev/null
+++ b/src/app/nav-menu/nav-menu.component.ts
@@ -0,0 +1,44 @@
+import { Component, OnInit , Output, EventEmitter } from "@angular/core";
+
+import { MovieService } from "../movie/services/movie.services";
+import { MovieGenre } from "../movie/models/genre.model";
+import { Movie } from "../movie/models/movie.models";
+
+@Component({
+ selector: "app-nav-menu",
+ templateUrl: "./nav-menu.component.html",
+ styleUrls: ["./nav-menu.component.scss"],
+})
+export class NavMenuComponent implements OnInit {
+ public movies: any;
+ public movieGenre = MovieGenre;
+ public loading: boolean;
+
+ selectedGenre = "action";
+ objectKeys = Object.keys;
+
+ @Output() onNavMenuChange = new EventEmitter();
+ @Output() showLoading = new EventEmitter();
+
+ constructor(private movieService: MovieService) {}
+
+ ngOnInit(): void {}
+
+ changeMenuItem(event: any) {
+ event.preventDefault();
+ const CurrentGenre = event.target.innerText.toLowerCase();
+ this.applyChange(CurrentGenre);
+ }
+
+ private applyChange(filterBy: string) {
+ this.selectedGenre = filterBy;
+ this.showLoading.emit(true);
+ this.movieService.getMovieByTitle(filterBy).subscribe(
+ (movies) => {
+ this.onNavMenuChange.emit(movies);
+ this.showLoading.emit(false);
+ },
+ (error) => (this.loading = false)
+ );
+ }
+}
diff --git a/src/app/nav-menu/nav-menu.module.ts b/src/app/nav-menu/nav-menu.module.ts
new file mode 100644
index 0000000..3495a72
--- /dev/null
+++ b/src/app/nav-menu/nav-menu.module.ts
@@ -0,0 +1,13 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { NavMenuRoutingModule } from './nav-menu-routing.module';
+
+@NgModule({
+ declarations: [],
+ imports: [
+ CommonModule,
+ NavMenuRoutingModule
+ ],
+ providers:[]
+})
+export class NavMenuModule { }
diff --git a/src/app/search-bar/search-bar.component.scss b/src/app/search-bar/search-bar.component.scss
index 8a771b7..02f1cd7 100644
--- a/src/app/search-bar/search-bar.component.scss
+++ b/src/app/search-bar/search-bar.component.scss
@@ -12,7 +12,7 @@
padding: 1.5em;
border: none;
outline: none;
- font-size: 1em;
+ font-size: 1.1em;
padding-left: 4em;
&::-webkit-input-placeholder {
diff --git a/src/app/search-bar/search-bar.component.spec.ts b/src/app/search-bar/search-bar.component.spec.ts
index de8089e..ce49237 100644
--- a/src/app/search-bar/search-bar.component.spec.ts
+++ b/src/app/search-bar/search-bar.component.spec.ts
@@ -6,6 +6,7 @@ describe('SearchBarComponent', () => {
let component: SearchBarComponent;
let fixture: ComponentFixture;
+
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SearchBarComponent ]
diff --git a/src/app/search-bar/search-bar.component.ts b/src/app/search-bar/search-bar.component.ts
index b971e64..f22c704 100644
--- a/src/app/search-bar/search-bar.component.ts
+++ b/src/app/search-bar/search-bar.component.ts
@@ -1,6 +1,7 @@
import { Component, OnInit, Output, EventEmitter } from "@angular/core";
import { MovieService } from "../movie/services/movie.services";
+
import { Movie } from "../movie/models/movie.models";
@Component({
selector: "app-search-bar",
@@ -9,16 +10,15 @@ import { Movie } from "../movie/models/movie.models";
})
export class SearchBarComponent implements OnInit {
searchText: any = "";
- public movies :any;
- @Output() search = new EventEmitter();
+ public movies: any;
+ @Output() onSearch = new EventEmitter();
constructor(private movieService: MovieService) {}
ngOnInit(): void {}
onEnter() {
this.movieService.getMovieByTitle(this.searchText).subscribe((movies) => {
- console.log(movies);
- this.search.emit(movies);
+ this.onSearch.emit(movies);
});
}
}
diff --git a/src/app/search-bar/search-bar.module.ts b/src/app/search-bar/search-bar.module.ts
index d033bcc..875b60c 100644
--- a/src/app/search-bar/search-bar.module.ts
+++ b/src/app/search-bar/search-bar.module.ts
@@ -1,6 +1,6 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
-
+import { HttpClient } from "@angular/common/http";
import { SearchBarRoutingModule } from './search-bar-routing.module';
@@ -9,6 +9,7 @@ import { SearchBarRoutingModule } from './search-bar-routing.module';
imports: [
CommonModule,
SearchBarRoutingModule
- ]
+ ],
+ providers: [HttpClient],
})
export class SearchBarModule { }
diff --git a/src/app/shared/enumToArray.pipe.ts b/src/app/shared/enumToArray.pipe.ts
new file mode 100644
index 0000000..13322a2
--- /dev/null
+++ b/src/app/shared/enumToArray.pipe.ts
@@ -0,0 +1,15 @@
+import { Pipe, PipeTransform } from "@angular/core";
+
+@Pipe({
+ name: "enumToArray",
+ pure: true,
+})
+
+export class EnumToArrayPipe implements PipeTransform {
+ transform(data: object) {
+ const keys = Object.keys(data);
+ return keys;
+ }
+
+
+}
diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts
index 5c31258..099c9a2 100644
--- a/src/app/shared/shared.module.ts
+++ b/src/app/shared/shared.module.ts
@@ -3,19 +3,16 @@ import { CommonModule } from '@angular/common';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
-
@NgModule({
imports: [
CommonModule,
BrowserAnimationsModule,
NoopAnimationsModule
],
- declarations: [
- ],
+ declarations: [],
exports: [
CommonModule,
BrowserAnimationsModule
- ],
- providers: [ ]
+ ]
})
-export class SharedModule { }
+export class SharedModule {}
diff --git a/src/app/sidebar/sidebar.component.html b/src/app/sidebar/sidebar.component.html
index f6a6398..c3874cc 100644
--- a/src/app/sidebar/sidebar.component.html
+++ b/src/app/sidebar/sidebar.component.html
@@ -1,17 +1,17 @@
-