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
8e0f829a
Commit
8e0f829a
authored
Apr 11, 2017
by
dev0tion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add global service to login component, improve code
parent
9295c144
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
37 deletions
+34
-37
login.component.html
Breeze.UI/src/app/login/login.component.html
+1
-1
login.component.ts
Breeze.UI/src/app/login/login.component.ts
+22
-32
wallet-load.ts
Breeze.UI/src/app/shared/classes/wallet-load.ts
+11
-4
No files found.
Breeze.UI/src/app/login/login.component.html
View file @
8e0f829a
...
...
@@ -24,4 +24,4 @@
<p>
Looks like you're new here. Please create or restore a wallet.
</p>
</ng-template>
<button
type=
"button"
(
click
)="
clickedCreate
()"
class=
"btn btn-success"
>
Create or restore wallet
</button>
\ No newline at end of file
<button
type=
"button"
(
click
)="
onCreateClicked
()"
class=
"btn btn-success"
>
Create or restore wallet
</button>
Breeze.UI/src/app/login/login.component.ts
View file @
8e0f829a
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
Router
}
from
'@angular/router'
;
import
{
GlobalService
}
from
'../shared/services/global.service'
;
import
{
ApiService
}
from
'../shared/services/api.service'
;
import
{
WalletLoad
}
from
'../shared/classes/wallet-load'
;
...
...
@@ -9,81 +10,70 @@ import { WalletLoad } from '../shared/classes/wallet-load';
styleUrls
:
[
'./login.component.css'
]
})
export
class
LoginComponent
implements
OnInit
{
constructor
(
private
apiService
:
ApiService
,
private
router
:
Router
)
{
}
constructor
(
private
globalService
:
GlobalService
,
private
apiService
:
ApiService
,
private
router
:
Router
)
{
}
private
walletLoad
:
WalletLoad
;
private
hasWallet
:
boolean
=
false
;
private
currentWalletName
:
string
;
private
wallets
:
[
any
];
private
walletPath
:
string
;
private
wallets
:
[
string
];
private
password
:
string
;
private
responseMessage
:
any
;
private
errorMessage
:
any
;
ngOnInit
()
{
this
.
apiService
.
getWalletFiles
()
.
subscribe
(
response
=>
{
if
(
response
.
status
>=
200
&&
response
.
status
<
400
)
{
this
.
responseMessage
=
response
;
this
.
wallets
=
response
.
json
()
.
walletsFiles
;
this
.
walletPath
=
response
.
json
().
walletsPath
;
let
responseMessage
=
response
.
json
()
;
this
.
wallets
=
response
Message
.
walletsFiles
;
this
.
globalService
.
setWalletPath
(
responseMessage
.
walletsPath
)
;
if
(
this
.
wallets
.
length
>
0
)
{
this
.
hasWallet
=
true
;
this
.
currentWalletName
=
this
.
wallets
[
0
].
slice
(
0
,
-
5
);
for
(
let
wallet
in
this
.
wallets
)
{
this
.
wallets
[
wallet
]
=
this
.
wallets
[
wallet
].
slice
(
0
,
-
5
);
}
this
.
globalService
.
setCurrentWalletName
(
this
.
wallets
[
0
]);
}
else
{
this
.
hasWallet
=
false
;
}
}
},
error
=>
{
this
.
errorMessage
=
<
any
>
error
;
let
errorMessage
=
<
any
>
error
;
if
(
error
.
status
>=
400
)
{
alert
(
this
.
errorMessage
);
console
.
log
(
this
.
errorMessage
);
alert
(
errorMessage
);
console
.
log
(
errorMessage
);
}
}
);
}
private
onSubmit
()
{
let
walletLoad
=
new
WalletLoad
(
this
.
password
,
this
.
globalService
.
getWalletPath
(),
this
.
globalService
.
getCurrentWalletName
());
this
.
walletLoad
=
new
WalletLoad
();
this
.
walletLoad
.
password
=
this
.
password
;
this
.
walletLoad
.
name
=
this
.
currentWalletName
;
this
.
walletLoad
.
folderPath
=
this
.
walletPath
;
console
.
log
(
this
.
walletLoad
);
this
.
apiService
.
loadWallet
(
this
.
walletLoad
)
this
.
apiService
.
loadWallet
(
walletLoad
)
.
subscribe
(
response
=>
{
console
.
log
(
response
);
if
(
response
.
status
>=
200
&&
response
.
status
<
400
)
{
this
.
responseMessage
=
response
;
let
responseMessage
=
response
.
json
()
;
this
.
router
.
navigate
([
'/wallet'
]);
}
},
error
=>
{
this
.
errorMessage
=
<
any
>
error
;
let
errorMessage
=
<
any
>
error
;
if
(
error
.
status
===
403
&&
error
.
json
().
errors
[
0
].
message
===
"Wrong password, please try again."
)
{
alert
(
"Wrong password, try again."
);
}
else
if
(
error
.
status
>=
400
)
{
alert
(
this
.
errorMessage
);
console
.
log
(
this
.
errorMessage
);
alert
(
errorMessage
);
console
.
log
(
errorMessage
);
}
}
);
}
private
walletChanged
(
walletName
:
string
)
{
let
walletNameNoJson
:
string
=
walletName
.
slice
(
0
,
-
5
);
this
.
currentWalletName
=
walletNameNoJson
;
this
.
globalService
.
setCurrentWalletName
(
walletName
);
}
private
clickedCreate
()
{
private
onCreateClicked
()
{
this
.
router
.
navigate
([
'/setup'
]);
}
}
\ No newline at end of file
}
Breeze.UI/src/app/shared/classes/wallet-load.ts
View file @
8e0f829a
export
class
WalletLoad
{
password
:
string
;
folderPath
:
string
;
name
:
string
;
}
\ No newline at end of file
constructor
(
password
:
string
,
folderPath
:
string
,
name
:
string
)
{
this
.
password
=
password
;
this
.
folderPath
=
folderPath
;
this
.
name
=
name
;
}
private
password
:
string
;
private
folderPath
:
string
;
private
name
:
string
;
}
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