From 9d54a8a4b69fcd7327a91b0a924c1583ab239ef8 Mon Sep 17 00:00:00 2001 From: Victor Leung Date: Fri, 16 Jan 2015 06:19:18 +0800 Subject: [PATCH 1/3] add link from recommendation to beer --- public/modules/ratings/views/list-ratings.client.view.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/modules/ratings/views/list-ratings.client.view.html b/public/modules/ratings/views/list-ratings.client.view.html index f9d7cb0..556f032 100644 --- a/public/modules/ratings/views/list-ratings.client.view.html +++ b/public/modules/ratings/views/list-ratings.client.view.html @@ -36,7 +36,9 @@

Our customised recommendation for you:

Name:
-
{{itemScore.name}}
+
Brewery:
@@ -67,8 +69,6 @@

Our customised recommendation for you:

-
-

You may also want to try:

From 3bbd89851e4893281c796ebcf01d9dc56fd33c05 Mon Sep 17 00:00:00 2001 From: Victor Leung Date: Fri, 16 Jan 2015 06:24:47 +0800 Subject: [PATCH 2/3] uncomment default coordinate --- public/modules/nearby/controllers/nearby.client.controller.js | 4 ++-- public/modules/ratings/views/list-ratings.client.view.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/modules/nearby/controllers/nearby.client.controller.js b/public/modules/nearby/controllers/nearby.client.controller.js index 317878f..c941a7b 100644 --- a/public/modules/nearby/controllers/nearby.client.controller.js +++ b/public/modules/nearby/controllers/nearby.client.controller.js @@ -93,9 +93,9 @@ angular.module('nearby').controller('NearbyController', ['$scope', 'uiGmapGoogle // function to access users geolocation coordinates, draw map and place markers geolocation.getLocation().then(function(data){ // set to san francisco by Default for Victor - $scope.coords = {lat:37.783973, long:-122.409100}; + // $scope.coords = {lat:37.783973, long:-122.409100}; - // $scope.coords = {lat:data.coords.latitude, long:data.coords.longitude}; + $scope.coords = {lat:data.coords.latitude, long:data.coords.longitude}; $scope.map = { center: { latitude: $scope.coords.lat, longitude: $scope.coords.long }, zoom: 12}; // initialize the Google map $scope.windowOptions = { visible: true diff --git a/public/modules/ratings/views/list-ratings.client.view.html b/public/modules/ratings/views/list-ratings.client.view.html index 556f032..7a7516b 100644 --- a/public/modules/ratings/views/list-ratings.client.view.html +++ b/public/modules/ratings/views/list-ratings.client.view.html @@ -49,7 +49,7 @@

Our customised recommendation for you:

Style:
- {{itemScore.style.name}} + {{itemScore.style.name}}
From 97eedd729af8649c97b32b0c2419e966afab84ed Mon Sep 17 00:00:00 2001 From: Victor Leung Date: Fri, 16 Jan 2015 06:25:31 +0800 Subject: [PATCH 3/3] grunt build --- public/dist/application.js | 7 ++++--- public/dist/application.min.js | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/public/dist/application.js b/public/dist/application.js index 9713fc0..17726f7 100644 --- a/public/dist/application.js +++ b/public/dist/application.js @@ -761,9 +761,11 @@ angular.module('ratings').controller('RatingsController', ['$scope', '$statePara $scope.find = function() { $scope.ratings = Ratings.query(); + + var userId = Authentication.user._id; + $scope.ratings.$promise.then(function(data){ - console.log(data); - getPredition(data[0].user._id); + getPredition(userId); }); }; @@ -804,7 +806,6 @@ angular.module('ratings').controller('RatingsController', ['$scope', '$statePara PredictionIO.getRecommendaton(userId).success(function(data, status){ Beer.getData(data.itemScores[0].item).success(function(data, status){ $scope.itemScores = [data.data]; - console.log(data.data); }); }); }; diff --git a/public/dist/application.min.js b/public/dist/application.min.js index cf6fd52..2ce41a7 100755 --- 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.hashPrefix("!"),$locationProvider.html5Mode(!0)}]),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 handleSuccess=function(data){$scope.recommendations=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("/beer/"+beerId)}}}]),angular.module("beer").factory("StyleQuery",["$http",function($http){return{getStyle:function(styleName){return $http.get("/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",function($scope,Brewery,$stateParams,Ratings,$location){function sortOn(collection,name){collection.sort(function(a,b){return a[name]<=b[name]?-1:1})}$scope.breweryId=$stateParams.breweryId;var holdSocial=[];Brewery.getData($scope.breweryId).success(function(results){if($scope.brewery=results.data||"Request failed",void 0!==$scope.brewery.socialAccounts){for(var i=0;i<$scope.brewery.socialAccounts.length;i++){var tempSocial=$scope.brewery.socialAccounts[i];[1,2,3,8,10,14,15,16].indexOf(tempSocial.socialMediaId)>-1&&holdSocial.push(tempSocial)}$scope.socialMedia=holdSocial}}),$scope.groupBy=function(attribute){$scope.groups=[],sortOn($scope.beers,attribute);for(var groupValue="_INVALID_GROUP_VALUE_",i=0;i<$scope.beers.length;i++){var group,beer=$scope.beers[i];beer[attribute]!==groupValue&&(group={label:beer[attribute],beers:[]},groupValue=group.label,$scope.groups.push(group)),group.beers.push(beer)}},$scope.beers=[],$scope.groups=[],$scope.breweryId=$stateParams.breweryId;var handleSuccess=function(data){$scope.beers=data.data,$scope.groupBy("availableId")};Brewery.getBeersData($scope.breweryId).success(handleSuccess),$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){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})}}]),angular.module("nearby").factory("Brewery",["$http",function($http){return{getData:function(breweryId){return $http.get("/brewery/"+breweryId)},getBeersData:function(breweryId){return $http.get("/beers/"+breweryId)}}}]),angular.module("core").config(["$stateProvider","$urlRouterProvider",function($stateProvider,$urlRouterProvider){$urlRouterProvider.otherwise("/"),$stateProvider.state("home",{url:"/",templateUrl:"modules/core/views/home.client.view.html"})}]),angular.module("core").controller("HeaderController",["$scope","Authentication","Menus","$state",function($scope,Authentication,Menus,$state){$scope.authentication=Authentication,$scope.isCollapsed=!1,$scope.menu=Menus.getMenu("topbar"),$scope.toggleCollapsibleMenu=function(){$scope.isCollapsed=!$scope.isCollapsed},$scope.$on("$stateChangeSuccess",function(){$scope.isCollapsed=!1}),$scope.results=[],$scope.totalResults=void 0,$scope.search=function(currentPage){currentPage=currentPage||1,$state.go("search",{page:currentPage,keyword:$scope.keyword}),$scope.keyword=""}}]),angular.module("core").controller("HomeController",["$scope","Authentication",function($scope,Authentication){$scope.authentication=Authentication}]),angular.module("core").service("Menus",[function(){this.defaultRoles=["*"],this.menus={};var shouldRender=function(user){if(!user)return this.isPublic;if(~this.roles.indexOf("*"))return!0;for(var userRoleIndex in user.roles)for(var roleIndex in this.roles)if(this.roles[roleIndex]===user.roles[userRoleIndex])return!0;return!1};this.validateMenuExistance=function(menuId){if(menuId&&menuId.length){if(this.menus[menuId])return!0;throw new Error("Menu does not exists")}throw new Error("MenuId was not provided")},this.getMenu=function(menuId){return this.validateMenuExistance(menuId),this.menus[menuId]},this.addMenu=function(menuId,isPublic,roles){return this.menus[menuId]={isPublic:isPublic||!1,roles:roles||this.defaultRoles,items:[],shouldRender:shouldRender},this.menus[menuId]},this.removeMenu=function(menuId){this.validateMenuExistance(menuId),delete this.menus[menuId]},this.addMenuItem=function(menuId,menuItemTitle,menuItemURL,menuItemType,menuItemUIRoute,isPublic,roles,position){return this.validateMenuExistance(menuId),this.menus[menuId].items.push({title:menuItemTitle,link:menuItemURL,menuItemType:menuItemType||"item",menuItemClass:menuItemType,uiRoute:menuItemUIRoute||"/"+menuItemURL,isPublic:null===isPublic||"undefined"==typeof isPublic?this.menus[menuId].isPublic:isPublic,roles:null===roles||"undefined"==typeof roles?this.menus[menuId].roles:roles,position:position||0,items:[],shouldRender:shouldRender}),this.menus[menuId]},this.addSubMenuItem=function(menuId,rootMenuItemURL,menuItemTitle,menuItemURL,menuItemUIRoute,isPublic,roles,position){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)this.menus[menuId].items[itemIndex].link===rootMenuItemURL&&this.menus[menuId].items[itemIndex].items.push({title:menuItemTitle,link:menuItemURL,uiRoute:menuItemUIRoute||"/"+menuItemURL,isPublic:null===isPublic||"undefined"==typeof isPublic?this.menus[menuId].items[itemIndex].isPublic:isPublic,roles:null===roles||"undefined"==typeof roles?this.menus[menuId].items[itemIndex].roles:roles,position:position||0,shouldRender:shouldRender});return this.menus[menuId]},this.removeMenuItem=function(menuId,menuItemURL){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)this.menus[menuId].items[itemIndex].link===menuItemURL&&this.menus[menuId].items.splice(itemIndex,1);return this.menus[menuId]},this.removeSubMenuItem=function(menuId,submenuItemURL){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)for(var subitemIndex in this.menus[menuId].items[itemIndex].items)this.menus[menuId].items[itemIndex].items[subitemIndex].link===submenuItemURL&&this.menus[menuId].items[itemIndex].items.splice(subitemIndex,1);return this.menus[menuId]},this.addMenu("topbar")}]),angular.module("core").factory("Search",["$http",function($http){return{getData:function(keyword,page){return $http.get("/search/"+keyword+"/"+page)}}}]),angular.module("nearby").run(["Menus",function(Menus){Menus.addMenuItem("topbar","Nearby","nearby","/nearby")}]),angular.module("nearby").config(["$stateProvider","uiGmapGoogleMapApiProvider",function($stateProvider,uiGmapGoogleMapApiProvider){$stateProvider.state("nearby",{url:"/nearby",templateUrl:"modules/nearby/views/nearby.client.view.html"}),uiGmapGoogleMapApiProvider.configure({key:"AIzaSyAQHm36O2gZr34HkBjElKYHox3LVWR8UWY",v:"3.17",libraries:"geometry,visualization"})}]),angular.module("nearby").controller("infoWindowController",["$scope","$stateParams",function($scope,$stateParams){$scope.params=$stateParams}]),angular.module("nearby").controller("NearbyController",["$scope","uiGmapGoogleMapApi","Breweries","geolocation","uiGmapLogger","usSpinnerService",function($scope,uiGmapGoogleMapApi,Breweries,geolocation,uiGmapLogger,usSpinnerService){uiGmapLogger.doLog=!0,$scope.breweries=[],$scope.coords={},$scope.allMarkers=[],$scope.oldWindow=-1;var handleSuccess=function(data){data.data?($scope.breweries=data.data,placeMarker()):$scope.breweries=[{brewery:{name:"Sorry",description:"No breweries nearby"}}],usSpinnerService.stop("spinner-1")},curLocationMarker=function(){$scope.marker={id:"curLoc",coords:{latitude:$scope.coords.lat,longitude:$scope.coords["long"]},options:{title:"You are here!"}}},createMarker=function(i){var name=$scope.breweries[i].brewery.name,addr=void 0!==$scope.breweries[i].streetAddress?$scope.breweries[i].streetAddress+"
":"",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+'List their beers
',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},$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("/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(),$scope.ratings.$promise.then(function(data){console.log(data),getPredition(data[0].user._id)})},$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){Beer.getData(data.itemScores[0].item).success(function(data){$scope.itemScores=[data.data],console.log(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("/beer/"+beerId)}}}]),angular.module("ratings").factory("PredictionIO",["$http",function($http){return{getRecommendaton:function(userId){return $http.get("/recommendation/"+userId)}}}]),angular.module("ratings").factory("Ratings",["$resource",function($resource){return $resource("ratings/:ratingId",{ratingId:"@_id"},{update:{method:"PUT"}})}]),angular.module("ratings").factory("StyleQuery",["$http",function($http){return{getStyle:function(styleName){return $http.get("/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=[],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.hashPrefix("!"),$locationProvider.html5Mode(!0)}]),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 handleSuccess=function(data){$scope.recommendations=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("/beer/"+beerId)}}}]),angular.module("beer").factory("StyleQuery",["$http",function($http){return{getStyle:function(styleName){return $http.get("/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",function($scope,Brewery,$stateParams,Ratings,$location){function sortOn(collection,name){collection.sort(function(a,b){return a[name]<=b[name]?-1:1})}$scope.breweryId=$stateParams.breweryId;var holdSocial=[];Brewery.getData($scope.breweryId).success(function(results){if($scope.brewery=results.data||"Request failed",void 0!==$scope.brewery.socialAccounts){for(var i=0;i<$scope.brewery.socialAccounts.length;i++){var tempSocial=$scope.brewery.socialAccounts[i];[1,2,3,8,10,14,15,16].indexOf(tempSocial.socialMediaId)>-1&&holdSocial.push(tempSocial)}$scope.socialMedia=holdSocial}}),$scope.groupBy=function(attribute){$scope.groups=[],sortOn($scope.beers,attribute);for(var groupValue="_INVALID_GROUP_VALUE_",i=0;i<$scope.beers.length;i++){var group,beer=$scope.beers[i];beer[attribute]!==groupValue&&(group={label:beer[attribute],beers:[]},groupValue=group.label,$scope.groups.push(group)),group.beers.push(beer)}},$scope.beers=[],$scope.groups=[],$scope.breweryId=$stateParams.breweryId;var handleSuccess=function(data){$scope.beers=data.data,$scope.groupBy("availableId")};Brewery.getBeersData($scope.breweryId).success(handleSuccess),$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){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})}}]),angular.module("nearby").factory("Brewery",["$http",function($http){return{getData:function(breweryId){return $http.get("/brewery/"+breweryId)},getBeersData:function(breweryId){return $http.get("/beers/"+breweryId)}}}]),angular.module("core").config(["$stateProvider","$urlRouterProvider",function($stateProvider,$urlRouterProvider){$urlRouterProvider.otherwise("/"),$stateProvider.state("home",{url:"/",templateUrl:"modules/core/views/home.client.view.html"})}]),angular.module("core").controller("HeaderController",["$scope","Authentication","Menus","$state",function($scope,Authentication,Menus,$state){$scope.authentication=Authentication,$scope.isCollapsed=!1,$scope.menu=Menus.getMenu("topbar"),$scope.toggleCollapsibleMenu=function(){$scope.isCollapsed=!$scope.isCollapsed},$scope.$on("$stateChangeSuccess",function(){$scope.isCollapsed=!1}),$scope.results=[],$scope.totalResults=void 0,$scope.search=function(currentPage){currentPage=currentPage||1,$state.go("search",{page:currentPage,keyword:$scope.keyword}),$scope.keyword=""}}]),angular.module("core").controller("HomeController",["$scope","Authentication",function($scope,Authentication){$scope.authentication=Authentication}]),angular.module("core").service("Menus",[function(){this.defaultRoles=["*"],this.menus={};var shouldRender=function(user){if(!user)return this.isPublic;if(~this.roles.indexOf("*"))return!0;for(var userRoleIndex in user.roles)for(var roleIndex in this.roles)if(this.roles[roleIndex]===user.roles[userRoleIndex])return!0;return!1};this.validateMenuExistance=function(menuId){if(menuId&&menuId.length){if(this.menus[menuId])return!0;throw new Error("Menu does not exists")}throw new Error("MenuId was not provided")},this.getMenu=function(menuId){return this.validateMenuExistance(menuId),this.menus[menuId]},this.addMenu=function(menuId,isPublic,roles){return this.menus[menuId]={isPublic:isPublic||!1,roles:roles||this.defaultRoles,items:[],shouldRender:shouldRender},this.menus[menuId]},this.removeMenu=function(menuId){this.validateMenuExistance(menuId),delete this.menus[menuId]},this.addMenuItem=function(menuId,menuItemTitle,menuItemURL,menuItemType,menuItemUIRoute,isPublic,roles,position){return this.validateMenuExistance(menuId),this.menus[menuId].items.push({title:menuItemTitle,link:menuItemURL,menuItemType:menuItemType||"item",menuItemClass:menuItemType,uiRoute:menuItemUIRoute||"/"+menuItemURL,isPublic:null===isPublic||"undefined"==typeof isPublic?this.menus[menuId].isPublic:isPublic,roles:null===roles||"undefined"==typeof roles?this.menus[menuId].roles:roles,position:position||0,items:[],shouldRender:shouldRender}),this.menus[menuId]},this.addSubMenuItem=function(menuId,rootMenuItemURL,menuItemTitle,menuItemURL,menuItemUIRoute,isPublic,roles,position){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)this.menus[menuId].items[itemIndex].link===rootMenuItemURL&&this.menus[menuId].items[itemIndex].items.push({title:menuItemTitle,link:menuItemURL,uiRoute:menuItemUIRoute||"/"+menuItemURL,isPublic:null===isPublic||"undefined"==typeof isPublic?this.menus[menuId].items[itemIndex].isPublic:isPublic,roles:null===roles||"undefined"==typeof roles?this.menus[menuId].items[itemIndex].roles:roles,position:position||0,shouldRender:shouldRender});return this.menus[menuId]},this.removeMenuItem=function(menuId,menuItemURL){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)this.menus[menuId].items[itemIndex].link===menuItemURL&&this.menus[menuId].items.splice(itemIndex,1);return this.menus[menuId]},this.removeSubMenuItem=function(menuId,submenuItemURL){this.validateMenuExistance(menuId);for(var itemIndex in this.menus[menuId].items)for(var subitemIndex in this.menus[menuId].items[itemIndex].items)this.menus[menuId].items[itemIndex].items[subitemIndex].link===submenuItemURL&&this.menus[menuId].items[itemIndex].items.splice(subitemIndex,1);return this.menus[menuId]},this.addMenu("topbar")}]),angular.module("core").factory("Search",["$http",function($http){return{getData:function(keyword,page){return $http.get("/search/"+keyword+"/"+page)}}}]),angular.module("nearby").run(["Menus",function(Menus){Menus.addMenuItem("topbar","Nearby","nearby","/nearby")}]),angular.module("nearby").config(["$stateProvider","uiGmapGoogleMapApiProvider",function($stateProvider,uiGmapGoogleMapApiProvider){$stateProvider.state("nearby",{url:"/nearby",templateUrl:"modules/nearby/views/nearby.client.view.html"}),uiGmapGoogleMapApiProvider.configure({key:"AIzaSyAQHm36O2gZr34HkBjElKYHox3LVWR8UWY",v:"3.17",libraries:"geometry,visualization"})}]),angular.module("nearby").controller("infoWindowController",["$scope","$stateParams",function($scope,$stateParams){$scope.params=$stateParams}]),angular.module("nearby").controller("NearbyController",["$scope","uiGmapGoogleMapApi","Breweries","geolocation","uiGmapLogger","usSpinnerService",function($scope,uiGmapGoogleMapApi,Breweries,geolocation,uiGmapLogger,usSpinnerService){uiGmapLogger.doLog=!0,$scope.breweries=[],$scope.coords={},$scope.allMarkers=[],$scope.oldWindow=-1;var handleSuccess=function(data){data.data?($scope.breweries=data.data,placeMarker()):$scope.breweries=[{brewery:{name:"Sorry",description:"No breweries nearby"}}],usSpinnerService.stop("spinner-1")},curLocationMarker=function(){$scope.marker={id:"curLoc",coords:{latitude:$scope.coords.lat,longitude:$scope.coords["long"]},options:{title:"You are here!"}}},createMarker=function(i){var name=$scope.breweries[i].brewery.name,addr=void 0!==$scope.breweries[i].streetAddress?$scope.breweries[i].streetAddress+"
":"",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+'List their beers
',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},$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("/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){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("/beer/"+beerId)}}}]),angular.module("ratings").factory("PredictionIO",["$http",function($http){return{getRecommendaton:function(userId){return $http.get("/recommendation/"+userId)}}}]),angular.module("ratings").factory("Ratings",["$resource",function($resource){return $resource("ratings/:ratingId",{ratingId:"@_id"},{update:{method:"PUT"}})}]),angular.module("ratings").factory("StyleQuery",["$http",function($http){return{getStyle:function(styleName){return $http.get("/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=[],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