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
b4366998
Commit
b4366998
authored
Mar 31, 2017
by
dev0tion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add wallet status call
parent
564c52a4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
22 deletions
+50
-22
app.component.ts
Breeze.UI/src/app/app.component.ts
+20
-6
app.module.ts
Breeze.UI/src/app/app.module.ts
+5
-2
setup.module.ts
Breeze.UI/src/app/setup/setup.module.ts
+1
-4
api.service.ts
Breeze.UI/src/app/shared/api/api.service.ts
+24
-8
wallet.module.ts
Breeze.UI/src/app/wallet/wallet.module.ts
+0
-2
No files found.
Breeze.UI/src/app/app.component.ts
View file @
b4366998
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
Router
}
from
'@angular/router'
;
import
{
remote
}
from
'electron'
;
import
{
ApiService
}
from
'./shared/api/api.service'
;
@
Component
({
selector
:
'app-root'
,
...
...
@@ -8,19 +10,31 @@ import { Router } from '@angular/router';
})
export
class
AppComponent
implements
OnInit
{
constructor
(
private
router
:
Router
)
{}
constructor
(
private
router
:
Router
,
private
apiService
:
ApiService
)
{}
private
errorMessage
:
string
;
private
response
:
any
;
private
isConfigured
:
boolean
=
true
;
private
checkConfigured
(){
if
(
this
.
isConfigured
)
{
ngOnInit
()
{
this
.
response
=
this
.
checkWalletStatus
();
}
private
checkWalletStatus
(){
this
.
apiService
.
getWalletStatus
()
.
subscribe
(
response
=>
this
.
response
=
response
,
error
=>
this
.
errorMessage
=
<
any
>
error
);
if
(
this
.
response
.
success
=
"true"
)
{
remote
.
dialog
.
showMessageBox
({
message
:
remote
.
app
.
getPath
(
'userData'
)})
this
.
router
.
navigateByUrl
(
'/wallet'
)
}
else
{
this
.
router
.
navigateByUrl
(
'/setup'
)
}
}
ngOnIni
t
()
{
this
.
checkConfigured
()
;
private
hasWalle
t
()
{
return
true
;
}
}
\ No newline at end of file
Breeze.UI/src/app/app.module.ts
View file @
b4366998
...
...
@@ -10,6 +10,9 @@ import { AppRoutingModule } from './app-routing.module';
import
{
AppComponent
}
from
'./app.component'
;
import
{
ApiService
}
from
'./shared/api/api.service'
;
@
NgModule
({
imports
:
[
AppRoutingModule
,
...
...
@@ -22,8 +25,8 @@ import { AppComponent } from './app.component';
declarations
:
[
AppComponent
],
providers
:
[],
bootstrap
:
[
AppComponent
]
providers
:
[
ApiService
],
bootstrap
:
[
AppComponent
]
})
export
class
AppModule
{
}
\ No newline at end of file
Breeze.UI/src/app/setup/setup.module.ts
View file @
b4366998
import
{
BrowserModule
}
from
'@angular/platform-browser'
;
import
{
NgModule
}
from
'@angular/core'
;
import
{
FormsModule
}
from
'@angular/forms'
;
import
{
HttpModule
}
from
'@angular/http'
;
import
{
RouterModule
}
from
'@angular/router'
;
import
{
SetupComponent
}
from
'./setup.component'
;
...
...
@@ -11,13 +10,11 @@ import { ApiComponent } from './create/api.component';
import
{
SharedModule
}
from
'../shared/shared.module'
;
import
{
SetupRoutingModule
}
from
'./setup-routing.module'
;
import
{
ApiService
}
from
'../shared/api/api.service'
;
@
NgModule
({
imports
:
[
BrowserModule
,
FormsModule
,
HttpModule
,
SetupRoutingModule
,
SharedModule
],
...
...
@@ -26,7 +23,7 @@ import { ApiService } from '../shared/api/api.service';
SetupComponent
,
ApiComponent
],
exports
:
[
SetupComponent
],
exports
:
[
SetupComponent
],
providers
:
[]
})
...
...
Breeze.UI/src/app/shared/api/api.service.ts
View file @
b4366998
import
{
Injectable
}
from
'@angular/core'
;
import
{
Http
,
Headers
}
from
'@angular/http'
;
import
{
Http
,
Headers
,
Response
}
from
'@angular/http'
;
import
{
Observable
}
from
'rxjs/Observable'
;
import
'rxjs/add/operator/map'
;
import
'rxjs/add/operator/
toPromise
'
;
import
'rxjs/add/operator/
catch
'
;
import
{
SafeCreation
}
from
'../safe-creation'
;
import
{
Mnemonic
}
from
'../mnemonic'
;
...
...
@@ -11,13 +11,21 @@ import { Mnemonic } from '../mnemonic';
export
class
ApiService
{
constructor
(
private
http
:
Http
)
{};
private
webApiUrl
=
'http://localhost:
5
000/api/v1'
;
private
webApiUrl
=
'http://localhost:
3
000/api/v1'
;
private
headers
=
new
Headers
({
'Content-Type'
:
'application/json'
});
isConnected
():
Observable
<
string
>
{
isConnected
():
Observable
<
any
>
{
return
this
.
http
.
get
(
this
.
webApiUrl
+
'/safe/connected'
)
.
map
(
data
=>
data
.
json
())
.
map
((
response
:
Response
)
=>
response
.
json
())
.
catch
(
this
.
handleError
);
}
getWalletStatus
():
Observable
<
any
>
{
return
this
.
http
.
get
(
this
.
webApiUrl
+
'/wallet/status'
)
.
map
((
response
:
Response
)
=>
response
.
json
())
.
catch
(
this
.
handleError
);
}
createWallet
(
data
:
SafeCreation
):
Observable
<
any
>
{
...
...
@@ -27,8 +35,16 @@ export class ApiService {
.
map
(
response
=>
response
.
json
());
}
private
handleError
(
error
:
any
):
Promise
<
any
>
{
console
.
error
(
'An error occurred'
,
error
);
return
Promise
.
reject
(
error
.
message
||
error
);
private
handleError
(
error
:
Response
|
any
)
{
let
errMsg
:
string
;
if
(
error
instanceof
Response
)
{
const
body
=
error
.
json
()
||
''
;
const
err
=
body
.
error
||
JSON
.
stringify
(
body
);
errMsg
=
`
${
error
.
status
}
-
${
error
.
statusText
||
''
}
${
err
}
`
;
}
else
{
errMsg
=
error
.
message
?
error
.
message
:
error
.
toString
();
}
console
.
error
(
errMsg
);
return
Observable
.
throw
(
errMsg
);
}
}
Breeze.UI/src/app/wallet/wallet.module.ts
View file @
b4366998
import
{
BrowserModule
}
from
'@angular/platform-browser'
;
import
{
NgModule
}
from
'@angular/core'
;
import
{
FormsModule
}
from
'@angular/forms'
;
import
{
HttpModule
}
from
'@angular/http'
;
import
{
RouterModule
}
from
'@angular/router'
;
import
{
WalletComponent
}
from
'./wallet.component'
;
...
...
@@ -18,7 +17,6 @@ import { WalletRoutingModule } from './wallet-routing.module';
imports
:
[
BrowserModule
,
FormsModule
,
HttpModule
,
WalletRoutingModule
,
SharedModule
],
...
...
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