settings: create new model
This commit is contained in:
parent
921cb8dd90
commit
d2861d9c2a
4 changed files with 32 additions and 22 deletions
|
|
@ -1,10 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('MoreController',
|
||||
function($scope, $rootScope, $location, backupService, walletFactory, controllerUtils, notification) {
|
||||
function($scope, $rootScope, $location, backupService, walletFactory, controllerUtils, notification, rateService) {
|
||||
var w = $rootScope.wallet;
|
||||
|
||||
|
||||
$scope.unitOpts = [{
|
||||
name: 'Satoshis (100,000,000 satoshis = 1BTC)',
|
||||
shortName: 'SAT',
|
||||
|
|
@ -49,6 +48,15 @@ angular.module('copayApp.controllers').controller('MoreController',
|
|||
break;
|
||||
}
|
||||
}
|
||||
$scope.save = function() {
|
||||
w.changeSettings({
|
||||
unitName: $scope.selectedUnit.shortName,
|
||||
unitToSatoshi: $scope.selectedUnit.value,
|
||||
unitDecimals: $scope.selectedUnit.decimals,
|
||||
alternativeName: $scope.selectedAlternative.name,
|
||||
alternativeIsoCode: $scope.selectedAlternative.isoCode,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
$scope.hideAdv = true;
|
||||
|
|
@ -57,19 +65,16 @@ angular.module('copayApp.controllers').controller('MoreController',
|
|||
$scope.priv = w.privateKey.toObj().extendedPrivateKeyString;
|
||||
|
||||
$scope.downloadBackup = function() {
|
||||
var w = $rootScope.wallet;
|
||||
backupService.download(w);
|
||||
}
|
||||
|
||||
$scope.deleteWallet = function() {
|
||||
var w = $rootScope.wallet;
|
||||
walletFactory.delete(w.id, function() {
|
||||
controllerUtils.logout();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.purge = function(deleteAll) {
|
||||
var w = $rootScope.wallet;
|
||||
var removed = w.purgeTxProposals(deleteAll);
|
||||
if (removed) {
|
||||
controllerUtils.updateBalance();
|
||||
|
|
@ -78,7 +83,6 @@ angular.module('copayApp.controllers').controller('MoreController',
|
|||
};
|
||||
|
||||
$scope.updateIndexes = function() {
|
||||
var w = $rootScope.wallet;
|
||||
notification.info('Scaning for transactions', 'Using derived addresses from your wallet');
|
||||
w.updateIndexes(function(err) {
|
||||
notification.info('Scan Ended', 'Updating balance');
|
||||
|
|
|
|||
|
|
@ -37,24 +37,16 @@ angular.module('copayApp.controllers').controller('SettingsController', function
|
|||
network.port = $scope.insightPort;
|
||||
network.schema = $scope.insightSecure ? 'https' : 'http';
|
||||
|
||||
var insightSettings = {
|
||||
host: $scope.insightHost,
|
||||
port: $scope.insightPort,
|
||||
schema: $scope.insightSecure ? 'https' : 'http',
|
||||
}
|
||||
|
||||
localStorage.setItem('config', JSON.stringify({
|
||||
networkName: $scope.networkName,
|
||||
blockchain: {
|
||||
host: $scope.insightHost,
|
||||
port: $scope.insightPort,
|
||||
schema: $scope.insightSecure ? 'https' : 'http',
|
||||
},
|
||||
socket: {
|
||||
host: $scope.insightHost,
|
||||
port: $scope.insightPort,
|
||||
schema: $scope.insightSecure ? 'https' : 'http',
|
||||
},
|
||||
blockchain: insightSettings,
|
||||
socket: insightSettings,
|
||||
network: network,
|
||||
unitName: $scope.selectedUnit.shortName,
|
||||
unitToSatoshi: $scope.selectedUnit.value,
|
||||
unitDecimals: $scope.selectedUnit.decimals,
|
||||
alternativeName: $scope.selectedAlternative.name,
|
||||
alternativeIsoCode: $scope.selectedAlternative.isoCode,
|
||||
|
||||
version: copay.version,
|
||||
defaultLanguage: $scope.selectedLanguage.isoCode
|
||||
|
|
|
|||
12
js/models/core/Settings.js
Normal file
12
js/models/core/Settings.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
var preconditions = require('preconditions').singleton();
|
||||
var log = require('../../log');
|
||||
|
||||
var copayConfig = require('../../../config');
|
||||
|
||||
function Settings(opts) {
|
||||
var self = this;
|
||||
}
|
||||
|
||||
module.exports = Settings;
|
||||
|
|
@ -25,6 +25,7 @@ var TxProposal = require('./TxProposal');
|
|||
var TxProposals = require('./TxProposals');
|
||||
var PrivateKey = require('./PrivateKey');
|
||||
var WalletLock = require('./WalletLock');
|
||||
var Settings = require('./Settings');
|
||||
var copayConfig = require('../../../config');
|
||||
|
||||
/**
|
||||
|
|
@ -73,6 +74,7 @@ function Wallet(opts) {
|
|||
this.id = opts.id || Wallet.getRandomId();
|
||||
this.secretNumber = opts.secretNumber || Wallet.getRandomNumber();
|
||||
this.lock = new WalletLock(this.storage, this.id, opts.lockTimeOutMin);
|
||||
this.settings = new Settings(opts.settings);
|
||||
this.name = opts.name;
|
||||
|
||||
this.verbose = opts.verbose;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue