Merge pull request #60 from cmgustavo/ref/design-17

Ref/design 17
This commit is contained in:
Matias Alejo Garcia 2016-09-05 18:37:03 -03:00 committed by GitHub
commit 774aaec8ca
41 changed files with 314 additions and 299 deletions

View file

@ -1,15 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('amazonController',
function($scope, $timeout, $ionicModal, $log, lodash, bwcError, amazonService, platformInfo, nodeWebkit, popupService) {
function($scope, $timeout, $ionicModal, $log, lodash, bwcError, amazonService, platformInfo, externalLinkService, popupService) {
$scope.openExternalLink = function(url, target) {
if (platformInfo.isNW) {
nodeWebkit.openExternalLink(url);
} else {
target = target || '_blank';
var ref = window.open(url, target, 'location=no');
}
externalLinkService.open(url, target);
};
this.init = function() {

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('buyAmazonController',
function($scope, $log, $timeout, $state, lodash, profileService, bwcError, gettextCatalog, configService, walletService, amazonService, ongoingProcess, platformInfo, nodeWebkit, popupService) {
function($scope, $log, $timeout, $state, lodash, profileService, bwcError, gettextCatalog, configService, walletService, amazonService, ongoingProcess, platformInfo, externalLinkService, popupService) {
var self = this;
var wallet;
@ -16,12 +16,7 @@ angular.module('copayApp.controllers').controller('buyAmazonController',
});
$scope.openExternalLink = function(url, target) {
if (platformInfo.isNW) {
nodeWebkit.openExternalLink(url);
} else {
target = target || '_blank';
var ref = window.open(url, target, 'location=no');
}
externalLinkService.open(url, target);
};
this.init = function() {

View file

@ -1,15 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('glideraController',
function($scope, $timeout, $ionicModal, $log, storageService, glideraService, ongoingProcess, platformInfo, nodeWebkit, popupService, gettextCatalog) {
function($scope, $timeout, $ionicModal, $log, storageService, glideraService, ongoingProcess, platformInfo, externalLinkService, popupService, gettextCatalog) {
$scope.openExternalLink = function(url, target) {
if (platformInfo.isNW) {
nodeWebkit.openExternalLink(url);
} else {
target = target || '_blank';
var ref = window.open(url, target, 'location=no');
}
externalLinkService.open(url, target);
};
$scope.init = function(accessToken) {

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('txDetailsController', function($rootScope, $log, $scope, $filter, $stateParams, $ionicPopup, gettextCatalog, profileService, configService, lodash, txFormatService, platformInfo) {
angular.module('copayApp.controllers').controller('txDetailsController', function($rootScope, $log, $scope, $filter, $stateParams, $ionicPopup, gettextCatalog, profileService, configService, lodash, txFormatService, platformInfo, externalLinkService) {
var self = $scope.self;
var wallet = profileService.getWallet($stateParams.walletId);
@ -81,12 +81,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
};
$scope.openExternalLink = function(url, target) {
if (platformInfo.isNW) {
nodeWebkit.openExternalLink(url);
} else {
target = target || '_blank';
var ref = window.open(url, target, 'location=no');
}
externalLinkService.open(url, target);
};
$scope.getShortNetworkName = function() {

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('termsController', function($scope, $log, $state, uxLanguage, profileService) {
angular.module('copayApp.controllers').controller('termsController', function($scope, $log, $state, uxLanguage, profileService, externalLinkService) {
$scope.lang = uxLanguage.currentLanguage;
$scope.confirm = function() {
@ -12,4 +12,8 @@ angular.module('copayApp.controllers').controller('termsController', function($s
});
};
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
};
});

View file

@ -2,7 +2,7 @@
angular.module('copayApp.controllers').controller('preferencesController',
function($scope, $rootScope, $timeout, $log, $stateParams, $ionicHistory, $ionicNavBarDelegate, gettextCatalog, configService, profileService, fingerprintService, walletService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Preferences'));
$ionicNavBarDelegate.title(gettextCatalog.getString('Wallet Preferences'));
var wallet = profileService.getWallet($stateParams.walletId);
var walletId = wallet.credentials.walletId;
$scope.wallet = wallet;
@ -14,9 +14,6 @@ angular.module('copayApp.controllers').controller('preferencesController',
return $ionicHistory.goBack();
var config = configService.getSync();
config.aliasFor = config.aliasFor || {};
$scope.alias = config.aliasFor[walletId] || wallet.credentials.walletName;
$scope.color = config.colorFor[walletId] || '#4A90E2';
$scope.encryptEnabled = walletService.isEncrypted(wallet);
if (wallet.isPrivKeyExternal)

View file

@ -1,9 +1,14 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesAbout',
function($scope, $window, $ionicNavBarDelegate, gettextCatalog) {
$ionicNavBarDelegate.title(gettextCatalog.getString('About Copay'));
function($scope, $window, $ionicNavBarDelegate, gettextCatalog, externalLinkService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('About') + ' ' + $window.appConfig.nameCase);
$scope.version = $window.version;
$scope.commitHash = $window.commitHash;
$scope.name = $window.appConfig.gitHubRepoName;
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
};
});

View file

@ -8,9 +8,8 @@ angular.module('copayApp.controllers').controller('preferencesAliasController',
var walletId = wallet.credentials.walletId;
var config = configService.getSync();
config.aliasFor = config.aliasFor || {};
$scope.walletName = wallet.credentials.walletName;
$scope.alias = config.aliasFor[walletId] || wallet.walletName;
$scope.alias = (config.aliasFor && config.aliasFor[walletId]) || wallet.walletName;
$scope.save = function() {
var opts = {

View file

@ -1,32 +1,17 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesDeleteWalletController',
function($scope, $ionicPopup, $stateParams, $ionicNavBarDelegate, $ionicHistory, gettextCatalog, lodash, profileService, $state, ongoingProcess, popupService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Delete Wallet'));
function($scope, $stateParams, $ionicNavBarDelegate, $ionicHistory, gettextCatalog, lodash, profileService, $state, ongoingProcess, popupService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Delete'));
var wallet = profileService.getWallet($stateParams.walletId);
$scope.alias = lodash.isEqual(wallet.name, wallet.credentials.walletName) ? null : wallet.name + ' ';
$scope.walletName = '[' + wallet.credentials.walletName + ']';
$scope.showDeletePopup = function() {
var popup = $ionicPopup.show({
template: '<span>' + gettextCatalog.getString('Are you sure you want to delete this wallet?') + '</span>',
title: gettextCatalog.getString('Confirm'),
buttons: [
{
text: gettextCatalog.getString('Cancel'),
onTap: function(e) {
popup.close();
}
},
{
text: gettextCatalog.getString('Accept'),
type: 'button-positive',
onTap: function(e) {
deleteWallet();
popup.close();
}
}
]
var title = gettextCatalog.getString('Warning!');
var message = gettextCatalog.getString('Are you sure you want to delete this wallet?');
popupService.showConfirm(title, message, function(res) {
if (res) deleteWallet();
});
};

View file

@ -1,12 +1,12 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesFeeController', function($scope, $timeout, $ionicHistory, $ionicNavBarDelegate, gettextCatalog, configService, feeService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Preferences fee'));
angular.module('copayApp.controllers').controller('preferencesFeeController', function($scope, $timeout, $ionicHistory, $ionicNavBarDelegate, gettextCatalog, configService, feeService, ongoingProcess) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Bitcoin Network Fee Policy'));
$scope.init = function() {
$scope.loading = true;
ongoingProcess.set('gettingFeeLevels', true);
feeService.getFeeLevels(function(levels) {
$scope.loading = false;
ongoingProcess.set('gettingFeeLevels', false);
$scope.feeOpts = feeService.feeOpts;
$scope.currentFeeLevel = feeService.getCurrentFeeLevel();
$scope.feeLevels = levels;
@ -29,7 +29,7 @@ angular.module('copayApp.controllers').controller('preferencesFeeController', fu
$ionicHistory.goBack();
$timeout(function() {
$scope.$apply();
}, 10);
}, 100);
});
};
});

View file

@ -3,15 +3,14 @@
angular.module('copayApp.controllers').controller('preferencesHistory',
function($scope, $log, $stateParams, $timeout, $ionicNavBarDelegate, gettextCatalog, storageService, $state, $ionicHistory, profileService, lodash) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Transaction History'));
var wallet = profileService.getWallet($stateParams.walletId);
var c = wallet.credentials;
$scope.wallet = profileService.getWallet($stateParams.walletId);
$scope.csvReady = false;
$scope.csvHistory = function(cb) {
var allTxs = [];
function getHistory(cb) {
storageService.getTxHistory(c.walletId, function(err, txs) {
storageService.getTxHistory($scope.wallet.id, function(err, txs) {
if (err) return cb(err);
var txsFromLocal = [];
@ -40,7 +39,7 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
var data = txs;
var satToBtc = 1 / 100000000;
$scope.csvContent = [];
$scope.csvFilename = 'Copay-' + ($scope.alias || $scope.walletName) + '.csv';
$scope.csvFilename = 'Copay-' + $scope.wallet.name + '.csv';
$scope.csvHeader = ['Date', 'Destination', 'Description', 'Amount', 'Currency', 'Txid', 'Creator', 'Copayers', 'Comment'];
var _amount, _note, _copayers, _creator, _comment;
@ -118,7 +117,7 @@ angular.module('copayApp.controllers').controller('preferencesHistory',
};
$scope.clearTransactionHistory = function() {
storageService.removeTxHistory(c.walletId, function(err) {
storageService.removeTxHistory($scope.wallet.id, function(err) {
if (err) {
$log.error(err);
return;

View file

@ -1,9 +1,13 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesLanguageController',
function($scope, $log, $ionicNavBarDelegate, $ionicHistory, gettextCatalog, configService, profileService, uxLanguage, walletService) {
function($scope, $log, $ionicNavBarDelegate, $ionicHistory, gettextCatalog, configService, profileService, uxLanguage, walletService, externalLinkService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Language'));
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
};
$scope.init = function() {
$scope.availableLanguages = uxLanguage.getLanguages();
$scope.currentLanguage = uxLanguage.getCurrentLanguage();

View file

@ -8,13 +8,19 @@ angular.module('copayApp.controllers').controller('preferencesLogs',
$scope.logs = historicLog.get();
}
$scope.sendLogs = function() {
var body = 'Copay Session Logs\n Be careful, this could contain sensitive private data\n\n';
body += '\n\n';
body += $scope.logs.map(function(v) {
$scope.prepare = function() {
var log = 'Copay Session Logs\n Be careful, this could contain sensitive private data\n\n';
log += '\n\n';
log += $scope.logs.map(function(v) {
return v.msg;
}).join('\n');
return log;
};
$scope.sendLogs = function() {
var body = $scope.prepare();
window.plugins.socialsharing.shareViaEmail(
body,
'Copay Logs',

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, $rootScope, $log, $ionicModal, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) {
angular.module('copayApp.controllers').controller('tabSettingsController', function($scope, $rootScope, $log, $ionicModal, $window, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) {
$scope.init = function() {
@ -9,6 +9,8 @@ angular.module('copayApp.controllers').controller('tabSettingsController', funct
var isWP = platformInfo.isWP;
var isIOS = platformInfo.isIOS;
$scope.appName = $window.appConfig.nameCase;
$scope.unitName = config.wallet.settings.unitName;
$scope.currentLanguageName = uxLanguage.getCurrentLanguageName();
$scope.selectedAlternative = {

View file

@ -1,7 +1,12 @@
'use strict';
angular.module('copayApp.controllers').controller('termOfUseController',
function($scope, uxLanguage, $ionicNavBarDelegate, gettextCatalog) {
$ionicNavBarDelegate.title(gettextCatalog.getString('About Copay'));
function($scope, $window, uxLanguage, $ionicNavBarDelegate, gettextCatalog, externalLinkService) {
$ionicNavBarDelegate.title(gettextCatalog.getString('Terms Of Use'));
$scope.lang = uxLanguage.currentLanguage;
$scope.disclaimerUrl = $window.appConfig.disclaimerUrl;
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
};
});

View file

@ -0,0 +1,8 @@
'use strict';
angular.module('copayApp.controllers').controller('translatorsController',
function($scope, externalLinkService) {
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
};
});

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $ionicNavBarDelegate, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService, $ionicPopup, txpModalService) {
angular.module('copayApp.controllers').controller('walletDetailsController', function($scope, $rootScope, $interval, $timeout, $filter, $log, $ionicModal, $ionicPopover, $ionicNavBarDelegate, $state, $stateParams, bwcError, profileService, lodash, configService, gettext, gettextCatalog, platformInfo, walletService, $ionicPopup, txpModalService, externalLinkService) {
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
@ -12,6 +12,9 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
var HISTORY_SHOW_LIMIT = 10;
$scope.txps = [];
$scope.openExternalLink = function(url, target) {
externalLinkService.open(url, target);
};
var setPendingTxps = function(txps) {
if (!txps) {

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.directives')
.directive('copyToClipboard', function(platformInfo, nodeWebkit, gettextCatalog, ionicToast, clipboard) {
.directive('copyToClipboard', function(platformInfo, nodeWebkitService, gettextCatalog, ionicToast, clipboard) {
return {
restrict: 'A',
scope: {
@ -22,7 +22,7 @@ angular.module('copayApp.directives')
window.cordova.plugins.clipboard.copy(data);
window.plugins.toast.showShortCenter(msg);
} else if (isNW) {
nodeWebkit.writeToClipboard(data);
nodeWebkitService.writeToClipboard(data);
scope.$apply(function() {
ionicToast.show(msg, 'bottom', false, 1000);
});

View file

@ -0,0 +1,14 @@
'use strict';
angular.module('copayApp.services').service('externalLinkService', function(platformInfo, nodeWebkitService) {
this.open = function(url, target) {
if (platformInfo.isNW) {
nodeWebkitService.openExternalLink(url);
} else {
target = target || '_blank';
var ref = window.open(url, target, 'location=no');
}
};
});

View file

@ -1,38 +0,0 @@
'use strict';
angular.module('copayApp.services').factory('nodeWebkit', function nodeWebkitFactory() {
var root = {};
var isNodeWebkit = function() {
var isNode = (typeof process !== "undefined" && typeof require !== "undefined");
if(isNode) {
try {
return (typeof require('nw.gui') !== "undefined");
} catch(e) {
return false;
}
}
};
root.readFromClipboard = function() {
if (!isNodeWebkit()) return;
var gui = require('nw.gui');
var clipboard = gui.Clipboard.get();
return clipboard.get();
};
root.writeToClipboard = function(text) {
if (!isNodeWebkit()) return;
var gui = require('nw.gui');
var clipboard = gui.Clipboard.get();
return clipboard.set(text);
};
root.openExternalLink = function(url) {
if (!isNodeWebkit()) return;
var gui = require('nw.gui');
return gui.Shell.openExternal(url);
};
return root;
});

View file

@ -0,0 +1,22 @@
'use strict';
angular.module('copayApp.services').service('nodeWebkitService', function() {
this.readFromClipboard = function() {
var gui = require('nw.gui');
var clipboard = gui.Clipboard.get();
return clipboard.get();
};
this.writeToClipboard = function(text) {
var gui = require('nw.gui');
var clipboard = gui.Clipboard.get();
return clipboard.set(text);
};
this.openExternalLink = function(url) {
var gui = require('nw.gui');
return gui.Shell.openExternal(url);
};
});

View file

@ -31,6 +31,7 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
'sweepingWallet': gettext('Sweeping Wallet...'),
'deletingWallet': gettext('Deleting Wallet...'),
'extractingWalletInfo': gettext('Extracting Wallet Information...'),
'gettingFeeLevels': gettext('Getting fee levels...'),
};
root.clear = function() {

View file

@ -31,9 +31,9 @@ angular.module('copayApp.services')
root.updateWalletSettings = function(wallet) {
var defaults = configService.getDefaults();
configService.whenAvailable(function(config){
wallet.usingCustomBWS = config.bwsFor[wallet.id] && (config.bwsFor[wallet.id] != defaults.bws.url);
wallet.name = config.aliasFor[wallet.id] || wallet.credentials.walletName;
wallet.color = config.colorFor[wallet.id] || '#4A90E2';
wallet.usingCustomBWS = config.bwsFor && config.bwsFor[wallet.id] && (config.bwsFor[wallet.id] != defaults.bws.url);
wallet.name = (config.aliasFor && config.aliasFor[wallet.id]) || wallet.credentials.walletName;
wallet.color = (config.colorFor && config.colorFor[wallet.id]) || '#4A90E2';
wallet.email = config.emailFor && config.emailFor[wallet.id];
});
}