updated schedule api; updated index routing; + routing based on Accept header;

This commit is contained in:
tmshv committed 2015-03-01 01:59:00 +03:00
1 parent 6af90258c9
commit a694abb3e5
6 files changed
+148 -29

No files matched your search

+3 -1
View File
@@ -46,10 +46,12 @@ app.config(function ($locationProvider, $routeProvider) {
});
});
app.run(function($location, $rootScope) {
app.run(function($location, $rootScope, $http) {
$rootScope.$on("$routeChangeSuccess", function (event, current, previous) {
$rootScope.title = current.$$route.title;
});
$http.defaults.headers.common["Accept"] = "application/json";
});
require("./api/api")(app);
+16 -8
View File
@@ -2,20 +2,28 @@ var populate = require("../../utils/populate").populate;
const course = require("../../models/course");
module.exports = function (app) {
app.controller("ScheduleController", function ($scope, schedule, team) {
app.controller("ScheduleController", function ($scope, $http, schedule, team) {
var now = new Date();
var dates = getDates(now);
var sem = "late";
$scope.sem = [["early", "весеннего"], ["late", "осеннего"]].reduce(function (s, word) {
var sem = "autumn";
$scope.sem = [["spring", "весеннего"], ["autumn", "осеннего"]].reduce(function (s, word) {
if (word[0] === sem) return word[1];
});
$scope.year = 2014;
$scope.year = "2014-2015";
$scope.schedule = schedule($scope.year, sem, [
populate(team.short, "teacher"),
populate(course.name, "lesson")
]);
$http.get("/schedule/2014-2015/spring")
.success(function (s) {
$scope.schedule = schedule.populate(s.schedule, [
populate(team.short, "teacher"),
populate(course.name, "lesson")
]);
});
//$scope.schedule = schedule($scope.year, sem, [
// populate(team.short, "teacher"),
// populate(course.name, "lesson")
//]);
$scope.isToday = function (weekDayIndex) {
return (now.getDay() - 1) === weekDayIndex;