--- a/client/.jshintrc Thu Oct 02 13:24:57 2014 +0200
+++ b/client/.jshintrc Fri Oct 03 10:38:50 2014 +0200
@@ -3,14 +3,14 @@
"node": true,
"esnext": true,
"bitwise": true,
- "camelcase": true,
+ "camelcase": false,
"eqeqeq": true,
"immed": true,
"indent": 4,
"latedef": true,
"newcap": true,
"noarg": true,
- "quotmark": "single",
+ "quotmark": true,
"regexp": true,
"undef": true,
"unused": true,
--- a/client/app/app.js Thu Oct 02 13:24:57 2014 +0200
+++ b/client/app/app.js Fri Oct 03 10:38:50 2014 +0200
@@ -15,8 +15,12 @@
when('/slideshow/', {
controller: 'slideshowCtrl',
templateUrl: 'slideshow/slideshow.html'
- }).
- when('/slideshow/:iSlide', {
+ }).
+ /*when('/slideshow/:iSlide', {
+ controller: 'slideshowCtrl',
+ templateUrl: 'slideshow/slideshow.html'
+ }).*/
+ when('/slideshow/add/:searched', {
controller: 'slideshowCtrl',
templateUrl: 'slideshow/slideshow.html'
}).
@@ -40,6 +44,22 @@
// });
.config(function($logProvider){
$logProvider.debugEnabled(true);
+ })
+ .service('searchApi', function($resource, context) {
+ console.log('search 4',$resource, context);
+ this.searchResource = function(params){
+ return $resource(context.urls.searchUrl,
+ {
+ callback: 'JSON_CALLBACK'
+ },
+ {
+ getJsonp: {
+ method: 'JSONP',
+ params: params,
+ isArray: false
+ }
+ }).getJsonp();
+ };
});
})();
--- a/client/app/search/search.css Thu Oct 02 13:24:57 2014 +0200
+++ b/client/app/search/search.css Fri Oct 03 10:38:50 2014 +0200
@@ -1,12 +1,14 @@
.item {
min-height: 250px;
border-bottom: 1px solid #000;
+}
+.item:not(:first-child){
padding-top: 10px;
}
.item img {
max-height: 230px;
}
-.item p {
+.item p, .item a.btn {
margin: 0 0 5px;
}
--- a/client/app/search/search.html Thu Oct 02 13:24:57 2014 +0200
+++ b/client/app/search/search.html Fri Oct 03 10:38:50 2014 +0200
@@ -3,7 +3,7 @@
<div ng-if="results.nhits>0">
<div class="row item" ng-repeat="h in results.hits">
<img class="col-md-3" src="{{ h.url }}"/>
- <div class="col-md-8">
+ <div class="col-md-7">
<p><strong>Nom :</strong> {{ h.metas|meta:"name" }}</p>
<p><strong>Description :</strong> {{ h.metas|meta:"description" }}</p>
<p><small><strong>Classification :</strong> {{ h.metas|meta:"classification" }}</small></p>
@@ -13,5 +13,9 @@
<p><small><strong>Acteurs :</strong> {{ h.metas|meta:"actors" }}</small></p>
<p><small><strong>Lieux :</strong> {{ h.metas|meta:"places" }}</small></p>
</div>
+ <div class="col-md-1">
+ <a class="btn btn-default" href="#/slideshow/add/{{q}},{{$index}}"><span class="glyphicon glyphicon-plus"></span></a>
+ <a class="btn btn-default"><span class="glyphicon glyphicon-eye-open"></span></a>
+ </div>
</div>
</div>
--- a/client/app/search/search_controller.js Thu Oct 02 13:24:57 2014 +0200
+++ b/client/app/search/search_controller.js Fri Oct 03 10:38:50 2014 +0200
@@ -9,50 +9,26 @@
controller: 'searchCtrl'
});
})
- .service('searchApi', function($resource, context) {
- console.log('search 4',$resource, context);
- this.searchResource = function(params){
- return $resource(context.urls.searchUrl,
- {
- callback: 'JSON_CALLBACK'
- },
- {
- getJsonp: {
- method: 'JSONP',
- params: params,
- isArray: false
- }
- });
- };
-
- })
- .service('searchModel', function(searchApi) {
- console.log('search 5');
- this.searchResults = function(params){
- return searchApi.searchResource(params).getJsonp();
- };
- })
- .controller('searchCtrl', function($scope, $location, $routeParams, searchModel){
+ .controller('searchCtrl', function($scope, $location, $routeParams, searchApi){
console.log('search 6',$scope, $location, $routeParams);
$scope.q = $routeParams.q || '';
- searchModel.searchResults({q:$scope.q, of: 'json', synthesis: 'false', callback: 'JSON_CALLBACK'}).$promise.then(
+ searchApi.searchResource({q:$scope.q, of: 'json', synthesis: 'false', nresults:'50', callback: 'JSON_CALLBACK'}).$promise.then(
//success
function( data ){
- console.log('SUCCESS !', data);
$scope.results = data;
},
//error
function( error ){
- console.log('ERROR !', error);
+ alert('Erreur avec la requête', error);
}
);
- //window.myres = res;
- //$scope.results = res;
- //console.log('search 6-blabla', res);
- console.log('search 7', $scope.q);
- //$scope.search = searchModel.search;
- // query = ?q=violon&of=json&synthesis=false
+ $scope.addItem = function(i){
+ console.log('addItem',i);
+ if($scope.results.hits.length>0 && 0<=i && i<$scope.results.hits.length){
+
+ }
+ };
})
.filter('meta', function() {
return function(input, metaName) {
@@ -64,6 +40,7 @@
}
i++;
}
+ return '';
};
});
--- a/client/app/slideshow/slideshow.html Thu Oct 02 13:24:57 2014 +0200
+++ b/client/app/slideshow/slideshow.html Fri Oct 03 10:38:50 2014 +0200
@@ -2,7 +2,7 @@
<p>{{ slideshow.description }}</p>
<div class="carousel-holder row">
<carousel>
- <slide ng-repeat="slide in slideshow.images" active="slide.active" ng-init="slide.active = (iSlide==$index)">
+ <slide ng-repeat="slide in slideshow.images" active="slide.active">
<div class="row">
<div class="col-md-7 col-md-offset-1">
<img ng-src="{{slide.url}}" style="margin:auto;">
--- a/client/app/slideshow/slideshow_controller.js Thu Oct 02 13:24:57 2014 +0200
+++ b/client/app/slideshow/slideshow_controller.js Fri Oct 03 10:38:50 2014 +0200
@@ -10,24 +10,45 @@
});
})
.service('slideshowApi', function($resource, context) {
- console.log('5',this);
+ console.log('slideshow 5',this);
this.slideshow = $resource(context.urls.slideshowUrl);
})
.service('slideshowModel', function(slideshowApi, context) {
- console.log('6',this);
+ console.log('slideshow 6',this);
if(typeof context.slideshow === 'undefined') {
- console.log('6-1');
+ console.log('slideshow 6-1');
this.slideshow = slideshowApi.slideshow.get();
}
else {
- console.log('6-2');
+ console.log('slideshow 6-2');
this.slideshow = new slideshowApi.slideshow(context.slideshow);
}
})
- .controller('slideshowCtrl', function($scope, $location, $routeParams, slideshowModel){
- console.log('7',$scope, $location, slideshowModel);
+ .controller('slideshowCtrl', function($scope, $filter, $location, $routeParams, $timeout, searchApi, slideshowModel){
+ console.log('slideshow 7', $filter, $routeParams, searchApi, slideshowModel);
$scope.slideshow = slideshowModel.slideshow;
$scope.iSlide = parseInt($routeParams.iSlide) || 0;
+ if(typeof $routeParams.searched !== 'undefined'){
+ var a = $routeParams.searched.split(',');
+ var q = a[0], i = parseInt(a[1]);
+ if(a.length===2 && !isNaN(i)){
+ searchApi.searchResource({q:q, of: 'json', synthesis: 'false', nresults:'50', callback: 'JSON_CALLBACK'}).$promise.then(
+ //success
+ function( data ){
+ var hit = data.hits[i];
+ $scope.slideshow.images.push({url: $filter('meta')(hit.metas, 'url'),
+ title: $filter('meta')(hit.metas, 'name'),
+ description: $filter('meta')(hit.metas, 'description'), tags: [], user_title:'', user_description:''});
+ // timeout because
+ $timeout(function(){$scope.slideshow.images[$scope.slideshow.images.length-1].active = true;}, 200);
+ },
+ //error
+ function( error ){
+ alert('Erreur avec la requête (dans slideshow)', error);
+ }
+ );
+ }
+ }
$scope.save = function(){
console.log('8 call save POST',$scope.slideshow);
@@ -43,7 +64,6 @@
);
};
})
- //.directive('slideEditor', function(context) {
.directive('slideEditor', function() {
return {
restrict: 'AE',