diff --git a/src/client/app.js b/src/client/app.js index 2cf6c4a5..73cf88a1 100644 --- a/src/client/app.js +++ b/src/client/app.js @@ -19,9 +19,9 @@ import FooterLinks from './components/FooterLinks'; import PageSchool from './components/PageSchool'; import PageSchedule from './components/PageSchedule'; import PageCollective from './components/PageCollective'; +import PageGallery from './components/PageGallery'; import AppController from './controllers/AppController'; -import GalleryController from './controllers/GalleryController'; import AlbumController from './controllers/AlbumController'; import DocumentsController from './controllers/DocumentsController'; import CopyrightController from './controllers/CopyrightController'; @@ -93,8 +93,8 @@ app.run(($location, $rootScope, $http) => { PageSchool, PageSchedule, PageCollective, + PageGallery, AppController, - GalleryController, AlbumController, DocumentsController, CopyrightController, @@ -106,10 +106,6 @@ app.run(($location, $rootScope, $http) => { ScheduleRecord, FooterLinks, function (app) { - app.controller('GalleryPageController', ($scope) => { - $scope.pageClass = 'page-gallery'; - }); - app.controller('AlbumPageController', ($scope) => { $scope.pageClass = 'page-album'; }); diff --git a/src/client/components/PageGallery.js b/src/client/components/PageGallery.js new file mode 100644 index 00000000..76ad0d7e --- /dev/null +++ b/src/client/components/PageGallery.js @@ -0,0 +1,28 @@ +import template from '../../templates/components/page-gallery.html'; + +export default function (app) { + app.component('pageCollective', { + template: template, + controller: function (api) { + this.pageClass = 'page-gallery'; + + this.years = []; + [2015, 2014, 2013, 2012, 2011, 2010] + .forEach((year, year_index) => { + api.gallery.year(year) + .success(albums => { + if (albums.length) { + this.years[year_index] = { + year: year, + albums: albums.map(album => { + let preview = album.content[0]; + album.preview_url = preview.content.medium.url; + return album; + }) + }; + } + }) + }); + } + }); +}; \ No newline at end of file diff --git a/src/client/config.js b/src/client/config.js index 4d2e401d..ddabb0a1 100644 --- a/src/client/config.js +++ b/src/client/config.js @@ -37,8 +37,7 @@ export let routes = [ }, { name: '/gallery', - templateUrl: '/views/gallery.html', - controller: 'GalleryPageController', + template: '', title: 'Работы учащихся' }, { diff --git a/src/client/controllers/GalleryController.js b/src/client/controllers/GalleryController.js deleted file mode 100644 index d0e72e0b..00000000 --- a/src/client/controllers/GalleryController.js +++ /dev/null @@ -1,22 +0,0 @@ -export default function (app) { - app.controller("GalleryController", ($scope, api) => { - $scope.years = []; - - let years = [2015, 2014, 2013, 2012, 2011, 2010]; - years.forEach((year, year_index) => { - api.gallery.year(year) - .success(albums => { - if (albums.length) { - $scope.years[year_index] = { - year: year, - albums: albums.map(album => { - let preview = album.content[0]; - album.preview_url = preview.content.medium.url; - return album; - }) - }; - } - }) - }); - }); -}; diff --git a/src/templates/components/page-gallery.html b/src/templates/components/page-gallery.html new file mode 100644 index 00000000..a7dbeab6 --- /dev/null +++ b/src/templates/components/page-gallery.html @@ -0,0 +1,5 @@ +
+ +
diff --git a/src/templates/views/gallery.html b/src/templates/views/gallery.html deleted file mode 100644 index 61b8a4ea..00000000 --- a/src/templates/views/gallery.html +++ /dev/null @@ -1,5 +0,0 @@ -
- -