Merge branch 'ref/design' of github.com:matiu/copay into ref/design
This commit is contained in:
commit
bc4f7e841e
15 changed files with 235 additions and 429 deletions
|
|
@ -5,8 +5,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
var self = this;
|
||||
var client;
|
||||
|
||||
var network = 'livenet';
|
||||
self.sandbox = network == 'testnet' ? true : false;
|
||||
self.sandbox = bitpayCardService.getEnvironment() == 'testnet' ? true : false;
|
||||
|
||||
if (platformInfo.isCordova && StatusBar.isVisible) {
|
||||
StatusBar.backgroundColorByHexString("#293C92");
|
||||
|
|
@ -71,7 +70,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
this.update = function() {
|
||||
var dateRange = setDateRange($scope.dateRange);
|
||||
self.loadingSession = true;
|
||||
bitpayCardService.setCredentials(network);
|
||||
bitpayCardService.isAuthenticated(function(err, bpSession) {
|
||||
self.loadingSession = false;
|
||||
if (err) {
|
||||
|
|
@ -110,14 +108,16 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
|||
$scope.dateRange = 'last30Days';
|
||||
self.update();
|
||||
|
||||
self.allWallets = profileService.getWallets(network);
|
||||
client = profileService.focusedClient;
|
||||
|
||||
if (!client) return;
|
||||
var network = bitpayCardService.getEnvironment();
|
||||
self.allWallets = profileService.getWallets({
|
||||
network: network,
|
||||
n: 1,
|
||||
onlyComplete: true
|
||||
});
|
||||
|
||||
if (lodash.isEmpty(self.allWallets)) return;
|
||||
|
||||
if (client.credentials.network != network) return;
|
||||
client = self.allWallets[0];
|
||||
|
||||
if (client.credentials.n > 1)
|
||||
self.isMultisigWallet = true;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('bitpayCardConfirmationController', function($scope, $timeout, go, bitpayCardService) {
|
||||
angular.module('copayApp.controllers').controller('bitpayCardConfirmationController', function($scope, $timeout, $state, bitpayCardService) {
|
||||
|
||||
$scope.ok = function() {
|
||||
bitpayCardService.logout(function() {
|
||||
go.path('bitpayCard');
|
||||
$state.go('bitpayCard.main');
|
||||
});
|
||||
$scope.cancel();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo) {
|
||||
var self = this;
|
||||
|
||||
self.glideraEnabled = configService.getSync().glidera.enabled;
|
||||
self.setWallets = function() {
|
||||
$scope.wallets = profileService.getWallets();
|
||||
};
|
||||
|
||||
|
||||
var setPendingTxps = function(txps) {
|
||||
|
|
@ -144,14 +146,13 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
});
|
||||
});
|
||||
|
||||
var config = configService.getSync().wallet;
|
||||
|
||||
var GLIDERA_LOCK_TIME = 6 * 60 * 60;
|
||||
|
||||
var glideraActive = true; // TODO TODO TODO
|
||||
// isGlidera flag is a security measure so glidera status is not
|
||||
// only determined by the tx.message
|
||||
$scope.openTxpModal = function(tx) {
|
||||
var config = configService.getSync().wallet;
|
||||
var scope = $rootScope.$new(true);
|
||||
scope.tx = tx;
|
||||
scope.wallet = tx.wallet;
|
||||
|
|
@ -167,12 +168,12 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
});
|
||||
};
|
||||
|
||||
$scope.init = function() {
|
||||
configService.whenAvailable(function() {
|
||||
var config = configService.getSync();
|
||||
var isWindowsPhoneApp = platformInfo.isWP && isCordova;
|
||||
var glideraEnabled = config.glidera.enabled;
|
||||
var coinbaseEnabled = config.coinbase.enabled;
|
||||
var isWindowsPhoneApp = platformInfo.isWP && isCordova;
|
||||
$scope.buyAndSellEnabled = !isWindowsPhoneApp && (glideraEnabled || coinbaseEnabled);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $ionicModal, $log, $timeout, addressbookService, profileService, configService, lodash, $state, walletService) {
|
||||
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $ionicModal, $log, $timeout, addressbookService, profileService, lodash, $state, walletService) {
|
||||
|
||||
var originalList;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
function selectText(element) {
|
||||
var doc = document;
|
||||
if (doc.body.createTextRange) { // ms
|
||||
var range = doc.body.createTextRange();
|
||||
range.moveToElementText(element);
|
||||
range.select();
|
||||
} else if (window.getSelection) {
|
||||
var selection = window.getSelection();
|
||||
var range = doc.createRange();
|
||||
range.selectNodeContents(element);
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
|
||||
}
|
||||
}
|
||||
angular.module('copayApp.directives')
|
||||
.directive('validAddress', ['$rootScope', 'bitcore',
|
||||
.directive('validAddress', ['$rootScope', 'bitcore',
|
||||
function($rootScope, bitcore) {
|
||||
return {
|
||||
require: 'ngModel',
|
||||
|
|
@ -24,10 +8,6 @@ angular.module('copayApp.directives')
|
|||
var URI = bitcore.URI;
|
||||
var Address = bitcore.Address
|
||||
var validator = function(value) {
|
||||
var networkName = attrs.networkName;
|
||||
|
||||
if (!networkName)
|
||||
throw 'validAddress should provide network name';
|
||||
|
||||
// Regular url
|
||||
if (/^https?:\/\//.test(value)) {
|
||||
|
|
@ -37,13 +17,14 @@ angular.module('copayApp.directives')
|
|||
|
||||
// Bip21 uri
|
||||
if (/^bitcoin:/.test(value)) {
|
||||
var uri, isAddressValid;
|
||||
var uri, isAddressValidLivenet, isAddressValidTestnet;
|
||||
var isUriValid = URI.isValid(value);
|
||||
if (isUriValid) {
|
||||
uri = new URI(value);
|
||||
isAddressValid = Address.isValid(uri.address.toString(), networkName)
|
||||
isAddressValidLivenet = Address.isValid(uri.address.toString(), 'livenet')
|
||||
isAddressValidTestnet = Address.isValid(uri.address.toString(), 'testnet')
|
||||
}
|
||||
ctrl.$setValidity('validAddress', isUriValid && isAddressValid);
|
||||
ctrl.$setValidity('validAddress', isUriValid && (isAddressValidLivenet || isAddressValidTestnet));
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
@ -53,34 +34,13 @@ angular.module('copayApp.directives')
|
|||
}
|
||||
|
||||
// Regular Address
|
||||
ctrl.$setValidity('validAddress', Address.isValid(value, networkName));
|
||||
var regularAddressLivenet = Address.isValid(value, 'livenet');
|
||||
var regularAddressTestnet = Address.isValid(value, 'testnet');
|
||||
ctrl.$setValidity('validAddress', (regularAddressLivenet || regularAddressTestnet));
|
||||
return value;
|
||||
};
|
||||
|
||||
|
||||
ctrl.$parsers.unshift(validator);
|
||||
ctrl.$formatters.unshift(validator);
|
||||
}
|
||||
};
|
||||
}
|
||||
])
|
||||
.directive('validUrl', [
|
||||
|
||||
function() {
|
||||
return {
|
||||
require: 'ngModel',
|
||||
link: function(scope, elem, attrs, ctrl) {
|
||||
var validator = function(value) {
|
||||
// Regular url
|
||||
if (/^https?:\/\//.test(value)) {
|
||||
ctrl.$setValidity('validUrl', true);
|
||||
return value;
|
||||
} else {
|
||||
ctrl.$setValidity('validUrl', false);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
ctrl.$parsers.unshift(validator);
|
||||
ctrl.$formatters.unshift(validator);
|
||||
}
|
||||
|
|
@ -143,23 +103,6 @@ angular.module('copayApp.directives')
|
|||
}
|
||||
};
|
||||
})
|
||||
.directive('loading', function() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function($scope, element, attr) {
|
||||
var a = element.html();
|
||||
var text = attr.loading;
|
||||
element.on('click', function() {
|
||||
element.html('<i class="size-21 fi-bitcoin-circle icon-rotate spinner"></i> ' + text + '...');
|
||||
});
|
||||
$scope.$watch('loading', function(val) {
|
||||
if (!val) {
|
||||
element.html(a);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.directive('ngFileSelect', function() {
|
||||
return {
|
||||
link: function($scope, el) {
|
||||
|
|
@ -187,147 +130,6 @@ angular.module('copayApp.directives')
|
|||
};
|
||||
}
|
||||
])
|
||||
.directive('highlightOnChange', function() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function(scope, element, attrs) {
|
||||
scope.$watch(attrs.highlightOnChange, function(newValue, oldValue) {
|
||||
element.addClass('highlight');
|
||||
setTimeout(function() {
|
||||
element.removeClass('highlight');
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.directive('checkStrength', function() {
|
||||
return {
|
||||
replace: false,
|
||||
restrict: 'EACM',
|
||||
require: 'ngModel',
|
||||
link: function(scope, element, attrs) {
|
||||
|
||||
var MIN_LENGTH = 8;
|
||||
var MESSAGES = ['Very Weak', 'Very Weak', 'Weak', 'Medium', 'Strong', 'Very Strong'];
|
||||
var COLOR = ['#dd514c', '#dd514c', '#faa732', '#faa732', '#16A085', '#16A085'];
|
||||
|
||||
function evaluateMeter(password) {
|
||||
var passwordStrength = 0;
|
||||
var text;
|
||||
if (password.length > 0) passwordStrength = 1;
|
||||
if (password.length >= MIN_LENGTH) {
|
||||
if ((password.match(/[a-z]/)) && (password.match(/[A-Z]/))) {
|
||||
passwordStrength++;
|
||||
} else {
|
||||
text = ', add mixed case';
|
||||
}
|
||||
if (password.match(/\d+/)) {
|
||||
passwordStrength++;
|
||||
} else {
|
||||
if (!text) text = ', add numerals';
|
||||
}
|
||||
if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)) {
|
||||
passwordStrength++;
|
||||
} else {
|
||||
if (!text) text = ', add punctuation';
|
||||
}
|
||||
if (password.length > 12) {
|
||||
passwordStrength++;
|
||||
} else {
|
||||
if (!text) text = ', add characters';
|
||||
}
|
||||
} else {
|
||||
text = ', that\'s short';
|
||||
}
|
||||
if (!text) text = '';
|
||||
|
||||
return {
|
||||
strength: passwordStrength,
|
||||
message: MESSAGES[passwordStrength] + text,
|
||||
color: COLOR[passwordStrength]
|
||||
}
|
||||
}
|
||||
|
||||
scope.$watch(attrs.ngModel, function(newValue, oldValue) {
|
||||
if (newValue && newValue !== '') {
|
||||
var info = evaluateMeter(newValue);
|
||||
scope[attrs.checkStrength] = info;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
})
|
||||
.directive('showFocus', function($timeout) {
|
||||
return function(scope, element, attrs) {
|
||||
scope.$watch(attrs.showFocus,
|
||||
function(newValue) {
|
||||
$timeout(function() {
|
||||
newValue && element[0].focus();
|
||||
});
|
||||
}, true);
|
||||
};
|
||||
})
|
||||
.directive('match', function() {
|
||||
return {
|
||||
require: 'ngModel',
|
||||
restrict: 'A',
|
||||
scope: {
|
||||
match: '='
|
||||
},
|
||||
link: function(scope, elem, attrs, ctrl) {
|
||||
scope.$watch(function() {
|
||||
return (ctrl.$pristine && angular.isUndefined(ctrl.$modelValue)) || scope.match === ctrl.$modelValue;
|
||||
}, function(currentValue) {
|
||||
ctrl.$setValidity('match', currentValue);
|
||||
});
|
||||
}
|
||||
};
|
||||
})
|
||||
.directive('clipCopy', function() {
|
||||
return {
|
||||
restrict: 'A',
|
||||
scope: {
|
||||
clipCopy: '=clipCopy'
|
||||
},
|
||||
link: function(scope, elm) {
|
||||
// TODO this does not work (FIXME)
|
||||
elm.attr('tooltip', 'Press Ctrl+C to Copy');
|
||||
elm.attr('tooltip-placement', 'top');
|
||||
|
||||
elm.bind('click', function() {
|
||||
selectText(elm[0]);
|
||||
});
|
||||
}
|
||||
};
|
||||
})
|
||||
.directive('menuToggle', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
templateUrl: 'views/includes/menu-toggle.html'
|
||||
}
|
||||
})
|
||||
.directive('logo', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
width: "@",
|
||||
negative: "="
|
||||
},
|
||||
controller: function($scope) {
|
||||
$scope.logo_url = $scope.negative ? 'img/logo-negative.svg' : 'img/logo.svg';
|
||||
},
|
||||
replace: true,
|
||||
template: '<img ng-src="{{ logo_url }}" alt="Copay">'
|
||||
}
|
||||
})
|
||||
.directive('availableBalance', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
templateUrl: 'views/includes/available-balance.html'
|
||||
}
|
||||
})
|
||||
.directive('ignoreMouseWheel', function($rootScope, $timeout) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*
|
||||
*/
|
||||
|
||||
.state('disclaimer', {
|
||||
.state('disclaimer', {
|
||||
url: '/disclaimer',
|
||||
templateUrl: 'views/disclaimer.html',
|
||||
})
|
||||
|
|
@ -557,13 +557,26 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*
|
||||
*/
|
||||
|
||||
.state('bitpayCard', {
|
||||
url: '/bitpay-card',
|
||||
templateUrl: 'views/bitpayCard.html'
|
||||
.state('bitpayCard', {
|
||||
url: '/bitpayCard',
|
||||
abstract: true,
|
||||
template: '<ion-nav-view name="bitpayCard"></ion-nav-view>'
|
||||
})
|
||||
.state('preferencesBitpayCard', {
|
||||
url: '/preferences-bitpay-card',
|
||||
templateUrl: 'views/preferencesBitpayCard.html'
|
||||
.state('bitpayCard.main', {
|
||||
url: '/main',
|
||||
views: {
|
||||
'bitpayCard': {
|
||||
templateUrl: 'views/bitpayCard.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('bitpayCard.preferences', {
|
||||
url: '/preferences',
|
||||
views: {
|
||||
'bitpayCard': {
|
||||
templateUrl: 'views/preferencesBitpayCard.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -5,9 +5,13 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
var credentials = {};
|
||||
var bpSession = {};
|
||||
|
||||
root.setCredentials = function(network) {
|
||||
credentials.NETWORK = network;
|
||||
if (network == 'testnet') {
|
||||
var _setCredentials = function() {
|
||||
/*
|
||||
* Development: 'testnet'
|
||||
* Production: 'livenet'
|
||||
*/
|
||||
credentials.NETWORK = 'livenet';
|
||||
if (credentials.NETWORK == 'testnet') {
|
||||
credentials.BITPAY_API_URL = 'https://test.bitpay.com';
|
||||
}
|
||||
else {
|
||||
|
|
@ -16,6 +20,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
};
|
||||
|
||||
var _getUser = function(cb) {
|
||||
_setCredentials();
|
||||
storageService.getBitpayCard(credentials.NETWORK, function(err, user) {
|
||||
if (err) return cb(err);
|
||||
if (lodash.isString(user)) {
|
||||
|
|
@ -26,6 +31,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
};
|
||||
|
||||
var _setUser = function(user, cb) {
|
||||
_setCredentials();
|
||||
user = JSON.stringify(user);
|
||||
storageService.setBitpayCard(credentials.NETWORK, user, function(err) {
|
||||
return cb(err);
|
||||
|
|
@ -33,6 +39,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
};
|
||||
|
||||
var _getSession = function(cb) {
|
||||
_setCredentials();
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: credentials.BITPAY_API_URL + '/visa-api/session',
|
||||
|
|
@ -50,6 +57,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
};
|
||||
|
||||
var _getBitPay = function(endpoint) {
|
||||
_setCredentials();
|
||||
return {
|
||||
method: 'GET',
|
||||
url: credentials.BITPAY_API_URL + endpoint,
|
||||
|
|
@ -61,6 +69,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
};
|
||||
|
||||
var _postBitPay = function(endpoint, data) {
|
||||
_setCredentials();
|
||||
return {
|
||||
method: 'POST',
|
||||
url: credentials.BITPAY_API_URL + endpoint,
|
||||
|
|
@ -72,6 +81,11 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
};
|
||||
};
|
||||
|
||||
root.getEnvironment = function() {
|
||||
_setCredentials();
|
||||
return credentials.NETWORK;
|
||||
};
|
||||
|
||||
root.topUp = function(data, cb) {
|
||||
var dataSrc = {
|
||||
amount: data.amount,
|
||||
|
|
@ -173,6 +187,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http,
|
|||
};
|
||||
|
||||
root.logout = function(cb) {
|
||||
_setCredentials();
|
||||
storageService.removeBitpayCard(credentials.NETWORK, function(err) {
|
||||
$http(_getBitPay('/visa-api/logout')).then(function(data) {
|
||||
$log.info('BitPay Logout: SUCCESS');
|
||||
|
|
|
|||
|
|
@ -955,3 +955,13 @@ input[type="number"] {
|
|||
.calculator .button-calc .columns { padding: 20px; }
|
||||
.calculator .header-calc { top: 18%; }
|
||||
}
|
||||
|
||||
/* Turn Off Number Input Spinners */
|
||||
|
||||
input[type=number] {
|
||||
&::-webkit-inner-spin-button, &::-webkit-outer-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue