});
})
+.factory('remoteService',function(){
+ var remoteServer="localhost:8000";
+ var server={};
+
+
+ server.getRemote=function(){return remoteServer;}
+ server.setRemote=function(newRemote){
+ remoteServer=newRemote;
+ }
-.factory('AuthenticationService', function($rootScope, $http, authService) {
+ return server;
+})
+
+.factory('AuthenticationService', function($rootScope, $http, authService,remoteService) {
var service = {
login: function(user) {
- $http.post('http://localhost:8000/auth/login',"username="+encodeURI(user.username)+"&password="+encodeURI(user.password),{headers:{'Content-Type':'application/x-www-form-urlencoded'}})
+ $http.post('https://'+remoteService.getRemote()+'/auth/login',"username="+encodeURI(user.username)+"&password="+encodeURI(user.password),{headers:{'Content-Type':'application/x-www-form-urlencoded'}})
//$http.post('http://localhost:8000/auth/login',user)
.success(function (data, status, headers, config) {
// $http.defaults.headers.common.Cookie = data.Set-Cookie; // Step 1
-
+ console.log('http://'+remoteService.getRemote()+'/auth/login',"username="+encodeURI(user.username)+"&password="+encodeURI(user.password));
// Need to inform the http-auth-interceptor that
// the user has logged in successfully. To do this, we pass in a function that
// will configure the request headers with the authorization token so
});
})
-.controller('TemplateSyncCtrl', function($scope, $http, $state ,AuthenticationService) {
+.controller('TemplateSyncCtrl', function($scope, $http, $state ,remoteService,AuthenticationService) {
//The full template list, loaded at start-up from the BD and updated by the
//server.
//When closing the app, the localDB is updated by this list, ensuring
};
//API call to get alive template list
- $scope.fetchTemplateList=function(server,full){
+ $scope.fetchTemplateList=function(full){
//Get list of full template from server
if(full){
- $http.get("http://"+server+"/template/?alive=true&json=true",{withCredentials :"true"}).then(function(resp) {
+ $http.get("https://"+remoteService.getRemote()+"/template/?alive=true&json=true",{withCredentials :"true"}).then(function(resp) {
console.log('Success', resp);
$scope.fetchedFullTemplateList=resp.data;
});
}
//Get list of template from server
else{
- $http.get("http://"+server+"/template/?alive=true",{withCredentials :"true"}).then(function(resp) {
+ $http.get("http://"+remoteService.getRemote()+"/template/?alive=true",{withCredentials :"true"}).then(function(resp) {
console.log('Success', resp);
$scope.fetchedTemplateList=resp.data;
});
};
//API : Fetch a specific template
- $scope.fetchTemplate=function(server,templateID){
- $http.get("http://"+server+"/template/"+templateID,{withCredentials :"true"}).then(function(resp) {
+ $scope.fetchTemplate=function(templateID){
+ $http.get("http://"+remoteService.getRemote()+"/template/"+templateID,{withCredentials :"true"}).then(function(resp) {
console.log('Success', resp);
$scope.fetchedTemplateJSON=resp.data;
}
})
-.controller('LoginCtrl', function($scope, $http, $state ,AuthenticationService,$ionicSideMenuDelegate) {
+.controller('LoginCtrl', function($scope, $http, $state ,AuthenticationService,remoteService,$ionicSideMenuDelegate) {
$scope.message = "";
$scope.user = {
username: null,
- password: null
+ password: null,
+ server: null
};
-
+
$ionicSideMenuDelegate.canDragContent(false);
$scope.login = function() {
+ remoteService.setRemote($scope.user.server);
AuthenticationService.login($scope.user);
};
})
-.controller('DossierSyncCtrl', function($scope, $http, $state ,AuthenticationService) {
+.controller('DossierSyncCtrl', function($scope, $http, $state ,remoteService,authenticationService) {
- $scope.getFile=function(server,dossierID){
- $http.get("http://"+server+"/"+dossierID).then(function(resp) {
+ $scope.getFile=function(dossierID){
+ $http.get("http://"+remoteService.getRemote()+"/"+dossierID).then(function(resp) {
console.log('Success', resp);
// For JSON responses, resp.data contains the result
}, function(err) {
}
};
- $scope.sendFile=function(server){
+ $scope.sendFile=function(templateID){
if ($scope.checkCompleteness($scope.currentTemplate).bool) {
- $http.post(server,$scope,currentTemplate).then(function(resp) {
+ $http.post("http://"+remoteService.getRemote()+"/"+templateID,$scope.currentTemplate).then(function(resp) {
console.log('Success', resp);
// For JSON responses, resp.data contains the result
}, function(err) {