This commit is contained in:
tmshv committed 2016-03-07 04:46:42 +03:00
1 parent 261e842802
commit 0485a4acea
122 files changed
+4866 -3842

No files matched your search

+4 -1
View File
@@ -1,7 +1,10 @@
import EndPoint from './EndPoint';
export default class APIEvent extends EndPoint {
list(skip=1, limit=10) {
list(page = 1) {
let limit = 5;
let skip = (page - 1) * limit;
let url = `/events?skip=${skip}&limit=${limit}`;
return this.get(url);
}
+29 -12
View File
@@ -10,7 +10,6 @@ import AlbumCollection from './components/AlbumCollection';
import TeacherProfile from './components/TeacherProfile';
import Timeline from './components/Timeline';
import TimelineRecord from './components/TimelineRecord';
import TimelineRecordPost from './components/TimelineRecordPost';
import TimelineRecordInstagram from './components/TimelineRecordInstagram';
import Schedule from './components/Schedule';
import ScheduleTable from './components/ScheduleTable';
@@ -18,7 +17,8 @@ import ScheduleSlider from './components/ScheduleSlider';
import ScheduleSlide from './components/ScheduleSlide';
import ScheduleRecord from './components/ScheduleRecord';
import FooterLinks from './components/FooterLinks';
import EventPost from './components/EventPost';
import Article from './components/Article';
import ArticlePageControl from './components/ArticlePageControl';
import Album from './components/Album';
import Parallax from './components/Parallax';
@@ -48,7 +48,8 @@ import IOService from './services/io';
import MenuService from './services/menu';
import API from './services/api';
import {collectiveSortPattern} from './config';
import {sortByPattern} from '../utils/sort';
import {documentsSortPattern, collectiveSortPattern} from './config';
let app = angular.module('hudozka', [
'ngRoute',
@@ -68,18 +69,31 @@ app.config(($locationProvider, $routeProvider) => {
title: 'ДХШ Шлиссельбурга'
},
{
name: '/events/:page?/:pageNumber?',
template: '<page-events events="$resolve.posts"></page-events>',
name: '/events/:page?',
template: '<page-events page="{{$.page.page}}" total-pages="{{$.page.totalPages}}" posts="$.page.data"></page-events>',
title: 'События Школы',
resolveAs: '$',
resolve: {
posts: api => api.event
.list()
.then(i => i.data)
page: ($route, api) => {
let page = $route.current.params.page;
if(!page) page = 1;
return api.event
.list(page)
.then(i => i.data)
.then(i => {
let totalPages = Math.ceil(i.total / i.limit);
return {
data: i.data,
page: page,
totalPages: totalPages
}
});
}
}
},
{
name: '/event/:event',
name: '/article/:event',
template: '<page-event></page-event>'
},
{
@@ -150,6 +164,9 @@ app.config(($locationProvider, $routeProvider) => {
documents: api => api.document
.documents()
.then(i => i.data)
.then(i => {
return sortByPattern(i, documentsSortPattern, i => i.category);
})
}
}
]
@@ -196,9 +213,9 @@ app.run(($location, $rootScope, $http) => {
Breadcrumbs,
Timeline,
TimelineRecord,
TimelineRecordPost,
TimelineRecordInstagram,
EventPost,
Article,
ArticlePageControl,
Album,
Parallax,
Document,
@@ -1,7 +1,7 @@
import template from '../../templates/components/event-post.html';
import template from '../../templates/components/article.html';
export default function (app) {
app.component('eventPost', {
app.component('hArticle', {
bindings: {
post: '<'
},
@@ -9,7 +9,7 @@ export default function (app) {
controllerAs: '$',
controller: function ($sce) {
this.message = $sce.trustAsHtml(this.post.post);
this.url = `/event/${this.post.id}`;
this.url = `/article/${this.post.id}`;
}
});
};
@@ -0,0 +1,17 @@
import template from '../../templates/components/article-page-control.html';
export default function (app) {
app.component('articlePageControl', {
bindings: {
direction: '@',
page: '@'
},
template: template,
controllerAs: '$',
controller: function () {
let i = this.direction === 'direct' ? 1 : 0;
this.text = ['↑ Предыдущая страница', '↓ Следующая страница'][i];
this.style = ['article-page-control__top', 'article-page-control__bottom'][i];
}
});
};
+9 -7
View File
@@ -3,18 +3,20 @@ import template from '../../templates/components/page-events.html';
export default function (app) {
app.component('pageEvents', {
bindings: {
events: '<'
posts: '<',
page: '@',
totalPages: '@'
},
template: template,
controllerAs: '$',
controller: function (api, menu) {
this.pageClass = 'page-events';
menu.activate('/events');
//api.event.list()
// .success(posts => {
// this.posts = posts;
// });
this.page = parseInt(this.page);
this.totalPages = parseInt(this.totalPages);
this.prevPage = this.page === 1 ? null : this.page - 1;
this.nextPage = this.page === this.totalPages ? null : this.page + 1;
}
});
};
};
+5 -7
View File
@@ -53,17 +53,13 @@ export default function(app) {
};
}
this.showFooter = () => this.feed && this.feed.length;
this.loadNext = () => {
this.timelineUpdating = true;
usSpinnerService.spin('timelineMore');
api.timeline.feed(limit, skip)
.error(error => {
console.log(error);
})
.success(feed => {
.then(i => i.data)
.then(feed => {
this.timelineUpdating = false;
usSpinnerService.stop('timelineMore');
@@ -72,8 +68,10 @@ export default function(app) {
else return post;
});
skip++;
//skip++;
skip += limit;
this.feed = this.feed.concat(feed2);
this.showFooter = this.feed && this.feed.length;
});
};
@@ -1,13 +0,0 @@
import template from '../../templates/components/timeline-record-post.html';
export default function (app) {
app.component('timelineRecordPost', {
bindings: {
post: '<'
},
template: template,
controller: function($sce){
this.message = $sce.trustAsHtml(this.post.message);
}
});
};
+8
View File
@@ -21,6 +21,14 @@ export const collectiveSortPattern = [
'nv-andreeva'
];
export const documentsSortPattern = [
'Основные документы',
'Документы для поступления',
'Учебные программы',
'Прочее',
'Архив'
];
export const footer = {
links: {
docs: {
+8 -13
View File
@@ -1,9 +1,5 @@
/**
* Created by tmshv on 06/11/14.
*/
angular.module("hudozhka.instagram", [])
.controller("InstagramController", function($scope, $http, $window){
angular.module('hudozka.instagram', [])
.controller('InstagramController', function ($scope, $http) {
//$scope.auth = function() {
// $http.get("/instagram/auth/url")
// .success(function (data) {
@@ -11,17 +7,16 @@ angular.module("hudozhka.instagram", [])
// });
//};
$http.get("/instagram/user")
.error(function() {
})
.success(function (user) {
$http.get('/instagram/user')
.then(i => i.data)
.then(user => {
$scope.user = user;
});
$scope.invite = function() {
$http.get("/instagram/invite")
.success(function (data) {
$http.get('/instagram/invite')
.then(i => i.data)
.success(data => {
$scope.inviteCode = data.code;
});
};