| author | rougeronj |
| Thu, 02 Apr 2015 12:06:51 +0200 | |
| changeset 54 | ccb586464a6f |
| parent 52 | ce9aefce6e41 |
| child 55 | 10fd23382e76 |
| permissions | -rw-r--r-- |
| 0 | 1 |
(function(){ |
2 |
'use strict'; |
|
3 |
||
| 27 | 4 |
angular.module('ammico', [ 'ngRoute','ammicoHome', 'ammicoBooks', 'ammicoSlides', 'ammicoSlideshow', 'ammicoSearch', 'ammicoAuth', 'templates' ]) |
| 0 | 5 |
.config(function($routeProvider) { |
6 |
$routeProvider. |
|
7 |
when('/', { |
|
8 |
controller: 'homeCtrl', |
|
9 |
templateUrl: 'home/home.html' |
|
10 |
}). |
|
| 27 | 11 |
when('/books', { |
12 |
controller: 'booksCtrl', |
|
13 |
templateUrl: 'books/books.html' |
|
14 |
}). |
|
15 |
when('/books/:idBook', { |
|
16 |
controller: 'bookCtrl', |
|
17 |
templateUrl: 'books/book.html' |
|
| 0 | 18 |
}). |
|
47
dd750778535c
udate add fonction from a research and add a modal to select the book we want to add the slide
rougeronj
parents:
40
diff
changeset
|
19 |
when('/books/:idBook/add/:searched', { |
|
dd750778535c
udate add fonction from a research and add a modal to select the book we want to add the slide
rougeronj
parents:
40
diff
changeset
|
20 |
controller: 'booksCtrl', |
|
dd750778535c
udate add fonction from a research and add a modal to select the book we want to add the slide
rougeronj
parents:
40
diff
changeset
|
21 |
templateUrl: 'books/book.html' |
|
dd750778535c
udate add fonction from a research and add a modal to select the book we want to add the slide
rougeronj
parents:
40
diff
changeset
|
22 |
}). |
|
32
802ba9793507
add delete request to delete a slide - rename some .ressources fonctions
rougeronj
parents:
27
diff
changeset
|
23 |
when('/slide/:idSlide', { |
| 27 | 24 |
controller: 'slidesCtrl', |
25 |
templateUrl: 'slides/slides.html' |
|
26 |
}). |
|
|
40
4b3bebe4355d
add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents:
32
diff
changeset
|
27 |
when('/slideshow/', { |
| 1 | 28 |
controller: 'slideshowCtrl', |
29 |
templateUrl: 'slideshow/slideshow.html' |
|
| 2 | 30 |
}). |
| 4 | 31 |
when('/slideshow/:iSlide', { |
| 2 | 32 |
controller: 'slideshowCtrl', |
33 |
templateUrl: 'slideshow/slideshow.html' |
|
| 4 | 34 |
}). |
| 1 | 35 |
when('/search/:q', { |
36 |
controller: 'searchCtrl', |
|
37 |
templateUrl: 'search/search.html' |
|
38 |
}). |
|
| 27 | 39 |
when('/login', { |
|
40
4b3bebe4355d
add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents:
32
diff
changeset
|
40 |
controller: 'authCtrl', |
|
4b3bebe4355d
add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents:
32
diff
changeset
|
41 |
templateUrl: 'auth/auth.html' |
| 13 | 42 |
}). |
| 0 | 43 |
otherwise({ |
| 1 | 44 |
redirectTo: '/' |
| 0 | 45 |
}); |
46 |
}) |
|
47 |
// .config(function ($routeProvider) { |
|
48 |
// $routeProvider |
|
49 |
// .otherwise({ |
|
50 |
// redirectTo: '/' |
|
51 |
// }); |
|
52 |
// }); |
|
53 |
.config(function($logProvider){ |
|
54 |
$logProvider.debugEnabled(true); |
|
| 2 | 55 |
}) |
|
40
4b3bebe4355d
add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents:
32
diff
changeset
|
56 |
.service('searchApi', function($resource, context, $sce) { |
| 2 | 57 |
this.searchResource = function(params){ |
58 |
return $resource(context.urls.searchUrl, |
|
59 |
{ |
|
60 |
callback: 'JSON_CALLBACK' |
|
61 |
}, |
|
62 |
{ |
|
63 |
getJsonp: { |
|
64 |
method: 'JSONP', |
|
65 |
params: params, |
|
|
8
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
66 |
isArray: false, |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
67 |
transformResponse: function(data){ |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
68 |
// Transform meta list into meta dict |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
69 |
var nb = data.hits.length; |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
70 |
for(var i=0;i<nb;i++){ |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
71 |
var nb_metas = data.hits[i].metas.length; |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
72 |
data.hits[i].metas_dict = {}; |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
73 |
for(var j=0;j<nb_metas;j++){ |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
74 |
if(typeof data.hits[i].metas[j].images==='undefined'){ |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
75 |
data.hits[i].metas_dict[data.hits[i].metas[j].name] = data.hits[i].metas[j].value; |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
76 |
} |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
77 |
else{ |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
78 |
data.hits[i].metas_dict.images = data.hits[i].metas[j].images[0].value; |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
79 |
} |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
80 |
} |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
81 |
} |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
82 |
return data; |
|
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
83 |
} |
| 2 | 84 |
} |
|
8
824c87a9084c
(really) better management of slideshowModel with new api.
cavaliet
parents:
4
diff
changeset
|
85 |
}); |
| 2 | 86 |
}; |
|
47
dd750778535c
udate add fonction from a research and add a modal to select the book we want to add the slide
rougeronj
parents:
40
diff
changeset
|
87 |
this.listBooks = $resource(context.urls.ammicoUrl+'/books'); |
|
dd750778535c
udate add fonction from a research and add a modal to select the book we want to add the slide
rougeronj
parents:
40
diff
changeset
|
88 |
this.book = $resource(context.urls.ammicoUrl+'/books/:idBook', {idBook:'@idBook'}); |
|
dd750778535c
udate add fonction from a research and add a modal to select the book we want to add the slide
rougeronj
parents:
40
diff
changeset
|
89 |
this.order = $resource(context.urls.ammicoUrl+'/books/:idBook/order', {idBook:'@idBook'}); |
|
dd750778535c
udate add fonction from a research and add a modal to select the book we want to add the slide
rougeronj
parents:
40
diff
changeset
|
90 |
this.booksSlides = $resource(context.urls.ammicoUrl+'/books/:idBook/slides', {idBook:'@idBook'}); |
|
dd750778535c
udate add fonction from a research and add a modal to select the book we want to add the slide
rougeronj
parents:
40
diff
changeset
|
91 |
this.listSlides= $resource(context.urls.ammicoUrl+'/slides'); |
|
dd750778535c
udate add fonction from a research and add a modal to select the book we want to add the slide
rougeronj
parents:
40
diff
changeset
|
92 |
this.slide = $resource(context.urls.ammicoUrl+'/slides/:idSlide', {idSlide:'@idSlide'}); |
|
40
4b3bebe4355d
add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents:
32
diff
changeset
|
93 |
this.sanitizeUrls = function(data){ |
|
4b3bebe4355d
add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents:
32
diff
changeset
|
94 |
data.details.audio = $sce.trustAsResourceUrl(data.details.audio); |
|
4b3bebe4355d
add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents:
32
diff
changeset
|
95 |
data.details.video = $sce.trustAsResourceUrl(data.details.video); |
|
4b3bebe4355d
add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents:
32
diff
changeset
|
96 |
data.audio = $sce.trustAsResourceUrl(data.audio); |
|
4b3bebe4355d
add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents:
32
diff
changeset
|
97 |
data.video = $sce.trustAsResourceUrl(data.video); |
|
4b3bebe4355d
add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents:
32
diff
changeset
|
98 |
return data; |
|
4b3bebe4355d
add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents:
32
diff
changeset
|
99 |
}; |
| 52 | 100 |
}) |
101 |
.service('authApi', function($resource, context) { |
|
102 |
this.login = $resource(context.urls.ammicoUrl+'/auth/api-token-auth'); |
|
103 |
this.logout = $resource(context.urls.ammicoUrl+'/auth/logout'); |
|
104 |
this.user = $resource(context.urls.ammicoUrl+'/auth/user'); |
|
105 |
this.test = $resource(context.urls.ammicoUrl+'/auth/auth'); |
|
106 |
}); |
|
| 0 | 107 |
|
108 |
})(); |