fix interfase and loggin

This commit is contained in:
Matias Alejo Garcia 2014-09-18 19:20:00 -03:00
parent 238d36c0a7
commit 409cef4d4b
7 changed files with 32 additions and 21 deletions

View File

@ -53,8 +53,8 @@ var defaultConfig = {
verbose: 1,
plugins: {
LocalStorage: true,
// GoogleDrive: true,
//LocalStorage: true,
GoogleDrive: true,
},
GoogleDrive: {

View File

@ -5,8 +5,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
controllerUtils.redirIfLogged();
$scope.retreiving = true;
walletFactory.getWallets(function(ret) {
walletFactory.getWallets(function(err,ret) {
$scope.retreiving = false;
$scope.hasWallets = (ret && ret.length > 0) ? true : false;
});

View File

@ -16,16 +16,23 @@ angular.module('copayApp.controllers').controller('OpenController', function($sc
$scope.loading = false;
$scope.retreiving = true;
walletFactory.getWallets(function(wallets) {
walletFactory.getWallets(function(err, wallets) {
if (!wallets || !wallets.length) {
if (err || !wallets || !wallets.length) {
$location.path('/');
} else {
$scope.retreiving = false;
$scope.wallets = wallets.sort(cmp);
walletFactory.storage.getLastOpened(function(ret) {
if (ret && _.indexOf(_.pluck($scope.wallets, 'id')) == -1)
ret = null;
$scope.selectedWalletId = ret || ($scope.wallets[0] && $scope.wallets[0].id);
$scope.retreiving = false;
setTimeout(function() {
$rootScope.$digest();
}, 0);
});
}
});
@ -49,9 +56,10 @@ angular.module('copayApp.controllers').controller('OpenController', function($sc
$scope.loading = false;
notification.error('Error', err.errMsg || 'Wrong password');
$rootScope.$digest();
} else {
$rootScope.updatingBalance = true;
controllerUtils.startNetwork(w, $scope);
}
$rootScope.updatingBalance = true;
controllerUtils.startNetwork(w, $scope);
});
});
};

View File

@ -4,12 +4,13 @@ var CryptoJS = require('node-cryptojs-aes').CryptoJS;
var bitcore = require('bitcore');
var preconditions = require('preconditions').instance();
var _ = require('underscore');
var CACHE_DURATION = 1000 * 60 * 5;
var id = 0;
function Storage(opts) {
opts = opts || {};
this.wListCache = {};
this.__uniqueid = ++id;
if (opts.password)
this.setPassphrase(opts.password);
@ -211,6 +212,9 @@ Storage.prototype.getWalletIds = function(cb) {
Storage.prototype.getWallets = function(cb) {
preconditions.checkArgument(cb);
if (this.wListCache.ts > Date.now())
return cb(this.wListCache.data)
var wallets = [];
var self = this;
@ -228,6 +232,8 @@ Storage.prototype.getWallets = function(cb) {
name: name,
});
if (++i == l) {
self.wListCache.data = wallets;
self.wListCache.ts = Date.now() + CACHE_DURATION;
return cb(wallets);
}
})

View File

@ -50,7 +50,6 @@ TxProposals.prototype.getNtxidsSince = function(sinceTs) {
if (txp.createdTs >= sinceTs)
ret.push(ii);
}
console.log('[TxProposals.js.52:ret:]',ret); //TODO
return ret;
};

View File

@ -3,6 +3,7 @@
var preconditions = require('preconditions').singleton();
var loaded = 0;
var SCOPES = 'https://www.googleapis.com/auth/drive';
var log = require('../js/log');
function GoogleDrive(config) {
preconditions.checkArgument(config && config.clientId, 'No clientId at GoogleDrive config');
@ -24,8 +25,7 @@ function GoogleDrive(config) {
};
window.InitGoogleDrive = function() {
// console.log('[googleDrive.js.18] setting loaded'); //TODO
log.debug('googleDrive loadeded'); //TODO
loaded = 1;
};
@ -47,7 +47,7 @@ GoogleDrive.prototype.initLoaded = function() {
*/
GoogleDrive.prototype.checkAuth = function() {
console.log('\tChecking google Auth');
log.debug('Google Drive: Checking Auth');
gapi.auth.authorize({
'client_id': this.clientId,
'scope': SCOPES,
@ -61,7 +61,7 @@ GoogleDrive.prototype.checkAuth = function() {
*/
GoogleDrive.prototype.handleAuthResult = function(authResult) {
var self = this;
// console.log('[googleDrive.js.39:authResult:]', authResult); //TODO
log.debug('Google Drive: authResult', authResult); //TODO
if (authResult.error) {
if (authResult.error) {
@ -93,7 +93,7 @@ GoogleDrive.prototype._httpGet = function(theUrl) {
}
GoogleDrive.prototype.getItem = function(k, cb) {
console.log('[googleDrive.js.95:getItem:]', k); //TODO
//console.log('[googleDrive.js.95:getItem:]', k); //TODO
var self = this;
self.checkReady();
@ -208,7 +208,7 @@ GoogleDrive.prototype._mkdir = function(cb) {
preconditions.checkArgument(cb);
var self = this;
console.log('Creating drive folder ' + this.home);
log.debug('Creating drive folder ' + this.home);
var request = gapi.client.request({
'path': '/drive/v2/files',
@ -231,18 +231,17 @@ GoogleDrive.prototype._idForName = function(name, cb) {
var self = this;
if (!self.isReady) {
console.log('\tWaiting for Drive');
log.debug('Waiting for Google Drive');
self.ts = self.ts * 1.5;
return setTimeout(self._idForName.bind(self, name, cb), self.ts);
}
// console.log('[googleDrive.js.178:name:]', name); //TODO
if (self.idCache[name]) {
// console.log('[googleDrive.js.212:] FROM CACHE', name, self.idCache[name]); //TODO
return cb(self.idCache[name]);
}
console.log('Querying for: ', name); //TODO
log.debug('GoogleDrive Querying for: ', name); //TODO
var args;
var idParent = name == this.home ? 'root' : self.idCache[this.home];

View File

@ -3,7 +3,7 @@
<i class="size-60 fi-bitcoin-circle icon-rotate spinner"></i>
Retreiving information from storage...
</div>
<div class="row" ng-show="!loading">
<div class="row" ng-show="!loading && !retreiving">
<div class="large-4 columns logo-setup">
<img src="img/logo-negative-beta.svg" alt="Copay" width="146" height="59">
<div ng-include="'views/includes/version.html'"></div>