mirror of
https://github.com/arnaucube/commonroutesApp.git
synced 2026-02-07 03:26:44 +01:00
notification system fixed
This commit is contained in:
@@ -478,6 +478,11 @@
|
|||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.ctext_blueGrey500{
|
||||||
|
color: #607D8B!important;
|
||||||
|
}
|
||||||
|
|
||||||
.c_blueGradient1{
|
.c_blueGradient1{
|
||||||
background: #2d4a56;
|
background: #2d4a56;
|
||||||
background: -moz-linear-gradient(left, #2d4a56 0%, #1c2b36 100%);
|
background: -moz-linear-gradient(left, #2d4a56 0%, #1c2b36 100%);
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
// 'starter.controllers' is found in controllers.js
|
// 'starter.controllers' is found in controllers.js
|
||||||
|
|
||||||
|
|
||||||
//var urlapi = "http://localhost:3000/api/";
|
var urlapi = "http://localhost:3000/api/";
|
||||||
var urlapi = "http://192.168.1.36:3000/api/";
|
//var urlapi = "http://192.168.1.36:3000/api/";
|
||||||
//var urlapi = "http://51.255.193.106:3000/api/";
|
//var urlapi = "http://51.255.193.106:3000/api/";
|
||||||
|
|
||||||
angular.module('starter', [
|
angular.module('starter', [
|
||||||
@@ -24,7 +24,7 @@ angular.module('starter', [
|
|||||||
'app.travel',
|
'app.travel',
|
||||||
'app.newTravel',
|
'app.newTravel',
|
||||||
'app.offerCar',
|
'app.offerCar',
|
||||||
/* 'app.askCar',
|
/* 'app.askCar',
|
||||||
'app.askPackage',*/
|
'app.askPackage',*/
|
||||||
'app.users',
|
'app.users',
|
||||||
'app.user',
|
'app.user',
|
||||||
@@ -56,12 +56,14 @@ angular.module('starter', [
|
|||||||
$stateProvider
|
$stateProvider
|
||||||
|
|
||||||
.state('app', {
|
.state('app', {
|
||||||
|
cache: false,
|
||||||
url: '/app',
|
url: '/app',
|
||||||
abstract: true,
|
abstract: true,
|
||||||
templateUrl: 'templates/menu.html',
|
templateUrl: 'templates/menu.html',
|
||||||
controller: 'MenuCtrl'
|
controller: 'MenuCtrl'
|
||||||
})
|
})
|
||||||
.state('app.main', {
|
.state('app.main', {
|
||||||
|
cache: false,
|
||||||
url: '/main',
|
url: '/main',
|
||||||
views: {
|
views: {
|
||||||
'menuContent': {
|
'menuContent': {
|
||||||
@@ -245,28 +247,28 @@ angular.module('starter', [
|
|||||||
}])
|
}])
|
||||||
.factory('httpInterceptor', function httpInterceptor($q, $window, $location) {
|
.factory('httpInterceptor', function httpInterceptor($q, $window, $location) {
|
||||||
return {
|
return {
|
||||||
request: function (config) {
|
request: function(config) {
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
requestError: function (config) {
|
requestError: function(config) {
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
response: function (res) {
|
response: function(res) {
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
responseError: function (res) {
|
responseError: function(res) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.factory('api', function ($http) {
|
.factory('api', function($http) {
|
||||||
return {
|
return {
|
||||||
init: function () {
|
init: function() {
|
||||||
$http.defaults.headers.common['X-Access-Token'] = localStorage.getItem("cim_app_token");
|
$http.defaults.headers.common['X-Access-Token'] = localStorage.getItem("cim_app_token");
|
||||||
$http.defaults.headers.post['X-Access-Token'] = localStorage.getItem("cim_app_token");
|
$http.defaults.headers.post['X-Access-Token'] = localStorage.getItem("cim_app_token");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.run(function (api) {
|
.run(function(api) {
|
||||||
api.init();
|
api.init();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,23 @@
|
|||||||
angular.module('app.main', ['pascalprecht.translate'])
|
angular.module('app.main', ['pascalprecht.translate'])
|
||||||
|
|
||||||
.controller('MainCtrl', function($scope, $stateParams, $translate, $filter) {
|
.controller('MainCtrl', function($scope, $stateParams, $translate, $filter,
|
||||||
|
$ionicLoading, $http) {
|
||||||
});
|
if (localStorage.getItem("cim_app_userdata")) {
|
||||||
|
$scope.storageuser = JSON.parse(localStorage.getItem("cim_app_userdata"));
|
||||||
|
console.log($scope.storageuser);
|
||||||
|
}
|
||||||
|
//get the num of pendent notifications each time
|
||||||
|
$http.get(urlapi + 'numnotifications')
|
||||||
|
.then(function(data) {
|
||||||
|
$scope.storageuser.notifications = data.data;
|
||||||
|
console.log(data.data);
|
||||||
|
localStorage.setItem("cim_app_storageuser", JSON.stringify($scope.storageuser));
|
||||||
|
}, function(data) {
|
||||||
|
console.log('data error');
|
||||||
|
$ionicLoading.show({
|
||||||
|
template: 'Error connecting server',
|
||||||
|
noBackdrop: true,
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ angular.module('app.menu', ['pascalprecht.translate'])
|
|||||||
$scope.logout = function() {
|
$scope.logout = function() {
|
||||||
localStorage.removeItem("cim_app_token");
|
localStorage.removeItem("cim_app_token");
|
||||||
localStorage.removeItem("cim_app_userdata");
|
localStorage.removeItem("cim_app_userdata");
|
||||||
|
localStorage.removeItem("cim_app_storageuser");
|
||||||
|
localStorage.removeItem("cim_app_notifications");
|
||||||
$window.location.reload(true);
|
$window.location.reload(true);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,25 +1,52 @@
|
|||||||
angular.module('app.notifications', ['pascalprecht.translate'])
|
angular.module('app.notifications', ['pascalprecht.translate'])
|
||||||
|
|
||||||
.controller('NotificationsCtrl', function($scope, $http, $ionicLoading,
|
.controller('NotificationsCtrl', function($scope, $http, $ionicLoading,
|
||||||
$stateParams, $translate, $filter) {
|
$stateParams, $translate, $filter) {
|
||||||
$scope.notifications=[];
|
$scope.notifications = [];
|
||||||
$scope.doRefresh = function(){
|
$scope.doRefresh = function() {
|
||||||
|
//first, if already have notifications, set to viewed
|
||||||
|
if(localStorage.getItem("cim_app_notifications")!=undefined){
|
||||||
|
//console.log(localStorage.getItem("cim_app_notifications"));
|
||||||
|
$scope.notifications = JSON.parse(localStorage.getItem("cim_app_notifications"));
|
||||||
|
for(var i=0; i<$scope.notifications.length; i++){
|
||||||
|
$scope.notifications[i].state = "viewed";
|
||||||
|
}
|
||||||
|
localStorage.setItem("cim_app_notifications", JSON.stringify($scope.notifications));
|
||||||
|
}
|
||||||
$http.get(urlapi + 'notifications')
|
$http.get(urlapi + 'notifications')
|
||||||
.then(function(data){
|
.then(function(data) {
|
||||||
console.log(data); // for browser console
|
//console.log(data); // for browser console
|
||||||
$scope.storageuser = JSON.parse(localStorage.getItem("cim_app_userdata"));
|
/*$scope.storageuser = JSON.parse(localStorage.getItem("cim_app_userdata"));
|
||||||
$scope.storageuser.notifications = data.data;
|
$scope.storageuser.notifications = [];
|
||||||
localStorage.setItem("cim_app_userdata", JSON.stringify($scope.storageuser));
|
console.log($scope.storageuser.notifications.length);
|
||||||
|
localStorage.setItem("cim_app_userdata", JSON.stringify($scope.storageuser));*/
|
||||||
|
|
||||||
$scope.notifications = data.data; // for UI
|
//get the storage notifications
|
||||||
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
if (localStorage.getItem("cim_app_notifications")) {
|
||||||
|
$scope.notifications = JSON.parse(localStorage.getItem("cim_app_notifications"));
|
||||||
|
$scope.notifications = $scope.notifications.concat(data.data); // for UI
|
||||||
|
} else {
|
||||||
|
$scope.notifications = data.data;
|
||||||
|
}
|
||||||
|
//store the notifications
|
||||||
|
localStorage.setItem("cim_app_notifications", JSON.stringify($scope.notifications));
|
||||||
|
|
||||||
}, function(data){
|
//now clean the notification number that is showed in the menu and main page, from the storageuser.notifications
|
||||||
|
/*$scope.storageuser = JSON.parse(localStorage.getItem("cim_app_userdata"));
|
||||||
|
$scope.storageuser.pendentnotifications = [];
|
||||||
|
localStorage.setItem("cim_app_userdata", JSON.stringify($scope.storageuser));*/
|
||||||
|
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
|
||||||
|
|
||||||
|
}, function(data) {
|
||||||
console.log('data error');
|
console.log('data error');
|
||||||
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
|
||||||
$ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 });
|
$ionicLoading.show({
|
||||||
|
template: 'Error connecting server',
|
||||||
|
noBackdrop: true,
|
||||||
|
duration: 2000
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
$scope.doRefresh();
|
$scope.doRefresh();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -47,11 +47,11 @@
|
|||||||
<a class="item item-icon-left o_bSidenav" menu-close ng-href="#/app/users">
|
<a class="item item-icon-left o_bSidenav" menu-close ng-href="#/app/users">
|
||||||
<i class="icon ion-person-stalker"></i> {{'Users' | translate }}
|
<i class="icon ion-person-stalker"></i> {{'Users' | translate }}
|
||||||
</a>
|
</a>
|
||||||
<a class="item item-icon-left o_bSidenav" menu-close ng-href="#/app/notifications">
|
<!--<a class="item item-icon-left o_bSidenav" menu-close ng-href="#/app/notifications">
|
||||||
<i class="icon ion-android-notifications-none"></i>
|
<i class="icon ion-android-notifications-none"></i>
|
||||||
{{'Notifications' | translate }}
|
{{'Notifications' | translate }}
|
||||||
<span class="badge o_purple300">{{storageuser.notifications.length}}</span>
|
<span class="badge o_purple300">{{storageuser.notifications.length}}</span>
|
||||||
</a>
|
</a>-->
|
||||||
<a class="item item-icon-left o_bSidenav" menu-close ng-href="#/app/settings">
|
<a class="item item-icon-left o_bSidenav" menu-close ng-href="#/app/settings">
|
||||||
<i class="icon ion-settings"></i> {{'Settings' | translate }}
|
<i class="icon ion-settings"></i> {{'Settings' | translate }}
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
<i class="icon ion-android-car"></i>
|
<i class="icon ion-android-car"></i>
|
||||||
{{'Offer_Car' | translate}}
|
{{'Offer_Car' | translate}}
|
||||||
</a>
|
</a>
|
||||||
<a href="#/app/askCar" class="item item-icon-left o_purple400">
|
<a href="" class="item item-icon-left o_purple400">
|
||||||
<i class="icon ion-help"></i>
|
<i class="icon ion-help"></i>
|
||||||
{{'Ask_for_Car' | translate}} (not yet)
|
{{'Ask_for_Car' | translate}} (not yet)
|
||||||
</a>
|
</a>
|
||||||
<a href="#/app/askPackage" class="item item-icon-left o_purple300">
|
<a href="" class="item item-icon-left o_purple300">
|
||||||
<i class="icon ion-ios-box"></i>
|
<i class="icon ion-ios-box"></i>
|
||||||
{{'Ask_for_Package' | translate}} (not yet)
|
{{'Ask_for_Package' | translate}} (not yet)
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -1,12 +1,22 @@
|
|||||||
<ion-view view-title="{{'Notifications' | translate}}">
|
<ion-view view-title="{{'Notifications' | translate}}">
|
||||||
<ion-content class="has-footer">
|
<ion-content class="has-footer">
|
||||||
<ion-refresher
|
<ion-refresher pulling-text="{{'Pull_to_refresh' | translate}}..." on-refresh="doRefresh()">
|
||||||
pulling-text="{{'Pull_to_refresh' | translate}}..."
|
|
||||||
on-refresh="doRefresh()">
|
|
||||||
</ion-refresher>
|
</ion-refresher>
|
||||||
<a ng-repeat="notification in notifications | orderBy: '-date'"
|
<div ng-show="!notifications[0]" class="item">
|
||||||
|
No notifications yet
|
||||||
|
</div>
|
||||||
|
<a ng-repeat="notification in notifications | orderBy: '-date'" ng-show="notification.state=='pendent'"
|
||||||
|
class="item item-icon-left c_deepPurple100" href="#/app/{{notification.link}}">
|
||||||
|
<i ng-show="notification.state=='pendent'" class="icon ion-android-notifications-none o_text_purple600"></i>
|
||||||
|
<h2>{{notification.message}}</h2>
|
||||||
|
<div class="item-note text-right">
|
||||||
|
<div class="o_text_purple600">{{notification.date | date:"dd/MM"}}</div>
|
||||||
|
<div class="o_text_purple600">{{notification.date | date:"HH:mm:ss"}}</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<a ng-repeat="notification in notifications | orderBy: '-date'" ng-show="notification.state=='viewed'"
|
||||||
class="item item-icon-left" href="#/app/{{notification.link}}">
|
class="item item-icon-left" href="#/app/{{notification.link}}">
|
||||||
<i class="icon ion-android-notifications-none"></i>
|
<i ng-show="notification.state=='viewed'" class="icon ion-android-notifications-none"></i>
|
||||||
<h2>{{notification.message}}</h2>
|
<h2>{{notification.message}}</h2>
|
||||||
<div class="item-note text-right">
|
<div class="item-note text-right">
|
||||||
<div class="o_text_purple600">{{notification.date | date:"dd/MM"}}</div>
|
<div class="o_text_purple600">{{notification.date | date:"dd/MM"}}</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user