Browse Source

alert system implemented

master
arnaucode 7 years ago
parent
commit
840d8b8663
9 changed files with 146 additions and 18 deletions
  1. +7
    -7
      www/css/colors.css
  2. +1
    -0
      www/index.html
  3. +72
    -0
      www/js/alerts.js
  4. +10
    -0
      www/js/app.js
  5. +6
    -0
      www/js/events.js
  6. +34
    -0
      www/templates/alerts.html
  7. +12
    -7
      www/templates/events.html
  8. +3
    -3
      www/templates/main.html
  9. +1
    -1
      www/templates/menu.html

+ 7
- 7
www/css/colors.css

@ -13,31 +13,31 @@
}
.c_red300{
background: #E57373;
color: #ffffff;
color: #ffffff!important;
}
.c_red400{
background: #EF5350;
color: #ffffff;
color: #ffffff!important;
}
.c_red500{
background: #F44336;
color: #ffffff;
color: #ffffff!important;
}
.c_red600{
background: #E53935;
color: #ffffff;
color: #ffffff!important;
}
.c_red700{
background: #D32F2F;
color: #ffffff;
color: #ffffff!important;
}
.c_red800{
background: #C62828;
color: #ffffff;
color: #ffffff!important;
}
.c_red900{
background: #B71C1C;
color: #ffffff;
color: #ffffff!important;
}
.ctext_red400{

+ 1
- 0
www/index.html

@ -48,6 +48,7 @@
<script src="js/main.js"></script>
<script src="js/events.js"></script>
<script src="js/event.js"></script>
<script src="js/alerts.js"></script>
<script src="js/savedEvents.js"></script>
<script src="js/users.js"></script>
<script src="js/user.js"></script>

+ 72
- 0
www/js/alerts.js

@ -0,0 +1,72 @@
angular.module('app.alerts', ['pascalprecht.translate'])
.controller('AlertsCtrl', function($scope, $http, $ionicModal,
$timeout, $ionicLoading, $filter) {
$scope.events=[];
$scope.page=0;
$scope.doRefresh = function() {
/* events refresh: */
//$http.get(urlapi + 'events?page=' + $scope.page)
$http.get(urlapi + 'alerts')
.then(function(data){
console.log('data success events');
console.log(data); // for browser console
//$scope.events = data.data; // for UI
$scope.events=data.data;
$scope.$broadcast('scroll.refreshComplete');//refresher stop
}, function(data){
console.log('data error');
$scope.$broadcast('scroll.refreshComplete');//refresher stop
$ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 });
});
};
$scope.doRefresh();
$scope.share = function(event){
var message = "[" + event.title + "]" + event.description;
/*var subject = event.title;
var file= ['',''];*/
var link = "http://duckduckgo.com";
$cordovaSocialSharing
.share(message, link) // Share via native share sheet
.then(function(result) {
// Success!
}, function(err) {
// An error occured. Show a message to the user
});
};
$scope.savedEvents=[];
$scope.$on('$ionicView.enter', function(){//per executar-ho cada cop que es carrega el view
if (localStorage.getItem("events_app_savedEvents")) {
$scope.savedEvents = JSON.parse(localStorage.getItem("events_app_savedEvents"));
console.log("savedEvents");
console.log($scope.savedEvents);
}
});
$scope.saveEvent = function(event){
$scope.savedEvents.push(event);
localStorage.setItem("events_app_savedEvents", JSON.stringify($scope.savedEvents));
$ionicLoading.show({ template: 'Event saved', noBackdrop: true, duration: 1000 });
};
$scope.unsaveEvent = function(event){
for(var i=0; i<$scope.savedEvents.length; i++) {
if ($scope.savedEvents[i]._id === event._id){
$scope.savedEvents.splice(i, 1);
}
}
localStorage.setItem("events_app_savedEvents", JSON.stringify($scope.savedEvents));
$ionicLoading.show({ template: 'Event unsaved', noBackdrop: true, duration: 1000 });
};
$scope.isEventSaved = function(event) {
for(var i=0; i<$scope.savedEvents.length; i++) {
if ($scope.savedEvents[i]._id === event._id){
return true;
}
}
return false;
};
});

+ 10
- 0
www/js/app.js

@ -11,6 +11,7 @@ angular.module('app', [
'app.main',
'app.events',
'app.event',
'app.alerts',
'app.savedEvents',
'app.users',
'app.user'
@ -70,6 +71,15 @@ angular.module('app', [
}
}
})
.state('app.alerts', {
url: '/alerts',
views: {
'menuContent': {
templateUrl: 'templates/alerts.html',
controller: 'AlertsCtrl'
}
}
})
.state('app.savedEvents', {
url: '/savedEvents',
views: {

+ 6
- 0
www/js/events.js

@ -5,6 +5,7 @@ angular.module('app.events', ['pascalprecht.translate'])
$scope.events=[];
$scope.alerts=[];
$scope.page=0;
$scope.doRefresh = function() {
/* events refresh: */
@ -23,6 +24,11 @@ angular.module('app.events', ['pascalprecht.translate'])
$ionicLoading.show({ template: 'Error connecting server', noBackdrop: true, duration: 2000 });
});
$http.get(urlapi + 'alerts')
.then(function(data){
$scope.alerts=data.data;
}, function(data){
});
};
$scope.doRefresh();

+ 34
- 0
www/templates/alerts.html

@ -0,0 +1,34 @@
<ion-view view-title="Emergency alerts">
<ion-content class="c_red200">
<ion-refresher pulling-text="{{'Pull_to_refresh' | translate}}..." on-refresh="doRefresh()">
</ion-refresher>
<div class="card" ng-repeat="event in events">
<a class="item item-avatar" ng-href="#/app/users/{{event.user._id}}">
<img ng-src="{{event.user.img}}">
<h2>{{event.user.username}}</h2>
<p>{{event.user.shortDescription}}</p>
</a>
<a ng-href="#/app/events/{{event._id}}" class="item item-text-wrap">
<h2>{{event.title}}</h2>
<p>{{event.description}}</p>
<p>{{event.date | date: 'HH:mm, dd/MM/yyyy'}}</p>
</a>
<div class="item tabs tabs-icon-only">
<a class="tab-item" ng-click="share(event)">
<i class="icon ion-android-share-alt"></i>
</a>
<a class="tab-item">
</a>
<a class="tab-item" ng-click="unsaveEvent(event)"
ng-show="isEventSaved(event)">
<i class="icon ion-heart ctext_red600"></i>
</a>
<a class="tab-item" ng-click="saveEvent(event)"
ng-hide="isEventSaved(event)">
<i class="icon ion-heart"></i>
</a>
</div>
</div>
</ion-content>
</ion-view>

+ 12
- 7
www/templates/events.html

@ -2,19 +2,24 @@
<ion-content class="c_blueGrey100">
<ion-refresher pulling-text="{{'Pull_to_refresh' | translate}}..." on-refresh="doRefresh()">
</ion-refresher>
<a href="#/app/alerts" class="item item-icon-left c_red400"
ng-show="alerts">
<i class="icon ion-android-alert"></i> <b>{{alerts.length}}</b> Emergency alerts!
</a>
<div class="card" ng-repeat="event in events">
<a class="item item-avatar" ng-href="#/app/users/{{event.user._id}}">
<img ng-src="{{event.user.img}}">
<h2>{{event.user.username}}</h2>
<p>{{event.user.shortDescription}}</p>
</a>
<a ng-href="#/app/events/{{event._id}}" class="item item-image">
<img ng-src="{{event.img}}">
<div style="text-align: left; padding: 20px;">
<h2>{{event.title}}</h2>
<p>{{event.description}}</p>
<p>{{event.date | date: 'HH:mm, dd/MM/yyyy'}}</p>
</div>
<a ng-href="#/app/events/{{event._id}}" class="item item-image"
ng-show="event.img">
<img ng-src="{{event.img}}">
</a>
<a ng-href="#/app/events/{{event._id}}" class="item item-text-wrap">
<h2>{{event.title}}</h2>
<p>{{event.description}}</p>
<p>{{event.date | date: 'HH:mm, dd/MM/yyyy'}}</p>
</a>
<div class="item tabs tabs-icon-only">
<a class="tab-item" ng-click="share(event)">

+ 3
- 3
www/templates/main.html

@ -9,7 +9,7 @@
</a>
</div>
<div class="row o_mainOptionRow">
<a class="col c_indigo300" ng-href="#/app/savedEvents">
<a class="col 0 c_yellow600" ng-href="#/app/savedEvents">
<i class="icon ion-heart"></i>
</a>
<a class="col c_green400" ng-href="#/app/byplace">
@ -17,7 +17,7 @@
</a>
</div>
<div class="row o_mainOptionRow">
<a class="col c_yellow600" ng-href="#/app/search">
<a class="col c_deepPurple400" ng-href="#/app/search">
<i class="icon ion-search"></i>
</a>
<a class="col c_cyan400" ng-href="#/app/bycategories">
@ -25,7 +25,7 @@
</a>
</div>
<div class="row o_mainOptionRow">
<a class="col c_deepPurple400" ng-href="#/app/bydate">
<a class="col c_indigo300" ng-href="#/app/bydate">
<i class="icon ion-calendar"></i><!--by date-->
</a>
<a class="col c_orange400" ng-href="#/app/settings">

+ 1
- 1
www/templates/menu.html

@ -14,7 +14,7 @@
<ion-side-menu side="left">
<ion-header-bar class="bar-stable">
<h1 class="title">Left</h1>
<h1 class="title">Menu</h1>
</ion-header-bar>
<ion-content>
<ion-list>

Loading…
Cancel
Save