client/app/app.js
author rougeronj
Tue, 31 Mar 2015 12:24:05 +0200
changeset 47 dd750778535c
parent 40 4b3bebe4355d
child 52 ce9aefce6e41
permissions -rw-r--r--
udate add fonction from a research and add a modal to select the book we want to add the slide
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
(function(){
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
  'use strict';
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
27
2b508b65571a add routes for books and slides
rougeronj
parents: 14
diff changeset
     4
  angular.module('ammico', [ 'ngRoute','ammicoHome', 'ammicoBooks', 'ammicoSlides', 'ammicoSlideshow', 'ammicoSearch', 'ammicoAuth', 'templates' ])
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
    .config(function($routeProvider) {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
      $routeProvider.
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
        when('/', {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
        controller: 'homeCtrl',
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
        templateUrl: 'home/home.html'
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
      }).
27
2b508b65571a add routes for books and slides
rougeronj
parents: 14
diff changeset
    11
      when('/books', {
2b508b65571a add routes for books and slides
rougeronj
parents: 14
diff changeset
    12
          controller: 'booksCtrl',
2b508b65571a add routes for books and slides
rougeronj
parents: 14
diff changeset
    13
          templateUrl: 'books/books.html'
2b508b65571a add routes for books and slides
rougeronj
parents: 14
diff changeset
    14
      }).
2b508b65571a add routes for books and slides
rougeronj
parents: 14
diff changeset
    15
      when('/books/:idBook', {
2b508b65571a add routes for books and slides
rougeronj
parents: 14
diff changeset
    16
        controller: 'bookCtrl',
2b508b65571a add routes for books and slides
rougeronj
parents: 14
diff changeset
    17
        templateUrl: 'books/book.html'
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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
2b508b65571a add routes for books and slides
rougeronj
parents: 14
diff changeset
    24
          controller: 'slidesCtrl',
2b508b65571a add routes for books and slides
rougeronj
parents: 14
diff changeset
    25
          templateUrl: 'slides/slides.html'
2b508b65571a add routes for books and slides
rougeronj
parents: 14
diff changeset
    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
74bbdd739878 views, path, search...
cavaliet
parents: 0
diff changeset
    28
          controller: 'slideshowCtrl',
74bbdd739878 views, path, search...
cavaliet
parents: 0
diff changeset
    29
          templateUrl: 'slideshow/slideshow.html'
2
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    30
      }).
4
28208a0ad8b9 edit slide by url
cavaliet
parents: 2
diff changeset
    31
      when('/slideshow/:iSlide', {
2
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    32
          controller: 'slideshowCtrl',
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    33
          templateUrl: 'slideshow/slideshow.html'
4
28208a0ad8b9 edit slide by url
cavaliet
parents: 2
diff changeset
    34
      }).
28208a0ad8b9 edit slide by url
cavaliet
parents: 2
diff changeset
    35
      when('/slideshow/edit/:iSlide', {
28208a0ad8b9 edit slide by url
cavaliet
parents: 2
diff changeset
    36
          controller: 'slideshowCtrl',
28208a0ad8b9 edit slide by url
cavaliet
parents: 2
diff changeset
    37
          templateUrl: 'slideshow/slideshow.html'
28208a0ad8b9 edit slide by url
cavaliet
parents: 2
diff changeset
    38
      }).
2
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    39
      when('/slideshow/add/:searched', {
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
        controller: 'slideshowCtrl',
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
        templateUrl: 'slideshow/slideshow.html'
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
      }).
27
2b508b65571a add routes for books and slides
rougeronj
parents: 14
diff changeset
    43
      when('/search', {
1
74bbdd739878 views, path, search...
cavaliet
parents: 0
diff changeset
    44
          controller: 'searchCtrl',
74bbdd739878 views, path, search...
cavaliet
parents: 0
diff changeset
    45
          templateUrl: 'search/search.html'
74bbdd739878 views, path, search...
cavaliet
parents: 0
diff changeset
    46
      }).
74bbdd739878 views, path, search...
cavaliet
parents: 0
diff changeset
    47
      when('/search/:q', {
74bbdd739878 views, path, search...
cavaliet
parents: 0
diff changeset
    48
          controller: 'searchCtrl',
74bbdd739878 views, path, search...
cavaliet
parents: 0
diff changeset
    49
          templateUrl: 'search/search.html'
74bbdd739878 views, path, search...
cavaliet
parents: 0
diff changeset
    50
      }).
27
2b508b65571a add routes for books and slides
rougeronj
parents: 14
diff changeset
    51
      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
    52
          controller: 'authCtrl',
4b3bebe4355d add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents: 32
diff changeset
    53
          templateUrl: 'auth/auth.html'
13
08f34bbc70ee set up django rest framework
rougeronj
parents: 8
diff changeset
    54
      }).
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
      otherwise({
1
74bbdd739878 views, path, search...
cavaliet
parents: 0
diff changeset
    56
        redirectTo: '/'
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
      });
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
    })
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
    // .config(function ($routeProvider) {
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
    //   $routeProvider
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
    //     .otherwise({
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
    //       redirectTo: '/'
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
    //   });
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
    // });
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
    .config(function($logProvider){
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
      $logProvider.debugEnabled(true);
2
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    67
    })
40
4b3bebe4355d add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents: 32
diff changeset
    68
    .service('searchApi', function($resource, context, $sce) {
2
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    69
        this.searchResource = function(params){
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    70
            return $resource(context.urls.searchUrl,  
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    71
                {
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    72
                    callback: 'JSON_CALLBACK'
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    73
                },
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    74
                {
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    75
                    getJsonp: {
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    76
                        method: 'JSONP',
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    77
                        params: params,
8
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    78
                        isArray: false,
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    79
                        transformResponse: function(data){
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    80
                            // Transform meta list into meta dict
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    81
                            var nb = data.hits.length;
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    82
                            for(var i=0;i<nb;i++){
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    83
                                var nb_metas = data.hits[i].metas.length;
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    84
                                data.hits[i].metas_dict = {};
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    85
                                for(var j=0;j<nb_metas;j++){
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    86
                                    if(typeof data.hits[i].metas[j].images==='undefined'){
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    87
                                        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
    88
                                    }
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    89
                                    else{
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    90
                                        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
    91
                                    }
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    92
                                }
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    93
                            }
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    94
                            return data;
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    95
                        }
2
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    96
                    }
8
824c87a9084c (really) better management of slideshowModel with new api.
cavaliet
parents: 4
diff changeset
    97
                });
2
36ccc573af9a clean search resource
cavaliet
parents: 1
diff changeset
    98
        };
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
    99
        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
   100
        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
   101
        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
   102
        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
   103
        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
   104
        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
   105
        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
   106
        	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
   107
        	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
   108
        	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
   109
        	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
   110
        	return data;
4b3bebe4355d add sanitize function to accept url from the request response - enable edit on dbclick - improve html
rougeronj
parents: 32
diff changeset
   111
        };
0
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
    });
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
cef349423167 add basic file org + client prototype
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
})();