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';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('MoreController',
|
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;
|
var w = $rootScope.wallet;
|
||||||
|
|
||||||
|
|
||||||
$scope.unitOpts = [{
|
$scope.unitOpts = [{
|
||||||
name: 'Satoshis (100,000,000 satoshis = 1BTC)',
|
name: 'Satoshis (100,000,000 satoshis = 1BTC)',
|
||||||
shortName: 'SAT',
|
shortName: 'SAT',
|
||||||
|
|
@ -49,6 +48,15 @@ angular.module('copayApp.controllers').controller('MoreController',
|
||||||
break;
|
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;
|
$scope.hideAdv = true;
|
||||||
|
|
@ -57,19 +65,16 @@ angular.module('copayApp.controllers').controller('MoreController',
|
||||||
$scope.priv = w.privateKey.toObj().extendedPrivateKeyString;
|
$scope.priv = w.privateKey.toObj().extendedPrivateKeyString;
|
||||||
|
|
||||||
$scope.downloadBackup = function() {
|
$scope.downloadBackup = function() {
|
||||||
var w = $rootScope.wallet;
|
|
||||||
backupService.download(w);
|
backupService.download(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.deleteWallet = function() {
|
$scope.deleteWallet = function() {
|
||||||
var w = $rootScope.wallet;
|
|
||||||
walletFactory.delete(w.id, function() {
|
walletFactory.delete(w.id, function() {
|
||||||
controllerUtils.logout();
|
controllerUtils.logout();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.purge = function(deleteAll) {
|
$scope.purge = function(deleteAll) {
|
||||||
var w = $rootScope.wallet;
|
|
||||||
var removed = w.purgeTxProposals(deleteAll);
|
var removed = w.purgeTxProposals(deleteAll);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
controllerUtils.updateBalance();
|
controllerUtils.updateBalance();
|
||||||
|
|
@ -78,7 +83,6 @@ angular.module('copayApp.controllers').controller('MoreController',
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.updateIndexes = function() {
|
$scope.updateIndexes = function() {
|
||||||
var w = $rootScope.wallet;
|
|
||||||
notification.info('Scaning for transactions', 'Using derived addresses from your wallet');
|
notification.info('Scaning for transactions', 'Using derived addresses from your wallet');
|
||||||
w.updateIndexes(function(err) {
|
w.updateIndexes(function(err) {
|
||||||
notification.info('Scan Ended', 'Updating balance');
|
notification.info('Scan Ended', 'Updating balance');
|
||||||
|
|
|
||||||
|
|
@ -37,24 +37,16 @@ angular.module('copayApp.controllers').controller('SettingsController', function
|
||||||
network.port = $scope.insightPort;
|
network.port = $scope.insightPort;
|
||||||
network.schema = $scope.insightSecure ? 'https' : 'http';
|
network.schema = $scope.insightSecure ? 'https' : 'http';
|
||||||
|
|
||||||
|
var insightSettings = {
|
||||||
|
host: $scope.insightHost,
|
||||||
|
port: $scope.insightPort,
|
||||||
|
schema: $scope.insightSecure ? 'https' : 'http',
|
||||||
|
}
|
||||||
|
|
||||||
localStorage.setItem('config', JSON.stringify({
|
localStorage.setItem('config', JSON.stringify({
|
||||||
networkName: $scope.networkName,
|
blockchain: insightSettings,
|
||||||
blockchain: {
|
socket: insightSettings,
|
||||||
host: $scope.insightHost,
|
|
||||||
port: $scope.insightPort,
|
|
||||||
schema: $scope.insightSecure ? 'https' : 'http',
|
|
||||||
},
|
|
||||||
socket: {
|
|
||||||
host: $scope.insightHost,
|
|
||||||
port: $scope.insightPort,
|
|
||||||
schema: $scope.insightSecure ? 'https' : 'http',
|
|
||||||
},
|
|
||||||
network: network,
|
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,
|
version: copay.version,
|
||||||
defaultLanguage: $scope.selectedLanguage.isoCode
|
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 TxProposals = require('./TxProposals');
|
||||||
var PrivateKey = require('./PrivateKey');
|
var PrivateKey = require('./PrivateKey');
|
||||||
var WalletLock = require('./WalletLock');
|
var WalletLock = require('./WalletLock');
|
||||||
|
var Settings = require('./Settings');
|
||||||
var copayConfig = require('../../../config');
|
var copayConfig = require('../../../config');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -73,6 +74,7 @@ function Wallet(opts) {
|
||||||
this.id = opts.id || Wallet.getRandomId();
|
this.id = opts.id || Wallet.getRandomId();
|
||||||
this.secretNumber = opts.secretNumber || Wallet.getRandomNumber();
|
this.secretNumber = opts.secretNumber || Wallet.getRandomNumber();
|
||||||
this.lock = new WalletLock(this.storage, this.id, opts.lockTimeOutMin);
|
this.lock = new WalletLock(this.storage, this.id, opts.lockTimeOutMin);
|
||||||
|
this.settings = new Settings(opts.settings);
|
||||||
this.name = opts.name;
|
this.name = opts.name;
|
||||||
|
|
||||||
this.verbose = opts.verbose;
|
this.verbose = opts.verbose;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue