Skip to content

Commit

Permalink
Merge pull request #18 from openpearl/develop
Browse files Browse the repository at this point in the history
v1.1
  • Loading branch information
hdavidzhu committed Jul 25, 2015
2 parents dcccea7 + 935d9e4 commit d3246f9
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 21 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"ionic": "~1.0.0",
"ng-token-auth": "~0.0.25",
"angular-cookie": "~4.0.8",
"angular-toArrayFilter": "~1.0.1"
"angular-toArrayFilter": "~1.0.1",
"angular-cookies": "1.3.13"
}
}
1 change: 1 addition & 0 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
<splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640"/>
<splash height="480" src="resources/ios/splash/Default~iphone.png" width="320"/>
</platform>
<plugin name="cordova-plugin-whitelist" spec="^1.0.0"/>
</widget>
Empty file added www/app/app.config.js
Empty file.
6 changes: 5 additions & 1 deletion www/app/app.r.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ module.exports = function(app) {
app.config(appRoutes);
};

function appRoutes($stateProvider, $urlRouterProvider) {
function appRoutes($httpProvider, $stateProvider, $urlRouterProvider) {

$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers
.common['X-Requested-With'];

$stateProvider

Expand Down
1 change: 1 addition & 0 deletions www/app/app.run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = function(app) {
};

function appRun($ionicPlatform, $cordovaStatusbar) {

$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory
// bar above the keyboard for form inputs)
Expand Down
8 changes: 4 additions & 4 deletions www/app/components/chat/chat.d.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ function ChatCtrl($scope, $rootScope, $ionicPlatform, $ionicSlideBoxDelegate, Us
vm.doRefresh();
});

// FIXME: Resume not functional and causing 10 digest runs.
$ionicPlatform.on('resume', function() {
vm.doRefresh();
});

$rootScope.$on('refresh', function() {
$rootScope.$on('pearl:refresh', function() {
vm.doRefresh();
});

Expand All @@ -69,16 +70,15 @@ function ChatCtrl($scope, $rootScope, $ionicPlatform, $ionicSlideBoxDelegate, Us

// TODO: This seems like a pretty bad way of doing things.
// Refactor if possible.
ChatServ.chatMessages = [];
ChatServ.clearAll();

UserContextServ.httpGetRequiredContext().then(
function(data, status, headers, config) {
$scope.$broadcast('scroll.refreshComplete');
LoginRegisterServ.isLoggedIn = true;
$ionicSlideBoxDelegate.update();
console.log("Logged in.");
console.log("doRefresh: httpGetRequiredContext.");
console.log(data);

// If logged in...
UserContextServ.httpSendUserContext();
}, function() {
Expand Down
6 changes: 6 additions & 0 deletions www/app/components/chat/chat.s.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function ChatServ($http, $rootScope, ApiEndpoint) {
chatServ.addChatMessage = addChatMessage;
chatServ.inputOptionToMessages = inputOptionToMessages;
chatServ.clearInputOptions = clearInputOptions;
chatServ.clearAll = clearAll;

// METHODS ******************************************************************

Expand Down Expand Up @@ -106,6 +107,11 @@ function ChatServ($http, $rootScope, ApiEndpoint) {
console.log("inputOptions are cleared.");
}

function clearAll() {
chatServ.chatMessages = [];
chatServ.inputOptions = {};
}

// HELPERS ******************************************************************

return chatServ;
Expand Down
2 changes: 1 addition & 1 deletion www/app/components/chat/inputSpace/inputSpace.t.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div id="prl-input-space">
<div class="input-bubble-wrapper"
ng-repeat="(cardID, inputOption) in inputSpaceCtrl.ChatServ.inputOptions">
ng-repeat="(cardID, inputOption) in inputSpaceCtrl.ChatServ.inputOptions track by cardID">
<div class="chat-bubble-wrapper"
ng-switch="inputOption.cardType || 'cat'">

Expand Down
10 changes: 8 additions & 2 deletions www/app/components/chat/loginRegister.s.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function LoginRegisterServ($http, $auth, $rootScope, ApiEndpoint,
.then(function(resp) {
console.log("Logged in.");
console.log(resp);
$rootScope.$emit('refresh');
$rootScope.$emit('pearl:refresh');
})
.catch(function(resp) {
console.log("Failed logging in.");
Expand Down Expand Up @@ -152,7 +152,13 @@ function LoginRegisterServ($http, $auth, $rootScope, ApiEndpoint,
}).
error(function(data, status, headers, config) {
console.error("Error sending login-signup.");
console.log(registerData);

console.log("dbg: data, status, headers, config");
console.log(data);
console.log(status);
console.log(headers);
console.log(config);
console.log("dbg: end");
});
}

Expand Down
2 changes: 1 addition & 1 deletion www/app/components/chat/messages/messages.t.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div
class="chat-bubble-wrapper"
ng-repeat="chatMessage in messagesCtrl.CS.chatMessages track by $index">
ng-repeat="chatMessage in messagesCtrl.CS.chatMessages track by chatMessage.cardID">

<!-- TODO: This should not be hardcoded in the future. -->
<div class="chat-bubble"
Expand Down
8 changes: 4 additions & 4 deletions www/app/components/settings/settings.c.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ function SettingsCtrl($state, $ionicPlatform, UserServ, GoalsServ) {

// vm.httpGetGoals = GoalsServ.httpGetGoals;

$ionicPlatform.on('resume', function() {
console.log("Resuming.");
GoalsServ.httpGetGoals();
});
// $ionicPlatform.on('resume', function() {
// console.log("Resuming.");
// GoalsServ.httpGetGoals();
// });

function refresh() {
GoalsServ.httpGetGoals();
Expand Down
8 changes: 4 additions & 4 deletions www/app/components/settings/settings.d.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ function SettingsCtrl($http, $state, $window, $ionicPlatform, ApiEndpoint, UserS

// vm.httpGetGoals = GoalsServ.httpGetGoals;

$ionicPlatform.on('resume', function() {
console.log("Resuming.");
GoalsServ.httpGetGoals();
});
// $ionicPlatform.on('resume', function() {
// console.log("Resuming.");
// GoalsServ.httpGetGoals();
// });

function refresh() {
GoalsServ.httpGetGoals();
Expand Down
5 changes: 3 additions & 2 deletions www/app/core/apiEndpoint.const.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = function(app) {
app.constant('ApiEndpoint', {
// TODO: Toggle between proxies using gulp.
url: 'http://172.16.42.7:8100/api'
// url: 'https://1b68c6c2.ngrok.com'
// url: 'http://172.16.42.7:8100/api'
// url: 'https://openpearl.herokuapp.com'
url: 'https://openpearl.herokuapp.com'
});
};
3 changes: 2 additions & 1 deletion www/app/core/auth.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = function(app) {

function AuthConfiguration($authProvider, ApiEndpoint) {
$authProvider.configure({
apiUrl: ApiEndpoint.url
apiUrl: ApiEndpoint.url,
storage: 'localStorage'
});
}
3 changes: 3 additions & 0 deletions www/app/core/core.m.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
// require('../../assets/js/browserSettings.js');

var appCore = angular.module('app.core', [
'ngCookies',
'ionic',
// 'ngAnimate',
'ngCordova',
'ng-token-auth',

'angular-toArrayFilter'
]);

require('./csrf.p.js')(appCore);
require('./apiEndpoint.const.js')(appCore);
require('./auth.config.js')(appCore);

Expand Down
68 changes: 68 additions & 0 deletions www/app/core/csrf.p.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
module.exports = function(app) {

app

.provider('prlCSRF',[function(){
var headerName = 'X-CSRFToken';
var cookieName = 'csrftoken';
var allowedMethods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];

this.setHeaderName = function(n) {
headerName = n;
};

this.setCookieName = function(n) {
cookieName = n;
};

this.setAllowedMethods = function(n) {
allowedMethods = n;
};

this.$get = ['$cookies', function($cookies){

// console.log("dbg: csrf cookies");
// console.log($cookies);

return {
'request': function(config) {
if(allowedMethods.indexOf(config.method) === -1) {
// do something on success
config.headers[headerName] = $cookies[cookieName];
}
return config;
}
};
}];

}])

// .factory('CookieServ', ['$cookies', function($cookies) {
// var cookieServ = {
// request: function(config) {
// return config;
// },

// response: function(response) {
// console.log("response");
// console.log(response);

// console.log("cookies");
// console.log($cookies);

// return response;
// }
// };

// return cookieServ;
// }])

.config(function($httpProvider) {
// CORS and CSRF.
delete $httpProvider.defaults.headers.common['X-Requested-With'];
$httpProvider.defaults.withCredentials = true;
// $httpProvider.interceptors.push('prlCSRF');
// $httpProvider.interceptors.push('CookieServ');
});

};
4 changes: 4 additions & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
<html>
<head>

<!-- <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"> -->

<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">

<title></title>

<link href="assets/lib/ionic/css/ionic.min.css" rel="stylesheet">
Expand All @@ -13,6 +16,7 @@
<script src="assets/lib/ionic/js/ionic.bundle.js"></script>
<!-- <script src="assets/lib/angular-animate/angular-animate.min.js"></script> -->
<script src="assets/lib/angular-cookie/angular-cookie.js"></script>
<script src="assets/lib/angular-cookies/angular-cookies.min.js"></script>
<script src="assets/lib/ng-token-auth/dist/ng-token-auth.js"></script>
<script src="assets/lib/angular-toArrayFilter/toArrayFilter.js"></script>
<script src="assets/lib/ngCordova/dist/ng-cordova.js"></script>
Expand Down

0 comments on commit d3246f9

Please sign in to comment.