You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/03/10 23:23:54 UTC

[07/19] reset version number add built files, so site doesn't initially have to be built

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c1950d95/portal/js/usergrid.min.js
----------------------------------------------------------------------
diff --git a/portal/js/usergrid.min.js b/portal/js/usergrid.min.js
index 7dabf61..279579c 100644
--- a/portal/js/usergrid.min.js
+++ b/portal/js/usergrid.min.js
@@ -1,6 +1,6 @@
-/*! apigee-usergrid@1.0.2 2014-03-06 */
-!function(exports,global){function renderChart(chartsDefaults,chartdata){var newSettings={};$.extend(!0,newSettings,chartsDefaults,chartdata);new Highcharts.Chart(newSettings)}function menuBindClick(scope,lElement,cevent,menuContext){var currentSelection=angular.element(cevent.srcElement).parent(),previousSelection=scope[menuContext];previousSelection!==currentSelection&&(previousSelection&&angular.element(previousSelection).removeClass("active"),scope[menuContext]=currentSelection,scope.$apply(function(){currentSelection.addClass("active")}))}global["true"]=exports;var polyfills=function(window,Object){window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(callback){window.setTimeout(callback,1e3/60)}}(),Object.defineProperty(Object.prototype,"clone",{enumerable:!1,writable:!0,value:function(){var i,newObj=this instanceof Arra
 y?[]:{};for(i in this)"clone"!==i&&(newObj[i]=this[i]&&"object"==typeof this[i]?this[i].clone():this[i]);return newObj}}),Object.defineProperty(Object.prototype,"stringifyJSON",{enumerable:!1,writable:!0,value:function(){return JSON.stringify(this,null,"	")}})};polyfills(window,Object);var AppServices=AppServices||{};global.AppServices=global.AppServices||AppServices,AppServices.Constants=angular.module("appservices.constants",[]),AppServices.Services=angular.module("appservices.services",[]),AppServices.Controllers=angular.module("appservices.controllers",[]),AppServices.Filters=angular.module("appservices.filters",[]),AppServices.Directives=angular.module("appservices.directives",[]),AppServices.Performance=angular.module("appservices.performance",[]),AppServices.Push=angular.module("appservices.push",[]),angular.module("appservices",["ngRoute","ngResource","ngSanitize","ui.bootstrap","angulartics","angulartics.google.analytics","appservices.filters","appservices.services","appser
 vices.directives","appservices.constants","appservices.controllers","appservices.performance","appservices.push"]).config(["$routeProvider","$locationProvider","$sceDelegateProvider","$analyticsProvider",function($routeProvider,$locationProvider,$sceDelegateProvider,$analyticsProvider){$routeProvider.when("/org-overview",{templateUrl:"org-overview/org-overview.html",controller:"OrgOverviewCtrl"}).when("/login",{templateUrl:"login/login.html",controller:"LoginCtrl"}).when("/login/loading",{templateUrl:"login/loading.html",controller:"LoginCtrl"}).when("/app-overview/summary",{templateUrl:"app-overview/app-overview.html",controller:"AppOverviewCtrl"}).when("/getting-started/setup",{templateUrl:"app-overview/getting-started.html",controller:"GettingStartedCtrl"}).when("/forgot-password",{templateUrl:"login/forgot-password.html",controller:"ForgotPasswordCtrl"}).when("/register",{templateUrl:"login/register.html",controller:"RegisterCtrl"}).when("/users",{templateUrl:"users/users.html",
 controller:"UsersCtrl"}).when("/users/profile",{templateUrl:"users/users-profile.html",controller:"UsersProfileCtrl"}).when("/users/groups",{templateUrl:"users/users-groups.html",controller:"UsersGroupsCtrl"}).when("/users/activities",{templateUrl:"users/users-activities.html",controller:"UsersActivitiesCtrl"}).when("/users/feed",{templateUrl:"users/users-feed.html",controller:"UsersFeedCtrl"}).when("/users/graph",{templateUrl:"users/users-graph.html",controller:"UsersGraphCtrl"}).when("/users/roles",{templateUrl:"users/users-roles.html",controller:"UsersRolesCtrl"}).when("/groups",{templateUrl:"groups/groups.html",controller:"GroupsCtrl"}).when("/groups/details",{templateUrl:"groups/groups-details.html",controller:"GroupsDetailsCtrl"}).when("/groups/members",{templateUrl:"groups/groups-members.html",controller:"GroupsMembersCtrl"}).when("/groups/activities",{templateUrl:"groups/groups-activities.html",controller:"GroupsActivitiesCtrl"}).when("/groups/roles",{templateUrl:"groups/gro
 ups-roles.html",controller:"GroupsRolesCtrl"}).when("/roles",{templateUrl:"roles/roles.html",controller:"RolesCtrl"}).when("/roles/settings",{templateUrl:"roles/roles-settings.html",controller:"RolesSettingsCtrl"}).when("/roles/users",{templateUrl:"roles/roles-users.html",controller:"RolesUsersCtrl"}).when("/roles/groups",{templateUrl:"roles/roles-groups.html",controller:"RolesGroupsCtrl"}).when("/data",{templateUrl:"data/data.html",controller:"DataCtrl"}).when("/data/entity",{templateUrl:"data/entity.html",controller:"EntityCtrl"}).when("/data/shell",{templateUrl:"data/shell.html",controller:"ShellCtrl"}).when("/profile/organizations",{templateUrl:"profile/organizations.html",controller:"OrgCtrl"}).when("/profile/profile",{templateUrl:"profile/profile.html",controller:"ProfileCtrl"}).when("/profile",{templateUrl:"profile/account.html",controller:"AccountCtrl"}).when("/activities",{templateUrl:"activities/activities.html",controller:"ActivitiesCtrl"}).when("/shell",{templateUrl:"she
 ll/shell.html",controller:"ShellCtrl"}).when("/logout",{templateUrl:"login/logout.html",controller:"LogoutCtrl"}).otherwise({redirectTo:"/org-overview"}),$locationProvider.html5Mode(!1).hashPrefix("!"),$sceDelegateProvider.resourceUrlWhitelist(["self","http://apigee-internal-prod.jupiter.apigee.net/**","http://apigee-internal-prod.mars.apigee.net/**","https://appservices.apigee.com/**","https://api.usergrid.com/**"]),$analyticsProvider.virtualPageviews(!1),$analyticsProvider.firstPageview(!1)}]),AppServices.Controllers.controller("ActivitiesCtrl",["ug","$scope","$rootScope","$location","$route",function(ug,$scope,$rootScope){$scope.$on("app-activities-received",function(evt,data){$scope.activities=data,$scope.$apply()}),$scope.$on("app-activities-error",function(){$rootScope.$broadcast("alert","error","Application failed to retreive activities data.")}),ug.getActivities()}]),AppServices.Controllers.controller("AppOverviewCtrl",["ug","charts","$scope","$rootScope","$log",function(ug,
 charts,$scope,$rootScope,$log){var createGradient=function(color1,color2){var perShapeGradient={x1:0,y1:0,x2:0,y2:1};return{linearGradient:perShapeGradient,stops:[[0,color1],[1,color2]]}};$scope.appOverview={},$scope.collections=[],$scope.graph="",$scope.$on("top-collections-received",function(event,collections){var dataDescription={bar1:{labels:["Total"],dataAttr:["title","count"],colors:[createGradient("rgba(36,151,212,0.6)","rgba(119,198,240,0.6)")],borderColor:"#1b97d1"}};$scope.collections=collections;var arr=[];for(var i in collections)collections.hasOwnProperty(i)&&arr.push(collections[i]);$scope.appOverview={},$rootScope.chartTemplate?($scope.appOverview.chart=angular.copy($rootScope.chartTemplate.pareto),$scope.appOverview.chart=charts.convertParetoChart(arr,$scope.appOverview.chart,dataDescription.bar1,"1h","NOW"),$scope.applyScope()):ug.httpGet(null,"js/charts/highcharts.json").then(function(success){$rootScope.chartTemplate=success,$scope.appOverview.chart=angular.copy($
 rootScope.chartTemplate.pareto),$scope.appOverview.chart=charts.convertParetoChart(arr,$scope.appOverview.chart,dataDescription.bar1,"1h","NOW"),$scope.applyScope()},function(fail){$log.error("Problem getting chart template",fail)})}),$scope.$on("app-initialized",function(){ug.getTopCollections()}),$rootScope.activeUI&&ug.getTopCollections()}]),AppServices.Controllers.controller("GettingStartedCtrl",["ug","$scope","$rootScope","$location","$timeout","$anchorScroll",function(ug,$scope,$rootScope,$location,$timeout,$anchorScroll){$scope.collections=[],$scope.graph="",$scope.clientID="",$scope.clientSecret="";$scope.regenerateCredentialsDialog=function(modalId){$scope.orgAPICredentials={client_id:"regenerating...",client_secret:"regenerating..."},ug.regenerateAppCredentials(),$scope.hideModal(modalId)},$scope.$on("app-creds-updated",function(event,credentials){credentials?($scope.clientID=credentials.client_id,$scope.clientSecret=credentials.client_secret,$scope.$$phase||$scope.$apply(
 )):setTimeout(function(){ug.getAppCredentials()},5e3)}),ug.getAppCredentials(),$scope.contentTitle,$scope.showSDKDetail=function(name){var introContainer=document.getElementById("intro-container");if("nocontent"===name)return introContainer.style.height="0",!0;introContainer.style.opacity=.1,introContainer.style.height="0";var timeout=0;$scope.contentTitle&&(timeout=500),$timeout(function(){introContainer.style.height="1000px",introContainer.style.opacity=1},timeout),$scope.optionName=name,$scope.contentTitle=name,$scope.sdkLink="http://apigee.com/docs/content/"+name+"-sdk-redirect",$scope.docsLink="http://apigee.com/docs/app-services/content/installing-apigee-sdk-"+name,$scope.getIncludeURL=function(){return"app-overview/doc-includes/"+$scope.optionName+".html"}},$scope.scrollToElement=function(elem){return $location.hash(elem),$anchorScroll(),!1}}]),AppServices.Controllers.controller("ChartCtrl",["$scope","$location",function(){}]),AppServices.Directives.directive("chart",function
 (){return{restrict:"E",scope:{chartdata:"=chartdata"},template:"<div></div>",replace:!0,controller:function(){},link:function(scope,element,attrs){scope.$watch("chartdata",function(chartdata){if(chartdata){var chartsDefaults={chart:{renderTo:element[0],type:attrs.type||null,height:attrs.height||null,width:attrs.width||null,reflow:!0,animation:!1,zoomType:"x"}};if("pie"===attrs.type&&(chartsDefaults.chart.margin=[0,0,0,0],chartsDefaults.chart.spacingLeft=0,chartsDefaults.chart.spacingRight=0,chartsDefaults.chart.spacingTop=0,chartsDefaults.chart.spacingBottom=0,attrs.titleimage&&(chartdata.title.text='<img src="'+attrs.titleimage+'">'),attrs.titleicon&&(chartdata.title.text='<i class="pictogram '+attrs.titleiconclass+'">'+attrs.titleicon+"</i>"),attrs.titlecolor&&(chartdata.title.style.color=attrs.titlecolor),attrs.titleimagetop&&(chartdata.title.style.marginTop=attrs.titleimagetop),attrs.titleimageleft&&(chartdata.title.style.marginLeft=attrs.titleimageleft)),"line"===attrs.type&&(c
 hartsDefaults.chart.marginTop=30,chartsDefaults.chart.spacingTop=50),"column"===attrs.type&&(chartsDefaults.chart.marginBottom=80),"area"===attrs.type&&(chartsDefaults.chart.spacingLeft=0,chartsDefaults.chart.spacingRight=0,chartsDefaults.chart.marginLeft=0,chartsDefaults.chart.marginRight=0),Highcharts.setOptions({global:{useUTC:!1},chart:{style:{fontFamily:"marquette-light, Helvetica, Arial, sans-serif"}}}),"line"===attrs.type){var xAxis1=chartdata.xAxis[0];xAxis1.labels.formatter||(xAxis1.labels.formatter=new Function(attrs.xaxislabel)),xAxis1.labels.step||(xAxis1.labels.step=attrs.xaxisstep)}chartdata.tooltip&&"string"==typeof chartdata.tooltip.formatter&&(chartdata.tooltip.formatter=new Function(chartdata.tooltip.formatter)),renderChart(chartsDefaults,chartdata)}},!0)}}}),AppServices.Services.factory("charts",function(){function sortJsonArrayByProperty(objArray,prop){if(arguments.length<2)throw new Error("sortJsonArrayByProp requires 2 arguments");var direct=arguments.length>2?
 arguments[2]:1;if(objArray&&objArray.constructor===Array){var propPath=prop.constructor===Array?prop:prop.split(".");objArray.sort(function(a,b){for(var p in propPath)a[propPath[p]]&&b[propPath[p]]&&(a=a[propPath[p]],b=b[propPath[p]]);return a=a.match(/^\d+$/)?+a:a,b=b.match(/^\d+$/)?+b:b,b>a?-1*direct:a>b?1*direct:0})}}var lineChart,areaChart,paretoChart,pieChart,xaxis,seriesIndex;return{convertLineChart:function(chartData,chartTemplate,dataDescription,settings,currentCompare){function plotData(counter,dPLength,dataPoints,dataAttrs,detailedView){for(var i=0;dPLength>i;i++)for(var dp=dataPoints[i],localCounter=counter,j=0;j<dataAttrs.length;j++)lineChart.series[localCounter].data.push("undefined"==typeof dp?[i,0]:[i,dp[dataAttrs[j]]]),detailedView||localCounter++}lineChart=chartTemplate,"undefined"==typeof chartData[0]&&(chartData[0]={},chartData[0].datapoints=[]);var label,dataPoints=chartData[0].datapoints,dPLength=dataPoints.length;"YESTERDAY"===currentCompare?(seriesIndex=dataDe
 scription.dataAttr.length,label="Yesterday "):"LAST_WEEK"===currentCompare?(seriesIndex=dataDescription.dataAttr.length,label="Last Week "):(lineChart=chartTemplate,seriesIndex=0,lineChart.series=[],label=""),xaxis=lineChart.xAxis[0],xaxis.categories=[],settings.xaxisformat&&(xaxis.labels.formatter=new Function(settings.xaxisformat)),settings.step&&(xaxis.labels.step=settings.step);for(var i=0;dPLength>i;i++){var dp=dataPoints[i];xaxis.categories.push(dp.timestamp)}if(chartData.length>1)for(var l=0;l<chartData.length;l++)chartData[l].chartGroupName&&(dataPoints=chartData[l].datapoints,lineChart.series[l]={},lineChart.series[l].data=[],lineChart.series[l].name=chartData[l].chartGroupName,lineChart.series[l].yAxis=0,lineChart.series[l].type="line",lineChart.series[l].color=dataDescription.colors[i],lineChart.series[l].dashStyle="solid",lineChart.series[l].yAxis.title.text=dataDescription.yAxisLabels,plotData(l,dPLength,dataPoints,dataDescription.detailDataAttr,!0));else{for(var steady
 Counter=0,i=seriesIndex;i<dataDescription.dataAttr.length+(seriesIndex>0?seriesIndex:0);i++){var yAxisIndex=dataDescription.multiAxis?steadyCounter:0;lineChart.series[i]={},lineChart.series[i].data=[],lineChart.series[i].name=label+dataDescription.labels[steadyCounter],lineChart.series[i].yAxis=yAxisIndex,lineChart.series[i].type="line",lineChart.series[i].color=dataDescription.colors[i],lineChart.series[i].dashStyle="solid",lineChart.yAxis[yAxisIndex].title.text=dataDescription.yAxisLabels[dataDescription.yAxisLabels>1?steadyCounter:0],steadyCounter++}plotData(seriesIndex,dPLength,dataPoints,dataDescription.dataAttr,!1)}return lineChart},convertAreaChart:function(chartData,chartTemplate,dataDescription,settings,currentCompare){function plotData(counter,dPLength,dataPoints,dataAttrs,detailedView){for(var i=0;dPLength>i;i++)for(var dp=dataPoints[i],localCounter=counter,j=0;j<dataAttrs.length;j++)areaChart.series[localCounter].data.push("undefined"==typeof dp?0:dp[dataAttrs[j]]),detai
 ledView||localCounter++}areaChart=angular.copy(areaChart),"undefined"==typeof chartData[0]&&(chartData[0]={},chartData[0].datapoints=[]);var label,dataPoints=chartData[0].datapoints,dPLength=dataPoints.length;"YESTERDAY"===currentCompare?(seriesIndex=dataDescription.dataAttr.length,label="Yesterday "):"LAST_WEEK"===currentCompare?(seriesIndex=dataDescription.dataAttr.length,label="Last Week "):(areaChart=chartTemplate,seriesIndex=0,areaChart.series=[],label=""),xaxis=areaChart.xAxis[0],xaxis.categories=[],settings.xaxisformat&&(xaxis.labels.formatter=new Function(settings.xaxisformat)),settings.step&&(xaxis.labels.step=settings.step);for(var i=0;dPLength>i;i++){var dp=dataPoints[i];xaxis.categories.push(dp.timestamp)}if(chartData.length>1)for(var l=0;l<chartData.length;l++)chartData[l].chartGroupName&&(dataPoints=chartData[l].datapoints,areaChart.series[l]={},areaChart.series[l].data=[],areaChart.series[l].fillColor=dataDescription.areaColors[l],areaChart.series[l].name=chartData[l]
 .chartGroupName,areaChart.series[l].yAxis=0,areaChart.series[l].type="area",areaChart.series[l].pointInterval=1,areaChart.series[l].color=dataDescription.colors[l],areaChart.series[l].dashStyle="solid",areaChart.series[l].yAxis.title.text=dataDescription.yAxisLabels,plotData(l,dPLength,dataPoints,dataDescription.detailDataAttr,!0));else{for(var steadyCounter=0,i=seriesIndex;i<dataDescription.dataAttr.length+(seriesIndex>0?seriesIndex:0);i++){var yAxisIndex=dataDescription.multiAxis?steadyCounter:0;areaChart.series[i]={},areaChart.series[i].data=[],areaChart.series[i].fillColor=dataDescription.areaColors[i],areaChart.series[i].name=label+dataDescription.labels[steadyCounter],areaChart.series[i].yAxis=yAxisIndex,areaChart.series[i].type="area",areaChart.series[i].pointInterval=1,areaChart.series[i].color=dataDescription.colors[i],areaChart.series[i].dashStyle="solid",areaChart.yAxis[yAxisIndex].title.text=dataDescription.yAxisLabels[dataDescription.yAxisLabels>1?steadyCounter:0],stead
 yCounter++}plotData(seriesIndex,dPLength,dataPoints,dataDescription.dataAttr,!1)}return areaChart},convertParetoChart:function(chartData,chartTemplate,dataDescription,settings,currentCompare){function getPreviousData(){for(var i=0;i<chartTemplate.series[0].data.length;i++)allParetoOptions.push(chartTemplate.xAxis.categories[i])}function createStackedBar(dataDescription,paretoChart){paretoChart.plotOptions={series:{shadow:!1,borderColor:dataDescription.borderColor,borderWidth:1},column:{stacking:"normal",dataLabels:{enabled:!0,color:Highcharts.theme&&Highcharts.theme.dataLabelsColor||"white"}}};var start=dataDescription.dataAttr[1].length,steadyCounter=0;compare&&(paretoChart.legend.enabled=!0);for(var f=seriesIndex;start+seriesIndex>f;f++)paretoChart.series[f]||(paretoChart.series[f]={data:[]}),paretoChart.series[f].data.push(bar[dataDescription.dataAttr[1][steadyCounter]]),paretoChart.series[f].name=""!==label?label+" "+dataDescription.labels[steadyCounter]:dataDescription.labels[s
 teadyCounter],paretoChart.series[f].color=dataDescription.colors[f],paretoChart.series[f].stack=label,steadyCounter++}paretoChart=chartTemplate,"undefined"==typeof chartData&&(chartData=[]);var label,cdLength=chartData.length,compare=!1,allParetoOptions=[],stackedBar=!1;if(seriesIndex=0,"object"==typeof dataDescription.dataAttr[1]&&(stackedBar=!0),"YESTERDAY"===currentCompare?(label="Yesterday ",compare=!0,stackedBar&&(seriesIndex=dataDescription.dataAttr[1].length),getPreviousData()):"LAST_WEEK"===currentCompare?(label="Last Week ",compare=!0,stackedBar&&(seriesIndex=dataDescription.dataAttr[1].length),seriesIndex=getPreviousData()):(compare=!1,label="",paretoChart.xAxis.categories=[],paretoChart.series=[],paretoChart.series[0]={},paretoChart.series[0].data=[],paretoChart.legend.enabled=!1),paretoChart.plotOptions.series.borderColor=dataDescription.borderColor,compare&&!stackedBar){paretoChart.series[1]={},paretoChart.series[1].data=[];for(var i=0;i<allParetoOptions.length;i++)pare
 toChart.series[1].data.push(0);paretoChart.legend.enabled=!0}for(var i=0;cdLength>i;i++){var bar=chartData[i];if(compare){var newLabel=bar[dataDescription.dataAttr[0]],newValue=bar[dataDescription.dataAttr[1]],previousIndex=allParetoOptions.indexOf(newLabel);previousIndex>-1&&("object"==typeof dataDescription.dataAttr[1]?createStackedBar(dataDescription,paretoChart,paretoChart.series.length):(paretoChart.series[1].data[previousIndex]=newValue,paretoChart.series[1].name=""!==label?label+" "+dataDescription.labels[0]:dataDescription.labels[0],paretoChart.series[1].color=dataDescription.colors[1]))}else paretoChart.xAxis.categories.push(bar[dataDescription.dataAttr[0]]),"object"==typeof dataDescription.dataAttr[1]?createStackedBar(dataDescription,paretoChart,paretoChart.series.length):(paretoChart.series[0].data.push(bar[dataDescription.dataAttr[1]]),paretoChart.series[0].name=dataDescription.labels[0],paretoChart.series[0].color=dataDescription.colors[0])}return paretoChart},convertPi
 eChart:function(chartData,chartTemplate,dataDescription,settings,currentCompare){var label,cdLength=chartData.length,compare=!1;pieChart=chartTemplate,"YESTERDAY"===currentCompare?(label="Yesterday ",compare=!1):"LAST_WEEK"===currentCompare?(label="Last Week ",compare=!1):(compare=!1,pieChart.series[0].data=[],pieChart.series[0].dataLabels&&"string"==typeof pieChart.series[0].dataLabels.formatter&&(pieChart.series[0].dataLabels.formatter=new Function(pieChart.series[0].dataLabels.formatter))),pieChart.plotOptions.pie.borderColor=dataDescription.borderColor,compare&&(pieChart.series[1].data=[],pieChart.series[1].dataLabels&&"string"==typeof pieChart.series[1].dataLabels.formatter&&(pieChart.series[1].dataLabels.formatter=new Function(pieChart.series[1].dataLabels.formatter)));for(var tempArray=[],i=0;cdLength>i;i++){var pie=chartData[i];tempArray.push({name:pie[dataDescription.dataAttr[0]],y:pie[dataDescription.dataAttr[1]],color:""})}sortJsonArrayByProperty(tempArray,"name");for(var
  i=0;i<tempArray.length;i++)tempArray[i].color=dataDescription.colors[i];return compare?pieChart.series[1].data=tempArray:pieChart.series[0].data=tempArray,pieChart}}}),$(".sessions-bar").sparkline([3,5,6,3,4,5,6,7,8,4,3,5,6,3,4,5,6,7,8,4,3,5,6,3,4,5,6,7,8,4,3,5,6,3,4,5,6,7,8,4,3,5,6,3,4,5,6,7,8,4,3,5,6,3,4,5,6,7,8,1],{type:"bar",barColor:"#c5c5c5",width:"800px",height:100,barWidth:12,barSpacing:"1px"}),AppServices.Controllers.controller("DataCtrl",["ug","$scope","$rootScope","$location",function(ug,$scope,$rootScope){var init=function(){$scope.verb="GET",$scope.display="",$scope.queryBodyDetail={},$scope.queryBodyDisplay="none",$scope.queryLimitDisplay="block",$scope.queryStringDisplay="block",$scope.entitySelected={},$scope.newCollection={},$rootScope.queryCollection={},$scope.data={},$scope.data.queryPath="",$scope.data.queryBody='{ "name":"value" }',$scope.data.searchString="",$scope.data.queryLimit=""},runQuery=function(verb){$scope.loading=!0;var queryPath=$scope.removeFirstSl
 ash($scope.data.queryPath||""),searchString=$scope.data.searchString||"",queryLimit=$scope.data.queryLimit||"",body=JSON.parse($scope.data.queryBody||"{}");"POST"==verb&&$scope.validateJson(!0)?ug.runDataPOSTQuery(queryPath,body):"PUT"==verb&&$scope.validateJson(!0)?ug.runDataPutQuery(queryPath,searchString,queryLimit,body):"DELETE"==verb?ug.runDataDeleteQuery(queryPath,searchString,queryLimit):ug.runDataQuery(queryPath,searchString,queryLimit)};$scope.$on("top-collections-received",function(event,collectionList){$scope.loading=!1;var ignoredCollections=["events"];ignoredCollections.forEach(function(ignoredCollection){collectionList.hasOwnProperty(ignoredCollection)&&delete collectionList[ignoredCollection]}),$scope.collectionList=collectionList,$scope.queryBoxesSelected=!1,$scope.queryPath||$scope.loadCollection("/"+collectionList[Object.keys(collectionList).sort()[0]].name),$scope.applyScope()}),$scope.$on("error-running-query",function(){$scope.loading=!1,runQuery("GET"),$scope.a
 pplyScope()}),$scope.$on("entity-deleted",function(){$scope.deleteLoading=!1,$rootScope.$broadcast("alert","success","Entities deleted sucessfully"),$scope.queryBoxesSelected=!1,$scope.checkNextPrev(),$scope.applyScope()}),$scope.$on("entity-deleted-error",function(){$scope.deleteLoading=!1,runQuery("GET"),$scope.applyScope()}),$scope.$on("collection-created",function(){$scope.newCollection.name=""}),$scope.$on("query-received",function(event,collection){$scope.loading=!1,$rootScope.queryCollection=collection,ug.getIndexes($scope.data.queryPath),$scope.setDisplayType(),$scope.checkNextPrev(),$scope.applyScope(),$scope.queryBoxesSelected=!1}),$scope.$on("indexes-received",function(event,indexes){}),$scope.$on("app-changed",function(){init()}),$scope.setDisplayType=function(){$scope.display="generic"},$scope.deleteEntitiesDialog=function(modalId){$scope.deleteLoading=!1,$scope.deleteEntities($rootScope.queryCollection,"entity-deleted","error deleting entity"),$scope.hideModal(modalId)
 },$scope.newCollectionDialog=function(modalId){$scope.newCollection.name?(ug.createCollection($scope.newCollection.name),ug.getTopCollections(),$rootScope.$broadcast("alert","success","Collection created successfully."),$scope.hideModal(modalId)):$rootScope.$broadcast("alert","error","You must specify a collection name.")},$scope.addToPath=function(uuid){$scope.data.queryPath="/"+$rootScope.queryCollection._type+"/"+uuid},$scope.isDeep=function(item){return"[object Object]"===Object.prototype.toString.call(item)},$scope.loadCollection=function(type){$scope.data.queryPath="/"+type.substring(1,type.length),$scope.data.searchString="",$scope.data.queryLimit="",$scope.data.body='{ "name":"value" }',$scope.selectGET(),$scope.applyScope(),$scope.run()},$scope.selectGET=function(){$scope.queryBodyDisplay="none",$scope.queryLimitDisplay="block",$scope.queryStringDisplay="block",$scope.verb="GET"},$scope.selectPOST=function(){$scope.queryBodyDisplay="block",$scope.queryLimitDisplay="none",$s
 cope.queryStringDisplay="none",$scope.verb="POST"},$scope.selectPUT=function(){$scope.queryBodyDisplay="block",$scope.queryLimitDisplay="block",$scope.queryStringDisplay="block",$scope.verb="PUT"},$scope.selectDELETE=function(){$scope.queryBodyDisplay="none",$scope.queryLimitDisplay="block",$scope.queryStringDisplay="block",$scope.verb="DELETE"},$scope.validateJson=function(skipMessage){var queryBody=$scope.data.queryBody;try{queryBody=JSON.parse(queryBody)}catch(e){return $rootScope.$broadcast("alert","error","JSON is not valid"),!1}return queryBody=JSON.stringify(queryBody,null,2),!skipMessage&&$rootScope.$broadcast("alert","success","JSON is valid"),$scope.data.queryBody=queryBody,!0},$scope.saveEntity=function(entity){if(!$scope.validateJson())return!1;var queryBody=entity._json;queryBody=JSON.parse(queryBody),$rootScope.selectedEntity.set(),$rootScope.selectedEntity.set(queryBody),$rootScope.selectedEntity.set("type",entity._data.type),$rootScope.selectedEntity.set("uuid",entit
 y._data.uuid),$rootScope.selectedEntity.save(function(err,data){err?$rootScope.$broadcast("alert","error","error: "+data.error_description):$rootScope.$broadcast("alert","success","entity saved")})},$scope.run=function(){$rootScope.queryCollection="";var verb=$scope.verb;runQuery(verb)},$scope.hasProperty=function(prop){var retval=!1;return"undefined"!=typeof $rootScope.queryCollection._list&&angular.forEach($rootScope.queryCollection._list,function(value){retval||value._data[prop]&&(retval=!0)}),retval},$scope.resetNextPrev=function(){$scope.previous_display="none",$scope.next_display="none"},$scope.checkNextPrev=function(){$scope.resetNextPrev(),$rootScope.queryCollection.hasPreviousPage()&&($scope.previous_display="default"),$rootScope.queryCollection.hasNextPage()&&($scope.next_display="default")},$scope.selectEntity=function(uuid){$rootScope.selectedEntity=$rootScope.queryCollection.getEntityByUUID(uuid),$scope.addToPath(uuid)},$scope.getJSONView=function(entity){var tempjson=e
 ntity.get(),queryBody=JSON.stringify(tempjson,null,2);queryBody=JSON.parse(queryBody),delete queryBody.metadata,delete queryBody.uuid,delete queryBody.created,delete queryBody.modified,delete queryBody.type,$scope.queryBody=JSON.stringify(queryBody,null,2)},$scope.getPrevious=function(){$rootScope.queryCollection.getPreviousPage(function(err){err&&$rootScope.$broadcast("alert","error","error getting previous page of data"),$scope.checkNextPrev(),$scope.applyScope()})},$scope.getNext=function(){$rootScope.queryCollection.getNextPage(function(err){err&&$rootScope.$broadcast("alert","error","error getting next page of data"),$scope.checkNextPrev(),$scope.applyScope()})},init(),$rootScope.queryCollection=$rootScope.queryCollection||{},$rootScope.selectedEntity={},$rootScope.queryCollection&&$rootScope.queryCollection._type&&($scope.loadCollection($rootScope.queryCollection._type),$scope.setDisplayType()),ug.getTopCollections(),$scope.resetNextPrev()}]),AppServices.Controllers.controller
 ("EntityCtrl",["ug","$scope","$rootScope","$location",function(ug,$scope,$rootScope,$location){if(!$rootScope.selectedEntity)return void $location.path("/data");$scope.entityUUID=$rootScope.selectedEntity.get("uuid"),$scope.entityType=$rootScope.selectedEntity.get("type");var tempjson=$rootScope.selectedEntity.get(),queryBody=JSON.stringify(tempjson,null,2);queryBody=JSON.parse(queryBody),delete queryBody.metadata,delete queryBody.uuid,delete queryBody.created,delete queryBody.modified,delete queryBody.type,$scope.queryBody=JSON.stringify(queryBody,null,2),$scope.validateJson=function(){var queryBody=$scope.queryBody;try{queryBody=JSON.parse(queryBody)}catch(e){return $rootScope.$broadcast("alert","error","JSON is not valid"),!1}return queryBody=JSON.stringify(queryBody,null,2),$rootScope.$broadcast("alert","success","JSON is valid"),$scope.queryBody=queryBody,!0},$scope.saveEntity=function(){if(!$scope.validateJson())return!1;var queryBody=$scope.queryBody;queryBody=JSON.parse(quer
 yBody),$rootScope.selectedEntity.set(),$rootScope.selectedEntity.set(queryBody),$rootScope.selectedEntity.set("type",$scope.entityType),$rootScope.selectedEntity.set("uuid",$scope.entityUUID),$rootScope.selectedEntity.save(function(err,data){err?$rootScope.$broadcast("alert","error","error: "+data.error_description):$rootScope.$broadcast("alert","success","entity saved")})}}]),AppServices.Controllers.controller("ShellCtrl",["ug","$scope","$rootScope","$location",function(){}]),AppServices.Directives.directive("balloon",["$window","$timeout",function($window,$timeout){return{restrict:"ECA",scope:"=",template:'<div class="baloon {{direction}}" ng-transclude></div>',replace:!0,transclude:!0,link:function(scope,lElement,attrs){scope.direction=attrs.direction;var runScroll=!0,windowEl=angular.element($window);windowEl.on("scroll",function(){runScroll&&(lElement.addClass("fade-out"),$timeout(function(){lElement.addClass("hide")},1e3),runScroll=!1)})}}}]),AppServices.Directives.directive("
 bsmodal",["$rootScope",function($rootScope){return{restrict:"ECA",scope:{title:"@title",buttonid:"=buttonid",footertext:"=footertext",closelabel:"=closelabel"},transclude:!0,templateUrl:"dialogs/modal.html",replace:!0,link:function(scope,lElement,attrs,parentCtrl){scope.title=attrs.title,scope.footertext=attrs.footertext,scope.closelabel=attrs.closelabel,scope.close=attrs.close,scope.extrabutton=attrs.extrabutton,scope.extrabuttonlabel=attrs.extrabuttonlabel,scope.buttonId=attrs.buttonid,scope.closeDelegate=function(attr){scope.$parent[attr](attrs.id,scope)},scope.extraDelegate=function(attr){scope.dialogForm.$valid?(console.log(parentCtrl),scope.$parent[attr](attrs.id)):$rootScope.$broadcast("alert","error","Please check your form input and resubmit.")}}}}]),AppServices.Controllers.controller("AlertCtrl",["$scope","$rootScope","$timeout",function($scope,$rootScope,$timeout){$scope.alertDisplay="none",$scope.alerts=[],$scope.$on("alert",function(event,type,message,permanent){$scope.
 addAlert(type,message,permanent)}),$scope.$on("clear-alerts",function(){$scope.alerts=[]}),$scope.addAlert=function(type,message,permanent){$scope.alertDisplay="block",$scope.alerts.push({type:type,msg:message}),$scope.applyScope(),permanent||$timeout(function(){$scope.alerts.shift()},5e3)},$scope.closeAlert=function(index){$scope.alerts.splice(index,1)}}]),AppServices.Directives.directive("alerti",["$rootScope","$timeout",function($rootScope,$timeout){return{restrict:"ECA",scope:{type:"=type",closeable:"@closeable",index:"&index"},template:'<div class="alert" ng-class="type && \'alert-\' + type">    <button ng-show="closeable" type="button" class="close" ng-click="closeAlert(index)">&times;</button>    <i ng-if="type === \'warning\'" class="pictogram pull-left" style="font-size:3em;line-height:0.4">&#128165;</i>    <i ng-if="type === \'info\'" class="pictogram pull-left">&#8505;</i>    <i ng-if="type === \'error\'" class="pictogram pull-left">&#9889;</i>    <i ng-if="type === \'suc
 cess\'" class="pictogram pull-left">&#128077;</i><div ng-transclude></div></div>',replace:!0,transclude:!0,link:function(scope,lElement,attrs){$timeout(function(){lElement.addClass("fade-out")},4e3),lElement.click(function(){attrs.index&&scope.$parent.closeAlert(attrs.index)}),setTimeout(function(){lElement.addClass("alert-animate")},10)}}}]),AppServices.Directives.directive("appswitcher",["$rootScope",function(){return{restrict:"ECA",scope:"=",templateUrl:"global/appswitcher-template.html",replace:!0,transclude:!0,link:function(){function globalNavDetail(){$("#globalNavDetail > div").removeClass(classNameOpen),$("#globalNavDetailApiPlatform").addClass(classNameOpen)}var classNameOpen="open";$("ul.nav li.dropdownContainingSubmenu").hover(function(){$(this).addClass(classNameOpen)},function(){$(this).removeClass(classNameOpen)}),$("#globalNav > a").mouseover(globalNavDetail),$("#globalNavDetail").mouseover(globalNavDetail),$("#globalNavSubmenuContainer ul li").mouseover(function(){$(
 "#globalNavDetail > div").removeClass(classNameOpen),$("#"+this.getAttribute("data-globalNavDetail")).addClass(classNameOpen)
-})}}}]),AppServices.Directives.directive("insecureBanner",["$rootScope","ug",function($rootScope,ug){return{restrict:"E",transclude:!0,templateUrl:"global/insecure-banner.html",link:function(scope){scope.securityWarning=!1,scope.$on("roles-received",function(evt,roles){scope.securityWarning=!1,roles&&roles._list&&roles._list.forEach(function(roleHolder){var role=roleHolder._data;"GUEST"===role.name.toUpperCase()&&roleHolder.getPermissions(function(err){err||roleHolder.permissions&&roleHolder.permissions.forEach(function(permission){permission.path.indexOf("/**")>=0&&(scope.securityWarning=!0,scope.applyScope())})})})});var initialized=!1;scope.$on("app-initialized",function(){!initialized&&ug.getRoles(),initialized=!0}),scope.$on("app-changed",function(){scope.securityWarning=!1,ug.getRoles()})}}}]),AppServices.Constants.constant("configuration",{ITEMS_URL:"global/temp.json"}),AppServices.Controllers.controller("PageCtrl",["ug","utility","$scope","$rootScope","$location","$routePara
 ms","$q","$route","$log","$analytics",function(ug,utility,$scope,$rootScope,$location,$routeParams,$q,$route,$log,$analytics){var initScopeVariables=function(){$scope.loadingText="Loading...",$scope.use_sso=!1,$scope.newApp={name:""},$scope.getPerm="",$scope.postPerm="",$scope.putPerm="",$scope.deletePerm="",$scope.usersTypeaheadValues=[],$scope.groupsTypeaheadValues=[],$scope.rolesTypeaheadValues=[],$rootScope.sdkActive=!1,$rootScope.demoData=!1,$scope.queryStringApplied=!1,$rootScope.autoUpdateTimer=Usergrid.config?Usergrid.config.autoUpdateTimer:61,$rootScope.requiresDeveloperKey=Usergrid.config?Usergrid.config.client.requiresDeveloperKey:!1,$rootScope.loaded=$rootScope.activeUI=!1;for(var key in Usergrid.regex)$scope[key]=Usergrid.regex[key];$scope.options=Usergrid.options;var getQuery=function(){for(var m,result={},queryString=location.search.slice(1),re=/([^&=]+)=([^&]*)/g;m=re.exec(queryString);)result[decodeURIComponent(m[1])]=decodeURIComponent(m[2]);return result};$scope.q
 ueryString=getQuery()};initScopeVariables(),$rootScope.urls=function(){var urls=ug.getUrls();return $scope.apiUrl=urls.apiUrl,$scope.use_sso=urls.use_sso,urls},$rootScope.gotoPage=function(path){$location.path(path)};var notRegistration=function(){return"/forgot-password"!==$location.path()&&"/register"!==$location.path()},verifyUser=function(){"/login"!==$location.path().slice(0,"/login".length)&&($rootScope.currentPath=$location.path()),$routeParams.access_token&&$routeParams.admin_email&&$routeParams.uuid&&(ug.set("token",$routeParams.access_token),ug.set("email",$routeParams.admin_email),ug.set("uuid",$routeParams.uuid),$location.search("access_token",null),$location.search("admin_email",null),$location.search("uuid",null)),ug.checkAuthentication(!0)};$scope.profile=function(){$scope.use_sso?window.location=$rootScope.urls().PROFILE_URL+"?callback="+encodeURIComponent($location.absUrl()):$location.path("/profile")},$scope.showModal=function(id){$("#"+id).modal("show")},$scope.hi
 deModal=function(id){$("#"+id).modal("hide")},$scope.deleteEntities=function(collection,successBroadcast,errorMessage){collection.resetEntityPointer();for(var entitiesToDelete=[];collection.hasNextEntity();){var entity=collection.getNextEntity(),checked=entity.checked;checked&&entitiesToDelete.push(entity)}for(var count=0,success=!1,i=0;i<entitiesToDelete.length;i++){var entity=entitiesToDelete[i];collection.destroyEntity(entity,function(err){count++,err?($rootScope.$broadcast("alert","error",errorMessage),$rootScope.$broadcast(successBroadcast+"-error",err)):success=!0,count===entitiesToDelete.length&&(success&&$rootScope.$broadcast(successBroadcast),$scope.applyScope())})}},$scope.selectAllEntities=function(list,that,varName,setValue){varName=varName||"master";var val=that[varName];void 0==setValue&&(setValue=!0),setValue&&(that[varName]=val=!val),list.forEach(function(entitiy){entitiy.checked=val})},$scope.createPermission=function(type,entity,path,permissions){"/"!=path.charAt(0
 )&&(path="/"+path);var ops="",s="";permissions.getPerm&&(ops="get",s=","),permissions.postPerm&&(ops=ops+s+"post",s=","),permissions.putPerm&&(ops=ops+s+"put",s=","),permissions.deletePerm&&(ops=ops+s+"delete",s=",");var permission=ops+":"+path;return permission},$scope.formatDate=function(date){return new Date(date).toUTCString()},$scope.clearCheckbox=function(id){$("#"+id).attr("checked")&&$("#"+id).click()},$scope.removeFirstSlash=function(path){return 0===path.indexOf("/")?path.substring(1,path.length):path},$scope.applyScope=function(cb){return cb="function"==typeof cb?cb:function(){},this.$$phase?void cb():this.$apply(cb)},$scope.valueSelected=function(list){return list&&list.some(function(item){return item.checked})},$scope.sendHelp=function(modalId){ug.jsonpRaw("apigeeuihelpemail","",{useremail:$rootScope.userEmail}).then(function(){$rootScope.$broadcast("alert","success","Email sent. Our team will be in touch with you shortly.")},function(){$rootScope.$broadcast("alert","er
 ror","Problem Sending Email. Try sending an email to mobile@apigee.com.")}),$scope.hideModal(modalId)},$scope.$on("users-typeahead-received",function(event,users){$scope.usersTypeaheadValues=users,$scope.$$phase||$scope.$apply()}),$scope.$on("groups-typeahead-received",function(event,groups){$scope.groupsTypeaheadValues=groups,$scope.$$phase||$scope.$apply()}),$scope.$on("roles-typeahead-received",function(event,roles){$scope.rolesTypeaheadValues=roles,$scope.$$phase||$scope.$apply()}),$scope.$on("checkAuthentication-success",function(){sessionStorage.setItem("authenticateAttempts",0),$scope.loaded=!0,$rootScope.activeUI=!0,$scope.applyScope(),$scope.queryStringApplied||($scope.queryStringApplied=!0,setTimeout(function(){$scope.queryString.org&&$rootScope.$broadcast("change-org",$scope.queryString.org)},1e3)),$rootScope.$broadcast("app-initialized")}),$scope.$on("checkAuthentication-error",function(args,err,missingData,email){if($scope.loaded=!0,err&&!$scope.use_sso&&notRegistration
 ())ug.logout(),$location.path("/login"),$scope.applyScope();else if(missingData&&notRegistration()){if(!email&&$scope.use_sso)return void(window.location=$rootScope.urls().LOGIN_URL+"?callback="+encodeURIComponent($location.absUrl().split("?")[0]));ug.reAuthenticate(email)}}),$scope.$on("reAuthenticate-success",function(args,err,data,user,organizations,applications){sessionStorage.setItem("authenticateAttempts",0),$rootScope.$broadcast("loginSuccesful",user,organizations,applications),$rootScope.$emit("loginSuccesful",user,organizations,applications),$rootScope.$broadcast("checkAuthentication-success"),$scope.applyScope(function(){$scope.deferredLogin.resolve(),$location.path("/org-overview")})});var authenticateAttempts=parseInt(sessionStorage.getItem("authenticateAttempts")||0);$scope.$on("reAuthenticate-error",function(){if($scope.use_sso){if(authenticateAttempts++>5)return void $rootScope.$broadcast("alert","error","There is an issue with authentication. Please contact support."
 );console.error("Failed to login via sso "+authenticateAttempts),sessionStorage.setItem("authenticateAttempts",authenticateAttempts),window.location=$rootScope.urls().LOGIN_URL+"?callback="+encodeURIComponent($location.absUrl().split("?")[0])}else notRegistration()&&(ug.logout(),$location.path("/login"),$scope.applyScope())}),$scope.$on("loginSuccessful",function(){$rootScope.activeUI=!0}),$scope.$on("app-changed",function(args,oldVal,newVal,preventReload){newVal===oldVal||preventReload||$route.reload()}),$scope.$on("org-changed",function(){ug.getApplications(),$route.reload()}),$scope.$on("app-settings-received",function(){}),$scope.$on("request-times-slow",function(){$rootScope.$broadcast("alert","info","We are experiencing performance issues on our server.  Please click Get Help for support if this continues.")});var lastPage="";$scope.$on("$routeChangeSuccess",function(){verifyUser(),$scope.showDemoBar="/performance"===$location.path().slice(0,"/performance".length),$scope.showD
 emoBar||($rootScope.demoData=!1),setTimeout(function(){lastPage=""},50);var path=window.location.pathname.replace("index-debug.html","");""===lastPage&&$analytics.pageTrack((path+$location.path()).replace("//","/")),lastPage=$location.path()}),$scope.$on("applications-received",function(event,applications){$scope.applications=applications,$scope.hasApplications=Object.keys(applications).length>0}),ug.getAppSettings()}]),AppServices.Directives.directive("pageTitle",["$rootScope","data",function($rootScope,data){return{restrict:"ECA",scope:{},transclude:!0,templateUrl:"global/page-title.html",replace:!0,link:function(scope,lElement,attrs){scope.title=attrs.title,scope.icon=attrs.icon,scope.showHelp=function(){$("#need-help").modal("show")},scope.sendHelp=function(){data.jsonp_raw("apigeeuihelpemail","",{useremail:$rootScope.userEmail}).then(function(){$rootScope.$broadcast("alert","success","Email sent. Our team will be in touch with you shortly.")},function(){$rootScope.$broadcast("a
 lert","error","Problem Sending Email. Try sending an email to mobile@apigee.com.")}),$("#need-help").modal("hide")}}}}]),AppServices.Services.factory("ug",function(configuration,$rootScope,utility,$q,$http,$resource,$log,$analytics,$location){function reportError(data,config){try{$analytics.eventTrack("error",{category:"App Services",label:data+":"+config.url+":"+(sessionStorage.apigee_uuid||"na")})}catch(e){console.log(e)}}var requestTimes=[],running=!1,currentRequests={},getAccessToken=function(){return sessionStorage.getItem("accessToken")};return{get:function(prop,isObject){return isObject?this.client().getObject(prop):this.client().get(prop)},set:function(prop,value){this.client().set(prop,value)},getUrls:function(){var host=$location.host(),qs=$location.search(),BASE_URL="",DATA_URL="",use_sso=!1;switch(!0){case"appservices.apigee.com"===host&&location.pathname.indexOf("/dit")>=0:BASE_URL="https://accounts.jupiter.apigee.net",DATA_URL="http://apigee-internal-prod.jupiter.apige
 e.net",use_sso=!0;break;case"appservices.apigee.com"===host&&location.pathname.indexOf("/mars")>=0:BASE_URL="https://accounts.mars.apigee.net",DATA_URL="http://apigee-internal-prod.mars.apigee.net",use_sso=!0;break;case"appservices.apigee.com"===host:DATA_URL=Usergrid.overrideUrl;break;case"apigee.com"===host:BASE_URL="https://accounts.apigee.com",DATA_URL="https://api.usergrid.com",use_sso=!0;break;case"usergrid.dev"===host:DATA_URL="https://api.usergrid.com";break;default:DATA_URL=Usergrid.overrideUrl}return DATA_URL=qs.api_url||DATA_URL,DATA_URL=DATA_URL.lastIndexOf("/")===DATA_URL.length-1?DATA_URL.substring(0,DATA_URL.length-1):DATA_URL,{DATA_URL:DATA_URL,LOGIN_URL:BASE_URL+"/accounts/sign_in",PROFILE_URL:BASE_URL+"/accounts/my_account",LOGOUT_URL:BASE_URL+"/accounts/sign_out",apiUrl:DATA_URL,use_sso:use_sso}},orgLogin:function(username,password){var self=this;this.client().set("email",username),this.client().set("token",null),this.client().orgLogin(username,password,function(e
 rr,data,user,organizations,applications){err?$rootScope.$broadcast("loginFailed",err,data):self.initializeCurrentUser(function(){$rootScope.$broadcast("loginSuccesful",user,organizations,applications)})})},checkAuthentication:function(force){var ug=this,client=ug.client(),initialize=function(){ug.initializeCurrentUser(function(){$rootScope.userEmail=client.get("email"),$rootScope.organizations=client.getObject("organizations"),$rootScope.applications=client.getObject("applications"),$rootScope.currentOrg=client.get("orgName"),$rootScope.currentApp=client.get("appName");var key,size=0;for(key in $rootScope.applications)$rootScope.applications.hasOwnProperty(key)&&size++;$rootScope.$broadcast("checkAuthentication-success",client.getObject("organizations"),client.getObject("applications"),client.get("orgName"),client.get("appName"),client.get("email"))})},isAuthenticated=function(){var authenticated=null!==client.get("token")&&null!==client.get("organizations");return authenticated&&in
 itialize(),authenticated};if(!isAuthenticated()||force){if(!client.get("token"))return $rootScope.$broadcast("checkAuthentication-error","no token",{},client.get("email"));this.client().reAuthenticateLite(function(err){var missingData=err||!client.get("orgName")||!client.get("appName")||!client.getObject("organizations")||!client.getObject("applications"),email=client.get("email");err||missingData?$rootScope.$broadcast("checkAuthentication-error",err,missingData,email):initialize()})}},reAuthenticate:function(email,eventOveride){var ug=this;this.client().reAuthenticate(email,function(err,data,user,organizations,applications){err||($rootScope.currentUser=user),err||($rootScope.userEmail=user.get("email"),$rootScope.organizations=organizations,$rootScope.applications=applications,$rootScope.currentOrg=ug.get("orgName"),$rootScope.currentApp=ug.get("appName"),$rootScope.currentUser=user._data,$rootScope.currentUser.profileImg=utility.get_gravatar($rootScope.currentUser.email)),$rootSco
 pe.$broadcast((eventOveride||"reAuthenticate")+"-"+(err?"error":"success"),err,data,user,organizations,applications)})},logoutCallback:function(){$rootScope.$broadcast("userNotAuthenticated")},logout:function(){$rootScope.activeUI=!1,$rootScope.userEmail="user@apigee.com",$rootScope.organizations={noOrg:{name:"No Orgs Found"}},$rootScope.applications={noApp:{name:"No Apps Found"}},$rootScope.currentOrg="No Org Found",$rootScope.currentApp="No App Found",sessionStorage.setItem("accessToken",null),sessionStorage.setItem("userUUID",null),sessionStorage.setItem("userEmail",null),this.client().logout(),this._client=null},client:function(){var options={buildCurl:!0,logging:!0};return Usergrid.options&&Usergrid.options.client&&(options.keys=Usergrid.options.client),this._client=this._client||new Usergrid.Client(options,$rootScope.urls().DATA_URL),this._client},setClientProperty:function(key,value){this.client().set(key,value)},getTopCollections:function(){var options={method:"GET",endpoint
 :""};this.client().request(options,function(err,data){if(err)$rootScope.$broadcast("alert","error","error getting collections");else{var collections=data.entities[0].metadata.collections;$rootScope.$broadcast("top-collections-received",collections)}})},createCollection:function(collectionName){var collections={};collections[collectionName]={};var metadata={metadata:{collections:collections}},options={method:"PUT",body:metadata,endpoint:""};this.client().request(options,function(err){err?$rootScope.$broadcast("alert","error","error creating collection"):$rootScope.$broadcast("collection-created",collections)})},getApplications:function(){this.client().getApplications(function(err,applications){err?applications&&console.error(applications):$rootScope.$broadcast("applications-received",applications)})},getAdministrators:function(){this.client().getAdministrators(function(err,administrators){err&&$rootScope.$broadcast("alert","error","error getting administrators"),$rootScope.$broadcast
 ("administrators-received",administrators)})},createApplication:function(appName){this.client().createApplication(appName,function(err,applications){err?$rootScope.$broadcast("alert","error","error creating application"):($rootScope.$broadcast("applications-created",applications,appName),$rootScope.$broadcast("applications-received",applications))})},createAdministrator:function(adminName){this.client().createAdministrator(adminName,function(err,administrators){err&&$rootScope.$broadcast("alert","error","error creating administrator"),$rootScope.$broadcast("administrators-received",administrators)})},getFeed:function(){var options={method:"GET",endpoint:"management/organizations/"+this.client().get("orgName")+"/feed",mQuery:!0};this.client().request(options,function(err,data){if(err)$rootScope.$broadcast("alert","error","error getting feed");else{var feedData=data.entities,feed=[],i=0;for(i=0;i<feedData.length;i++){var date=new Date(feedData[i].created).toUTCString(),title=feedData[
 i].title,n=title.indexOf(">");title=title.substring(n+1,title.length),n=title.indexOf(">"),title=title.substring(n+1,title.length),feedData[i].actor&&(title=feedData[i].actor.displayName+" "+title),feed.push({date:date,title:title})}0===i&&feed.push({date:"",title:"No Activities found."}),$rootScope.$broadcast("feed-received",feed)}})},createGroup:function(path,title){var options={path:path,title:title},self=this;this.groupsCollection.addEntity(options,function(err){err?$rootScope.$broadcast("groups-create-error",err):($rootScope.$broadcast("groups-create-success",self.groupsCollection),$rootScope.$broadcast("groups-received",self.groupsCollection))})},createRole:function(name,title){var options={name:name,title:title},self=this;this.rolesCollection.addEntity(options,function(err){err?$rootScope.$broadcast("alert","error","error creating role"):$rootScope.$broadcast("roles-received",self.rolesCollection)})},createUser:function(username,name,email,password){var options={username:user
 name,name:name,email:email,password:password},self=this;this.usersCollection.addEntity(options,function(err,data){err?"string"==typeof data?$rootScope.$broadcast("alert","error","error: "+data):$rootScope.$broadcast("alert","error","error creating user. the email address might already exist."):($rootScope.$broadcast("users-create-success",self.usersCollection),$rootScope.$broadcast("users-received",self.usersCollection))})},getCollection:function(type,path,orderBy,query,limit){var options={type:path,qs:{}};query&&(options.qs.ql=query),options.qs.ql=options.qs.ql?options.qs.ql+" order by "+(orderBy||"created desc"):" order by "+(orderBy||"created desc"),limit&&(options.qs.limit=limit),this.client().createCollection(options,function(err,collection,data){err?$rootScope.$broadcast("alert","error","error getting "+collection._type+": "+data.error_description):$rootScope.$broadcast(type+"-received",collection),$rootScope.$$phase||$rootScope.$apply()})},runDataQuery:function(queryPath,sear
 chString,queryLimit){this.getCollection("query",queryPath,null,searchString,queryLimit)},runDataPOSTQuery:function(queryPath,body){var self=this,options={method:"POST",endpoint:queryPath,body:body};this.client().request(options,function(err,data){if(err)$rootScope.$broadcast("alert","error","error: "+data.error_description),$rootScope.$broadcast("error-running-query",data);else{var queryPath=data.path;self.getCollection("query",queryPath,null,"order by modified DESC",null)}})},runDataPutQuery:function(queryPath,searchString,queryLimit,body){var self=this,options={method:"PUT",endpoint:queryPath,body:body};searchString&&(options.qs.ql=searchString),queryLimit&&(options.qs.queryLimit=queryLimit),this.client().request(options,function(err,data){if(err)$rootScope.$broadcast("alert","error","error: "+data.error_description);else{var queryPath=data.path;self.getCollection("query",queryPath,null,"order by modified DESC",null)}})},runDataDeleteQuery:function(queryPath,searchString,queryLimi
 t){var self=this,options={method:"DELETE",endpoint:queryPath};searchString&&(options.qs.ql=searchString),queryLimit&&(options.qs.queryLimit=queryLimit),this.client().request(options,function(err,data){if(err)$rootScope.$broadcast("alert","error","error: "+data.error_description);else{var queryPath=data.path;self.getCollection("query",queryPath,null,"order by modified DESC",null)}})},getUsers:function(){this.getCollection("users","users","username");var self=this;$rootScope.$on("users-received",function(evt,users){self.usersCollection=users})},getGroups:function(){this.getCollection("groups","groups","title");var self=this;$rootScope.$on("groups-received",function(event,roles){self.groupsCollection=roles})},getRoles:function(){this.getCollection("roles","roles","name");var self=this;$rootScope.$on("roles-received",function(event,roles){self.rolesCollection=roles})},getNotifiers:function(){var query="",limit="100",self=this;this.getCollection("notifiers","notifiers","created",query,li
 mit),$rootScope.$on("notifiers-received",function(event,notifiers){self.notifiersCollection=notifiers})},getNotificationHistory:function(type){var query=null;type&&(query="select * where state = '"+type+"'"),this.getCollection("notifications","notifications","created desc",query);var self=this;$rootScope.$on("notifications-received",function(event,notifications){self.notificationCollection=notifications})},getNotificationReceipts:function(uuid){this.getCollection("receipts","notifications/"+uuid+"/receipts");var self=this;$rootScope.$on("receipts-received",function(event,receipts){self.receiptsCollection=receipts})},getIndexes:function(path){var options={method:"GET",endpoint:path.split("/").concat("indexes").filter(function(bit){return bit&&bit.length}).join("/")};this.client().request(options,function(err,data){err?$rootScope.$broadcast("alert","error","Problem getting indexes: "+data.error):$rootScope.$broadcast("indexes-received",data.data)})},sendNotification:function(path,body
 ){var options={method:"POST",endpoint:path,body:body};this.client().request(options,function(err,data){err?$rootScope.$broadcast("alert","error","Problem creating notification: "+data.error):$rootScope.$broadcast("send-notification-complete")})},getRolesUsers:function(username){var options={type:"roles/users/"+username,qs:{ql:"order by username"}};this.client().createCollection(options,function(err,users){err?$rootScope.$broadcast("alert","error","error getting users"):$rootScope.$broadcast("users-received",users)})},getTypeAheadData:function(type,searchString,searchBy,orderBy){var search="",qs={limit:100};searchString&&(search="select * where "+searchBy+" = '"+searchString+"'"),orderBy&&(search=search+" order by "+orderBy),search&&(qs.ql=search);var options={method:"GET",endpoint:type,qs:qs};this.client().request(options,function(err,data){if(err)$rootScope.$broadcast("alert","error","error getting "+type);else{var entities=data.entities;$rootScope.$broadcast(type+"-typeahead-recei
 ved",entities)}})},getUsersTypeAhead:function(searchString){this.getTypeAheadData("users",searchString,"username","username")},getGroupsTypeAhead:function(searchString){this.getTypeAheadData("groups",searchString,"path","path")},getRolesTypeAhead:function(searchString){this.getTypeAheadData("roles",searchString,"name","name")},getGroupsForUser:function(user){var options={type:"users/"+user+"/groups"};this.client().createCollection(options,function(err,groups){err?$rootScope.$broadcast("alert","error","error getting groups"):$rootScope.$broadcast("user-groups-received",groups)})},addUserToGroup:function(user,group){var options={type:"users/"+user+"/groups/"+group};this.client().createEntity(options,function(err){err?$rootScope.$broadcast("alert","error","error adding user to group"):$rootScope.$broadcast("user-added-to-group-received")})},addUserToRole:function(user,role){var options={method:"POST",endpoint:"roles/"+role+"/users/"+user};this.client().request(options,function(err){err
 ?$rootScope.$broadcast("alert","error","error adding user to role"):$rootScope.$broadcast("role-update-received")})},addGroupToRole:function(group,role){var options={method:"POST",endpoint:"roles/"+role+"/groups/"+group};this.client().request(options,function(err){err?$rootScope.$broadcast("alert","error","error adding group to role"):$rootScope.$broadcast("role-update-received")})},followUser:function(user){var username=$rootScope.selectedUser.get("uuid"),options={method:"POST",endpoint:"users/"+username+"/following/users/"+user};this.client().request(options,function(err){err?$rootScope.$broadcast("alert","error","error following user"):$rootScope.$broadcast("follow-user-received")})},newPermission:function(permission,type,entity){var options={method:"POST",endpoint:type+"/"+entity+"/permissions",body:{permission:permission}};this.client().request(options,function(err){err?$rootScope.$broadcast("alert","error","error adding permission"):$rootScope.$broadcast("permission-update-rec
 eived")})},newUserPermission:function(permission,username){this.newPermission(permission,"users",username)},newGroupPermission:function(permission,path){this.newPermission(permission,"groups",path)},newRolePermission:function(permission,name){this.newPermission(permission,"roles",name)},deletePermission:function(permission,type,entity){var options={method:"DELETE",endpoint:type+"/"+entity+"/permissions",qs:{permission:permission}};this.client().request(options,function(err){err?$rootScope.$broadcast("alert","error","error deleting permission"):$rootScope.$broadcast("permission-update-received")})},deleteUserPermission:function(permission,user){this.deletePermission(permission,"users",user)},deleteGroupPermission:function(permission,group){this.deletePermission(permission,"groups",group)},deleteRolePermission:function(permission,rolename){this.deletePermission(permission,"roles",rolename)},removeUserFromRole:function(user,role){var options={method:"DELETE",endpoint:"roles/"+role+"/us
 ers/"+user};this.client().request(options,function(err){err?$rootScope.$broadcast("alert","error","error removing user from role"):$rootScope.$broadcast("role-update-received")})},removeUserFromGroup:function(group,role){var options={method:"DELETE",endpoint:"roles/"+role+"/groups/"+group};this.client().request(options,function(err){err?$rootScope.$broadcast("alert","error","error removing role from the group"):$rootScope.$broadcast("role-update-received")})},createAndroidNotifier:function(name,APIkey){var options={method:"POST",endpoint:"notifiers",body:{apiKey:APIkey,name:name,provider:"google"}};this.client().request(options,function(err,data){err?(console.error(data),$rootScope.$broadcast("alert","error","error creating notifier ")):($rootScope.$broadcast("alert","success","New notifier created successfully."),$rootScope.$broadcast("notifier-update"))})},createAppleNotifier:function(file,name,environment,certificatePassword){var provider="apple",formData=new FormData;formData.ap
 pend("p12Certificate",file),formData.append("name",name),formData.append("provider",provider),formData.append("environment",environment),formData.append("certificatePassword",certificatePassword||"");var options={method:"POST",endpoint:"notifiers",formData:formData};this.client().request(options,function(err,data){err?(console.error(data),$rootScope.$broadcast("alert","error","error creating notifier.")):($rootScope.$broadcast("alert","success","New notifier created successfully."),$rootScope.$broadcast("notifier-update"))})},deleteNotifier:function(name){var options={method:"DELETE",endpoint:"notifiers/"+name};this.client().request(options,function(err){err?$rootScope.$broadcast("alert","error","error deleting notifier"):$rootScope.$broadcast("notifier-update")})},initializeCurrentUser:function(callback){if(callback=callback||function(){},$rootScope.currentUser&&!$rootScope.currentUser.reset)return callback($rootScope.currentUser),$rootScope.$broadcast("current-user-initialized",""
 );var options={method:"GET",endpoint:"management/users/"+this.client().get("email"),mQuery:!0};this.client().request(options,function(err,data){err?$rootScope.$broadcast("alert","error","Error getting user info"):($rootScope.currentUser=data.data,$rootScope.currentUser.profileImg=utility.get_gravatar($rootScope.currentUser.email),$rootScope.userEmail=$rootScope.currentUser.email,callback($rootScope.currentUser),$rootScope.$broadcast("current-user-initialized",$rootScope.currentUser))})},updateUser:function(user){var body=$rootScope.currentUser;body.username=user.username,body.name=user.name,body.email=user.email;var options={method:"PUT",endpoint:"management/users/"+user.uuid+"/",mQuery:!0,body:body},self=this;this.client().request(options,function(err,data){return self.client().set("email",user.email),self.client().set("username",user.username),err?$rootScope.$broadcast("user-update-error",data):($rootScope.currentUser.reset=!0,void self.initializeCurrentUser(function(){$rootScope.
 $broadcast("user-update-success",$rootScope.currentUser)}))})},resetUserPassword:function(user){var pwdata={};pwdata.oldpassword=user.oldPassword,pwdata.newpassword=user.newPassword,pwdata.username=user.username;var options={method:"PUT",endpoint:"users/"+pwdata.uuid+"/",body:pwdata};this.client().request(options,function(err){return err?$rootScope.$broadcast("alert","error","Error resetting password"):($rootScope.currentUser.oldPassword="",$rootScope.currentUser.newPassword="",void $rootScope.$broadcast("user-reset-password-success",$rootScope.currentUser))})},getOrgCredentials:function(){var options={method:"GET",endpoint:"management/organizations/"+this.client().get("orgName")+"/credentials",mQuery:!0};this.client().request(options,function(err,data){err&&data.credentials?$rootScope.$broadcast("alert","error","Error getting credentials"):$rootScope.$broadcast("org-creds-updated",data.credentials)})},regenerateOrgCredentials:function(){var options={method:"POST",endpoint:"manageme
 nt/organizations/"+this.client().get("orgName")+"/credentials",mQuery:!0};this.client().request(options,function(err,data){err&&data.credentials?$rootScope.$broadcast("alert","error","Error regenerating credentials"):($rootScope.$broadcast("alert","success","Regeneration of credentials complete."),$rootScope.$broadcast("org-creds-updated",data.credentials))})},getAppCredentials:function(){var options={method:"GET",endpoint:"credentials"};this.client().request(options,function(err,data){err&&data.credentials?$rootScope.$broadcast("alert","error","Error getting credentials"):$rootScope.$broadcast("app-creds-updated",data.credentials)})},regenerateAppCredentials:function(){var options={method:"POST",endpoint:"credentials"};this.client().request(options,function(err,data){err&&data.credentials?$rootScope.$broadcast("alert","error","Error regenerating credentials"):($rootScope.$broadcast("alert","success","Regeneration of credentials complete."),$rootScope.$broadcast("app-creds-updated",
 data.credentials))})},signUpUser:function(orgName,userName,name,email,password){var formData={organization:orgName,username:userName,name:name,email:email,password:password},options={method:"POST",endpoint:"management/organizations",body:formData,mQuery:!0},client=this.client();client.request(options,function(err,data){err?$rootScope.$broadcast("register-error",data):$rootScope.$broadcast("register-success",data)})},resendActivationLink:function(id){var options={method:"GET",endpoint:"management/users/"+id+"/reactivate",mQuery:!0};this.client().request(options,function(err,data){err?$rootScope.$broadcast("resend-activate-error",data):$rootScope.$broadcast("resend-activate-success",data)})},getAppSettings:function(){$rootScope.$broadcast("app-settings-received",{})},getActivities:function(){this.client().request({method:"GET",endpoint:"activities",qs:{limit:200}},function(err,data){if(err)return $rootScope.$broadcast("app-activities-error",data);var entities=data.entities;entities.fo
 rEach(function(entity){entity.actor.picture?(entity.actor.picture=entity.actor.picture.replace(/^http:\/\/www.gravatar/i,"https://secure.gravatar"),entity.actor.picture=~entity.actor.picture.indexOf("http")?entity.actor.picture:"https://apigee.com/usergrid/img/user_profile.png"):entity.actor.picture=window.location.protocol+"//"+window.location.host+window.location.pathname+"img/user_profile.png"}),$rootScope.$broadcast("app-activities-received",data.entities)})},getEntityActivities:function(entity,isFeed){var route=isFeed?"feed":"activities",endpoint=entity.get("type")+"/"+entity.get("uuid")+"/"+route,options={method:"GET",endpoint:endpoint,qs:{limit:200}};this.client().request(options,function(err,data){err&&$rootScope.$broadcast(entity.get("type")+"-"+route+"-error",data),data.entities.forEach(function(entityInstance){entityInstance.createdDate=new Date(entityInstance.created).toUTCString()}),$rootScope.$broadcast(entity.get("type")+"-"+route+"-received",data.entities)})},addUser
 Activity:function(user,content){var options={actor:{displayName:user.get("username"),uuid:user.get("uuid"),username:user.get("username")},verb:"post",content:content};
-this.client().createUserActivity(user.get("username"),options,function(err,activity){err?$rootScope.$broadcast("user-activity-add-error",err):$rootScope.$broadcast("user-activity-add-success",activity)})},runShellQuery:function(method,path,payload){var options={verb:method,endpoint:path};payload&&(options.body=payload),this.client().request(options,function(err,data){err?$rootScope.$broadcast("shell-error",data):$rootScope.$broadcast("shell-success",data)})},addOrganization:function(user,orgName){var options={method:"POST",endpoint:"management/users/"+user.uuid+"/organizations",body:{organization:orgName},mQuery:!0},client=this.client();client.request(options,function(err,data){err?$rootScope.$broadcast("user-add-org-error",data):$rootScope.$broadcast("user-add-org-success",$rootScope.organizations)})},leaveOrganization:function(user,org){var options={method:"DELETE",endpoint:"management/users/"+user.uuid+"/organizations/"+org.uuid,mQuery:!0};this.client().request(options,function(e
 rr,data){err?$rootScope.$broadcast("user-leave-org-error",data):(delete $rootScope.organizations[org.name],$rootScope.$broadcast("user-leave-org-success",$rootScope.organizations))})},httpGet:function(id,url){var deferred;return deferred=$q.defer(),$http.get(url||configuration.ITEMS_URL).success(function(data){var result;id?angular.forEach(data,function(obj){obj.id===id&&(result=obj)}):result=data,deferred.resolve(result)}).error(function(data,status,headers,config){$log.error(data,status,headers,config),reportError(data,config),deferred.reject(data)}),deferred.promise},jsonp:function(objectType,criteriaId,params,successCallback){params||(params={}),params.demoApp=$rootScope.demoData,params.access_token=getAccessToken(),params.callback="JSON_CALLBACK";var uri=$rootScope.urls().DATA_URL+"/"+$rootScope.currentOrg+"/"+$rootScope.currentApp+"/apm/"+objectType+"/"+criteriaId;return this.jsonpRaw(objectType,criteriaId,params,uri,successCallback)},jsonpSimple:function(objectType,appId,para
 ms){var uri=$rootScope.urls().DATA_URL+"/"+$rootScope.currentOrg+"/"+$rootScope.currentApp+"/apm/"+objectType+"/"+appId;return this.jsonpRaw(objectType,appId,params,uri)},calculateAverageRequestTimes:function(){if(!running){var self=this;running=!0,setTimeout(function(){running=!1;var length=requestTimes.length<10?requestTimes.length:10,sum=requestTimes.slice(0,length).reduce(function(a,b){return a+b}),avg=sum/length;self.averageRequestTimes=avg/1e3,self.averageRequestTimes>5&&$rootScope.$broadcast("request-times-slow",self.averageRequestTimes)},3e3)}},jsonpRaw:function(objectType,appId,params,uri,successCallback){"function"!=typeof successCallback&&(successCallback=null),uri=uri||$rootScope.urls().DATA_URL+"/"+$rootScope.currentOrg+"/"+$rootScope.currentApp+"/"+objectType,params||(params={});var start=(new Date).getTime(),self=this;params.access_token=getAccessToken(),params.callback="JSON_CALLBACK";var deferred=$q.defer(),diff=function(){currentRequests[uri]--,requestTimes.splice(
 0,0,(new Date).getTime()-start),self.calculateAverageRequestTimes()};successCallback&&$rootScope.$broadcast("ajax_loading",objectType);var reqCount=currentRequests[uri]||0;return self.averageRequestTimes>5&&reqCount>1?(setTimeout(function(){deferred.reject(new Error("query in progress"))},50),deferred):(currentRequests[uri]=(currentRequests[uri]||0)+1,$http.jsonp(uri,{params:params}).success(function(data,status,headers,config){diff(),successCallback&&(successCallback(data,status,headers,config),$rootScope.$broadcast("ajax_finished",objectType)),deferred.resolve(data)}).error(function(data,status,headers,config){diff(),$log.error("ERROR: Could not get jsonp data. "+uri),reportError(data,config),deferred.reject(data)}),deferred.promise)},resource:function(params,isArray){return $resource($rootScope.urls().DATA_URL+"/:orgname/:appname/:username/:endpoint",{},{get:{method:"JSONP",isArray:isArray,params:params},login:{method:"GET",url:$rootScope.urls().DATA_URL+"/management/token",isArr
 ay:!1,params:params},save:{url:$rootScope.urls().DATA_URL+"/"+params.orgname+"/"+params.appname,method:"PUT",isArray:!1,params:params}})},httpPost:function(url,callback,payload,headers){var accessToken=getAccessToken();payload?payload.access_token=accessToken:payload={access_token:accessToken},headers||(headers={Bearer:accessToken}),$http({method:"POST",url:url,data:payload,headers:headers}).success(function(data){callback(data)}).error(function(data,status,headers,config){reportError(data,config),callback(data)})}}}),AppServices.Directives.directive("ngFocus",["$parse",function($parse){return function(scope,element,attr){var fn=$parse(attr.ngFocus);element.bind("focus",function(event){scope.$apply(function(){fn(scope,{$event:event})})})}}]),AppServices.Directives.directive("ngBlur",["$parse",function($parse){return function(scope,element,attr){var fn=$parse(attr.ngBlur);element.bind("blur",function(event){scope.$apply(function(){fn(scope,{$event:event})})})}}]),AppServices.Services
 .factory("utility",function(){return{keys:function(o){var a=[];for(var propertyName in o)a.push(propertyName);return a},get_gravatar:function(email,size){try{var size=size||50;return email.length?"https://secure.gravatar.com/avatar/"+MD5(email)+"?s="+size:"https://apigee.com/usergrid/img/user_profile.png"}catch(e){return"https://apigee.com/usergrid/img/user_profile.png"}},get_qs_params:function(){var queryParams={};if(window.location.search)for(var params=window.location.search.slice(1).split("&"),i=0;i<params.length;i++){var tmp=params[i].split("=");queryParams[tmp[0]]=unescape(tmp[1])}return queryParams},safeApply:function(fn){var phase=this.$root.$$phase;"$apply"==phase||"$digest"==phase?fn&&"function"==typeof fn&&fn():this.$apply(fn)}}}),AppServices.Directives.directive("ugValidate",["$rootScope",function(){return{scope:!0,restrict:"A",require:"ng-model",replace:!0,link:function(scope,element,attrs,ctrl){var validate=function(){var id=element.attr("id"),validator=id+"-validator"
 ,title=element.attr("title");if(title=title&&title.length?title:"Please enter data",$("#"+validator).remove(),ctrl.$valid)element.removeClass("has-error"),$("#"+validator).remove();else{var validatorElem='<div id="'+validator+'"><span  class="validator-error-message">'+title+"</span></div>";$("#"+id).after(validatorElem),element.addClass("has-error")}},firing=!1;element.bind("blur",function(){validate(scope,element,attrs,ctrl)}).bind("input",function(){firing||(firing=!0,setTimeout(function(){validate(scope,element,attrs,ctrl),firing=!1},500))})}}}]),AppServices.Controllers.controller("GroupsActivitiesCtrl",["ug","$scope","$rootScope","$location",function(ug,$scope,$rootScope,$location){return $scope.activitiesSelected="active",$rootScope.selectedGroup?($rootScope.selectedGroup.activities=[],void $rootScope.selectedGroup.getActivities(function(err){err||$rootScope.$$phase||$rootScope.$apply()})):void $location.path("/groups")}]),AppServices.Controllers.controller("GroupsCtrl",["ug",
 "$scope","$rootScope","$location","$route",function(ug,$scope,$rootScope,$location,$route){$scope.groupsCollection={},$rootScope.selectedGroup={},$scope.previous_display="none",$scope.next_display="none",$scope.hasGroups=!1,$scope.newGroup={path:"",title:""},ug.getGroups(),$scope.currentGroupsPage={},$scope.selectGroupPage=function(route){$scope.currentGroupsPage.template=$route.routes[route].templateUrl,$scope.currentGroupsPage.route=route},$scope.newGroupDialog=function(modalId){$scope.newGroup.path&&$scope.newGroup.title?(ug.createGroup($scope.removeFirstSlash($scope.newGroup.path),$scope.newGroup.title),$scope.hideModal(modalId),$scope.newGroup={path:"",title:""}):$rootScope.$broadcast("alert","error","Missing required information.")},$scope.deleteGroupsDialog=function(modalId){$scope.deleteEntities($scope.groupsCollection,"group-deleted","error deleting group"),$scope.hideModal(modalId),$scope.newGroup={path:"",title:""}},$scope.$on("group-deleted",function(){$rootScope.$broadc
 ast("alert","success","Group deleted successfully.")}),$scope.$on("group-deleted-error",function(){ug.getGroups()}),$scope.$on("groups-create-success",function(){$rootScope.$broadcast("alert","success","Group created successfully.")}),$scope.$on("groups-create-error",function(){$rootScope.$broadcast("alert","error","Error creating group. Make sure you don't have spaces in the path.")}),$scope.$on("groups-received",function(event,groups){$scope.groupBoxesSelected=!1,$scope.groupsCollection=groups,$scope.newGroup.path="",$scope.newGroup.title="",!(groups._list.length>0)||$rootScope.selectedGroup._data&&groups._list.some(function(group){return $rootScope.selectedGroup._data.uuid===group._data.uuid})||$scope.selectGroup(groups._list[0]._data.uuid),$scope.hasGroups=groups._list.length>0,$scope.received=!0,$scope.checkNextPrev(),$scope.applyScope()}),$scope.resetNextPrev=function(){$scope.previous_display="none",$scope.next_display="none"},$scope.checkNextPrev=function(){$scope.resetNextP
 rev(),$scope.groupsCollection.hasPreviousPage()&&($scope.previous_display="block"),$scope.groupsCollection.hasNextPage()&&($scope.next_display="block")},$scope.selectGroup=function(uuid){$rootScope.selectedGroup=$scope.groupsCollection.getEntityByUUID(uuid),$scope.currentGroupsPage.template="groups/groups-details.html",$scope.currentGroupsPage.route="/groups/details",$rootScope.$broadcast("group-selection-changed",$rootScope.selectedGroup)},$scope.getPrevious=function(){$scope.groupsCollection.getPreviousPage(function(err){err&&$rootScope.$broadcast("alert","error","error getting previous page of groups"),$scope.checkNextPrev(),$scope.applyScope()})},$scope.getNext=function(){$scope.groupsCollection.getNextPage(function(err){err&&$rootScope.$broadcast("alert","error","error getting next page of groups"),$scope.checkNextPrev(),$scope.applyScope()})},$scope.$on("group-deleted",function(){$route.reload(),$scope.master=""})}]),AppServices.Controllers.controller("GroupsDetailsCtrl",["ug"
 ,"$scope","$rootScope","$location",function(ug,$scope,$rootScope,$location){var selectedGroup=$rootScope.selectedGroup.clone();return $scope.detailsSelected="active",$scope.json=selectedGroup._json||selectedGroup._data.stringifyJSON(),$scope.group=selectedGroup._data,$scope.group.path=0!=$scope.group.path.indexOf("/")?"/"+$scope.group.path:$scope.group.path,$scope.group.title=$scope.group.title,$rootScope.selectedGroup?($scope.$on("group-selection-changed",function(evt,selectedGroup){$scope.group.path=0!=selectedGroup._data.path.indexOf("/")?"/"+selectedGroup._data.path:selectedGroup._data.path,$scope.group.title=selectedGroup._data.title,$scope.detailsSelected="active",$scope.json=selectedGroup._json||selectedGroup._data.stringifyJSON()}),void($rootScope.saveSelectedGroup=function(){$rootScope.selectedGroup._data.title=$scope.group.title,$rootScope.selectedGroup._data.path=$scope.removeFirstSlash($scope.group.path),$rootScope.selectedGroup.save(function(err){err?$rootScope.$broadca
 st("alert","error","error saving group"):$rootScope.$broadcast("alert","success","group saved")})})):void $location.path("/groups")}]),AppServices.Controllers.controller("GroupsMembersCtrl",["ug","$scope","$rootScope","$location",function(ug,$scope,$rootScope,$location){return $scope.membersSelected="active",$scope.previous_display="none",$scope.next_display="none",$scope.user="",$scope.master="",$scope.hasMembers=!1,ug.getUsersTypeAhead(),$scope.usersTypeaheadValues=[],$scope.$on("users-typeahead-received",function(event,users){$scope.usersTypeaheadValues=users,$scope.applyScope()}),$scope.addGroupToUserDialog=function(modalId){if($scope.user){var path=$rootScope.selectedGroup.get("path");ug.addUserToGroup($scope.user.uuid,path),$scope.user="",$scope.hideModal(modalId)}else $rootScope.$broadcast("alert","error","Please select a user.")},$scope.removeUsersFromGroupDialog=function(modalId){$scope.deleteEntities($scope.groupsCollection.users,"group-update-received","Error removing use
 r from group"),$scope.hideModal(modalId)},$scope.get=function(){if($rootScope.selectedGroup.get){var options={type:"groups/"+$rootScope.selectedGroup.get("path")+"/users"};$scope.groupsCollection.addCollection("users",options,function(err){$scope.groupMembersSelected=!1,err?$rootScope.$broadcast("alert","error","error getting users for group"):($scope.hasMembers=$scope.groupsCollection.users._list.length>0,$scope.checkNextPrev(),$scope.applyScope())})}},$scope.resetNextPrev=function(){$scope.previous_display="none",$scope.next_display="none"},$scope.checkNextPrev=function(){$scope.resetNextPrev(),$scope.groupsCollection.users.hasPreviousPage()&&($scope.previous_display="block"),$scope.groupsCollection.users.hasNextPage()&&($scope.next_display="block")},$rootScope.selectedGroup?($scope.get(),$scope.getPrevious=function(){$scope.groupsCollection.users.getPreviousPage(function(err){err&&$rootScope.$broadcast("alert","error","error getting previous page of users"),$scope.checkNextPrev()
 ,$rootScope.$$phase||$rootScope.$apply()})},$scope.getNext=function(){$scope.groupsCollection.users.getNextPage(function(err){err&&$rootScope.$broadcast("alert","error","error getting next page of users"),$scope.checkNextPrev(),$rootScope.$$phase||$rootScope.$apply()})},$scope.$on("group-update-received",function(){$scope.get()}),void $scope.$on("user-added-to-group-received",function(){$scope.get()})):void $location.path("/groups")}]),AppServices.Controllers.controller("GroupsRolesCtrl",["ug","$scope","$rootScope","$location",function(ug,$scope,$rootScope,$location){return $scope.rolesSelected="active",$scope.roles_previous_display="none",$scope.roles_next_display="none",$scope.name="",$scope.master="",$scope.hasRoles=!1,$scope.hasPermissions=!1,$scope.permissions={},$scope.addGroupToRoleDialog=function(modalId){if($scope.name){var path=$rootScope.selectedGroup.get("path");ug.addGroupToRole(path,$scope.name),$scope.hideModal(modalId),$scope.name=""}else $rootScope.$broadcast("alert
 ","error","You must specify a role name.")},$scope.leaveRoleDialog=function(modalId){for(var path=$rootScope.selectedGroup.get("path"),roles=$scope.groupsCollection.roles._list,i=0;i<roles.length;i++)roles[i].checked&&ug.removeUserFromGroup(path,roles[i]._data.name);$scope.hideModal(modalId)},$scope.addGroupPermissionDialog=function(modalId){if($scope.permissions.path){var permission=$scope.createPermission(null,null,$scope.removeFirstSlash($scope.permissions.path),$scope.permissions),path=$rootScope.selectedGroup.get("path");ug.newGroupPermission(permission,path),$scope.hideModal(modalId),$scope.permissions&&($scope.permissions={})}else $rootScope.$broadcast("alert","error","You must specify a name for the permission.")},$scope.deleteGroupPermissionDialog=function(modalId){for(var path=$rootScope.selectedGroup.get("path"),permissions=$rootScope.selectedGroup.permissions,i=0;i<permissions.length;i++)permissions[i].checked&&ug.deleteGroupPermission(permissions[i].perm,path);$scope.hi
 deModal(modalId)},$scope.resetNextPrev=function(){$scope.roles_previous_display="none",$scope.roles_next_display="none",$scope.permissions_previous_display="none",$scope.permissions_next_display="none"},$scope.resetNextPrev(),$scope.checkNextPrevRoles=function(){$scope.resetNextPrev(),$scope.groupsCollection.roles.hasPreviousPage()&&($scope.roles_previous_display="block"),$scope.groupsCollection.roles.hasNextPage()&&($scope.roles_next_display="block")},$scope.checkNextPrevPermissions=function(){$scope.groupsCollection.permissions.hasPreviousPage()&&($scope.permissions_previous_display="block"),$scope.groupsCollection.permissions.hasNextPage()&&($scope.permissions_next_display="block")},$scope.getRoles=function(){var path=$rootScope.selectedGroup.get("path"),options={type:"groups/"+path+"/roles"};$scope.groupsCollection.addCollection("roles",options,function(err){$scope.groupRoleSelected=!1,err?$rootScope.$broadcast("alert","error","error getting roles for group"):($scope.hasRoles=$s
 cope.groupsCollection.roles._list.length>0,$scope.checkNextPrevRoles(),$scope.applyScope())})},$scope.getPermissions=function(){$rootScope.selectedGroup.permissions=[],$rootScope.selectedGroup.getPermissions(function(err){$scope.groupPermissionsSelected=!1,$scope.hasPermissions=$scope.selectedGroup.permissions.length,err||$scope.applyScope()})},$scope.getPreviousRoles=function(){$scope.groupsCollection.roles.getPreviousPage(function(err){err&&$rootScope.$broadcast("alert","error","error getting previous page of roles"),$scope.checkNextPrevRoles(),$scope.applyScope()})},$scope.getNextRoles=function(){$scope.groupsCollection.roles.getNextPage(function(err){err&&$rootScope.$broadcast("alert","error","error getting next page of roles"),$scope.checkNextPrevRoles(),$scope.applyScope()})},$scope.getPreviousPermissions=function(){$scope.groupsCollection.permissions.getPreviousPage(function(err){err&&$rootScope.$broadcast("alert","error","error getting previous page of permissions"),$scope.c
 heckNextPrevPermissions(),$scope.applyScope()})},$scope.getNextPermissions=function(){$scope.groupsCollection.permissions.getNextPage(function(err){err&&$rootScope.$broadcast("alert","error","error getting next page of permissions"),$scope.checkNextPrevPermissions(),$scope.applyScope()})},$scope.$on("role-update-received",function(){$scope.getRoles()}),$scope.$on("permission-update-received",function(){$scope.getPermissions()}),$scope.$on("groups-received",function(evt,data){$scope.groupsCollection=data,$scope.getRoles(),$scope.getPermissions()}),$rootScope.selectedGroup?(ug.getRolesTypeAhead(),void ug.getGroups()):void $location.path("/groups")}]),AppServices.Controllers.controller("ForgotPasswordCtrl",["ug","$scope","$rootScope","$location","$sce","utility",function(ug,$scope,$rootScope,$location,$sce){$rootScope.activeUI&&$location.path("/"),$scope.forgotPWiframeURL=$sce.trustAsResourceUrl($scope.apiUrl+"/management/users/resetpw")}]),AppServices.Controllers.controller("LoginCtrl
 ",["ug","$scope","$rootScope","$routeParams","$location","utility",function(ug,$scope,$rootScope,$routeParams,$location){$scope.loading=!1,$scope.login={},$scope.activation={},$scope.requiresDeveloperKey=$scope.options.client.requiresDeveloperKey||!1,$rootScope.gotoForgotPasswordPage=function(){$location.path("/forgot-password")},$rootScope.gotoSignUp=function(){$location.path("/register")},$scope.login=function(){var username=$scope.login.username,password=$scope.login.password;$scope.loginMessage="",$scope.loading=!0,ug.orgLogin(username,password)},$scope.$on("loginFailed",function(){$scope.loading=!1,$scope.loginMessage="Error: the username / password combination was not valid",$scope.applyScope()}),$scope.logout=function(){ug.logout(),ug.setClientProperty("developerkey",null),$scope.use_sso?window.location=$rootScope.urls().LOGOUT_URL+"?redirect=no&callback="+encodeURIComponent($location.absUrl().split("?")[0]):($location.path("/login"),$scope.applyScope())},$rootScope.$on("user
 NotAuthenticated",function(){"/forgot-password"!==$location.path()&&($location.path("/login"),$scope.logout()),$scope.applyScope()}),$scope.$on("loginSuccesful",function(){$scope.loading=!1,$scope.requiresDeveloperKey&&ug.setClientProperty("developerkey",$scope.login.developerkey),$scope.login={},$location.path("/login"===$rootScope.currentPath||"/login/loading"===$rootScope.currentPath||"undefined"==typeof $rootScope.currentPath?"/org-overview":$rootScope.currentPath),$scope.applyScope()}),$scope.resendActivationLink=function(modalId){var id=$scope.activation.id;ug.resendActivationLink(id),$scope.activation={},$scope.hideModal(modalId)},$scope.$on("resend-activate-success",function(){$scope.activationId="",$scope.$apply(),$rootScope.$broadcast("alert","success","Activation link sent successfully.")}),$scope.$on("resend-activate-error",function(){$rootScope.$broadcast("alert","error","Activation link failed to send.")})}]),AppServices.Controllers.controller("LogoutCtrl",["ug","$scop
 e","$rootScope","$routeParams","$location","utility",function(ug,$scope,$rootScope,$routeParams,$location){ug.logout(),$scope.use_sso?window.location=$rootScope.urls().LOGOUT_URL+"?callback="+encodeURIComponent($location.absUrl().split("?")[0]):($location.path("/login"),$scope.applyScope())}]),AppServices.Controllers.controller("RegisterCtrl",["ug","$scope","$rootScope","$routeParams","$location","utility",function(ug,$scope,$rootScope,$routeParams,$location){$rootScope.activeUI&&$location.path("/");var init=function(){$scope.registeredUser={}};init(),$scope.cancel=function(){$location.path("/")},$scope.register=function(){var user=$scope.registeredUser.clone();user.password===user.confirmPassword?ug.signUpUser(user.orgName,user.userName,user.name,user.email,user.password):$rootScope.$broadcast("alert","error","Passwords do not match."+name)},$scope.$on("register-error",function(event,data){$scope.signUpSuccess=!1,$rootScope.$broadcast("alert","error","Error registering: "+(data&&da
 ta.error_description?data.error_description:name))}),$scope.$on("register-success",function(){$scope.registeredUser={},$scope.signUpSuccess=!0,init(),$scope.$apply()})}]),AppServices.Directives.directive("menu",["$location","$rootScope","$log",function($location,$rootScope,$log){return{link:function(scope,lElement,attrs){function setActiveElement(ele,locationPath,$rootScope,isParentClick){ele.removeClass("active");var menuItem,parentMenuItem,newActiveElement=ele.parent().find('a[href*="#!'+locationPath+'"]');if(0===newActiveElement.length)parentMenuItem=ele;else{menuItem=newActiveElement.parent(),menuItem.hasClass("option")?parentMenuItem=menuItem[0]:1===menuItem.size()?(parentMenuItem=newActiveElement.parent().parent().parent(),parentMenuItem.addClass("active")):(parentMenuItem=menuItem[0],menuItem=menuItem[1]);try{var menuItemCompare=parentMenuItem[0]||parentMenuItem;ele[0]!==menuItemCompare&&isParentClick&&ele.find("ul")[0]&&(ele.find("ul")[0].style.height=0);var subMenuSizer=ang
 ular.element(parentMenuItem).find(".nav-list")[0];if(subMenuSizer){var heightChecker,clientHeight=subMenuSizer.getAttribute("data-height"),heightCounter=1;clientHeight||heightChecker?(menuItem.addClass("active"),subMenuSizer.style.height=clientHeight+"px"):heightChecker=setInterval(function(){var tempHeight=subMenuSizer.getAttribute("data-height")||subMenuSizer.clientHeight;heightCounter=subMenuSizer.clientHeight,0===heightCounter&&(heightCounter=1),"string"==typeof tempHeight&&(tempHeight=parseInt(tempHeight,10)),tempHeight>0&&heightCounter===tempHeight&&(subMenuSizer.setAttribute("data-height",tempHeight),menuItem.addClass("active"),subMenuSizer.style.height=tempHeight+"px",clearInterval(heightChecker)),heightCounter=tempHeight},20),$rootScope.menuExecute=!0}else menuItem.addClass("active")}catch(e){$log.error("Problem calculating size of menu",e)}}return{menuitem:menuItem,parentMenuItem:parentMenuItem}}function setupMenuState(){if(menuContext=attrs.menu,parentMenuItems=lElement.f
 ind("li.option"),0!==lElement.find("li.option.active").length&&($rootScope[menuContext+"Parent"]=lElement.find("li.option.active")),activeParentElement=$rootScope[menuContext+"Parent"]||null,activeParentElement&&(activeParentElement=angular.element(activeParentElement)),menuItems=lElement.find("li.option li"),locationPath=$location.path(),activeParentElement&&(activeMenuElement=angular.element(activeParentElement),activeMenuElement=activeMenuElement.find("li.active"),activeMenuElement.removeClass("active"),activeParentElement.find("a")[0])){subMenuContext=activeParentElement.find("a")[0].href.split("#!")[1];var tempMenuContext=subMenuContext.split("/");subMenuContext="/"+tempMenuContext[1],tempMenuContext.length>2&&(subMenuContext+="/"+tempMenuContext[2])}var activeElements;""!==locationPath&&-1===locationPath.indexOf(subMenuContext)?(activeElements=setActiveElement(activeParentElement,locationPath,scope),$rootScope[menuContext+"Parent"]=activeElements.parentMenuItem,$rootScope[menu
 Context+"Menu"]=activeElements.menuitem):setActiveElement(activeParentElement,subMenuContext,scope)}var menuContext,parentMenuItems,activeParentElement,menuItems,activeMenuElement,locationPath,subMenuContext,bound=!1;scope.$on("$routeChangeSuccess",function(){setupMenuState(),bound||(bound=!0,parentMenuItems.bind("click",function(cevent){var previousParentSelection=angular.element($rootScope[menuContext+"Parent"]),targetPath=angular.element(cevent.currentTarget).find("> a")[0].href.split("#!")[1];previousParentSelection.find(".nav > li").removeClass("active");var activeElements=setActiveElement(previousParentSelection,targetPath,scope,!0);$rootScope[menuContext+"Parent"]=activeElements.parentMenuItem,$rootScope[menuContext+"Menu"]=activeElements.menuitem,scope.$broadcast("menu-selection")}),menuItems.bind("click",function(cevent){var previousMenuSelection=$rootScope[menuContext+"Menu"],targetElement=cevent.currentTarget;previousMenuSelection!==targetElement&&(previousMenuSelection?a
 ngular.element(previousMenuSelection).removeClass("active"):activeMenuE

<TRUNCATED>