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
9700e4ed
Commit
9700e4ed
authored
Dec 07, 2018
by
Lukas Burgey
Browse files
Switch to new REST API for the ssh keys
parent
1b548a35
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/app/sshkeys/sshkeys.component.ts
View file @
9700e4ed
...
...
@@ -44,12 +44,7 @@ export class SshkeysComponent implements OnInit {
}
uploadKey
()
{
const
formData
=
new
FormData
()
formData
.
append
(
'
type
'
,
'
add
'
);
formData
.
append
(
'
name
'
,
this
.
formKey
.
name
);
formData
.
append
(
'
key
'
,
this
.
formKey
.
key
);
this
.
userService
.
uploadSshKey
(
formData
);
this
.
userService
.
uploadSshKey
(
this
.
formKey
.
name
,
this
.
formKey
.
key
);
this
.
resetKeyUpload
();
}
...
...
@@ -72,11 +67,11 @@ export class SshkeysComponent implements OnInit {
this
.
files
.
forEach
(
file
=>
{
const
formData
=
new
FormData
();
formData
.
append
(
'
type
'
,
'
add
'
);
formData
.
append
(
'
name
'
,
file
.
name
);
formData
.
append
(
'
file
'
,
file
,
file
.
name
)
;
this
.
userService
.
uploadSshKey
(
formData
);
const
reader
=
new
FileReader
();
reader
.
onload
=
(
e
)
=>
{
this
.
userService
.
uploadSshKey
(
file
.
name
,
reader
.
result
);
}
;
reader
.
readAsText
(
file
);
}
);
...
...
src/app/user.service.ts
View file @
9700e4ed
...
...
@@ -212,11 +212,6 @@ export class UserService {
(
state
:
State
)
=>
this
.
updateState
(
state
),
this
.
handleError
(
false
,
'
Error fetching state. Try again later
'
),
);
this
.
http
.
post
<
SSHKey
>
(
'
/rest/ssh-keys
'
,
{
'
name
'
:
'
foo
'
,
'
key
'
:
'
bar
'
}).
subscribe
(
(
key
:
SSHKey
)
=>
console
.
log
(
key
),
err
=>
console
.
log
(
err
),
);
}
private
handleError
(
fetch
:
boolean
,
msg
?:
string
)
{
...
...
@@ -289,8 +284,8 @@ export class UserService {
);
}
public
uploadSshKey
(
formData
:
FormData
):
void
{
this
.
http
.
post
<
SSHKey
>
(
'
/
backend/api
/sshkey
'
,
formData
).
pipe
(
public
uploadSshKey
(
name
:
string
,
key
:
string
|
ArrayBuffer
):
void
{
this
.
http
.
post
<
SSHKey
>
(
'
/
rest
/ssh
-
key
s
'
,
{
'
name
'
:
name
,
'
key
'
:
key
}
).
pipe
(
catchError
(
this
.
handleError
(
true
,
"
Error changing deployment
"
)),
).
subscribe
(
(
newKey
:
SSHKey
)
=>
{
...
...
@@ -303,19 +298,14 @@ export class UserService {
public
removeSshKey
(
key
:
SSHKey
)
{
console
.
log
(
'
Deleting key:
'
,
key
);
return
this
.
http
.
post
(
'
/backend/api/sshkey
'
,
{
'
type
'
:
'
remove
'
,
'
id
'
:
key
.
id
,
}).
pipe
(
return
this
.
http
.
delete
(
'
/rest/ssh-key?id=
'
+
key
.
id
.
toString
()).
pipe
(
catchError
(
this
.
handleError
(
true
,
"
Error changing deployment
"
)),
).
subscribe
(
(
data
:
{
deleted
:
boolean
})
=>
{
if
(
data
&&
data
.
deleted
)
{
_
=>
{
this
.
sshKeys
=
this
.
sshKeys
.
filter
(
k
=>
key
.
id
!=
k
.
id
);
this
.
sshKeys$
.
next
(
this
.
sshKeys
);
}
},
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