--- a/client/app/app.js Fri May 22 12:37:37 2015 +0200
+++ b/client/app/app.js Fri May 22 12:47:16 2015 +0200
@@ -1,116 +1,130 @@
(function(){
- 'use strict';
+ 'use strict';
- angular.module('ammico', [ 'ngRoute','ammicoHome', 'ammicoBooks', 'ammicoSlides', 'ammicoSlideshow', 'ammicoSearch', 'ammicoAuth', 'templates' ])
- .config(function($routeProvider) {
- $routeProvider.
- when('/', {
- controller: 'homeCtrl',
- templateUrl: 'home/home.html',
- authRequired: false
- }).
- when('/books', {
- controller: 'booksCtrl',
- templateUrl: 'books/books.html',
- authRequired: true
- }).
- when('/books/:idBook', {
- controller: 'bookCtrl',
- templateUrl: 'books/book.html',
- authRequired: true
- }).
- when('/slide/:idSlide', {
- controller: 'slidesCtrl',
- templateUrl: 'slides/slides.html',
- authRequired: true
- }).
- when('/slideshow/', {
- controller: 'slideshowCtrl',
- templateUrl: 'slideshow/slideshow.html',
- authRequired: true
- }).
- when('/slideshow/:iSlide', {
- controller: 'slideshowCtrl',
- templateUrl: 'slideshow/slideshow.html',
- authRequired: true
- }).
- when('/search/:q', {
- controller: 'searchCtrl',
- templateUrl: 'search/search.html',
- authRequired: true
- }).
- when('/auth/:action', {
- controller: 'authCtrl',
- templateUrl: 'home/home.html',
- authRequired: false
- }).
- otherwise({
- redirectTo: '/'
- });
- })
- .run( function($rootScope, $location, $window, $http) {
- $rootScope.globals = {};
- if ($window.sessionStorage.token) {
- $rootScope.globals.userLogged = true;
- $http.defaults.headers.common.Authorization = 'Token ' + $window.sessionStorage.token;
- }
- $rootScope.$on( '$routeChangeStart', function(event, next) {
- if (next.authRequired && !$rootScope.globals.userLogged) {
- $location.path( '/auth/login' );
- }
- });
- })
- .service('searchApi', function($resource, context) {
- this.searchResource = function(params){
- return $resource(context.urls.searchUrl,
- {
- callback: 'JSON_CALLBACK'
- },
- {
- getJsonp: {
- method: 'JSONP',
- params: params,
- isArray: false,
- transformResponse: function(data){
- // Transform meta list into meta dict
- var nb = data.hits.length;
- for(var i=0;i<nb;i++){
- var nb_metas = data.hits[i].metas.length;
- data.hits[i].metas_dict = {};
- for(var j=0;j<nb_metas;j++){
- if(typeof data.hits[i].metas[j].images==='undefined'){
- data.hits[i].metas_dict[data.hits[i].metas[j].name] = data.hits[i].metas[j].value;
- }
- else{
- data.hits[i].metas_dict.images = data.hits[i].metas[j].images[0].value;
- }
- }
- }
- return data;
- }
- }
- });
- };
- })
- .service('ammicoApi', function($resource, context, $sce) {
- this.listBooks = $resource(context.urls.ammicoUrl+'/books');
- this.book = $resource(context.urls.ammicoUrl+'/books/:idBook', {idBook:'@idBook'});
- this.order = $resource(context.urls.ammicoUrl+'/books/:idBook/order', {idBook:'@idBook'});
- this.booksSlides = $resource(context.urls.ammicoUrl+'/books/:idBook/slides', {idBook:'@idBook'});
- this.listSlides= $resource(context.urls.ammicoUrl+'/slides');
- this.slide = $resource(context.urls.ammicoUrl+'/slides/:idSlide', {idSlide:'@idSlide'});
- this.sanitizeUrls = function(data){
- data.details.audio = $sce.trustAsResourceUrl(data.details.audio);
- data.details.video = $sce.trustAsResourceUrl(data.details.video);
- data.audio = $sce.trustAsResourceUrl(data.audio);
- data.video = $sce.trustAsResourceUrl(data.video);
- return data;
- };
- })
- .service('authApi', function($resource, context) {
- this.login = $resource(context.urls.ammicoUrl+'/auth/api-token-auth');
- this.logout = $resource(context.urls.ammicoUrl+'/auth/logout');
- this.user = $resource(context.urls.ammicoUrl+'/auth/user');
- this.test = $resource(context.urls.ammicoUrl+'/auth/auth');
- });
+ angular.module('ammico', [ 'ngRoute','ammicoHome', 'ammicoMyvisit', 'ammicoBooks', 'ammicoVisites', 'ammicoSlides', 'ammicoSlideshow', 'ammicoSearch', 'ammicoAuth', 'templates' ])
+ .config(function($routeProvider) {
+ $routeProvider.
+ when('/', {
+ controller: 'homeCtrl',
+ templateUrl: 'home/home.html',
+ authRequired: false
+ }).
+ when('/my_visit', {
+ controller: 'my_visitCtrl',
+ templateUrl: 'my_visit/my_visit.html',
+ authRequired: true
+ }).
+ when('/books', {
+ controller: 'booksCtrl',
+ templateUrl: 'books/books.html'
+ }).
+ when('/books/:idBook', {
+ controller: 'bookCtrl',
+ templateUrl: 'books/book.html',
+ authRequired: true
+ }).
+ when('/visites', {
+ controller: 'visitesCtrl',
+ templateUrl: 'visites/visites.html',
+ authRequired: true
+ }).
+ when('/visites/:idVisit', {
+ controller: 'visiteCtrl',
+ templateUrl: 'visites/visite.html',
+ authRequired: true
+ }).
+ when('/slide/:idSlide', {
+ controller: 'slidesCtrl',
+ templateUrl: 'slides/slides.html',
+ authRequired: true
+ }).
+ when('/slideshow/', {
+ controller: 'slideshowCtrl',
+ templateUrl: 'slideshow/slideshow.html',
+ authRequired: true
+ }).
+ when('/slideshow/:iSlide', {
+ controller: 'slideshowCtrl',
+ templateUrl: 'slideshow/slideshow.html',
+ authRequired: true
+ }).
+ when('/search/:q', {
+ controller: 'searchCtrl',
+ templateUrl: 'search/search.html',
+ authRequired: true
+ }).
+ when('/auth/:action', {
+ controller: 'authCtrl',
+ templateUrl: 'home/home.html',
+ authRequired: false
+ }).
+ otherwise({
+ redirectTo: '/'
+ });
+ })
+ .run( function($rootScope, $location, $window, $http) {
+ $rootScope.globals = {};
+ if ($window.sessionStorage.token) {
+ $rootScope.globals.userLogged = true;
+ $http.defaults.headers.common.Authorization = 'Token ' + $window.sessionStorage.token;
+ }
+ $rootScope.$on( '$routeChangeStart', function(event, next) {
+ if (next.authRequired && !$rootScope.globals.userLogged) {
+ $location.path( '/auth/login' );
+ }
+ });
+ })
+ .service('searchApi', function($resource, context) {
+ this.searchResource = function(params){
+ return $resource(context.urls.searchUrl,
+ {
+ callback: 'JSON_CALLBACK'
+ },
+ {
+ getJsonp: {
+ method: 'JSONP',
+ params: params,
+ isArray: false,
+ transformResponse: function(data){
+ // Transform meta list into meta dict
+ var nb = data.hits.length;
+ for(var i=0;i<nb;i++){
+ var nb_metas = data.hits[i].metas.length;
+ data.hits[i].metas_dict = {};
+ for(var j=0;j<nb_metas;j++){
+ if(typeof data.hits[i].metas[j].images==='undefined'){
+ data.hits[i].metas_dict[data.hits[i].metas[j].name] = data.hits[i].metas[j].value;
+ }
+ else{
+ data.hits[i].metas_dict.images = data.hits[i].metas[j].images[0].value;
+ }
+ }
+ }
+ return data;
+ }
+ }
+ });
+ };
+ })
+ .service('ammicoApi', function($resource, context, $sce) {
+ this.listBooks = $resource(context.urls.ammicoUrl+'/books');
+ this.book = $resource(context.urls.ammicoUrl+'/books/:idBook', {idBook:'@id'});
+ this.order = $resource(context.urls.ammicoUrl+'/books/:idBook/order', {idBook:'@id'});
+ this.booksSlides = $resource(context.urls.ammicoUrl+'/books/:idBook/slides', {idBook:'@id'});
+ this.listSlides= $resource(context.urls.ammicoUrl+'/slides');
+ this.slide = $resource(context.urls.ammicoUrl+'/slides/:idSlide', {idSlide:'@id'});
+ this.sanitizeUrls = function(data){
+ data.details.audio = $sce.trustAsResourceUrl(data.details.audio);
+ data.details.video = $sce.trustAsResourceUrl(data.details.video);
+ data.audio = $sce.trustAsResourceUrl(data.audio);
+ data.video = $sce.trustAsResourceUrl(data.video);
+ return data;
+ };
+ })
+ .service('authApi', function($resource, context) {
+ this.login = $resource(context.urls.ammicoUrl+'/auth/api-token-auth');
+ this.logout = $resource(context.urls.ammicoUrl+'/auth/logout');
+ this.user = $resource(context.urls.ammicoUrl+'/auth/user');
+ this.test = $resource(context.urls.ammicoUrl+'/auth/auth');
+ });
})();