Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Breeze
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
Breeze
Commits
313255eb
Commit
313255eb
authored
Nov 08, 2017
by
dev0tion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make frontend network aware
parent
8e42d5f3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
14 deletions
+74
-14
login.component.ts
Breeze.UI/src/app/login/login.component.ts
+35
-4
api.service.ts
Breeze.UI/src/app/shared/services/api.service.ts
+12
-1
global.service.ts
Breeze.UI/src/app/shared/services/global.service.ts
+4
-4
sidebar.component.ts
Breeze.UI/src/app/wallet/sidebar/sidebar.component.ts
+23
-5
No files found.
Breeze.UI/src/app/login/login.component.ts
View file @
313255eb
...
@@ -7,6 +7,7 @@ import { ApiService } from '../shared/services/api.service';
...
@@ -7,6 +7,7 @@ import { ApiService } from '../shared/services/api.service';
import
{
ModalService
}
from
'../shared/services/modal.service'
;
import
{
ModalService
}
from
'../shared/services/modal.service'
;
import
{
WalletLoad
}
from
'../shared/classes/wallet-load'
;
import
{
WalletLoad
}
from
'../shared/classes/wallet-load'
;
import
{
WalletInfo
}
from
'../shared/classes/wallet-info'
;
@
Component
({
@
Component
({
selector
:
'app-login'
,
selector
:
'app-login'
,
...
@@ -117,6 +118,7 @@ export class LoginComponent implements OnInit {
...
@@ -117,6 +118,7 @@ export class LoginComponent implements OnInit {
private
onDecryptClicked
()
{
private
onDecryptClicked
()
{
this
.
isDecrypting
=
true
;
this
.
isDecrypting
=
true
;
this
.
globalService
.
setWalletName
(
this
.
openWalletForm
.
get
(
"selectWallet"
).
value
);
this
.
globalService
.
setWalletName
(
this
.
openWalletForm
.
get
(
"selectWallet"
).
value
);
this
.
getCurrentNetwork
();
let
walletLoad
=
new
WalletLoad
(
let
walletLoad
=
new
WalletLoad
(
this
.
openWalletForm
.
get
(
"selectWallet"
).
value
,
this
.
openWalletForm
.
get
(
"selectWallet"
).
value
,
this
.
openWalletForm
.
get
(
"password"
).
value
this
.
openWalletForm
.
get
(
"password"
).
value
...
@@ -129,11 +131,7 @@ export class LoginComponent implements OnInit {
...
@@ -129,11 +131,7 @@ export class LoginComponent implements OnInit {
.
subscribe
(
.
subscribe
(
response
=>
{
response
=>
{
if
(
response
.
status
>=
200
&&
response
.
status
<
400
)
{
if
(
response
.
status
>=
200
&&
response
.
status
<
400
)
{
// Set Bitcoin as the default wallet
this
.
globalService
.
setCoinName
(
"TestBitcoin"
);
this
.
globalService
.
setCoinUnit
(
"TBTC"
);
this
.
globalService
.
setWalletName
(
walletLoad
.
name
);
this
.
globalService
.
setWalletName
(
walletLoad
.
name
);
this
.
globalService
.
setCoinType
(
1
);
}
}
},
},
error
=>
{
error
=>
{
...
@@ -179,4 +177,37 @@ export class LoginComponent implements OnInit {
...
@@ -179,4 +177,37 @@ export class LoginComponent implements OnInit {
)
)
;
;
}
}
private
getCurrentNetwork
()
{
let
walletInfo
=
new
WalletInfo
(
this
.
globalService
.
getWalletName
())
this
.
apiService
.
getGeneralInfoOnce
(
walletInfo
)
.
subscribe
(
response
=>
{
if
(
response
.
status
>=
200
&&
response
.
status
<
400
)
{
let
responseMessage
=
response
.
json
();
this
.
globalService
.
setNetwork
(
responseMessage
.
network
);
if
(
responseMessage
.
network
===
"Main"
)
{
this
.
globalService
.
setCoinName
(
"Bitcoin"
);
this
.
globalService
.
setCoinUnit
(
"BTC"
);
}
else
if
(
responseMessage
.
network
===
"TestNet"
)
{
this
.
globalService
.
setCoinName
(
"TestBitcoin"
);
this
.
globalService
.
setCoinUnit
(
"TBTC"
);
}
}
},
error
=>
{
if
(
error
.
status
===
0
)
{
this
.
genericModalService
.
openModal
(
null
,
null
);
}
else
if
(
error
.
status
>=
400
)
{
if
(
!
error
.
json
().
errors
[
0
])
{
console
.
log
(
error
);
}
else
{
this
.
genericModalService
.
openModal
(
null
,
error
.
json
().
errors
[
0
].
message
);
}
}
}
)
;
}
}
}
Breeze.UI/src/app/shared/services/api.service.ts
View file @
313255eb
...
@@ -57,7 +57,6 @@ export class ApiService {
...
@@ -57,7 +57,6 @@ export class ApiService {
.
map
((
response
:
Response
)
=>
response
);
.
map
((
response
:
Response
)
=>
response
);
}
}
/**
/**
* Get a new mnemonic
* Get a new mnemonic
*/
*/
...
@@ -136,6 +135,18 @@ export class ApiService {
...
@@ -136,6 +135,18 @@ export class ApiService {
.
map
((
response
:
Response
)
=>
response
);
.
map
((
response
:
Response
)
=>
response
);
}
}
/**
* Get general wallet info from the API once.
*/
getGeneralInfoOnce
(
data
:
WalletInfo
):
Observable
<
any
>
{
let
params
:
URLSearchParams
=
new
URLSearchParams
();
params
.
set
(
'Name'
,
data
.
walletName
);
return
this
.
http
.
get
(
this
.
bitcoinApiUrl
+
'/wallet/general-info'
,
new
RequestOptions
({
headers
:
this
.
headers
,
search
:
params
}))
.
map
((
response
:
Response
)
=>
response
);
}
/**
/**
* Get general wallet info from the API.
* Get general wallet info from the API.
*/
*/
...
...
Breeze.UI/src/app/shared/services/global.service.ts
View file @
313255eb
...
@@ -6,10 +6,10 @@ export class GlobalService {
...
@@ -6,10 +6,10 @@ export class GlobalService {
private
walletPath
:
string
;
private
walletPath
:
string
;
private
currentWalletName
:
string
;
private
currentWalletName
:
string
;
private
coinType
:
number
=
0
;
private
coinType
:
number
;
private
coinName
:
string
=
"TestBitcoin"
;
private
coinName
:
string
;
private
coinUnit
:
string
=
"TBTC"
;
private
coinUnit
:
string
;
private
network
:
string
=
"TestNet"
;
private
network
:
string
;
getWalletPath
()
{
getWalletPath
()
{
return
this
.
walletPath
;
return
this
.
walletPath
;
...
...
Breeze.UI/src/app/wallet/sidebar/sidebar.component.ts
View file @
313255eb
...
@@ -3,7 +3,11 @@ import { NgbModal, NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
...
@@ -3,7 +3,11 @@ import { NgbModal, NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import
{
LogoutConfirmationComponent
}
from
'../logout-confirmation/logout-confirmation.component'
;
import
{
LogoutConfirmationComponent
}
from
'../logout-confirmation/logout-confirmation.component'
;
import
{
Router
}
from
'@angular/router'
;
import
{
Router
}
from
'@angular/router'
;
import
{
ApiService
}
from
'../../shared/services/api.service'
;
import
{
GlobalService
}
from
'../../shared/services/global.service'
;
import
{
GlobalService
}
from
'../../shared/services/global.service'
;
import
{
ModalService
}
from
'../../shared/services/modal.service'
;
import
{
WalletInfo
}
from
'../../shared/classes/wallet-info'
;
@
Component
({
@
Component
({
selector
:
'sidebar'
,
selector
:
'sidebar'
,
...
@@ -12,7 +16,7 @@ import { GlobalService } from '../../shared/services/global.service';
...
@@ -12,7 +16,7 @@ import { GlobalService } from '../../shared/services/global.service';
})
})
export
class
SidebarComponent
implements
OnInit
{
export
class
SidebarComponent
implements
OnInit
{
constructor
(
private
globalService
:
GlobalService
,
private
router
:
Router
,
private
modalService
:
NgbModal
)
{
}
constructor
(
private
globalService
:
GlobalService
,
private
apiService
:
ApiService
,
private
router
:
Router
,
private
modalService
:
NgbModal
,
private
genericModalService
:
ModalService
)
{
}
public
bitcoinActive
:
boolean
;
public
bitcoinActive
:
boolean
;
public
stratisActive
:
boolean
;
public
stratisActive
:
boolean
;
...
@@ -27,18 +31,32 @@ export class SidebarComponent implements OnInit {
...
@@ -27,18 +31,32 @@ export class SidebarComponent implements OnInit {
}
}
public
loadBitcoinWallet
()
{
public
loadBitcoinWallet
()
{
this
.
bitcoinActive
=
true
;
let
currentNetwork
=
this
.
globalService
.
getNetwork
();
this
.
stratisActive
=
false
;
if
(
currentNetwork
===
"Main"
)
{
this
.
globalService
.
setCoinName
(
"Bitcoin"
);
this
.
globalService
.
setCoinUnit
(
"BTC"
);
}
else
if
(
currentNetwork
===
"TestNet"
){
this
.
globalService
.
setCoinName
(
"TestBitcoin"
);
this
.
globalService
.
setCoinName
(
"TestBitcoin"
);
this
.
globalService
.
setCoinUnit
(
"TBTC"
);
this
.
globalService
.
setCoinUnit
(
"TBTC"
);
}
this
.
bitcoinActive
=
true
;
this
.
stratisActive
=
false
;
this
.
router
.
navigate
([
'/wallet'
]);
this
.
router
.
navigate
([
'/wallet'
]);
}
}
public
loadStratisWallet
()
{
public
loadStratisWallet
()
{
this
.
bitcoinActive
=
false
;
let
currentNetwork
=
this
.
globalService
.
getNetwork
();
this
.
stratisActive
=
true
;
if
(
currentNetwork
===
"Main"
)
{
this
.
globalService
.
setCoinName
(
"Stratis"
);
this
.
globalService
.
setCoinUnit
(
"STRAT"
);
}
else
if
(
currentNetwork
===
"TestNet"
){
this
.
globalService
.
setCoinName
(
"TestStratis"
);
this
.
globalService
.
setCoinName
(
"TestStratis"
);
this
.
globalService
.
setCoinUnit
(
"TSTRAT"
);
this
.
globalService
.
setCoinUnit
(
"TSTRAT"
);
}
this
.
bitcoinActive
=
false
;
this
.
stratisActive
=
true
;
this
.
router
.
navigate
([
'/wallet/stratis-wallet'
]);
this
.
router
.
navigate
([
'/wallet/stratis-wallet'
]);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment