From c19b104c1faddb80461a4472e09d0c40a17d982c Mon Sep 17 00:00:00 2001 From: JulieMarie Date: Wed, 21 Jan 2015 19:42:46 -0800 Subject: [PATCH] ratings fix --- public/dist/application.js | 10 +++++----- public/dist/application.min.js | 2 +- .../brewery/controllers/brewery.client.controller.js | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/public/dist/application.js b/public/dist/application.js index 8e1f568..88d41d2 100644 --- a/public/dist/application.js +++ b/public/dist/application.js @@ -254,11 +254,12 @@ angular.module('nearby').controller('BreweryController', ['$scope', 'Brewery', ' ]; // Create new Rating - $scope.create = function(beerId) { + $scope.create = function(index) { - index = Core.findIndexByKeyValue($scope.beers, 'id', beerId); - console.log('index: ', index); - console.log('beerId: ', beerId); + console.log('index before: ', index); + // index = Core.findIndexByKeyValue($scope.beers, 'id', beerId); + // console.log('index after: ', index); + // console.log('beerId: ', beerId); // Create new Rating object var rating = new Ratings ({ beerId: $scope.beers[index].id, @@ -266,7 +267,6 @@ angular.module('nearby').controller('BreweryController', ['$scope', 'Brewery', ' stars: this.rate, styleName: $scope.beers[index].style.name }); - console.log('rating.beerId: ', rating.beerId); // Redirect after save rating.$save(function(response) { diff --git a/public/dist/application.min.js b/public/dist/application.min.js index cc44295..4e6c199 100644 --- a/public/dist/application.min.js +++ b/public/dist/application.min.js @@ -1 +1 @@ -"use strict";var ApplicationConfiguration=function(){var applicationModuleName="onTappApp",applicationModuleVendorDependencies=["ngResource","ngAnimate","ui.router","ui.bootstrap","ui.utils","uiGmapgoogle-maps","geolocation","angularSpinner"],registerModule=function(moduleName,dependencies){angular.module(moduleName,dependencies||[]),angular.module(applicationModuleName).requires.push(moduleName)};return{applicationModuleName:applicationModuleName,applicationModuleVendorDependencies:applicationModuleVendorDependencies,registerModule:registerModule}}();angular.module(ApplicationConfiguration.applicationModuleName,ApplicationConfiguration.applicationModuleVendorDependencies),angular.module(ApplicationConfiguration.applicationModuleName).config(["$locationProvider",function($locationProvider){$locationProvider.html5Mode(!0),$locationProvider.hashPrefix("!")}]),angular.element(document).ready(function(){"#_=_"===window.location.hash&&(window.location.hash="#!"),angular.bootstrap(document,[ApplicationConfiguration.applicationModuleName])}),ApplicationConfiguration.registerModule("beer"),ApplicationConfiguration.registerModule("brewery"),ApplicationConfiguration.registerModule("core"),ApplicationConfiguration.registerModule("nearby"),ApplicationConfiguration.registerModule("ratings"),ApplicationConfiguration.registerModule("search"),ApplicationConfiguration.registerModule("users"),angular.module("beer").config(["$stateProvider",function($stateProvider){$stateProvider.state("beer",{url:"/beer/:beerId",templateUrl:"modules/beer/views/beer.client.view.html"})}]),angular.module("beer").controller("BeerController",["$scope","Beer","$stateParams","StyleQuery",function($scope,Beer,$stateParams,StyleQuery){$scope.beerId=$stateParams.beerId,$scope.recommendations=[];var shuffle=function(array){for(var temporaryValue,randomIndex,currentIndex=array.length;0!==currentIndex;)randomIndex=Math.floor(Math.random()*currentIndex),currentIndex-=1,temporaryValue=array[currentIndex],array[currentIndex]=array[randomIndex],array[randomIndex]=temporaryValue;return array},handleSuccess=function(data){$scope.recommendations=shuffle(data.data)},getRecommendations=function(styleName){StyleQuery.getStyle(styleName).success(handleSuccess)};Beer.getData($scope.beerId).success(function(results){$scope.beer=results.data||"Request failed",getRecommendations(results.data.style.name)})}]),angular.module("beer").factory("Beer",["$http",function($http){return{getData:function(beerId){return $http.get("/api/beer/"+beerId)}}}]),angular.module("beer").factory("StyleQuery",["$http",function($http){return{getStyle:function(styleName){return $http.get("/api/style/"+styleName)}}}]),angular.module("brewery").config(["$stateProvider",function($stateProvider){$stateProvider.state("brewery",{url:"/brewery/:breweryId",templateUrl:"modules/brewery/views/brewery.client.view.html"})}]),angular.module("nearby").controller("BreweryController",["$scope","Brewery","$stateParams","Ratings","$location","Core",function($scope,Brewery,$stateParams,Ratings,$location,Core){$scope.breweryId=$stateParams.breweryId,$scope.brewery=[],$scope.socialMedia=[];var socialMediaArr=[1,2,3,8,10,14,15,16];Brewery.getData($scope.breweryId).success(function(data){if($scope.brewery=data.data||"Request failed",void 0!==$scope.brewery.locations)for(var i=0;i<$scope.brewery.locations.length;i++)$scope.brewery.locations[i].region=Core.abbrState($scope.brewery.locations[i].region),-1===$scope.brewery.locations[i].phone.indexOf("-")&&($scope.brewery.locations[i].phone=Core.fixPhone($scope.brewery.locations[i].phone));if(void 0!==$scope.brewery.socialAccounts)for(var j=0;j<$scope.brewery.socialAccounts.length;j++){var tempSocial=$scope.brewery.socialAccounts[j];socialMediaArr.indexOf(tempSocial.socialMediaId)>-1&&$scope.socialMedia.push(tempSocial)}}),$scope.beers=[],$scope.availabilityGroups=[],Brewery.getBeersData($scope.breweryId).success(function(data){$scope.beers=data.data||"Request failed",$scope.availabilityGroups=uniqueItems($scope.beers)}),$scope.useAvailability=[],$scope.filterBeer=function(){return function(p){if(0===$scope.useAvailability.length||-1===$scope.useAvailability.indexOf(!0))return!0;for(var i in $scope.useAvailability)if(p.availableId===$scope.availabilityGroups[i].availableId&&$scope.useAvailability[i])return!0}},$scope.rate=0,$scope.max=5,$scope.isReadonly=!1;var index;$scope.hoveringOver=function(value){$scope.overStar=value,$scope.percent=100*(value/$scope.max)},$scope.ratingStates=[{stateOn:"glyphicon-star",stateOff:"glyphicon-star-empty"}],$scope.create=function(beerId){index=Core.findIndexByKeyValue($scope.beers,"id",beerId),console.log("index: ",index),console.log("beerId: ",beerId);var rating=new Ratings({beerId:$scope.beers[index].id,name:$scope.beers[index].name,stars:this.rate,styleName:$scope.beers[index].style.name});console.log("rating.beerId: ",rating.beerId),rating.$save(function(response){$location.path("beer/"+response.beerId),$scope.name=""},function(errorResponse){$scope.error=errorResponse.data.message})};var uniqueItems=function(data){for(var result=[],i=0;ib.availableId?1:a.availableId":"",phone=void 0!==$scope.breweries[i].phone?$scope.breweries[i].phone+"
":"",id=$scope.breweries[i].brewery.id,dist=$scope.breweries[i].distance+" miles away
",desc='
'+name+"
"+dist+addr+phone+"
",ret={id:i,coords:{latitude:$scope.breweries[i].latitude,longitude:$scope.breweries[i].longitude},options:{title:name},infoWindow:{content:desc},icon:"/modules/nearby/images/beer-icon.png",showWindow:!1};return ret.onClick=function(){$scope.oldWindow>-1&&($scope.allMarkers[$scope.oldWindow].showWindow=!1),$scope.oldWindow=ret.id,ret.showWindow=!ret.showWindow},ret},placeMarker=function(){for(var markers=[],i=0;i<$scope.breweries.length;i++)markers.push(createMarker(i));$scope.allMarkers=markers};$scope.closeClick=function(){$scope.windowOptions.visible=!1},$scope.getUserLocation=function(){geolocation.getLocation().then(function(data){$scope.coords={lat:data.coords.latitude,"long":data.coords.longitude},uiGmapGoogleMapApi.then(function(){$scope.map={center:{latitude:$scope.coords.lat,longitude:$scope.coords["long"]},zoom:12},$scope.windowOptions={visible:!0},curLocationMarker(),Breweries.getData($scope.coords).success(handleSuccess)})})}}]),angular.module("nearby").factory("Breweries",["$http",function($http){return{getData:function(coords){return $http.get("/api/breweries/"+coords.lat+"/"+coords["long"])}}}]),angular.module("ratings").run(["Menus",function(Menus){Menus.addMenuItem("topbar","Recommendations","recommendations","/ratings(/create)?")}]),angular.module("ratings").config(["$stateProvider",function($stateProvider){$stateProvider.state("listRatings",{url:"/recommendations",templateUrl:"modules/ratings/views/list-ratings.client.view.html"}).state("viewRating",{url:"/ratings/:ratingId",templateUrl:"modules/ratings/views/view-rating.client.view.html"}).state("editRating",{url:"/ratings/:ratingId/edit",templateUrl:"modules/ratings/views/edit-rating.client.view.html"})}]),angular.module("ratings").controller("RatingsController",["$scope","$stateParams","$location","Authentication","Ratings","StyleQuery","PredictionIO","Beer",function($scope,$stateParams,$location,Authentication,Ratings,StyleQuery,PredictionIO,Beer){$scope.authentication=Authentication,$scope.remove=function(rating){if(rating){rating.$remove();for(var i in $scope.ratings)$scope.ratings[i]===rating&&$scope.ratings.splice(i,1)}else $scope.rating.$remove(function(){$location.path("ratings")})},$scope.update=function(){var rating=$scope.rating;rating.$update(function(){$location.path("ratings/"+rating._id)},function(errorResponse){$scope.error=errorResponse.data.message})},$scope.find=function(){$scope.ratings=Ratings.query();var userId=Authentication.user._id;$scope.ratings.$promise.then(function(){getPredition(userId)})},$scope.findOne=function(){$scope.rating=Ratings.get({ratingId:$stateParams.ratingId}),$scope.rating.$promise.then(function(data){getStars(data.stars),getRecommendations(data.styleName),getPredition(data.user._id),getBeerDetails(data.beerId)})},$scope.stars=[];var getStars=function(noOfStars){$scope.stars=noOfStars},getRecommendations=function(styleName){StyleQuery.getStyle(styleName).success(handleSuccess)};$scope.itemScores=[];var getPredition=function(userId){PredictionIO.getRecommendaton(userId).success(function(data){console.log("this is the prediction data",data),Beer.getData(data.itemScores[0].item).success(function(data){$scope.itemScores=[data.data]})})};$scope.beer={};var getBeerDetails=function(beerId){Beer.getData(beerId).success(function(results){$scope.beer=results.data||"Request failed"})};$scope.recommendations=[];var handleSuccess=function(data){$scope.recommendations=data.data}}]),angular.module("beer").factory("Beer",["$http",function($http){return{getData:function(beerId){return $http.get("/api/beer/"+beerId)}}}]),angular.module("ratings").factory("PredictionIO",["$http",function($http){return{getRecommendaton:function(userId){return $http.get("/api/recommendation/"+userId)}}}]),angular.module("ratings").factory("Ratings",["$resource",function($resource){return $resource("/api/ratings/:ratingId",{ratingId:"@_id"},{update:{method:"PUT"}})}]),angular.module("ratings").factory("StyleQuery",["$http",function($http){return{getStyle:function(styleName){return $http.get("/api/style/"+styleName)}}}]),angular.module("search").config(["$stateProvider",function($stateProvider){$stateProvider.state("search",{url:"/search/:page/:keyword",templateUrl:"modules/search/views/search.client.view.html"})}]),angular.module("search").controller("SearchController",["$scope","Search","$stateParams","$state","usSpinnerService",function($scope,Search,$stateParams,$state,usSpinnerService){$scope.results=[],$scope.totalResults=void 0,$scope.search=function(currentPage){currentPage=currentPage||1,$state.go("search",{page:currentPage,keyword:$scope.keyword}),$scope.keyword=""},Search.getData($stateParams.keyword,$stateParams.page).success(function(response,status){$scope.status=status,200===$scope.status?void 0!==response.totalResults?($scope.numberOfPages=response.numberOfPages,$scope.totalResults=response.totalResults,$scope.keyword=$stateParams.keyword,$scope.currentPage=$stateParams.page,$scope.results=response.data):($scope.totalResults=0,$scope.numberOfPages=0):$scope.results=response||"Request failed",usSpinnerService.stop("spinner-2")})}]),angular.module("users").config(["$httpProvider",function($httpProvider){$httpProvider.interceptors.push(["$q","$location","Authentication",function($q,$location,Authentication){return{responseError:function(rejection){switch(rejection.status){case 401:Authentication.user=null,$location.path("signin");break;case 403:}return $q.reject(rejection)}}}])}]),angular.module("users").config(["$stateProvider",function($stateProvider){$stateProvider.state("profile",{url:"/settings/profile",templateUrl:"modules/users/views/settings/edit-profile.client.view.html"}).state("password",{url:"/settings/password",templateUrl:"modules/users/views/settings/change-password.client.view.html"}).state("accounts",{url:"/settings/accounts",templateUrl:"modules/users/views/settings/social-accounts.client.view.html"}).state("signup",{url:"/signup",templateUrl:"modules/users/views/authentication/signup.client.view.html"}).state("signin",{url:"/signin",templateUrl:"modules/users/views/authentication/signin.client.view.html"}).state("forgot",{url:"/password/forgot",templateUrl:"modules/users/views/password/forgot-password.client.view.html"}).state("reset-invalid",{url:"/password/reset/invalid",templateUrl:"modules/users/views/password/reset-password-invalid.client.view.html"}).state("reset-success",{url:"/password/reset/success",templateUrl:"modules/users/views/password/reset-password-success.client.view.html"}).state("reset",{url:"/password/reset/:token",templateUrl:"modules/users/views/password/reset-password.client.view.html"})}]),angular.module("users").controller("AuthenticationController",["$scope","$http","$location","Authentication",function($scope,$http,$location,Authentication){$scope.authentication=Authentication,$scope.authentication.user&&$location.path("/"),$scope.signup=function(){$http.post("/auth/signup",$scope.credentials).success(function(response){$scope.authentication.user=response,$location.path("/")}).error(function(response){$scope.error=response.message})},$scope.signin=function(){$http.post("/auth/signin",$scope.credentials).success(function(response){$scope.authentication.user=response,$location.path("/")}).error(function(response){$scope.error=response.message})}}]),angular.module("users").controller("PasswordController",["$scope","$stateParams","$http","$location","Authentication",function($scope,$stateParams,$http,$location,Authentication){$scope.authentication=Authentication,$scope.authentication.user&&$location.path("/"),$scope.askForPasswordReset=function(){$scope.success=$scope.error=null,$http.post("/auth/forgot",$scope.credentials).success(function(response){$scope.credentials=null,$scope.success=response.message}).error(function(response){$scope.credentials=null,$scope.error=response.message})},$scope.resetUserPassword=function(){$scope.success=$scope.error=null,$http.post("/auth/reset/"+$stateParams.token,$scope.passwordDetails).success(function(response){$scope.passwordDetails=null,Authentication.user=response,$location.path("/password/reset/success")}).error(function(response){$scope.error=response.message})}}]),angular.module("users").controller("SettingsController",["$scope","$http","$location","Users","Authentication",function($scope,$http,$location,Users,Authentication){$scope.user=Authentication.user,$scope.user||$location.path("/"),$scope.hasConnectedAdditionalSocialAccounts=function(){for(var i in $scope.user.additionalProvidersData)return!0;return!1},$scope.isConnectedSocialAccount=function(provider){return $scope.user.provider===provider||$scope.user.additionalProvidersData&&$scope.user.additionalProvidersData[provider]},$scope.removeUserSocialAccount=function(provider){$scope.success=$scope.error=null,$http["delete"]("/users/accounts",{params:{provider:provider}}).success(function(response){$scope.success=!0,$scope.user=Authentication.user=response}).error(function(response){$scope.error=response.message})},$scope.updateUserProfile=function(isValid){if(isValid){$scope.success=$scope.error=null;var user=new Users($scope.user);user.$update(function(response){$scope.success=!0,Authentication.user=response},function(response){$scope.error=response.data.message})}else $scope.submitted=!0},$scope.changeUserPassword=function(){$scope.success=$scope.error=null,$http.post("/users/password",$scope.passwordDetails).success(function(){$scope.success=!0,$scope.passwordDetails=null}).error(function(response){$scope.error=response.message})}}]),angular.module("users").factory("Authentication",[function(){var _this=this;return _this._data={user:window.user},_this._data}]),angular.module("users").factory("Users",["$resource",function($resource){return $resource("users",{},{update:{method:"PUT"}})}]); \ No newline at end of file +"use strict";var ApplicationConfiguration=function(){var applicationModuleName="onTappApp",applicationModuleVendorDependencies=["ngResource","ngAnimate","ui.router","ui.bootstrap","ui.utils","uiGmapgoogle-maps","geolocation","angularSpinner"],registerModule=function(moduleName,dependencies){angular.module(moduleName,dependencies||[]),angular.module(applicationModuleName).requires.push(moduleName)};return{applicationModuleName:applicationModuleName,applicationModuleVendorDependencies:applicationModuleVendorDependencies,registerModule:registerModule}}();angular.module(ApplicationConfiguration.applicationModuleName,ApplicationConfiguration.applicationModuleVendorDependencies),angular.module(ApplicationConfiguration.applicationModuleName).config(["$locationProvider",function($locationProvider){$locationProvider.html5Mode(!0),$locationProvider.hashPrefix("!")}]),angular.element(document).ready(function(){"#_=_"===window.location.hash&&(window.location.hash="#!"),angular.bootstrap(document,[ApplicationConfiguration.applicationModuleName])}),ApplicationConfiguration.registerModule("beer"),ApplicationConfiguration.registerModule("brewery"),ApplicationConfiguration.registerModule("core"),ApplicationConfiguration.registerModule("nearby"),ApplicationConfiguration.registerModule("ratings"),ApplicationConfiguration.registerModule("search"),ApplicationConfiguration.registerModule("users"),angular.module("beer").config(["$stateProvider",function($stateProvider){$stateProvider.state("beer",{url:"/beer/:beerId",templateUrl:"modules/beer/views/beer.client.view.html"})}]),angular.module("beer").controller("BeerController",["$scope","Beer","$stateParams","StyleQuery",function($scope,Beer,$stateParams,StyleQuery){$scope.beerId=$stateParams.beerId,$scope.recommendations=[];var shuffle=function(array){for(var temporaryValue,randomIndex,currentIndex=array.length;0!==currentIndex;)randomIndex=Math.floor(Math.random()*currentIndex),currentIndex-=1,temporaryValue=array[currentIndex],array[currentIndex]=array[randomIndex],array[randomIndex]=temporaryValue;return array},handleSuccess=function(data){$scope.recommendations=shuffle(data.data)},getRecommendations=function(styleName){StyleQuery.getStyle(styleName).success(handleSuccess)};Beer.getData($scope.beerId).success(function(results){$scope.beer=results.data||"Request failed",getRecommendations(results.data.style.name)})}]),angular.module("beer").factory("Beer",["$http",function($http){return{getData:function(beerId){return $http.get("/api/beer/"+beerId)}}}]),angular.module("beer").factory("StyleQuery",["$http",function($http){return{getStyle:function(styleName){return $http.get("/api/style/"+styleName)}}}]),angular.module("brewery").config(["$stateProvider",function($stateProvider){$stateProvider.state("brewery",{url:"/brewery/:breweryId",templateUrl:"modules/brewery/views/brewery.client.view.html"})}]),angular.module("nearby").controller("BreweryController",["$scope","Brewery","$stateParams","Ratings","$location","Core",function($scope,Brewery,$stateParams,Ratings,$location,Core){$scope.breweryId=$stateParams.breweryId,$scope.brewery=[],$scope.socialMedia=[];var socialMediaArr=[1,2,3,8,10,14,15,16];Brewery.getData($scope.breweryId).success(function(data){if($scope.brewery=data.data||"Request failed",void 0!==$scope.brewery.locations)for(var i=0;i<$scope.brewery.locations.length;i++)$scope.brewery.locations[i].region=Core.abbrState($scope.brewery.locations[i].region),-1===$scope.brewery.locations[i].phone.indexOf("-")&&($scope.brewery.locations[i].phone=Core.fixPhone($scope.brewery.locations[i].phone));if(void 0!==$scope.brewery.socialAccounts)for(var j=0;j<$scope.brewery.socialAccounts.length;j++){var tempSocial=$scope.brewery.socialAccounts[j];socialMediaArr.indexOf(tempSocial.socialMediaId)>-1&&$scope.socialMedia.push(tempSocial)}}),$scope.beers=[],$scope.availabilityGroups=[],Brewery.getBeersData($scope.breweryId).success(function(data){$scope.beers=data.data||"Request failed",$scope.availabilityGroups=uniqueItems($scope.beers)}),$scope.useAvailability=[],$scope.filterBeer=function(){return function(p){if(0===$scope.useAvailability.length||-1===$scope.useAvailability.indexOf(!0))return!0;for(var i in $scope.useAvailability)if(p.availableId===$scope.availabilityGroups[i].availableId&&$scope.useAvailability[i])return!0}},$scope.rate=0,$scope.max=5,$scope.isReadonly=!1;$scope.hoveringOver=function(value){$scope.overStar=value,$scope.percent=100*(value/$scope.max)},$scope.ratingStates=[{stateOn:"glyphicon-star",stateOff:"glyphicon-star-empty"}],$scope.create=function(index){console.log("index before: ",index);var rating=new Ratings({beerId:$scope.beers[index].id,name:$scope.beers[index].name,stars:this.rate,styleName:$scope.beers[index].style.name});rating.$save(function(response){$location.path("beer/"+response.beerId),$scope.name=""},function(errorResponse){$scope.error=errorResponse.data.message})};var uniqueItems=function(data){for(var result=[],i=0;ib.availableId?1:a.availableId":"",phone=void 0!==$scope.breweries[i].phone?$scope.breweries[i].phone+"
":"",id=$scope.breweries[i].brewery.id,dist=$scope.breweries[i].distance+" miles away
",desc='
'+name+"
"+dist+addr+phone+"
",ret={id:i,coords:{latitude:$scope.breweries[i].latitude,longitude:$scope.breweries[i].longitude},options:{title:name},infoWindow:{content:desc},icon:"/modules/nearby/images/beer-icon.png",showWindow:!1};return ret.onClick=function(){$scope.oldWindow>-1&&($scope.allMarkers[$scope.oldWindow].showWindow=!1),$scope.oldWindow=ret.id,ret.showWindow=!ret.showWindow},ret},placeMarker=function(){for(var markers=[],i=0;i<$scope.breweries.length;i++)markers.push(createMarker(i));$scope.allMarkers=markers};$scope.closeClick=function(){$scope.windowOptions.visible=!1},$scope.getUserLocation=function(){geolocation.getLocation().then(function(data){$scope.coords={lat:data.coords.latitude,"long":data.coords.longitude},uiGmapGoogleMapApi.then(function(){$scope.map={center:{latitude:$scope.coords.lat,longitude:$scope.coords["long"]},zoom:12},$scope.windowOptions={visible:!0},curLocationMarker(),Breweries.getData($scope.coords).success(handleSuccess)})})}}]),angular.module("nearby").factory("Breweries",["$http",function($http){return{getData:function(coords){return $http.get("/api/breweries/"+coords.lat+"/"+coords["long"])}}}]),angular.module("ratings").run(["Menus",function(Menus){Menus.addMenuItem("topbar","Recommendations","recommendations","/ratings(/create)?")}]),angular.module("ratings").config(["$stateProvider",function($stateProvider){$stateProvider.state("listRatings",{url:"/recommendations",templateUrl:"modules/ratings/views/list-ratings.client.view.html"}).state("viewRating",{url:"/ratings/:ratingId",templateUrl:"modules/ratings/views/view-rating.client.view.html"}).state("editRating",{url:"/ratings/:ratingId/edit",templateUrl:"modules/ratings/views/edit-rating.client.view.html"})}]),angular.module("ratings").controller("RatingsController",["$scope","$stateParams","$location","Authentication","Ratings","StyleQuery","PredictionIO","Beer",function($scope,$stateParams,$location,Authentication,Ratings,StyleQuery,PredictionIO,Beer){$scope.authentication=Authentication,$scope.remove=function(rating){if(rating){rating.$remove();for(var i in $scope.ratings)$scope.ratings[i]===rating&&$scope.ratings.splice(i,1)}else $scope.rating.$remove(function(){$location.path("ratings")})},$scope.update=function(){var rating=$scope.rating;rating.$update(function(){$location.path("ratings/"+rating._id)},function(errorResponse){$scope.error=errorResponse.data.message})},$scope.find=function(){$scope.ratings=Ratings.query();var userId=Authentication.user._id;$scope.ratings.$promise.then(function(){getPredition(userId)})},$scope.findOne=function(){$scope.rating=Ratings.get({ratingId:$stateParams.ratingId}),$scope.rating.$promise.then(function(data){getStars(data.stars),getRecommendations(data.styleName),getPredition(data.user._id),getBeerDetails(data.beerId)})},$scope.stars=[];var getStars=function(noOfStars){$scope.stars=noOfStars},getRecommendations=function(styleName){StyleQuery.getStyle(styleName).success(handleSuccess)};$scope.itemScores=[];var getPredition=function(userId){PredictionIO.getRecommendaton(userId).success(function(data){console.log("this is the prediction data",data),Beer.getData(data.itemScores[0].item).success(function(data){$scope.itemScores=[data.data]})})};$scope.beer={};var getBeerDetails=function(beerId){Beer.getData(beerId).success(function(results){$scope.beer=results.data||"Request failed"})};$scope.recommendations=[];var handleSuccess=function(data){$scope.recommendations=data.data}}]),angular.module("beer").factory("Beer",["$http",function($http){return{getData:function(beerId){return $http.get("/api/beer/"+beerId)}}}]),angular.module("ratings").factory("PredictionIO",["$http",function($http){return{getRecommendaton:function(userId){return $http.get("/api/recommendation/"+userId)}}}]),angular.module("ratings").factory("Ratings",["$resource",function($resource){return $resource("/api/ratings/:ratingId",{ratingId:"@_id"},{update:{method:"PUT"}})}]),angular.module("ratings").factory("StyleQuery",["$http",function($http){return{getStyle:function(styleName){return $http.get("/api/style/"+styleName)}}}]),angular.module("search").config(["$stateProvider",function($stateProvider){$stateProvider.state("search",{url:"/search/:page/:keyword",templateUrl:"modules/search/views/search.client.view.html"})}]),angular.module("search").controller("SearchController",["$scope","Search","$stateParams","$state","usSpinnerService",function($scope,Search,$stateParams,$state,usSpinnerService){$scope.results=[],$scope.totalResults=void 0,$scope.search=function(currentPage){currentPage=currentPage||1,$state.go("search",{page:currentPage,keyword:$scope.keyword}),$scope.keyword=""},Search.getData($stateParams.keyword,$stateParams.page).success(function(response,status){$scope.status=status,200===$scope.status?void 0!==response.totalResults?($scope.numberOfPages=response.numberOfPages,$scope.totalResults=response.totalResults,$scope.keyword=$stateParams.keyword,$scope.currentPage=$stateParams.page,$scope.results=response.data):($scope.totalResults=0,$scope.numberOfPages=0):$scope.results=response||"Request failed",usSpinnerService.stop("spinner-2")})}]),angular.module("users").config(["$httpProvider",function($httpProvider){$httpProvider.interceptors.push(["$q","$location","Authentication",function($q,$location,Authentication){return{responseError:function(rejection){switch(rejection.status){case 401:Authentication.user=null,$location.path("signin");break;case 403:}return $q.reject(rejection)}}}])}]),angular.module("users").config(["$stateProvider",function($stateProvider){$stateProvider.state("profile",{url:"/settings/profile",templateUrl:"modules/users/views/settings/edit-profile.client.view.html"}).state("password",{url:"/settings/password",templateUrl:"modules/users/views/settings/change-password.client.view.html"}).state("accounts",{url:"/settings/accounts",templateUrl:"modules/users/views/settings/social-accounts.client.view.html"}).state("signup",{url:"/signup",templateUrl:"modules/users/views/authentication/signup.client.view.html"}).state("signin",{url:"/signin",templateUrl:"modules/users/views/authentication/signin.client.view.html"}).state("forgot",{url:"/password/forgot",templateUrl:"modules/users/views/password/forgot-password.client.view.html"}).state("reset-invalid",{url:"/password/reset/invalid",templateUrl:"modules/users/views/password/reset-password-invalid.client.view.html"}).state("reset-success",{url:"/password/reset/success",templateUrl:"modules/users/views/password/reset-password-success.client.view.html"}).state("reset",{url:"/password/reset/:token",templateUrl:"modules/users/views/password/reset-password.client.view.html"})}]),angular.module("users").controller("AuthenticationController",["$scope","$http","$location","Authentication",function($scope,$http,$location,Authentication){$scope.authentication=Authentication,$scope.authentication.user&&$location.path("/"),$scope.signup=function(){$http.post("/auth/signup",$scope.credentials).success(function(response){$scope.authentication.user=response,$location.path("/")}).error(function(response){$scope.error=response.message})},$scope.signin=function(){$http.post("/auth/signin",$scope.credentials).success(function(response){$scope.authentication.user=response,$location.path("/")}).error(function(response){$scope.error=response.message})}}]),angular.module("users").controller("PasswordController",["$scope","$stateParams","$http","$location","Authentication",function($scope,$stateParams,$http,$location,Authentication){$scope.authentication=Authentication,$scope.authentication.user&&$location.path("/"),$scope.askForPasswordReset=function(){$scope.success=$scope.error=null,$http.post("/auth/forgot",$scope.credentials).success(function(response){$scope.credentials=null,$scope.success=response.message}).error(function(response){$scope.credentials=null,$scope.error=response.message})},$scope.resetUserPassword=function(){$scope.success=$scope.error=null,$http.post("/auth/reset/"+$stateParams.token,$scope.passwordDetails).success(function(response){$scope.passwordDetails=null,Authentication.user=response,$location.path("/password/reset/success")}).error(function(response){$scope.error=response.message})}}]),angular.module("users").controller("SettingsController",["$scope","$http","$location","Users","Authentication",function($scope,$http,$location,Users,Authentication){$scope.user=Authentication.user,$scope.user||$location.path("/"),$scope.hasConnectedAdditionalSocialAccounts=function(){for(var i in $scope.user.additionalProvidersData)return!0;return!1},$scope.isConnectedSocialAccount=function(provider){return $scope.user.provider===provider||$scope.user.additionalProvidersData&&$scope.user.additionalProvidersData[provider]},$scope.removeUserSocialAccount=function(provider){$scope.success=$scope.error=null,$http["delete"]("/users/accounts",{params:{provider:provider}}).success(function(response){$scope.success=!0,$scope.user=Authentication.user=response}).error(function(response){$scope.error=response.message})},$scope.updateUserProfile=function(isValid){if(isValid){$scope.success=$scope.error=null;var user=new Users($scope.user);user.$update(function(response){$scope.success=!0,Authentication.user=response},function(response){$scope.error=response.data.message})}else $scope.submitted=!0},$scope.changeUserPassword=function(){$scope.success=$scope.error=null,$http.post("/users/password",$scope.passwordDetails).success(function(){$scope.success=!0,$scope.passwordDetails=null}).error(function(response){$scope.error=response.message})}}]),angular.module("users").factory("Authentication",[function(){var _this=this;return _this._data={user:window.user},_this._data}]),angular.module("users").factory("Users",["$resource",function($resource){return $resource("users",{},{update:{method:"PUT"}})}]); \ No newline at end of file diff --git a/public/modules/brewery/controllers/brewery.client.controller.js b/public/modules/brewery/controllers/brewery.client.controller.js index 6947252..a95fcc6 100644 --- a/public/modules/brewery/controllers/brewery.client.controller.js +++ b/public/modules/brewery/controllers/brewery.client.controller.js @@ -86,7 +86,6 @@ angular.module('nearby').controller('BreweryController', ['$scope', 'Brewery', ' stars: this.rate, styleName: $scope.beers[index].style.name }); - console.log('rating.beerId: ', rating.beerId); // Redirect after save rating.$save(function(response) {