Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
feudal
feudalWebpage
Commits
8e571c0e
Commit
8e571c0e
authored
Jan 19, 2019
by
Lukas Burgey
Browse files
Put ssh keys into a map
parent
6eac125b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/app/user.service.ts
View file @
8e571c0e
...
...
@@ -28,7 +28,7 @@ export class UserService {
private
user
:
User
;
private
user$
:
BehaviorSubject
<
User
>
;
private
sshKeys
:
SSHKey
[]
=
new
Array
<
SSHKey
>
(
);
private
sshKeys
:
Map
<
number
,
SSHKey
>
=
new
Map
([]
);
private
sshKeys$
=
new
BehaviorSubject
<
SSHKey
[]
>
([]);
private
deploymentStates
:
Map
<
number
,
DeploymentState
>
=
new
Map
([]);
...
...
@@ -71,11 +71,10 @@ export class UserService {
this
.
user
=
undefined
;
this
.
deployments
=
new
Map
([]);
this
.
deployments$
.
next
([]);
this
.
sshKeys
=
[];
this
.
sshKeys
=
new
Map
(
[]
)
;
this
.
sshKeys$
.
next
([]);
}
this
.
loggedIn
=
false
;
}
else
{
// LOGGED IN
...
...
@@ -88,8 +87,11 @@ export class UserService {
this
.
connectLiveUpdates
(
newUser
.
id
);
}
if
(
newUser
.
ssh_keys
)
{
this
.
sshKeys
=
newUser
.
ssh_keys
;
this
.
sshKeys$
.
next
(
this
.
sshKeys
);
this
.
sshKeys
=
new
Map
([]);
newUser
.
ssh_keys
.
forEach
(
(
key
:
SSHKey
)
=>
this
.
sshKeys
.
set
(
key
.
id
,
key
),
);
this
.
sshKeys$
.
next
(
Array
.
from
(
this
.
sshKeys
.
values
()));
}
if
(
newUser
.
deployments
)
{
newUser
.
deployments
.
forEach
(
...
...
@@ -294,8 +296,8 @@ export class UserService {
catchError
(
this
.
handleError
(
true
,
"
Error changing deployment
"
)),
).
subscribe
(
(
newKey
:
SSHKey
)
=>
{
this
.
sshKeys
.
push
(
newKey
);
this
.
sshKeys$
.
next
(
this
.
sshKeys
);
this
.
sshKeys
.
set
(
newKey
.
id
,
newKey
);
this
.
sshKeys$
.
next
(
Array
.
from
(
this
.
sshKeys
.
values
())
);
},
this
.
logErrorAndFetch
,
);
...
...
@@ -307,10 +309,8 @@ export class UserService {
catchError
(
this
.
handleError
(
true
,
"
Error changing deployment
"
)),
).
subscribe
(
_
=>
{
this
.
sshKeys
=
this
.
sshKeys
.
filter
(
k
=>
key
.
id
!=
k
.
id
);
this
.
sshKeys$
.
next
(
this
.
sshKeys
);
this
.
sshKeys
.
delete
(
key
.
id
);
this
.
sshKeys$
.
next
(
Array
.
from
(
this
.
sshKeys
.
values
()));
},
this
.
logErrorAndFetch
,
);
...
...
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