Wallet/src/js/routes.js

1112 lines
29 KiB
JavaScript
Raw Normal View History

2015-03-06 12:00:10 -03:00
'use strict';
2015-05-12 14:56:24 -03:00
var unsupported, isaosp;
2015-03-06 12:00:10 -03:00
if (window && window.navigator) {
var rxaosp = window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);
2015-05-12 14:56:24 -03:00
isaosp = (rxaosp && rxaosp[1] < 537);
2015-03-06 12:00:10 -03:00
if (!window.cordova && isaosp)
unsupported = true;
if (unsupported) {
window.location = '#/unsupported';
}
2015-03-06 12:00:10 -03:00
}
//Setting up route
angular.module('copayApp').config(function(historicLogProvider, $provide, $logProvider, $stateProvider, $urlRouterProvider, $compileProvider, $ionicConfigProvider) {
2016-08-24 20:08:38 -03:00
$urlRouterProvider.otherwise('/starting');
// NO CACHE
2016-09-21 17:12:25 -03:00
//$ionicConfigProvider.views.maxCache(0);
2015-03-06 12:00:10 -03:00
// TABS BOTTOM
$ionicConfigProvider.tabs.position('bottom');
// NAV TITTLE CENTERED
$ionicConfigProvider.navBar.alignTitle('center');
// NAV BUTTONS ALIGMENT
$ionicConfigProvider.navBar.positionPrimaryButtons('left');
$ionicConfigProvider.navBar.positionSecondaryButtons('right');
2016-08-29 16:48:15 -03:00
// NAV BACK-BUTTON TEXT/ICON
$ionicConfigProvider.backButton.icon('icon ion-ios-arrow-thin-left').text('');
2016-08-29 16:48:15 -03:00
$ionicConfigProvider.backButton.previousTitleText(false);
2015-04-25 12:37:04 -03:00
$logProvider.debugEnabled(true);
2016-06-02 11:09:40 -03:00
$provide.decorator('$log', ['$delegate', 'platformInfo',
function($delegate, platformInfo) {
2015-04-25 12:37:04 -03:00
var historicLog = historicLogProvider.$get();
['debug', 'info', 'warn', 'error', 'log'].forEach(function(level) {
2016-06-02 11:09:40 -03:00
if (platformInfo.isDevel && level == 'error') return;
2015-04-25 12:37:04 -03:00
var orig = $delegate[level];
$delegate[level] = function() {
2015-07-13 13:21:47 -03:00
if (level == 'error')
2015-05-28 14:55:48 -03:00
console.log(arguments);
var args = Array.prototype.slice.call(arguments);
args = args.map(function(v) {
2015-04-25 20:53:31 -03:00
try {
if (typeof v == 'undefined') v = 'undefined';
if (!v) v = 'null';
2015-04-25 20:53:31 -03:00
if (typeof v == 'object') {
2015-04-27 02:07:26 -03:00
if (v.message)
v = v.message;
else
v = JSON.stringify(v);
2015-04-25 20:53:31 -03:00
}
2015-07-13 13:21:47 -03:00
// Trim output in mobile
2016-06-06 12:24:07 -03:00
if (platformInfo.isCordova) {
2015-07-13 13:21:47 -03:00
v = v.toString();
if (v.length > 3000) {
v = v.substr(0, 2997) + '...';
2015-07-13 13:21:47 -03:00
}
}
2015-04-25 20:53:31 -03:00
} catch (e) {
console.log('Error at log decorator:', e);
v = 'undefined';
}
2015-04-25 12:37:04 -03:00
return v;
});
2015-04-26 20:13:02 -03:00
try {
2016-06-06 12:24:07 -03:00
if (platformInfo.isCordova)
2015-04-26 20:13:02 -03:00
console.log(args.join(' '));
2015-04-26 20:13:02 -03:00
historicLog.add(level, args.join(' '));
2015-05-04 12:23:43 -03:00
orig.apply(null, args);
2015-04-26 20:13:02 -03:00
} catch (e) {
2015-06-19 15:00:27 -03:00
console.log('ERROR (at log decorator):', e, args[0]);
2015-04-26 20:13:02 -03:00
}
2015-04-25 12:37:04 -03:00
};
});
return $delegate;
}
]);
// whitelist 'chrome-extension:' for chromeApp to work with image URLs processed by Angular
// link: http://stackoverflow.com/questions/15606751/angular-changes-urls-to-unsafe-in-extension-page?lq=1
$compileProvider.imgSrcSanitizationWhitelist(/^\s*((https?|ftp|file|blob|chrome-extension):|data:image\/)/);
2015-10-02 11:27:17 -03:00
$stateProvider
2016-08-19 14:43:58 -03:00
/*
*
* Other pages
*
*/
2016-08-29 16:48:15 -03:00
.state('unsupported', {
2016-08-19 14:43:58 -03:00
url: '/unsupported',
templateUrl: 'views/unsupported.html'
})
2016-08-24 20:08:38 -03:00
.state('starting', {
url: '/starting',
2016-09-21 11:28:31 -03:00
template: '<ion-view id="starting"><ion-content>{{starting}}</ion-content></ion-view>',
controller: function($scope, $log, gettextCatalog) {
$log.info('Starting...');
$scope.starting = gettextCatalog.getString('Starting...');
}
2016-08-24 20:08:38 -03:00
})
2016-08-19 14:43:58 -03:00
/*
*
* URI
*
*/
2016-08-19 14:43:58 -03:00
.state('uri', {
url: '/uri/:url',
2016-08-25 12:24:25 -03:00
controller: function($stateParams, $log, openURLService, profileService) {
profileService.whenAvailable(function() {
$log.info('DEEP LINK from Browser:' + $stateParams.url);
openURLService.handleURL({
url: $stateParams.url
});
})
2016-08-25 16:31:47 -03:00
}
2015-07-29 18:15:37 -03:00
})
.state('uripayment', {
url: '/uri-payment/:url',
2016-08-24 18:08:00 -03:00
templateUrl: 'views/paymentUri.html'
})
.state('uriglidera', {
url: '/uri-glidera/:url',
controller: 'glideraUriController',
2016-08-24 18:08:00 -03:00
templateUrl: 'views/glideraUri.html'
})
.state('uricoinbase', {
url: '/uri-coinbase/:url',
templateUrl: 'views/coinbaseUri.html'
2015-06-11 11:59:48 -03:00
})
2016-08-25 16:31:47 -03:00
2016-08-19 14:43:58 -03:00
/*
*
* Wallet
*
*/
2016-09-28 11:08:08 -03:00
.state('tabs.wallet', {
2016-11-15 11:03:45 -03:00
url: '/wallet/:walletId/:fromOnboarding',
2016-09-05 11:04:40 -03:00
views: {
2016-09-28 11:08:08 -03:00
'tab-home@tabs': {
controller: 'walletDetailsController',
2016-09-05 11:04:40 -03:00
templateUrl: 'views/walletDetails.html'
}
}
2016-09-05 11:04:40 -03:00
})
.state('tabs.activity', {
url: '/activity',
views: {
2016-09-28 11:08:08 -03:00
'tab-home@tabs': {
controller: 'activityController',
2016-09-05 11:04:40 -03:00
templateUrl: 'views/activity.html',
}
}
})
.state('tabs.proposals', {
url: '/proposals',
views: {
2016-09-28 11:08:08 -03:00
'tab-home@tabs': {
controller: 'proposalsController',
2016-09-05 11:04:40 -03:00
templateUrl: 'views/proposals.html',
}
}
})
2016-10-21 16:56:19 -04:00
.state('tabs.wallet.tx-details', {
2016-10-22 17:43:05 -03:00
url: '/tx-details/:txid',
2016-10-21 16:56:19 -04:00
views: {
'tab-home@tabs': {
controller: 'txDetailsController',
2016-11-04 17:03:20 -03:00
templateUrl: 'views/tx-details.html'
2016-10-21 16:56:19 -04:00
}
}
})
2016-11-15 11:03:45 -03:00
.state('tabs.wallet.backupWarning', {
url: '/backupWarning/:from/:walletId',
views: {
'tab-home@tabs': {
templateUrl: 'views/backupWarning.html'
}
}
})
2016-11-15 14:19:00 -03:00
.state('tabs.wallet.backup', {
url: '/backup/:walletId',
views: {
'tab-home@tabs': {
templateUrl: 'views/backup.html',
controller: 'backupController'
}
}
})
2016-08-24 17:54:01 -03:00
2016-08-19 14:43:58 -03:00
/*
*
* Tabs
*
*/
2016-08-19 14:43:58 -03:00
.state('tabs', {
url: '/tabs',
abstract: true,
controller: 'tabsController',
templateUrl: 'views/tabs.html'
})
2016-08-11 17:38:27 -03:00
.state('tabs.home', {
url: '/home/:fromOnboarding',
2016-08-11 17:38:27 -03:00
views: {
'tab-home': {
2016-09-21 17:12:25 -03:00
controller: 'tabHomeController',
2016-08-11 17:38:27 -03:00
templateUrl: 'views/tab-home.html',
}
2016-08-11 17:38:27 -03:00
}
})
.state('tabs.receive', {
url: '/receive',
views: {
'tab-receive': {
2016-09-21 17:12:25 -03:00
controller: 'tabReceiveController',
2016-08-11 17:38:27 -03:00
templateUrl: 'views/tab-receive.html',
}
2016-08-11 17:38:27 -03:00
}
})
.state('tabs.scan', {
url: '/scan',
views: {
'tab-scan': {
controller: 'tabScanController',
templateUrl: 'views/tab-scan.html',
}
}
})
.state('scanner', {
url: '/scanner',
params: {
passthroughMode: null,
},
controller: 'tabScanController',
templateUrl: 'views/tab-scan.html'
})
2016-08-11 17:38:27 -03:00
.state('tabs.send', {
url: '/send',
views: {
'tab-send': {
2016-09-21 17:12:25 -03:00
controller: 'tabSendController',
2016-08-11 17:38:27 -03:00
templateUrl: 'views/tab-send.html',
}
2016-08-11 17:38:27 -03:00
}
})
.state('tabs.settings', {
url: '/settings',
views: {
'tab-settings': {
2016-09-21 17:12:25 -03:00
controller: 'tabSettingsController',
2016-08-11 17:38:27 -03:00
templateUrl: 'views/tab-settings.html',
}
2016-08-11 17:38:27 -03:00
}
})
/*
*
* Send
*
*/
2016-09-26 13:05:15 -03:00
.state('tabs.send.amount', {
2016-10-13 17:11:19 -03:00
url: '/amount/:isWallet/:toAddress/:toName/:toEmail/:toColor',
2015-03-06 12:00:10 -03:00
views: {
2016-09-16 21:01:19 -03:00
'tab-send@tabs': {
controller: 'amountController',
templateUrl: 'views/amount.html'
2015-03-06 12:00:10 -03:00
}
}
})
2016-09-16 21:01:19 -03:00
.state('tabs.send.confirm', {
url: '/confirm/:isWallet/:toAddress/:toName/:toAmount/:toEmail/:description',
views: {
2016-09-16 21:01:19 -03:00
'tab-send@tabs': {
controller: 'confirmController',
templateUrl: 'views/confirm.html'
}
},
2016-10-31 16:46:45 -03:00
params: {
paypro: null
}
})
.state('tabs.send.addressbook', {
url: '/addressbook/add/:fromSendTab/:addressbookEntry',
views: {
'tab-send@tabs': {
templateUrl: 'views/addressbook.add.html',
controller: 'addressbookAddController'
}
}
})
2016-08-19 14:43:58 -03:00
/*
*
* Add
*
*/
.state('tabs.add', {
url: '/add',
2015-03-06 12:00:10 -03:00
views: {
2016-09-16 21:01:19 -03:00
'tab-home@tabs': {
2016-09-02 13:00:38 -03:00
templateUrl: 'views/add.html'
}
}
2015-03-06 12:00:10 -03:00
})
2016-09-16 21:01:19 -03:00
.state('tabs.add.join', {
2016-08-25 11:18:10 -03:00
url: '/join/:url',
2015-03-06 12:00:10 -03:00
views: {
2016-09-16 21:01:19 -03:00
'tab-home@tabs': {
2015-03-06 12:00:10 -03:00
templateUrl: 'views/join.html'
},
}
})
2016-09-16 21:01:19 -03:00
.state('tabs.add.import', {
url: '/import',
2015-03-06 12:00:10 -03:00
views: {
2016-09-16 21:01:19 -03:00
'tab-home@tabs': {
2015-03-06 12:00:10 -03:00
templateUrl: 'views/import.html'
},
2016-09-01 12:10:08 -03:00
},
2015-03-06 12:00:10 -03:00
})
2016-09-16 21:01:19 -03:00
.state('tabs.add.create-personal', {
2016-09-08 11:28:41 -03:00
url: '/create-personal',
2015-03-06 12:00:10 -03:00
views: {
2016-09-16 21:01:19 -03:00
'tab-home@tabs': {
2016-09-08 11:28:41 -03:00
templateUrl: 'views/tab-create-personal.html'
},
}
})
2016-09-16 21:01:19 -03:00
.state('tabs.add.create-shared', {
2016-09-08 11:28:41 -03:00
url: '/create-shared',
views: {
2016-09-16 21:01:19 -03:00
'tab-home@tabs': {
2016-09-08 11:28:41 -03:00
templateUrl: 'views/tab-create-shared.html'
2015-03-06 12:00:10 -03:00
},
}
})
2016-08-19 14:43:58 -03:00
/*
*
* Global Settings
*
*/
2016-09-28 10:50:33 -03:00
.state('tabs.notifications', {
url: '/notifications',
views: {
'tab-settings@tabs': {
controller: 'preferencesNotificationsController',
templateUrl: 'views/preferencesNotifications.html'
}
}
})
.state('tabs.language', {
url: '/language',
2015-04-22 15:19:08 -03:00
views: {
2016-09-16 17:49:08 -03:00
'tab-settings@tabs': {
controller: 'preferencesLanguageController',
2015-04-22 15:19:08 -03:00
templateUrl: 'views/preferencesLanguage.html'
}
2015-04-22 15:19:08 -03:00
}
})
.state('tabs.unit', {
url: '/unit',
2015-03-06 12:00:10 -03:00
views: {
2016-09-16 17:49:08 -03:00
'tab-settings@tabs': {
controller: 'preferencesUnitController',
2015-03-06 12:00:10 -03:00
templateUrl: 'views/preferencesUnit.html'
}
2015-03-06 12:00:10 -03:00
}
})
.state('tabs.fee', {
url: '/fee',
views: {
2016-09-16 17:49:08 -03:00
'tab-settings@tabs': {
controller: 'preferencesFeeController',
templateUrl: 'views/preferencesFee.html'
}
}
})
.state('tabs.altCurrency', {
url: '/altCurrency',
views: {
2016-09-16 17:49:08 -03:00
'tab-settings@tabs': {
controller: 'preferencesAltCurrencyController',
templateUrl: 'views/preferencesAltCurrency.html'
}
}
})
.state('tabs.about', {
url: '/about',
2015-08-31 18:12:04 -03:00
views: {
2016-09-16 17:49:08 -03:00
'tab-settings@tabs': {
controller: 'preferencesAbout',
templateUrl: 'views/preferencesAbout.html'
}
2015-08-31 18:12:04 -03:00
}
})
2016-09-16 17:49:08 -03:00
.state('tabs.about.logs', {
url: '/logs',
2015-08-31 18:12:04 -03:00
views: {
2016-09-16 17:49:08 -03:00
'tab-settings@tabs': {
controller: 'preferencesLogs',
templateUrl: 'views/preferencesLogs.html'
}
2015-08-31 18:12:04 -03:00
}
})
2016-09-16 17:49:08 -03:00
.state('tabs.about.termsOfUse', {
2016-08-25 16:31:47 -03:00
url: '/termsOfUse',
2015-08-31 18:12:04 -03:00
views: {
2016-09-16 17:49:08 -03:00
'tab-settings@tabs': {
controller: 'termOfUseController',
2016-08-25 16:31:47 -03:00
templateUrl: 'views/termsOfUse.html',
}
2015-08-31 18:12:04 -03:00
}
})
2016-09-16 17:49:08 -03:00
.state('tabs.about.translators', {
url: '/translators',
2015-11-23 12:17:04 -03:00
views: {
2016-09-16 17:49:08 -03:00
'tab-settings@tabs': {
controller: 'translatorsController',
templateUrl: 'views/translators.html'
}
2015-11-23 12:17:04 -03:00
}
})
2016-09-27 15:57:39 -03:00
.state('tabs.advanced', {
url: '/advanced',
views: {
'tab-settings@tabs': {
controller: 'advancedSettingsController',
templateUrl: 'views/advancedSettings.html'
}
}
})
/*
*
* Wallet preferences
*
*/
2016-09-22 16:04:05 -03:00
.state('tabs.preferences', {
url: '/preferences/:walletId',
views: {
2016-09-16 17:49:08 -03:00
'tab-settings@tabs': {
controller: 'preferencesController',
templateUrl: 'views/preferences.html'
}
}
})
.state('tabs.preferences.preferencesAlias', {
url: '/preferencesAlias',
views: {
'tab-settings@tabs': {
controller: 'preferencesAliasController',
templateUrl: 'views/preferencesAlias.html'
}
}
})
.state('tabs.preferences.preferencesColor', {
url: '/preferencesColor',
views: {
'tab-settings@tabs': {
controller: 'preferencesColorController',
templateUrl: 'views/preferencesColor.html'
}
}
})
2016-09-26 16:11:45 -03:00
.state('tabs.preferences.backupWarning', {
url: '/backupWarning/:from',
views: {
'tab-settings@tabs': {
templateUrl: 'views/backupWarning.html'
}
}
})
.state('tabs.preferences.backup', {
url: '/backup',
views: {
'tab-settings@tabs': {
controller: 'backupController',
templateUrl: 'views/backup.html'
}
}
})
.state('tabs.preferences.preferencesAdvanced', {
url: '/preferencesAdvanced',
views: {
'tab-settings@tabs': {
controller: 'preferencesAdvancedController',
templateUrl: 'views/preferencesAdvanced.html'
}
}
})
.state('tabs.preferences.information', {
url: '/information',
views: {
'tab-settings@tabs': {
controller: 'preferencesInformation',
templateUrl: 'views/preferencesInformation.html'
}
}
})
.state('tabs.preferences.export', {
url: '/export',
views: {
'tab-settings@tabs': {
controller: 'exportController',
templateUrl: 'views/export.html'
}
}
})
.state('tabs.preferences.preferencesBwsUrl', {
url: '/preferencesBwsUrl',
views: {
'tab-settings@tabs': {
controller: 'preferencesBwsUrlController',
templateUrl: 'views/preferencesBwsUrl.html'
}
}
})
.state('tabs.preferences.preferencesHistory', {
url: '/preferencesHistory',
views: {
'tab-settings@tabs': {
controller: 'preferencesHistory',
templateUrl: 'views/preferencesHistory.html'
}
}
})
.state('tabs.preferences.delete', {
url: '/delete',
views: {
'tab-settings@tabs': {
controller: 'preferencesDeleteWalletController',
templateUrl: 'views/preferencesDeleteWallet.html'
}
}
})
.state('tabs.preferences.paperWallet', {
url: '/paperWallet',
views: {
'tab-settings@tabs': {
controller: 'paperWalletController',
templateUrl: 'views/paperWallet.html'
}
}
})
/*
*
* Addressbook
*
*/
2016-09-12 11:57:20 -03:00
.state('tabs.addressbook', {
2016-09-12 11:57:20 -03:00
url: '/addressbook',
views: {
2016-09-16 17:14:22 -03:00
'tab-settings@tabs': {
2016-09-12 11:57:20 -03:00
templateUrl: 'views/addressbook.html',
controller: 'addressbookListController'
}
}
})
.state('tabs.addressbook.add', {
2016-09-21 16:39:40 -03:00
url: '/add',
2016-09-12 11:57:20 -03:00
views: {
'tab-settings@tabs': {
templateUrl: 'views/addressbook.add.html',
controller: 'addressbookAddController'
}
}
})
.state('tabs.addressbook.view', {
2016-10-13 16:53:15 -03:00
url: '/view/:address/:email/:name',
2016-09-12 11:57:20 -03:00
views: {
'tab-settings@tabs': {
templateUrl: 'views/addressbook.view.html',
controller: 'addressbookViewController'
}
}
})
/*
*
2016-09-26 13:05:15 -03:00
* Copayers
*
*/
.state('tabs.copayers', {
2016-09-22 16:50:06 -03:00
url: '/copayers/:walletId',
views: {
2016-09-06 11:22:10 -03:00
'tab-home': {
2016-09-22 16:04:05 -03:00
templateUrl: 'views/copayers.html',
controller: 'copayersController'
}
}
})
2016-09-26 13:05:15 -03:00
/*
*
2016-11-15 11:03:45 -03:00
* Init backup flow
2016-09-26 13:05:15 -03:00
*
*/
2016-09-26 16:11:45 -03:00
.state('tabs.receive.backupWarning', {
url: '/backupWarning/:from/:walletId',
views: {
'tab-receive@tabs': {
templateUrl: 'views/backupWarning.html'
}
2016-09-26 13:05:15 -03:00
}
2016-09-26 16:11:45 -03:00
})
.state('tabs.receive.backup', {
url: '/backup/:walletId',
views: {
'tab-receive@tabs': {
controller: 'backupController',
templateUrl: 'views/backup.html'
}
}
})
2016-09-26 13:05:15 -03:00
2016-08-25 16:31:47 -03:00
/*
*
* Onboarding
*
*/
.state('onboarding', {
2016-09-02 11:20:33 -03:00
url: '/onboarding',
2016-08-25 16:31:47 -03:00
abstract: true,
2016-09-02 15:42:45 -03:00
template: '<ion-nav-view name="onboarding"></ion-nav-view>'
2016-08-25 16:31:47 -03:00
})
.state('onboarding.welcome', {
url: '/welcome',
views: {
'onboarding': {
templateUrl: 'views/onboarding/welcome.html'
}
}
})
.state('onboarding.tour', {
url: '/tour',
views: {
'onboarding': {
templateUrl: 'views/onboarding/tour.html'
}
}
})
.state('onboarding.collectEmail', {
2016-09-02 15:42:45 -03:00
url: '/collectEmail/:walletId',
2016-08-25 16:31:47 -03:00
views: {
'onboarding': {
templateUrl: 'views/onboarding/collectEmail.html'
}
}
})
.state('onboarding.notifications', {
2016-09-02 15:42:45 -03:00
url: '/notifications/:walletId',
2016-08-25 16:31:47 -03:00
views: {
'onboarding': {
templateUrl: 'views/onboarding/notifications.html'
}
}
})
.state('onboarding.backupRequest', {
2016-09-02 15:42:45 -03:00
url: '/backupRequest/:walletId',
2016-08-25 16:31:47 -03:00
views: {
'onboarding': {
templateUrl: 'views/onboarding/backupRequest.html'
}
}
})
.state('onboarding.backupWarning', {
2016-09-26 16:11:45 -03:00
url: '/backupWarning/:from/:walletId',
2016-08-25 16:31:47 -03:00
views: {
'onboarding': {
2016-09-26 16:11:45 -03:00
templateUrl: 'views/backupWarning.html'
2016-08-25 16:31:47 -03:00
}
}
})
.state('onboarding.backup', {
2016-09-26 16:11:45 -03:00
url: '/backup/:walletId',
views: {
'onboarding': {
2016-09-23 15:42:09 -03:00
templateUrl: 'views/backup.html',
controller: 'backupController'
}
}
})
2016-08-25 16:31:47 -03:00
.state('onboarding.disclaimer', {
2016-10-11 12:42:53 -03:00
url: '/disclaimer/:walletId/:backedUp/:resume',
2016-08-25 16:31:47 -03:00
views: {
'onboarding': {
templateUrl: 'views/onboarding/disclaimer.html'
}
}
})
.state('onboarding.terms', {
url: '/terms',
views: {
'onboarding': {
templateUrl: 'views/onboarding/terms.html'
}
}
})
.state('onboarding.import', {
url: '/import',
views: {
'onboarding': {
templateUrl: 'views/import.html'
},
},
params: {
2016-09-02 15:42:45 -03:00
code: null,
fromOnboarding: null
},
})
2016-08-25 16:31:47 -03:00
/*
*
2016-11-16 11:16:20 -03:00
* Feedback
*
*/
2016-09-16 14:46:25 -03:00
2016-11-16 11:16:20 -03:00
.state('tabs.feedback', {
2016-11-01 14:21:35 -03:00
url: '/feedback',
2016-11-16 11:16:20 -03:00
views: {
'tab-settings@tabs': {
templateUrl: 'views/feedback/send.html',
controller: 'sendController'
}
}
})
.state('tabs.rate', {
url: '/rate',
2016-11-16 13:06:02 -05:00
abstract: true
2016-11-01 14:21:35 -03:00
})
2016-11-16 11:16:20 -03:00
.state('tabs.rate.send', {
2016-11-11 17:05:06 -03:00
url: '/send/:score',
2016-11-01 14:21:35 -03:00
views: {
2016-11-16 11:16:20 -03:00
'tab-home@tabs': {
templateUrl: 'views/feedback/send.html',
controller: 'sendController'
2016-11-01 14:21:35 -03:00
}
}
})
2016-11-16 11:16:20 -03:00
.state('tabs.rate.complete', {
2016-11-11 17:05:06 -03:00
url: '/complete/:score/:skipped',
2016-11-01 14:21:35 -03:00
views: {
2016-11-16 11:16:20 -03:00
'tab-home@tabs': {
2016-11-11 17:05:06 -03:00
controller: 'completeController',
templateUrl: 'views/feedback/complete.html'
2016-11-01 14:21:35 -03:00
}
},
customConfig: {
hideStatusBar: true
2016-11-01 14:21:35 -03:00
}
})
2016-11-16 11:16:20 -03:00
.state('tabs.rate.rateApp', {
2016-11-11 17:05:06 -03:00
url: '/rateApp/:score',
2016-11-01 14:21:35 -03:00
views: {
2016-11-16 11:16:20 -03:00
'tab-home@tabs': {
2016-11-11 17:05:06 -03:00
controller: 'rateAppController',
templateUrl: 'views/feedback/rateApp.html'
2016-11-01 14:21:35 -03:00
}
},
customConfig: {
hideStatusBar: true
2016-11-01 14:21:35 -03:00
}
})
2016-11-15 17:38:48 -03:00
/*
*
* Buy or Sell Bitcoin
*
*/
2016-11-01 14:21:35 -03:00
.state('tabs.buyandsell', {
url: '/buyandsell',
views: {
'tab-home': {
templateUrl: 'views/buyandsell.html'
2016-09-16 14:46:25 -03:00
}
}
})
2016-09-16 14:46:25 -03:00
/*
*
* Glidera
*
*
*/
2016-09-16 14:46:25 -03:00
.state('tabs.buyandsell.glidera', {
2016-09-16 14:46:25 -03:00
url: '/glidera',
2016-08-24 11:33:43 -03:00
views: {
2016-09-16 14:46:25 -03:00
'tab-home@tabs': {
controller: 'glideraController',
controllerAs: 'glidera',
2016-08-24 11:33:43 -03:00
templateUrl: 'views/glidera.html'
}
}
})
2016-09-16 14:46:25 -03:00
.state('tabs.buyandsell.glidera.buy', {
url: '/buy',
2016-08-24 11:33:43 -03:00
views: {
2016-09-16 14:46:25 -03:00
'tab-home@tabs': {
controller: 'buyGlideraController',
controllerAs: 'buy',
2016-08-24 11:33:43 -03:00
templateUrl: 'views/buyGlidera.html'
}
}
})
2016-09-16 14:46:25 -03:00
.state('tabs.buyandsell.glidera.sell', {
url: '/sell',
2016-08-22 17:43:31 -03:00
views: {
2016-09-16 14:46:25 -03:00
'tab-home@tabs': {
controller: 'sellGlideraController',
controllerAs: 'sell',
2016-08-24 11:33:43 -03:00
templateUrl: 'views/sellGlidera.html'
2016-08-22 17:43:31 -03:00
}
}
2016-08-10 15:29:31 -03:00
})
2016-09-16 14:46:25 -03:00
.state('tabs.buyandsell.glidera.preferences', {
2016-08-22 17:43:31 -03:00
url: '/preferences',
views: {
2016-09-16 14:46:25 -03:00
'tab-home@tabs': {
controller: 'preferencesGlideraController',
2016-08-24 11:33:43 -03:00
templateUrl: 'views/preferencesGlidera.html'
2016-08-22 17:43:31 -03:00
}
}
2016-08-10 15:29:31 -03:00
})
2016-08-19 14:43:58 -03:00
/*
*
* Coinbase
*
*/
2016-08-19 14:43:58 -03:00
.state('coinbase', {
Feat/coinbase integration (#4012) * Oauth2 and first view * Connect with Coinbase using mobile * Buy and Sell through Coinbase * Fix buy * Receive and send bitcoin to Coinbase account * Receive bitcoin from Coinbase to Copay * Complete user and account information. Connection errors * Improves error handler * Removes console.log * Coinbase background color. Send to Coinbase form validation * Fix send from different wallet * Send and receive using Coinbase * Pagination activity * Fix Buy and Sell * One option in the sidebar to Buy and Sell * Native balance on Coinbase homepage * Rename receive and send * Auto-close window after authenticate * Reorder * Get payment methods * Fix when token expired * Fix token expired * Integration: sell and send to Coinbase * Store pending transaction before sell * Sell flow completed * Removing files * Fix sell * Fix sell * Fix sell * Sell completed * Buy bitcoin through coinbase * Buy auto * Currency set to USD * Select payment methods. Limits * Removes payment methods from preferences * Fix signs. Tx ordered by updated. Minor fixes * Removes console.log * Improving ux-language things * Fix selectedpaymentmethod if not verified * Set error if tx not found * Price sensitivity. Minor fixes * Adds coinbase api key to gitignore * Coinbase production ready * Fix sell in usd * Bug fixes * New Sensitivity step * Refresh token with a simple click * Refresh token * Refactor * Fix auto reconnect if token expired Signed-off-by: Gustavo Maximiliano Cortez <cmgustavo83@gmail.com> * Fix calls if token expired
2016-04-13 14:08:03 -03:00
url: '/coinbase',
templateUrl: 'views/coinbase.html'
Feat/coinbase integration (#4012) * Oauth2 and first view * Connect with Coinbase using mobile * Buy and Sell through Coinbase * Fix buy * Receive and send bitcoin to Coinbase account * Receive bitcoin from Coinbase to Copay * Complete user and account information. Connection errors * Improves error handler * Removes console.log * Coinbase background color. Send to Coinbase form validation * Fix send from different wallet * Send and receive using Coinbase * Pagination activity * Fix Buy and Sell * One option in the sidebar to Buy and Sell * Native balance on Coinbase homepage * Rename receive and send * Auto-close window after authenticate * Reorder * Get payment methods * Fix when token expired * Fix token expired * Integration: sell and send to Coinbase * Store pending transaction before sell * Sell flow completed * Removing files * Fix sell * Fix sell * Fix sell * Sell completed * Buy bitcoin through coinbase * Buy auto * Currency set to USD * Select payment methods. Limits * Removes payment methods from preferences * Fix signs. Tx ordered by updated. Minor fixes * Removes console.log * Improving ux-language things * Fix selectedpaymentmethod if not verified * Set error if tx not found * Price sensitivity. Minor fixes * Adds coinbase api key to gitignore * Coinbase production ready * Fix sell in usd * Bug fixes * New Sensitivity step * Refresh token with a simple click * Refresh token * Refactor * Fix auto reconnect if token expired Signed-off-by: Gustavo Maximiliano Cortez <cmgustavo83@gmail.com> * Fix calls if token expired
2016-04-13 14:08:03 -03:00
})
.state('preferencesCoinbase', {
url: '/preferencesCoinbase',
templateUrl: 'views/preferencesCoinbase.html'
Feat/coinbase integration (#4012) * Oauth2 and first view * Connect with Coinbase using mobile * Buy and Sell through Coinbase * Fix buy * Receive and send bitcoin to Coinbase account * Receive bitcoin from Coinbase to Copay * Complete user and account information. Connection errors * Improves error handler * Removes console.log * Coinbase background color. Send to Coinbase form validation * Fix send from different wallet * Send and receive using Coinbase * Pagination activity * Fix Buy and Sell * One option in the sidebar to Buy and Sell * Native balance on Coinbase homepage * Rename receive and send * Auto-close window after authenticate * Reorder * Get payment methods * Fix when token expired * Fix token expired * Integration: sell and send to Coinbase * Store pending transaction before sell * Sell flow completed * Removing files * Fix sell * Fix sell * Fix sell * Sell completed * Buy bitcoin through coinbase * Buy auto * Currency set to USD * Select payment methods. Limits * Removes payment methods from preferences * Fix signs. Tx ordered by updated. Minor fixes * Removes console.log * Improving ux-language things * Fix selectedpaymentmethod if not verified * Set error if tx not found * Price sensitivity. Minor fixes * Adds coinbase api key to gitignore * Coinbase production ready * Fix sell in usd * Bug fixes * New Sensitivity step * Refresh token with a simple click * Refresh token * Refactor * Fix auto reconnect if token expired Signed-off-by: Gustavo Maximiliano Cortez <cmgustavo83@gmail.com> * Fix calls if token expired
2016-04-13 14:08:03 -03:00
})
.state('buyCoinbase', {
url: '/buycoinbase',
templateUrl: 'views/buyCoinbase.html'
Feat/coinbase integration (#4012) * Oauth2 and first view * Connect with Coinbase using mobile * Buy and Sell through Coinbase * Fix buy * Receive and send bitcoin to Coinbase account * Receive bitcoin from Coinbase to Copay * Complete user and account information. Connection errors * Improves error handler * Removes console.log * Coinbase background color. Send to Coinbase form validation * Fix send from different wallet * Send and receive using Coinbase * Pagination activity * Fix Buy and Sell * One option in the sidebar to Buy and Sell * Native balance on Coinbase homepage * Rename receive and send * Auto-close window after authenticate * Reorder * Get payment methods * Fix when token expired * Fix token expired * Integration: sell and send to Coinbase * Store pending transaction before sell * Sell flow completed * Removing files * Fix sell * Fix sell * Fix sell * Sell completed * Buy bitcoin through coinbase * Buy auto * Currency set to USD * Select payment methods. Limits * Removes payment methods from preferences * Fix signs. Tx ordered by updated. Minor fixes * Removes console.log * Improving ux-language things * Fix selectedpaymentmethod if not verified * Set error if tx not found * Price sensitivity. Minor fixes * Adds coinbase api key to gitignore * Coinbase production ready * Fix sell in usd * Bug fixes * New Sensitivity step * Refresh token with a simple click * Refresh token * Refactor * Fix auto reconnect if token expired Signed-off-by: Gustavo Maximiliano Cortez <cmgustavo83@gmail.com> * Fix calls if token expired
2016-04-13 14:08:03 -03:00
})
.state('sellCoinbase', {
url: '/sellcoinbase',
templateUrl: 'views/sellCoinbase.html'
Feat/coinbase integration (#4012) * Oauth2 and first view * Connect with Coinbase using mobile * Buy and Sell through Coinbase * Fix buy * Receive and send bitcoin to Coinbase account * Receive bitcoin from Coinbase to Copay * Complete user and account information. Connection errors * Improves error handler * Removes console.log * Coinbase background color. Send to Coinbase form validation * Fix send from different wallet * Send and receive using Coinbase * Pagination activity * Fix Buy and Sell * One option in the sidebar to Buy and Sell * Native balance on Coinbase homepage * Rename receive and send * Auto-close window after authenticate * Reorder * Get payment methods * Fix when token expired * Fix token expired * Integration: sell and send to Coinbase * Store pending transaction before sell * Sell flow completed * Removing files * Fix sell * Fix sell * Fix sell * Sell completed * Buy bitcoin through coinbase * Buy auto * Currency set to USD * Select payment methods. Limits * Removes payment methods from preferences * Fix signs. Tx ordered by updated. Minor fixes * Removes console.log * Improving ux-language things * Fix selectedpaymentmethod if not verified * Set error if tx not found * Price sensitivity. Minor fixes * Adds coinbase api key to gitignore * Coinbase production ready * Fix sell in usd * Bug fixes * New Sensitivity step * Refresh token with a simple click * Refresh token * Refactor * Fix auto reconnect if token expired Signed-off-by: Gustavo Maximiliano Cortez <cmgustavo83@gmail.com> * Fix calls if token expired
2016-04-13 14:08:03 -03:00
})
2016-08-24 11:33:43 -03:00
/*
*
* Gift Cards
*
*/
.state('tabs.giftcards', {
url: '/giftcards',
abstract: true
})
/*
*
* Amazon.com Gift Card
*
*/
2016-09-16 16:25:45 -03:00
.state('tabs.giftcards.amazon', {
url: '/amazon',
2016-08-19 18:03:25 -03:00
views: {
2016-09-16 16:25:45 -03:00
'tab-home@tabs': {
controller: 'amazonController',
2016-08-19 18:03:25 -03:00
templateUrl: 'views/amazon.html'
}
}
})
2016-09-16 16:25:45 -03:00
.state('tabs.giftcards.amazon.buy', {
2016-08-19 18:03:25 -03:00
url: '/buy',
views: {
2016-09-16 16:25:45 -03:00
'tab-home@tabs': {
controller: 'buyAmazonController',
controllerAs: 'buy',
2016-08-19 18:03:25 -03:00
templateUrl: 'views/buyAmazon.html'
}
}
2016-08-24 11:33:43 -03:00
})
/*
*
* BitPay Card
*
*/
2016-08-24 11:33:43 -03:00
2016-10-22 17:43:05 -03:00
.state('tabs.bitpayCardIntro', {
2016-10-06 19:23:39 -03:00
url: '/bitpay-card-intro/:secret/:email/:otp',
2016-10-04 12:06:06 -03:00
views: {
'tab-home@tabs': {
controller: 'bitpayCardIntroController',
templateUrl: 'views/bitpayCardIntro.html'
}
}
})
.state('tabs.bitpayCard', {
2016-10-06 19:23:39 -03:00
url: '/bitpay-card/:id',
2016-08-24 11:33:43 -03:00
views: {
2016-09-28 11:08:08 -03:00
'tab-home@tabs': {
controller: 'bitpayCardController',
controllerAs: 'bitpayCard',
2016-08-24 11:33:43 -03:00
templateUrl: 'views/bitpayCard.html'
}
}
})
.state('tabs.bitpayCard.amount', {
2016-10-06 19:23:39 -03:00
url: '/amount/:cardId/:toName',
views: {
'tab-home@tabs': {
controller: 'amountController',
templateUrl: 'views/amount.html'
}
}
})
.state('tabs.bitpayCard.confirm', {
2016-10-26 17:21:44 -04:00
url: '/confirm/:cardId/:toAddress/:toName/:toAmount/:toEmail/:description',
views: {
'tab-home@tabs': {
controller: 'confirmController',
templateUrl: 'views/confirm.html'
}
2016-10-26 17:21:44 -04:00
},
2016-10-31 16:46:45 -03:00
params: {
paypro: null
}
})
2016-09-28 11:08:08 -03:00
.state('tabs.bitpayCard.preferences', {
2016-08-24 11:33:43 -03:00
url: '/preferences',
views: {
2016-09-28 11:08:08 -03:00
'tab-home@tabs': {
controller: 'preferencesBitpayCardController',
2016-08-24 11:33:43 -03:00
templateUrl: 'views/preferencesBitpayCard.html'
}
}
});
})
2016-10-18 15:27:09 -03:00
.run(function($rootScope, $state, $location, $log, $timeout, $ionicHistory, $ionicPlatform, $window, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService, scannerService) {
2015-12-10 09:59:56 -03:00
2016-08-25 12:24:25 -03:00
uxLanguage.init();
$ionicPlatform.ready(function() {
2016-06-06 12:24:07 -03:00
if (platformInfo.isCordova) {
2015-12-10 15:55:08 -03:00
if (screen.width < 768)
screen.lockOrientation('portrait');
2016-08-17 15:23:17 -03:00
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
2016-08-17 15:23:17 -03:00
cordova.plugins.Keyboard.disableScroll(true);
}
2016-06-28 15:18:55 -03:00
2016-09-12 16:24:02 -03:00
window.addEventListener('native.keyboardshow', function() {
document.body.classList.add('keyboard-open');
2016-09-12 16:24:02 -03:00
});
2016-08-22 14:16:41 -03:00
$ionicPlatform.registerBackButtonAction(function(e) {
2015-12-10 15:55:08 -03:00
//from root tabs view
2016-10-10 17:51:36 -03:00
var matchHome = $ionicHistory.currentStateName() == 'tabs.home' ? true : false;
var matchReceive = $ionicHistory.currentStateName() == 'tabs.receive' ? true : false;
var matchScan = $ionicHistory.currentStateName() == 'tabs.scan' ? true : false;
var matchSend = $ionicHistory.currentStateName() == 'tabs.send' ? true : false;
var matchSettings = $ionicHistory.currentStateName() == 'tabs.settings' ? true : false;
var fromTabs = matchHome | matchReceive | matchScan | matchSend | matchSettings;
//onboarding with no back views
2016-10-10 17:51:36 -03:00
var matchWelcome = $ionicHistory.currentStateName() == 'onboarding.welcome' ? true : false;
var matchCollectEmail = $ionicHistory.currentStateName() == 'onboarding.collectEmail' ? true : false;
var matchBackupRequest = $ionicHistory.currentStateName() == 'onboarding.backupRequest' ? true : false;
var matchNotifications = $ionicHistory.currentStateName() == 'onboarding.notifications' ? true : false;
var fromOnboarding = matchCollectEmail | matchBackupRequest | matchNotifications | matchWelcome;
if ($ionicHistory.backView() && !fromTabs && !fromOnboarding) {
2016-09-05 11:04:40 -03:00
$ionicHistory.goBack();
} else
if ($rootScope.backButtonPressedOnceToExit) {
ionic.Platform.exitApp();
2016-09-05 11:04:40 -03:00
} else {
$rootScope.backButtonPressedOnceToExit = true;
window.plugins.toast.showShortBottom(gettextCatalog.getString('Press again to exit'));
$timeout(function() {
2016-09-05 11:04:40 -03:00
$rootScope.backButtonPressedOnceToExit = false;
}, 3000);
2016-09-05 11:04:40 -03:00
}
e.preventDefault();
2016-09-02 13:00:38 -03:00
}, 101);
$ionicPlatform.on('pause', function() {
// Nothing to do
});
$ionicPlatform.on('resume', function() {
// Nothing to do
});
$ionicPlatform.on('menubutton', function() {
window.location = '#/preferences';
});
}
2016-08-16 18:38:18 -03:00
2016-11-11 18:11:52 -05:00
$log.info('Verifying storage...');
storageService.verify(function(err) {
2016-08-16 18:38:18 -03:00
if (err) {
2016-11-11 18:11:52 -05:00
$log.error('Storage failed to verify: ' + err);
// TODO - what next?
} else {
$log.info('Storage OK');
}
$log.info('Init profile...');
// Try to open local profile
profileService.loadAndBindProfile(function(err) {
$ionicHistory.nextViewOptions({
disableAnimate: true
});
if (err) {
if (err.message && err.message.match('NOPROFILE')) {
$log.debug('No profile... redirecting');
$state.go('onboarding.welcome');
2016-11-11 18:11:52 -05:00
} else if (err.message && err.message.match('NONAGREEDDISCLAIMER')) {
if (lodash.isEmpty(profileService.getWallets())) {
$log.debug('No wallets and no disclaimer... redirecting');
$state.go('onboarding.welcome');
} else {
$log.debug('Display disclaimer... redirecting');
$state.go('onboarding.disclaimer', {
resume: true
});
}
} else {
2016-11-11 18:11:52 -05:00
throw new Error(err); // TODO
}
2016-08-16 18:38:18 -03:00
} else {
2016-11-11 18:11:52 -05:00
profileService.storeProfileIfDirty();
$log.debug('Profile loaded ... Starting UX.');
scannerService.gentleInitialize();
$state.go('tabs.home');
2016-08-16 18:38:18 -03:00
}
2016-11-11 18:11:52 -05:00
// After everything have been loaded, initialize handler URL
$timeout(function() {
openURLService.init();
}, 1000);
});
2016-08-16 18:38:18 -03:00
});
2016-08-25 16:31:47 -03:00
});
2015-03-06 12:00:10 -03:00
if (platformInfo.isNW) {
2015-05-28 10:52:33 -03:00
var gui = require('nw.gui');
var win = gui.Window.get();
2015-07-13 13:21:47 -03:00
var nativeMenuBar = new gui.Menu({
type: "menubar"
});
2015-05-28 12:14:04 -03:00
try {
2016-10-18 15:27:09 -03:00
nativeMenuBar.createMacBuiltin($window.appConfig.nameCase);
2015-07-13 13:21:47 -03:00
} catch (e) {
2015-05-28 12:14:04 -03:00
$log.debug('This is not OSX');
}
2015-05-28 10:52:33 -03:00
win.menu = nativeMenuBar;
}
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
$log.debug('Route change from:', fromState.name || '-', ' to:', toState.name);
$log.debug(' toParams:' + JSON.stringify(toParams || {}));
$log.debug(' fromParams:' + JSON.stringify(fromParams || {}));
2016-11-16 13:06:02 -05:00
});
2016-11-16 13:06:02 -05:00
$rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
2016-11-16 13:31:18 -05:00
if($window.StatusBar) {
if(toState.customConfig && toState.customConfig.hideStatusBar) {
$window.StatusBar.hide();
} else {
$window.StatusBar.show();
}
}
2015-03-06 12:00:10 -03:00
});
});