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
f7c107e9
Unverified
Commit
f7c107e9
authored
Nov 08, 2017
by
Pieterjan Vanhoof
Committed by
GitHub
Nov 08, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #350 from stratisproject/ui
Make frontend network aware
parents
0ef810ed
313255eb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
18 deletions
+94
-18
main.ts
Breeze.UI/main.ts
+20
-4
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/main.ts
View file @
f7c107e9
...
...
@@ -11,8 +11,10 @@ const url = require('url');
const
os
=
require
(
'os'
);
let
serve
;
let
testnet
;
const
args
=
process
.
argv
.
slice
(
1
);
serve
=
args
.
some
(
val
=>
val
===
"--serve"
);
testnet
=
args
.
some
(
val
=>
val
===
"--testnet"
);
if
(
serve
)
{
require
(
'electron-reload'
)(
__dirname
,
{
...
...
@@ -158,9 +160,16 @@ function startBitcoinApi() {
apiPath
=
path
.
resolve
(
__dirname
,
'assets
\\
daemon
\\
Stratis.BreezeD.exe'
);
}
bitcoinProcess
=
spawnBitcoin
(
apiPath
,
[
'-testnet'
],
{
if
(
!
testnet
)
{
bitcoinProcess
=
spawnBitcoin
(
apiPath
,
{
detached
:
true
});
});
}
else
if
(
testnet
)
{
bitcoinProcess
=
spawnBitcoin
(
apiPath
,
[
'-testnet'
],
{
detached
:
true
});
}
bitcoinProcess
.
stdout
.
on
(
'data'
,
(
data
)
=>
{
writeLog
(
`Bitcoin:
${
data
}
`
);
...
...
@@ -177,9 +186,16 @@ function startStratisApi() {
apiPath
=
path
.
resolve
(
__dirname
,
'assets
\\
daemon
\\
Stratis.BreezeD.exe'
);
}
stratisProcess
=
spawnStratis
(
apiPath
,
[
'stratis'
,
'-testnet'
],
{
if
(
!
testnet
)
{
stratisProcess
=
spawnStratis
(
apiPath
,
[
'stratis'
],
{
detached
:
true
});
});
}
else
if
(
testnet
)
{
stratisProcess
=
spawnStratis
(
apiPath
,
[
'stratis'
,
'-testnet'
],
{
detached
:
true
});
}
stratisProcess
.
stdout
.
on
(
'data'
,
(
data
)
=>
{
writeLog
(
`Stratis:
${
data
}
`
);
...
...
Breeze.UI/src/app/login/login.component.ts
View file @
f7c107e9
...
...
@@ -7,6 +7,7 @@ import { ApiService } from '../shared/services/api.service';
import
{
ModalService
}
from
'../shared/services/modal.service'
;
import
{
WalletLoad
}
from
'../shared/classes/wallet-load'
;
import
{
WalletInfo
}
from
'../shared/classes/wallet-info'
;
@
Component
({
selector
:
'app-login'
,
...
...
@@ -117,6 +118,7 @@ export class LoginComponent implements OnInit {
private
onDecryptClicked
()
{
this
.
isDecrypting
=
true
;
this
.
globalService
.
setWalletName
(
this
.
openWalletForm
.
get
(
"selectWallet"
).
value
);
this
.
getCurrentNetwork
();
let
walletLoad
=
new
WalletLoad
(
this
.
openWalletForm
.
get
(
"selectWallet"
).
value
,
this
.
openWalletForm
.
get
(
"password"
).
value
...
...
@@ -129,11 +131,7 @@ export class LoginComponent implements OnInit {
.
subscribe
(
response
=>
{
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
.
setCoinType
(
1
);
}
},
error
=>
{
...
...
@@ -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 @
f7c107e9
...
...
@@ -57,7 +57,6 @@ export class ApiService {
.
map
((
response
:
Response
)
=>
response
);
}
/**
* Get a new mnemonic
*/
...
...
@@ -136,6 +135,18 @@ export class ApiService {
.
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.
*/
...
...
Breeze.UI/src/app/shared/services/global.service.ts
View file @
f7c107e9
...
...
@@ -6,10 +6,10 @@ export class GlobalService {
private
walletPath
:
string
;
private
currentWalletName
:
string
;
private
coinType
:
number
=
0
;
private
coinName
:
string
=
"TestBitcoin"
;
private
coinUnit
:
string
=
"TBTC"
;
private
network
:
string
=
"TestNet"
;
private
coinType
:
number
;
private
coinName
:
string
;
private
coinUnit
:
string
;
private
network
:
string
;
getWalletPath
()
{
return
this
.
walletPath
;
...
...
Breeze.UI/src/app/wallet/sidebar/sidebar.component.ts
View file @
f7c107e9
...
...
@@ -3,7 +3,11 @@ import { NgbModal, NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import
{
LogoutConfirmationComponent
}
from
'../logout-confirmation/logout-confirmation.component'
;
import
{
Router
}
from
'@angular/router'
;
import
{
ApiService
}
from
'../../shared/services/api.service'
;
import
{
GlobalService
}
from
'../../shared/services/global.service'
;
import
{
ModalService
}
from
'../../shared/services/modal.service'
;
import
{
WalletInfo
}
from
'../../shared/classes/wallet-info'
;
@
Component
({
selector
:
'sidebar'
,
...
...
@@ -12,7 +16,7 @@ import { GlobalService } from '../../shared/services/global.service';
})
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
stratisActive
:
boolean
;
...
...
@@ -27,18 +31,32 @@ export class SidebarComponent implements OnInit {
}
public
loadBitcoinWallet
()
{
let
currentNetwork
=
this
.
globalService
.
getNetwork
();
if
(
currentNetwork
===
"Main"
)
{
this
.
globalService
.
setCoinName
(
"Bitcoin"
);
this
.
globalService
.
setCoinUnit
(
"BTC"
);
}
else
if
(
currentNetwork
===
"TestNet"
){
this
.
globalService
.
setCoinName
(
"TestBitcoin"
);
this
.
globalService
.
setCoinUnit
(
"TBTC"
);
}
this
.
bitcoinActive
=
true
;
this
.
stratisActive
=
false
;
this
.
globalService
.
setCoinName
(
"TestBitcoin"
);
this
.
globalService
.
setCoinUnit
(
"TBTC"
);
this
.
router
.
navigate
([
'/wallet'
]);
}
public
loadStratisWallet
()
{
let
currentNetwork
=
this
.
globalService
.
getNetwork
();
if
(
currentNetwork
===
"Main"
)
{
this
.
globalService
.
setCoinName
(
"Stratis"
);
this
.
globalService
.
setCoinUnit
(
"STRAT"
);
}
else
if
(
currentNetwork
===
"TestNet"
){
this
.
globalService
.
setCoinName
(
"TestStratis"
);
this
.
globalService
.
setCoinUnit
(
"TSTRAT"
);
}
this
.
bitcoinActive
=
false
;
this
.
stratisActive
=
true
;
this
.
globalService
.
setCoinName
(
"TestStratis"
);
this
.
globalService
.
setCoinUnit
(
"TSTRAT"
);
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