Browse Source

notification system almost implemented at the app

master
arnaucode 8 years ago
parent
commit
53ccc9c17f
10 changed files with 79 additions and 22 deletions
  1. BIN
      www/img/comment.png
  2. BIN
      www/img/fav.png
  3. BIN
      www/img/join.png
  4. BIN
      www/img/notification.png
  5. +9
    -1
      www/js/app.js
  6. +49
    -20
      www/js/controllers.js
  7. +1
    -0
      www/js/translations.js
  8. +5
    -0
      www/templates/menu.html
  9. +14
    -0
      www/templates/notifications.html
  10. +1
    -1
      www/templates/settings.html

BIN
www/img/comment.png

Before After
Width: 32  |  Height: 32  |  Size: 754 B

BIN
www/img/fav.png

Before After
Width: 32  |  Height: 32  |  Size: 722 B

BIN
www/img/join.png

Before After
Width: 32  |  Height: 32  |  Size: 291 B

BIN
www/img/notification.png

Before After
Width: 32  |  Height: 32  |  Size: 797 B

+ 9
- 1
www/js/app.js

@ -52,7 +52,15 @@ angular.module('starter', ['ionic',
}
}
})
.state('app.notifications', {
url: '/notifications/:username',
views: {
'menuContent': {
templateUrl: 'templates/notifications.html',
controller: 'NotificationsCtrl'
}
}
})
.state('app.users', {
url: '/users',
views: {

+ 49
- 20
www/js/controllers.js

@ -23,6 +23,8 @@ angular.module('starter.controllers', ['pascalprecht.translate'])
$scope.storageusername=localStorage.getItem("c_username");
$scope.storageavatar=localStorage.getItem("c_avatar");
$scope.userdata=JSON.parse(localStorage.getItem('c_userdata'));
console.log($scope.userdata);
// Create the login modal that we will use later
$ionicModal.fromTemplateUrl('templates/login.html', {
scope: $scope
@ -189,7 +191,7 @@ angular.module('starter.controllers', ['pascalprecht.translate'])
})
.controller('TravelsCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading) {
.controller('TravelsCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) {
if(localStorage.getItem('c_token')){// adding token to the headers
//console.log("token added to headers in run module");
//console.log($http.defaults);
@ -204,13 +206,14 @@ angular.module('starter.controllers', ['pascalprecht.translate'])
$scope.travels="";
$scope.travels=JSON.parse(localStorage.getItem('c_travels'));
$scope.userdata=JSON.parse(localStorage.getItem('c_userdata'));
//$scope.storageusername=JSON.parse(localStorage.getItem('c_username'));
console.log($scope.userdata);
$scope.doRefresh = function() {
/* travels refresh: */
$http.get(urlapi + 'travels')
.success(function(data, status, headers,config){
console.log('data success');
console.log('data success travels');
console.log(data); // for browser console
$scope.travels = data; // for UI
localStorage.setItem('c_travels', JSON.stringify($scope.travels));
@ -232,11 +235,17 @@ angular.module('starter.controllers', ['pascalprecht.translate'])
/* users refresh: */
$http.get(urlapi + 'users')
.success(function(data, status, headers, config){
console.log('data success');
console.log('data success users');
console.log(data); // for browser console
$scope.users = data; // for UI
localStorage.setItem('c_users', JSON.stringify($scope.users));
$scope.$broadcast('scroll.refreshComplete');//refresher stop
//set userdata
$scope.userdata = $filter('filter')($scope.users, {username: $scope.storageusername}, true)[0];
console.log("userdata");
console.log($scope.userdata);
localStorage.setItem("c_userdata", JSON.stringify($scope.userdata));
})
.error(function(data, status, headers,config){
console.log('data error');
@ -307,9 +316,9 @@ angular.module('starter.controllers', ['pascalprecht.translate'])
console.log('Doing new travel', $scope.newtravel);
$scope.newtravel.icon="lorry";
$scope.newtravel.generateddate=$scope.newtravel.date;
$scope.newtravel.owner=localStorage.getItem("c_username");
/*$scope.newtravel.owner=localStorage.getItem("c_username");
$scope.newtravel.telegram=JSON.parse(localStorage.getItem("c_userdata")).telegram;
$scope.newtravel.phone=JSON.parse(localStorage.getItem("c_userdata")).phone;
$scope.newtravel.phone=JSON.parse(localStorage.getItem("c_userdata")).phone;*/
$scope.newtravel.modality="offering";
//$scope.newtravel.token=localStorage.getItem("c_token");
console.log($scope.newtravel);
@ -349,9 +358,9 @@ angular.module('starter.controllers', ['pascalprecht.translate'])
console.log('Doing new travel', $scope.newtravel);
$scope.newtravel.icon="lorry";
$scope.newtravel.generateddate=$scope.newtravel.date;
$scope.newtravel.owner=localStorage.getItem("c_username");
/*$scope.newtravel.owner=localStorage.getItem("c_username");
$scope.newtravel.telegram=JSON.parse(localStorage.getItem("c_userdata")).telegram;
$scope.newtravel.phone=JSON.parse(localStorage.getItem("c_userdata")).phone;
$scope.newtravel.phone=JSON.parse(localStorage.getItem("c_userdata")).phone;*/
$scope.newtravel.modality="asking";
console.log($scope.newtravel);
@ -391,9 +400,9 @@ angular.module('starter.controllers', ['pascalprecht.translate'])
console.log('Doing new package', $scope.newtravel);
$scope.newtravel.icon="lorry";
$scope.newtravel.generateddate=$scope.newtravel.date;
$scope.newtravel.owner=localStorage.getItem("c_username");
/*$scope.newtravel.owner=localStorage.getItem("c_username");
$scope.newtravel.telegram=JSON.parse(localStorage.getItem("c_userdata")).telegram;
$scope.newtravel.phone=JSON.parse(localStorage.getItem("c_userdata")).phone;
$scope.newtravel.phone=JSON.parse(localStorage.getItem("c_userdata")).phone;*/
$scope.newtravel.package=true;
@ -487,9 +496,9 @@ angular.module('starter.controllers', ['pascalprecht.translate'])
$scope.joinTravel = function(){
$scope.newjoin={
//travelId: $stateParams.travelId,
joinedUserId: localStorage.getItem("c_userid"),
/*joinedUserId: localStorage.getItem("c_userid"),
joinedUsername: localStorage.getItem("c_username"),
joinedAvatar: localStorage.getItem("c_avatar")
joinedAvatar: localStorage.getItem("c_avatar")*/
};
$http({
url: urlapi + 'travels/'+ $stateParams.travelId+'/join',
@ -515,9 +524,9 @@ angular.module('starter.controllers', ['pascalprecht.translate'])
console.log("unjoin");
$scope.unjoin={
travelId: $stateParams.travelId,
joinedUserId: localStorage.getItem("c_userid"),
/*joinedUserId: localStorage.getItem("c_userid"),
joinedUsername: localStorage.getItem("c_username"),
joinedAvatar: localStorage.getItem("c_avatar")
joinedAvatar: localStorage.getItem("c_avatar")*/
};
$http({
url: urlapi + 'travels/'+ $stateParams.travelId+'/unjoin',
@ -551,9 +560,9 @@ angular.module('starter.controllers', ['pascalprecht.translate'])
$scope.doingNewComment=false;
};
$scope.doNewComment = function() {
$scope.newComment.commentUserId=localStorage.getItem("c_userid");
/*$scope.newComment.commentUserId=localStorage.getItem("c_userid");
$scope.newComment.commentUsername=localStorage.getItem("c_username");
$scope.newComment.commentAvatar=localStorage.getItem("c_avatar");
$scope.newComment.commentAvatar=localStorage.getItem("c_avatar");*/
console.log($scope.newComment);
$http({
url: urlapi + 'travels/'+ $stateParams.travelId+'/comment',
@ -600,7 +609,7 @@ console.log($scope.newComment);
};
})
.controller('UsersCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading) {
.controller('UsersCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) {
$scope.users="";
$scope.users=JSON.parse(localStorage.getItem('c_users'));
@ -636,6 +645,12 @@ console.log($scope.newComment);
$scope.users = data; // for UI
localStorage.setItem('c_users', JSON.stringify($scope.users));
$scope.$broadcast('scroll.refreshComplete');//refresher stop
//set userdata
$scope.userdata = $filter('filter')($scope.users, {username: $scope.storageusername}, true)[0];
console.log("userdata");
console.log($scope.userdata);
localStorage.setItem("c_userdata", JSON.stringify($scope.userdata));
})
.error(function(data, status, headers,config){
console.log('data error');
@ -687,9 +702,9 @@ console.log($scope.newComment);
$scope.favUser = function(){
$scope.newfav={
//travelId: $stateParams.travelId,
userId: localStorage.getItem("c_userid"),
/*userId: localStorage.getItem("c_userid"),
username: localStorage.getItem("c_username"),
avatar: localStorage.getItem("c_avatar")
avatar: localStorage.getItem("c_avatar")*/
};
$scope.user.favs.push($scope.newfav);//al unfav no cal fer aquest simulacre pq ja no existeix a l'array i no el resta dos cops en cas de que cliquin dos cops
$http({
@ -715,9 +730,9 @@ console.log($scope.newComment);
$scope.unfavUser = function(){
console.log("unfav");
$scope.unfav={
userId: localStorage.getItem("c_userid"),
/*userId: localStorage.getItem("c_userid"),
username: localStorage.getItem("c_username"),
avatar: localStorage.getItem("c_avatar")
avatar: localStorage.getItem("c_avatar")*/
};
$http({
//url: urlapi + 'users/'+ $stateParams.username+'/fav',
@ -766,6 +781,20 @@ console.log($scope.newComment);
return -1;
};
})
.controller('NotificationsCtrl', function($scope, $stateParams, $translate, $filter) {
if(localStorage.getItem('c_token')){// adding token to the headers
// $http.defaults.headers.common['X-Access-Token'] = localStorage.getItem('c_token');
}
$scope.storageusername=localStorage.getItem("c_username");
$scope.users= JSON.parse(localStorage.getItem('c_users'));
$scope.user = $filter('filter')($scope.users, {username: $stateParams.username}, true)[0];
$scope.notifications=$scope.user.notifications;
console.log($stateParams.username);
console.log($scope.notifications);
console.log("notifications page");
})
.controller('SettingsCtrl', function($scope, $stateParams, $translate) {
if(localStorage.getItem('lang'))//initialization
{

+ 1
- 0
www/js/translations.js

@ -6,6 +6,7 @@ var translations = {
"Login": "Login",
"Travels": "Travels",
"Users": "Users",
"Notifications": "Notifications",
"Logout": "Logout",
"Settings": "Settings",
"Help": "Help",

+ 5
- 0
www/templates/menu.html

@ -32,6 +32,11 @@
<img class='o-imgMenu' src="img/users.png" />
{{'Users' | translate }}
</ion-item>
<ion-item menu-close href="#/app/notifications/{{storageusername}}" ng-show="storageusername">
<img class='o-imgMenu' src="img/notification.png" />
{{'Notifications' | translate }}
<span class="badge badge-positive">{{userdata.notifications.length}}</span>
</ion-item>
<ion-item menu-close href="#/app/users/{{storageusername}}" ng-show="storageusername">
<img class='o-imgMenu' ng-src="img/avatars/{{storageavatar}}.png" />
{{storageusername}}

+ 14
- 0
www/templates/notifications.html

@ -0,0 +1,14 @@
<ion-view view-title="{{'Notifications' | translate}} {{user.username}}">
<ion-content>
<div class="item item-body">
<a ng-repeat="notification in notifications | orderBy: '-date'" class="item item-avatar" href="#/app/{{notification.link}}">
<img ng-src="img/{{notification.type}}.png"/>
<h2>{{notification.description}}</h2>
<div class="item-note text-right">
<div class="positive">{{notification.date | date:"dd/MM"}}</div>
<div class="positive">{{notification.date | date:"HH:mm:ss"}}</div>
</div>
</a>
</div>
</ion-content>
</ion-view>

+ 1
- 1
www/templates/settings.html

@ -10,7 +10,7 @@
</select>
</label>
<p>
version: CarsInCommon-v011
version: CarsInCommon-v012
</p>
</ion-content>
</ion-view>

Loading…
Cancel
Save