From 8dd7576d05a7aaa7bda4cacb27e4a9e5048a57de Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Thu, 2 Mar 2017 16:12:12 +0100 Subject: [PATCH 1/2] Setup autologin from a cookie for development purposes --- src/app/app.js | 1 + src/app/components/login/login.js | 11 +++++++---- src/app/index.js | 1 + src/package.json | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/app.js b/src/app/app.js index 8107d4b4b..4ee794a18 100644 --- a/src/app/app.js +++ b/src/app/app.js @@ -3,5 +3,6 @@ export default angular.module('app', [ 'ngMessages', 'ngMaterial', 'ngAnimate', + 'ngCookies', 'md.data.table', ]) diff --git a/src/app/components/login/login.js b/src/app/components/login/login.js index e9199bc4e..7d050e233 100644 --- a/src/app/components/login/login.js +++ b/src/app/components/login/login.js @@ -12,16 +12,17 @@ app.component('login', { onLogin: '&', }, controller: class login { - constructor ($scope, $rootScope, $timeout, $document, $mdDialog, $mdMedia) { + constructor ($scope, $rootScope, $timeout, $document, $mdDialog, $mdMedia, $cookies) { this.$scope = $scope this.$rootScope = $rootScope this.$timeout = $timeout this.$document = $document this.$mdDialog = $mdDialog this.$mdMedia = $mdMedia + this.$cookies = $cookies this.$scope.$watch('$ctrl.input_passphrase', this.isValid.bind(this)) - // this.$timeout(this.devTestAccount.bind(this), 200) + this.$timeout(this.devTestAccount.bind(this), 200) this.$scope.$watch(() => { return this.$mdMedia('xs') || this.$mdMedia('sm'); @@ -178,8 +179,10 @@ app.component('login', { } devTestAccount () { - this.input_passphrase = 'stay undo beyond powder sand laptop grow gloom apology hamster primary arrive' - this.$timeout(this.go.bind(this), 100) + this.input_passphrase = this.$cookies.get('passphrase'); + if (this.input_passphrase) { + this.$timeout(this.go.bind(this), 100) + } } fix (v) { diff --git a/src/app/index.js b/src/app/index.js index 718925019..11071190f 100644 --- a/src/app/index.js +++ b/src/app/index.js @@ -3,6 +3,7 @@ import 'jquery' import 'angular' import 'angular-animate' +import 'angular-cookies' import 'angular-aria' import 'angular-messages' import 'angular-material' diff --git a/src/package.json b/src/package.json index 53cc732bd..ba65b9b6d 100644 --- a/src/package.json +++ b/src/package.json @@ -9,6 +9,7 @@ "dependencies": { "angular": "^1.5.8", "angular-animate": "^1.5.8", + "angular-cookies": "=1.5.8", "angular-aria": "^1.5.8", "angular-material": "^1.1.1", "angular-material-data-table": "^0.10.9", From e6ed9d4bb87fa3345920730e5ef49d3545278c4c Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Thu, 2 Mar 2017 16:36:56 +0100 Subject: [PATCH 2/2] Allow to make testnet the default peer by a cookie, for development purposes The cookie can be set from browser console like this: angular.element(document.body).injector().get('$cookies').put('peerStack', 'testnet') --- src/app/services/peers/peers.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/services/peers/peers.js b/src/app/services/peers/peers.js index 32a59af10..6fb508bcc 100644 --- a/src/app/services/peers/peers.js +++ b/src/app/services/peers/peers.js @@ -5,7 +5,7 @@ import './peer' const UPDATE_INTERVAL_CHECK = 10000 -app.factory('$peers', ($peer, $timeout) => { +app.factory('$peers', ($peer, $timeout, $cookies) => { class $peers { constructor () { this.stack = { @@ -38,7 +38,9 @@ app.factory('$peers', ($peer, $timeout) => { setActive () { this.active = _.chain([]) - .concat(this.stack.official, this.stack.public) + .concat($cookies.get('peerStack') == 'testnet' ? + this.stack.testnet : this.stack.official, + this.stack.public) .sample() .value()