Skip to content

Commit

Permalink
Merge pull request #147 from rafaelcoutinho/sprint4
Browse files Browse the repository at this point in the history
Sprint4
  • Loading branch information
rafaelcoutinho authored Jun 24, 2016
2 parents 2f9ca1d + 12215b2 commit ea0bf71
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 110 deletions.
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.northbrasil.app" version="0.1.31" android-versionCode="1032" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="com.northbrasil.app" version="0.1.5" android-versionCode="1050" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>NorthApp</name>
<description>
Aplicativo da NorthBrasil
Expand Down
3 changes: 2 additions & 1 deletion www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ angular.module('north', ['ionic', 'north.services', 'north.controllers', 'ngCord
"backendSecure": "https://cumeqetrekking.appspot.com/",
"backend": "http://cumeqetrekking.appspot.com/",
"enhancedRestBackend": "http://cumeqetrekking.appspot.com/app/enhanced",
// "enhancedRestBackend": "http://localhost/northServer/app.php",
//"enhancedRestBackend": "http://localhost/northServer/app.php",
"openRestBackend": "http://cumeqetrekking.appspot.com/app/rest",
// "openRestBackend": "http://localhost/northServer/apiPub.php",
"secureEndpointBackend": "https://cumeqetrekking.appspot.com/endpoints"


Expand Down
149 changes: 106 additions & 43 deletions www/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ angular.module('north.controllers', ['ionic', 'ngCordova', 'ngStorage', 'north.s
$scope.results = results;
for (var index = 0; index < results.length; index++) {
var element = results[index];

EtapasService.get({ id: element.id_Etapa }).then(function (etapa) {

for (var index = 0; index < $scope.results.length; index++) {
Expand All @@ -112,7 +112,7 @@ angular.module('north.controllers', ['ionic', 'ngCordova', 'ngStorage', 'north.s

if (element.id_Etapa == etapa.id) {
element.etapa = etapa;
break;

}
}
$scope.$broadcast('scroll.refreshComplete');
Expand Down Expand Up @@ -342,7 +342,7 @@ angular.module('north.controllers', ['ionic', 'ngCordova', 'ngStorage', 'north.s
$rootScope.$emit("addRight", { state: "app.profile", btns: [{ icon: "ion-android-more-vertical", callback: $scope.mudarSenha }] });
},
function (error) {
console.log(error);


switch (error.status) {
case 404:
Expand All @@ -356,6 +356,7 @@ angular.module('north.controllers', ['ionic', 'ngCordova', 'ngStorage', 'north.s
break;

default:
console.log(error);
$scope.loginData.errorMsg = "Usuário ou senha incorretos.";
break;
}
Expand All @@ -373,8 +374,25 @@ angular.module('north.controllers', ['ionic', 'ngCordova', 'ngStorage', 'north.s

confirmPopup.then(function (res) {
if (res) {
loginService.startPwdRecovery($scope.loginData.username);
$scope.closeLogin();
loginService.startPwdRecovery($scope.loginData.username).then(
function () {
$scope.closeLogin();
},
function (error) {
switch (error.status) {
case 404:
$scope.loginData.errorMsg = "Usuário não encontrado. Crie uma conta com este e-mail para se conectar.";
break;


default:
console.log(error);
$scope.loginData.errorMsg = "Erro ao executar lembrar senha, confirme que você utilizou este mesmo e-mail anteriormente.";
break;
}
}
);

} else {

}
Expand Down Expand Up @@ -481,7 +499,7 @@ angular.module('north.controllers', ['ionic', 'ngCordova', 'ngStorage', 'north.s
})

.controller('EtapaCtrl', function (
$scope, $stateParams, WeatherService, tab, EtapasService, LocationService, $location, $ionicBackdrop, $timeout, $rootScope, $ionicHistory, $cordovaInAppBrowser, $localStorage, $log, UtilsService, $cordovaLaunchNavigator, $ionicLoading) {
$scope, $stateParams, WeatherService, tab, EtapasService, LocationService, $location, $ionicBackdrop, $timeout, $rootScope, $ionicHistory, $cordovaInAppBrowser, $localStorage, $log, UtilsService, $cordovaLaunchNavigator, $ionicLoading, loginService) {
$scope.doRefresh = function () {
switch ($scope.currTab) {
case 'grid':
Expand All @@ -491,14 +509,13 @@ angular.module('north.controllers', ['ionic', 'ngCordova', 'ngStorage', 'north.s
default:
break;
}

$scope.setTab($scope.currTab);
}

console.log($stateParams, tab);
$scope.currTab = "details";
if (tab) {
$scope.currTab = tab;
}



$scope.tabstemplate = "templates/etapa.tabs.html";
$scope.etapaNotComplete = true;

Expand All @@ -508,8 +525,11 @@ angular.module('north.controllers', ['ionic', 'ngCordova', 'ngStorage', 'north.s
if ($localStorage.lastSelectedCat) {
selectedCat = $localStorage.lastSelectedCat;
}

return { id_Categoria: selectedCat };
if ($scope.defaultNomeResultado == null) {
return { id_Categoria: selectedCat};
} else {
return { id_Categoria: selectedCat, nomeResultado: $scope.defaultNomeResultado };
}
}
$scope.getLastSelectedGrid = function () {
var grid = $scope.categoriasGrid[0].id;
Expand Down Expand Up @@ -542,23 +562,85 @@ angular.module('north.controllers', ['ionic', 'ngCordova', 'ngStorage', 'north.s
return categoriaGrid.id_Config == item.id_Categoria;
};
}

$scope.defaultNomeResultado = "Final"
$scope.setTab = function (tabName) {
$scope.currTab = tabName;
if ($scope.currTab == "grid") {
EtapasService.getGrid({ id: $scope.etapa.id }).then(function (data) {
$scope.inscricaoInfo = data;
$scope.$broadcast('scroll.refreshComplete');;
}, function () {
$scope.$broadcast('scroll.refreshComplete');
});
} else if ($scope.currTab == "results") {
EtapasService.getResultados($scope.etapa).then(function (data) {
$scope.resultados = data;

EtapasService.getResultados({ id: $scope.etapa.id }).then(function (data) {
$scope.resultados = [];
$scope.nomesResultados = [];

if (data.length > 0) {
if (data[0].nomeResultado) {
$scope.nomesResultados = data;
var found = false;
for (var i = 0; i < data.length; i++) {
var element = data[i];
$scope.resultados = $scope.resultados.concat(element.resultados);
if (element.nomeResultado == "Final") {
found = true;
}
}
if (found == false) {
$scope.defaultNomeResultado = data[0].nomeResultado;
} else {
$scope.defaultNomeResultado = "Final";
}
} else {
$scope.resultados = data;
$scope.defaultNomeResultado = null;
}
}

$scope.$broadcast('scroll.refreshComplete');;
}, function (error) {
$scope.$broadcast('scroll.refreshComplete');
});
} else if ($scope.currTab == "details") {
EtapasService.get({ id: $stateParams.id }).then(function (dadosEtapa) {

$scope.etapa = dadosEtapa;
if ($scope.etapa.active == true && loginService.getUser() != null) {
//checar inscricao
EtapasService.getInscricao({ idEtapa: $stateParams.id, idTrekker: loginService.getUserID() }, function (inscricao) {
$scope.inscricao = inscricao;
})

}
$scope.etapaNotComplete = $scope.etapa.data < new Date().getTime();
if (dadosEtapa.id_Local) {
LocationService.get({ id: $scope.etapa.id_Local }).then(function (location) {
$scope.etapa.location = location;
if (location.latitude != null) {
var lat = parseFloat(location.latitude) / 1000000;
var lng = parseFloat(location.latitude) / 1000000;

WeatherService.getPerCoords(lat, lng, dadosEtapa.data).then(
function (weather) {
$scope.weather = weather;
},
function (err) {

$log.log("erro carregando clima", err);
});
}
});
}

}, function (error) {
$log.log("Não carregou etapa");
$scope.$broadcast('scroll.refreshComplete');
});
}
}
};
$scope.isTab = function (val) {

if ($scope.currTab == val) {
Expand All @@ -567,32 +649,13 @@ angular.module('north.controllers', ['ionic', 'ngCordova', 'ngStorage', 'north.s
return "";
}

EtapasService.get({ id: $stateParams.id }).then(function (dadosEtapa) {

$scope.etapa = dadosEtapa;
$scope.etapaNotComplete = $scope.etapa.data < new Date().getTime();
if (dadosEtapa.id_Local) {
LocationService.get({ id: $scope.etapa.id_Local }).then(function (location) {
$scope.etapa.location = location;
if (location.latitude != null) {
var lat = parseFloat(location.latitude) / 1000000;
var lng = parseFloat(location.latitude) / 1000000;

WeatherService.getPerCoords(lat, lng, dadosEtapa.data).then(
function (weather) {
$scope.weather = weather;

},
function (err) {
$log.log("erro carregando clima", err);
});
}
})
}
$scope.currTab = "details";
if (tab) {
$scope.currTab = tab;
}
$scope.setTab($scope.currTab);

}, function (error) {
$log.log("Não carregou etapa");
});
$scope.inscricao = {};



Expand Down Expand Up @@ -708,7 +771,7 @@ angular.module('north.controllers', ['ionic', 'ngCordova', 'ngStorage', 'north.s
$scope.$broadcast('scroll.refreshComplete');
});
}
console.log("Entrou no etapas");

$scope.loadData();

})
Expand Down
39 changes: 29 additions & 10 deletions www/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,28 @@ angular.module('north.services', ['ionic', 'ngCordova', 'ngStorage', 'ngResource
return etapa.data < cacheEntry.date;//TODO uns 5 dias;
}
return $cachedResource(appConfigs.enhancedRestBackend + "/Etapa/:id", {}, {
getInscricao: {
isArray: false,
cache: true,
method: "GET",
url: appConfigs.enhancedRestBackend + "/InscricaoCompetidor/:idEtapa/:idTrekker",
cr: {
cacheName: function (params) {
return params.id + "_inscricao"
},
timeout: 30 * 60 * 1000,
cacheHalfLife: function (cacheEntry) {
if (cacheEntry.date < (new Date().getTime() - (this.timeout / 1.5))) {
return true;
}
return false;
}
}
},
query: {
isArray: true,
cache: true,
cr: {
cr: {
timeout: 7 * 60 * 60 * 1000,
cacheHalfLife: function (cacheEntry) {
if (cacheEntry.date < (new Date().getTime() - (this.timeout / 1.5))) {
Expand Down Expand Up @@ -250,13 +268,7 @@ angular.module('north.services', ['ionic', 'ngCordova', 'ngStorage', 'ngResource
}
},
{name:"LocSvc"});
// return $resource(appConfigs.openRestBackend + '/Local/:id', {}, {
// query: {
// isArray: true,
// transformResponse: jsonTransformQuery
// }
// });


}])
.service('RankingService', ['$http', '$q', '$resource', 'appConfigs','$cachedResource', function ($http, $q, $resource, appConfigs,$cachedResource) {
return $cachedResource(appConfigs.enhancedRestBackend + '/Ranking', {},
Expand Down Expand Up @@ -496,7 +508,7 @@ angular.module('north.services', ['ionic', 'ngCordova', 'ngStorage', 'ngResource
inverse: false
});

console.error("Realmente empatados " + a.nome + " e " + b.nome, a.col, b.col);
console.warn("Realmente empatados " + a.nome + " e " + b.nome, a.col, b.col);
return 0;
}

Expand Down Expand Up @@ -621,7 +633,14 @@ angular.module('north.services', ['ionic', 'ngCordova', 'ngStorage', 'ngResource

return {
startPwdRecovery: function (email) {
UserService.rememberPwd({}, { email: email });
var deferred = $q.defer();
UserService.rememberPwd({}, { email: email },function(response){
deferred.resolve(response.data);
},
function(error){
deferred.reject(error);
});
return deferred.promise;
},
saveUser: function (user) {
var deferred = $q.defer();
Expand Down
Loading

0 comments on commit ea0bf71

Please sign in to comment.