actualitzant...

This commit is contained in:
arnaucode
2017-01-25 22:27:33 +01:00
parent 6e914b3ebe
commit 5f16f060c1
23 changed files with 1104 additions and 941 deletions

View File

@@ -4,73 +4,133 @@
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic',
'starter.controllers',
'pascalprecht.translate'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})
var urlapi = "http://localhost:3000/api/";
//var urlapi="https://collectivecar.paas.primustech.io/api/";
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('app', {
url: '/app',
abstract: true,
templateUrl: 'templates/menu.html',
controller: 'AppCtrl'
})
angular.module('starter', [
'ionic',
'pascalprecht.translate',
'app.login',
'app.signup',
'app.menu',
'app.footerMenu',
'app.main',
'app.travels',
'app.travel',
'app.newPublication',
'app.offerCar',
/* 'app.askCar',
'app.askPackage',*/
'app.users',
'app.user',
'app.notifications',
'app.settings',
'app.help'
])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
.state('app.settings', {
url: '/settings',
views: {
'menuContent': {
templateUrl: 'templates/settings.html',
controller: 'SettingsCtrl'
}
}
})
.state('app.help', {
url: '/help',
views: {
'menuContent': {
templateUrl: 'templates/help.html',
controller: 'HelpCtrl'
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
}
});
})
.state('app.notifications', {
url: '/notifications/:username',
views: {
'menuContent': {
templateUrl: 'templates/notifications.html',
controller: 'NotificationsCtrl'
}
}
})
.state('app.users', {
url: '/users',
views: {
'menuContent': {
templateUrl: 'templates/users.html',
controller: 'UsersCtrl'
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('app', {
url: '/app',
abstract: true,
templateUrl: 'templates/menu.html',
controller: 'MenuCtrl'
})
.state('app.main', {
url: '/main',
views: {
'menuContent': {
templateUrl: 'templates/main.html',
controller: 'MainCtrl'
}
}
}
})
.state('app.user', {
})
.state('app.login', {
url: '/login',
views: {
'menuContent': {
templateUrl: 'templates/login.html',
controller: 'LoginCtrl'
}
}
})
.state('app.signup', {
url: '/signup',
views: {
'menuContent': {
templateUrl: 'templates/signup.html',
controller: 'SignupCtrl'
}
}
})
.state('app.travels', {
url: '/travels',
views: {
'menuContent': {
templateUrl: 'templates/travels.html',
controller: 'TravelsCtrl'
}
}
})
.state('app.travel', {
url: '/travels/:travelId',
views: {
'menuContent': {
templateUrl: 'templates/travel.html',
controller: 'TravelCtrl'
}
}
})
.state('app.newPublication', {
url: '/newPublication',
views: {
'menuContent': {
templateUrl: 'templates/newPublication.html',
controller: 'NewPublicationCtrl'
}
}
})
.state('app.offerCar', {
url: '/offerCar',
views: {
'menuContent': {
templateUrl: 'templates/offerCar.html',
controller: 'OfferCarCtrl'
}
}
})
.state('app.users', {
url: '/users',
views: {
'menuContent': {
templateUrl: 'templates/users.html',
controller: 'UsersCtrl'
}
}
})
.state('app.user', {
url: '/users/:username',
views: {
'menuContent': {
@@ -79,45 +139,66 @@ angular.module('starter', ['ionic',
}
}
})
.state('app.travels', {
url: '/travels',
views: {
'menuContent': {
templateUrl: 'templates/travels.html',
controller: 'TravelsCtrl'
.state('app.notifications', {
url: '/notifications',
views: {
'menuContent': {
templateUrl: 'templates/notifications.html',
controller: 'NotificationsCtrl'
}
}
}
})
.state('app.travel', {
url: '/travels/:travelId',
views: {
'menuContent': {
templateUrl: 'templates/travel.html',
controller: 'TravelCtrl'
}
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/app/travels');
})
})
.state('app.settings', {
url: '/settings',
views: {
'menuContent': {
templateUrl: 'templates/settings.html',
controller: 'SettingsCtrl'
}
}
})
.state('app.help', {
url: '/help',
views: {
'menuContent': {
templateUrl: 'templates/help.html',
controller: 'HelpCtrl'
}
}
});
// if none of the above states are matched, use this as the fallback
if ((localStorage.getItem("cim_app_token")) && (JSON.parse(localStorage.getItem("cim_app_userdata")) != "null") && (JSON.parse(localStorage.getItem("cim_app_userdata")) != null)) {
if ((window.location.hash == "#/app/login") || (window.location.hash == "#/app/signup")) {
window.location = '#/app/main';
}
$urlRouterProvider.otherwise('/app/main');
} else {
if ((window.location != "#/app/login") || (window.location != "#/app/signup")) {
console.log("removing data, and going to login");
localStorage.removeItem("cim_app_token");
localStorage.removeItem("cim_app_userdata");
window.location = "#/app/login";
$urlRouterProvider.otherwise('/app/login');
}
}
})
/* translator */
.config(['$translateProvider',function($translateProvider) {
/* translator */
.config(['$translateProvider', function($translateProvider) {
/* get lang from the file translations.js */
for(lang in translations){
$translateProvider.translations(lang, translations[lang]);
for (lang in translations) {
$translateProvider.translations(lang, translations[lang]);
}
if(window.localStorage.getItem('lang')) {
$translateProvider.preferredLanguage(window.localStorage.getItem('lang'));
}else{
$translateProvider.preferredLanguage('english');
if (window.localStorage.getItem('lang')) {
$translateProvider.preferredLanguage(window.localStorage.getItem('lang'));
} else {
$translateProvider.preferredLanguage('english');
};
$translateProvider.useSanitizeValueStrategy('escape');
}]);
}]);