copay/js/routes.js

137 lines
3.7 KiB
JavaScript
Raw Normal View History

2014-04-07 20:54:38 -07:00
'use strict';
//Setting up route
angular
.module('copayApp')
.config(function($routeProvider) {
2014-04-07 20:54:38 -07:00
$routeProvider
.when('/', {
templateUrl: 'views/home.html',
})
.when('/createProfile', {
templateUrl: 'views/createProfile.html',
})
.when('/unsupported', {
templateUrl: 'views/unsupported.html'
})
.when('/confirmed', {
template: " ", // just fire controller
controller: 'EmailConfirmationController',
})
.when('/uri-payment/:data', {
templateUrl: 'views/uri-payment.html'
})
.when('/paymentIntent', {
templateUrl: 'views/paymentIntent.html',
logged: true
})
.when('/join', {
templateUrl: 'views/join.html',
logged: true
})
.when('/import', {
templateUrl: 'views/import.html',
logged: true
})
2014-10-31 15:39:01 -07:00
.when('/importProfile', {
templateUrl: 'views/importProfile.html',
})
.when('/create', {
templateUrl: 'views/create.html',
logged: true
})
.when('/copayers', {
templateUrl: 'views/copayers.html',
logged: true
})
2014-10-31 07:49:52 -07:00
.when('/homeWallet', {
templateUrl: 'views/homeWallet.html',
2014-11-29 13:35:48 -08:00
walletShouldBeReady: true,
2014-10-31 07:49:52 -07:00
logged: true
})
.when('/receive', {
2014-10-30 10:13:40 -07:00
templateUrl: 'views/receive.html',
2014-11-29 13:35:48 -08:00
walletShouldBeReady: true,
logged: true
})
.when('/history', {
2014-10-30 10:13:40 -07:00
templateUrl: 'views/history.html',
2014-11-29 13:35:48 -08:00
walletShouldBeReady: true,
logged: true
})
.when('/send', {
templateUrl: 'views/send.html',
2014-11-29 13:35:48 -08:00
walletShouldBeReady: true,
logged: true
})
.when('/more', {
templateUrl: 'views/more.html',
2014-11-29 13:35:48 -08:00
walletShouldBeReady: true,
logged: true
})
.when('/settings', {
templateUrl: 'views/settings.html',
2014-11-29 13:35:48 -08:00
walletShouldBeReady: true,
logged: false
})
.when('/warning', {
templateUrl: 'views/warning.html',
logged: true
})
.when('/profile', {
templateUrl: 'views/profile.html',
logged: true
});
2014-11-04 06:30:44 -08:00
if (config.developmentFeatures) {
$routeProvider.when('/devLogin/:mail/:password', {
2014-11-04 05:58:32 -08:00
templateUrl: 'views/devLogin.html',
logged: false
});
2014-11-04 06:30:44 -08:00
}
$routeProvider.otherwise({
templateUrl: 'views/errors/404.html',
title: 'Error'
});
2014-04-07 20:54:38 -07:00
});
//Setting HTML5 Location Mode
angular
.module('copayApp')
.config(function($locationProvider, $idleProvider, $keepaliveProvider) {
$locationProvider
.html5Mode(false)
.hashPrefix('!');
// IDLE timeout
var timeout = config.wallet.idleDurationMin * 60 || 300;
$idleProvider.idleDuration(timeout); // in seconds
$idleProvider.warningDuration(40); // in seconds
$keepaliveProvider.interval(30); // in seconds
})
.run(function($rootScope, $location, $idle, gettextCatalog, uriHandler) {
gettextCatalog.currentLanguage = config.defaultLanguage;
// not for mobileApp
if (!window.cordova) {
$idle.watch();
uriHandler.register();
}
$rootScope.$on('$routeChangeStart', function(event, next, current) {
if (!localStorage || localStorage.length < 1) {
$location.path('unsupported');
} else {
if (!$rootScope.iden && next.logged) {
$idle.unwatch();
$location.path('/');
}
2014-11-29 13:35:48 -08:00
if ($rootScope.wallet && !$rootScope.wallet.isReady() && next.walletShouldBeReady) {
$location.path('/copayers');
}
2014-08-12 12:26:15 -07:00
}
});
})
.config(function($compileProvider) {
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|tel|chrome-extension|resource):/);
2014-04-07 20:54:38 -07:00
});