From 6199af6633900daacaa8cb393c38ff989d43a256 Mon Sep 17 00:00:00 2001 From: nela Date: Sat, 25 Jul 2020 20:15:23 +0300 Subject: [PATCH 1/3] adapted to movie app --- app/app.css | 35 ++++++------- app/app.js | 26 ++++++--- app/configuration.js | 6 +++ app/core/version/interpolate-filter.js | 9 ---- app/core/version/interpolate-filter.spec.js | 15 ------ app/core/version/version-directive.js | 9 ---- app/core/version/version-directive.spec.js | 17 ------ app/core/version/version.js | 8 --- app/core/version/version.spec.js | 11 ---- app/index-async.html | 58 --------------------- app/index.html | 39 ++++---------- app/services/movieService.js | 6 +++ app/view1/view1.html | 22 +++++++- app/view1/view1.js | 2 +- app/view2/view2.html | 5 -- app/view2/view2.js | 14 ----- app/view2/view2.spec.js | 16 ------ package-lock.json | 41 +++++++++++---- 18 files changed, 110 insertions(+), 229 deletions(-) create mode 100644 app/configuration.js delete mode 100644 app/core/version/interpolate-filter.js delete mode 100644 app/core/version/interpolate-filter.spec.js delete mode 100644 app/core/version/version-directive.js delete mode 100644 app/core/version/version-directive.spec.js delete mode 100644 app/core/version/version.js delete mode 100644 app/core/version/version.spec.js delete mode 100644 app/index-async.html create mode 100644 app/services/movieService.js delete mode 100644 app/view2/view2.html delete mode 100644 app/view2/view2.js delete mode 100644 app/view2/view2.spec.js diff --git a/app/app.css b/app/app.css index 48e881d4ec..6d26056bf2 100644 --- a/app/app.css +++ b/app/app.css @@ -1,25 +1,22 @@ -/* app css stylesheet */ - -.menu { - list-style: none; - border-bottom: 0.1em solid black; - margin-bottom: 2em; - padding: 0 0 0.5em; +img { + padding: 1rem; + max-height: 15rem; } -.menu:before { - content: "["; +.flex-item { + background-color: #fff; } -.menu:after { - content: "]"; -} +.flex-container { + display: flex; + overflow: auto; + white-space: nowrap; + } -.menu > li { - display: inline; -} + body { + background-color:#011229; + } -.menu > li + li:before { - content: "|"; - padding-right: 0.3em; -} + h2, p { + color: #ebf0f7; + } \ No newline at end of file diff --git a/app/app.js b/app/app.js index 3a0ca2557e..e48ed656ea 100644 --- a/app/app.js +++ b/app/app.js @@ -1,14 +1,28 @@ 'use strict'; -// Declare app level module which depends on views, and core components -angular.module('myApp', [ + +const app = angular.module('myApp', [ 'ngRoute', 'myApp.view1', - 'myApp.view2', - 'myApp.version' + ]). config(['$locationProvider', '$routeProvider', function($locationProvider, $routeProvider) { $locationProvider.hashPrefix('!'); - $routeProvider.otherwise({redirectTo: '/view1'}); -}]); + $routeProvider.otherwise({redirectTo: '/'}); +}]). +controller('MainController', function (movieService) { + movieService.getData('now_playing') + .then((result) => this.nowPlaying = result); + + movieService.getData('popular') + .then((result) => this.latest = result); + + movieService.getData('upcoming') + .then((result) => this.upcoming = result); + + this.getImage = function (movie) { + return imageURL + movie.poster_path; + }; + }); + diff --git a/app/configuration.js b/app/configuration.js new file mode 100644 index 0000000000..0b65d6a428 --- /dev/null +++ b/app/configuration.js @@ -0,0 +1,6 @@ +const tmdbKey = '06f99320c4d4aafa43383b3d6c8da151'; +const imageURL = 'https://image.tmdb.org/t/p/w500'; + +getLink = function (category) { + return `https://api.themoviedb.org/3/movie/${category}?api_key=${tmdbKey}`; +}; diff --git a/app/core/version/interpolate-filter.js b/app/core/version/interpolate-filter.js deleted file mode 100644 index 03bb1987df..0000000000 --- a/app/core/version/interpolate-filter.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -angular.module('myApp.version.interpolate-filter', []) - -.filter('interpolate', ['version', function(version) { - return function(text) { - return String(text).replace(/\%VERSION\%/mg, version); - }; -}]); diff --git a/app/core/version/interpolate-filter.spec.js b/app/core/version/interpolate-filter.spec.js deleted file mode 100644 index ff56c529eb..0000000000 --- a/app/core/version/interpolate-filter.spec.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -describe('myApp.version module', function() { - beforeEach(module('myApp.version')); - - describe('interpolate filter', function() { - beforeEach(module(function($provide) { - $provide.value('version', 'TEST_VER'); - })); - - it('should replace VERSION', inject(function(interpolateFilter) { - expect(interpolateFilter('before %VERSION% after')).toEqual('before TEST_VER after'); - })); - }); -}); diff --git a/app/core/version/version-directive.js b/app/core/version/version-directive.js deleted file mode 100644 index 74088f8add..0000000000 --- a/app/core/version/version-directive.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -angular.module('myApp.version.version-directive', []) - -.directive('appVersion', ['version', function(version) { - return function(scope, elm, attrs) { - elm.text(version); - }; -}]); diff --git a/app/core/version/version-directive.spec.js b/app/core/version/version-directive.spec.js deleted file mode 100644 index 4a59e1193a..0000000000 --- a/app/core/version/version-directive.spec.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -describe('myApp.version module', function() { - beforeEach(module('myApp.version')); - - describe('app-version directive', function() { - it('should print current version', function() { - module(function($provide) { - $provide.value('version', 'TEST_VER'); - }); - inject(function($compile, $rootScope) { - var element = $compile('')($rootScope); - expect(element.text()).toEqual('TEST_VER'); - }); - }); - }); -}); diff --git a/app/core/version/version.js b/app/core/version/version.js deleted file mode 100644 index cb7a10f9db..0000000000 --- a/app/core/version/version.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -angular.module('myApp.version', [ - 'myApp.version.interpolate-filter', - 'myApp.version.version-directive' -]) - -.value('version', '0.1'); diff --git a/app/core/version/version.spec.js b/app/core/version/version.spec.js deleted file mode 100644 index 4ca6880dab..0000000000 --- a/app/core/version/version.spec.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -describe('myApp.version module', function() { - beforeEach(module('myApp.version')); - - describe('version service', function() { - it('should return current version', inject(function(version) { - expect(version).toEqual('0.1'); - })); - }); -}); diff --git a/app/index-async.html b/app/index-async.html deleted file mode 100644 index e66b69c302..0000000000 --- a/app/index-async.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - My AngularJS App - - - - - -
- -
AngularJS seed app: v
- - - diff --git a/app/index.html b/app/index.html index 091d5a2df5..60add1c896 100644 --- a/app/index.html +++ b/app/index.html @@ -1,43 +1,24 @@ - - - - + - + My AngularJS App - - - - + - + - - - - +
- -
AngularJS seed app: v
- - + - - - - + + + + diff --git a/app/services/movieService.js b/app/services/movieService.js new file mode 100644 index 0000000000..e4bc74e61c --- /dev/null +++ b/app/services/movieService.js @@ -0,0 +1,6 @@ +app.factory('movieService', ($http) => ({ + getData(category) { + return $http.get(getLink(category)) + .then((response) => response.data.results); + }, +})); diff --git a/app/view1/view1.html b/app/view1/view1.html index 89459a65ca..aee4af92d3 100644 --- a/app/view1/view1.html +++ b/app/view1/view1.html @@ -1 +1,21 @@ -

This is the partial for view 1.

+ +

Now Playing

+ + +

Latest

+ + +

Upcoming

+ \ No newline at end of file diff --git a/app/view1/view1.js b/app/view1/view1.js index 4ce0b4f118..e3cb27e8b6 100644 --- a/app/view1/view1.js +++ b/app/view1/view1.js @@ -3,7 +3,7 @@ angular.module('myApp.view1', ['ngRoute']) .config(['$routeProvider', function($routeProvider) { - $routeProvider.when('/view1', { + $routeProvider.when('/', { templateUrl: 'view1/view1.html', controller: 'View1Ctrl' }); diff --git a/app/view2/view2.html b/app/view2/view2.html deleted file mode 100644 index b6503ee11a..0000000000 --- a/app/view2/view2.html +++ /dev/null @@ -1,5 +0,0 @@ -

This is the partial for view 2.

-

- Showing of 'interpolate' filter: - {{ 'Current version is v%VERSION%.' | interpolate }} -

diff --git a/app/view2/view2.js b/app/view2/view2.js deleted file mode 100644 index a0ff97dbd7..0000000000 --- a/app/view2/view2.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -angular.module('myApp.view2', ['ngRoute']) - -.config(['$routeProvider', function($routeProvider) { - $routeProvider.when('/view2', { - templateUrl: 'view2/view2.html', - controller: 'View2Ctrl' - }); -}]) - -.controller('View2Ctrl', [function() { - -}]); \ No newline at end of file diff --git a/app/view2/view2.spec.js b/app/view2/view2.spec.js deleted file mode 100644 index 07b34d6bb3..0000000000 --- a/app/view2/view2.spec.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -describe('myApp.view2 module', function() { - - beforeEach(module('myApp.view2')); - - describe('view2 controller', function(){ - - it('should ....', inject(function($controller) { - //spec body - var view2Ctrl = $controller('View2Ctrl'); - expect(view2Ctrl).toBeDefined(); - })); - - }); -}); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ebd10fafde..8c974333e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1317,7 +1317,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -1338,12 +1339,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1358,17 +1361,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -1485,7 +1491,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -1497,6 +1504,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -1511,6 +1519,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -1518,12 +1527,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -1542,6 +1553,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -1622,7 +1634,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -1634,6 +1647,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -1719,7 +1733,8 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -1755,6 +1770,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -1774,6 +1790,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -1817,12 +1834,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, From 31a56a6df69a18fa73b5f6d863a0b9fc49929557 Mon Sep 17 00:00:00 2001 From: nela Date: Sat, 25 Jul 2020 21:29:02 +0300 Subject: [PATCH 2/3] add list component --- app/app.js | 1 - app/configuration.js | 4 ++++ app/index.html | 5 +---- app/list/list.html | 6 ++++++ app/list/list.js | 13 +++++++++++++ app/view1/view1.html | 38 +++++++++++++++++++------------------- 6 files changed, 43 insertions(+), 24 deletions(-) create mode 100644 app/list/list.html create mode 100644 app/list/list.js diff --git a/app/app.js b/app/app.js index e48ed656ea..46b1812209 100644 --- a/app/app.js +++ b/app/app.js @@ -1,6 +1,5 @@ 'use strict'; - const app = angular.module('myApp', [ 'ngRoute', 'myApp.view1', diff --git a/app/configuration.js b/app/configuration.js index 0b65d6a428..0521be0442 100644 --- a/app/configuration.js +++ b/app/configuration.js @@ -4,3 +4,7 @@ const imageURL = 'https://image.tmdb.org/t/p/w500'; getLink = function (category) { return `https://api.themoviedb.org/3/movie/${category}?api_key=${tmdbKey}`; }; + +// getImage = function (movie) { +// return imageURL + movie.poster_path; +// }; \ No newline at end of file diff --git a/app/index.html b/app/index.html index 60add1c896..fc898d48cf 100644 --- a/app/index.html +++ b/app/index.html @@ -2,14 +2,10 @@ - My AngularJS App - - -
@@ -17,6 +13,7 @@ + diff --git a/app/list/list.html b/app/list/list.html new file mode 100644 index 0000000000..6bf00fa911 --- /dev/null +++ b/app/list/list.html @@ -0,0 +1,6 @@ +

list tag

+ \ No newline at end of file diff --git a/app/list/list.js b/app/list/list.js new file mode 100644 index 0000000000..48836e8784 --- /dev/null +++ b/app/list/list.js @@ -0,0 +1,13 @@ + +angular. + module('myApp'). + component('list', { + templateUrl: 'list/list.html', + controller: function ListController(category, movieService) { + + movieService.getData(category) + .then((result) => this.category = result); + + } + + }); diff --git a/app/view1/view1.html b/app/view1/view1.html index aee4af92d3..0106798e4a 100644 --- a/app/view1/view1.html +++ b/app/view1/view1.html @@ -1,21 +1,21 @@ + + -

Now Playing

- +

Latest

+ -

Latest

- - -

Upcoming

- \ No newline at end of file +

Upcoming

+ \ No newline at end of file From 33b4914afe8bff351019fa4d0629d65ffb71c612 Mon Sep 17 00:00:00 2001 From: Plesca Date: Mon, 27 Jul 2020 10:14:18 +0300 Subject: [PATCH 3/3] linter corrections --- app/app.js | 21 +++++++++------------ app/configuration.js | 2 +- app/list/list.js | 15 ++++++--------- app/view1/view1.js | 18 ++++++++---------- 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/app/app.js b/app/app.js index 46b1812209..b5e387caa6 100644 --- a/app/app.js +++ b/app/app.js @@ -1,27 +1,24 @@ -'use strict'; - const app = angular.module('myApp', [ 'ngRoute', 'myApp.view1', -]). -config(['$locationProvider', '$routeProvider', function($locationProvider, $routeProvider) { - $locationProvider.hashPrefix('!'); +]) + . config(['$locationProvider', '$routeProvider', function ($locationProvider, $routeProvider) { + $locationProvider.hashPrefix('!'); - $routeProvider.otherwise({redirectTo: '/'}); -}]). -controller('MainController', function (movieService) { + $routeProvider.otherwise({ redirectTo: '/' }); + }]) + . controller('MainController', function (movieService) { movieService.getData('now_playing') .then((result) => this.nowPlaying = result); - + movieService.getData('popular') .then((result) => this.latest = result); - + movieService.getData('upcoming') .then((result) => this.upcoming = result); - + this.getImage = function (movie) { return imageURL + movie.poster_path; }; }); - diff --git a/app/configuration.js b/app/configuration.js index 0521be0442..9da461704f 100644 --- a/app/configuration.js +++ b/app/configuration.js @@ -7,4 +7,4 @@ getLink = function (category) { // getImage = function (movie) { // return imageURL + movie.poster_path; -// }; \ No newline at end of file +// }; diff --git a/app/list/list.js b/app/list/list.js index 48836e8784..90d2c0f4ef 100644 --- a/app/list/list.js +++ b/app/list/list.js @@ -1,13 +1,10 @@ - -angular. - module('myApp'). - component('list', { +angular + .module('myApp') + .component('list', { templateUrl: 'list/list.html', controller: function ListController(category, movieService) { + movieService.getData(category) + .then((result) => this.category = result); + }, - movieService.getData(category) - .then((result) => this.category = result); - - } - }); diff --git a/app/view1/view1.js b/app/view1/view1.js index e3cb27e8b6..0b2680d05f 100644 --- a/app/view1/view1.js +++ b/app/view1/view1.js @@ -1,14 +1,12 @@ -'use strict'; - angular.module('myApp.view1', ['ngRoute']) -.config(['$routeProvider', function($routeProvider) { - $routeProvider.when('/', { - templateUrl: 'view1/view1.html', - controller: 'View1Ctrl' - }); -}]) + .config(['$routeProvider', function ($routeProvider) { + $routeProvider.when('/', { + templateUrl: 'view1/view1.html', + controller: 'View1Ctrl', + }); + }]) -.controller('View1Ctrl', [function() { + .controller('View1Ctrl', [function () { -}]); \ No newline at end of file + }]);