Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
feudal
feudalWebpage
Commits
ec1715e2
Commit
ec1715e2
authored
Mar 12, 2018
by
Lukas Burgey
Browse files
Implement user deletion
parent
d6b72c4f
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/app/account/account.component.css
0 → 100644
View file @
ec1715e2
src/app/account/account.component.html
0 → 100644
View file @
ec1715e2
<p>
You can delete your account. All deployments will be withdrawn if you chose to do so.
</p>
<p>
<mat-checkbox
[(ngModel)]=
"sure"
style=
"margin-right: 8px"
[checked]=
"sure"
>
I'm sure i want to delete all my data on the server.
</mat-checkbox>
<button
mat-raised-button
mat-dialog-close
color=
"primary"
(click)=
"delete()"
[disabled]=
"!sure"
>
Delete
</button>
</p>
src/app/account/account.component.spec.ts
0 → 100644
View file @
ec1715e2
import
{
async
,
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
AccountComponent
}
from
'
./account.component
'
;
describe
(
'
AccountComponent
'
,
()
=>
{
let
component
:
AccountComponent
;
let
fixture
:
ComponentFixture
<
AccountComponent
>
;
beforeEach
(
async
(()
=>
{
TestBed
.
configureTestingModule
({
declarations
:
[
AccountComponent
]
})
.
compileComponents
();
}));
beforeEach
(()
=>
{
fixture
=
TestBed
.
createComponent
(
AccountComponent
);
component
=
fixture
.
componentInstance
;
fixture
.
detectChanges
();
});
it
(
'
should create
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
});
src/app/account/account.component.ts
0 → 100644
View file @
ec1715e2
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
UserService
}
from
'
../user.service
'
;
@
Component
({
selector
:
'
app-account
'
,
templateUrl
:
'
./account.component.html
'
,
styleUrls
:
[
'
./account.component.css
'
]
})
export
class
AccountComponent
implements
OnInit
{
public
sure
:
boolean
;
constructor
(
public
userService
:
UserService
,
)
{
this
.
sure
=
false
;
}
ngOnInit
()
{
}
delete
()
{
this
.
userService
.
deleteUser
();
}
}
src/app/app.module.ts
View file @
ec1715e2
...
...
@@ -33,6 +33,7 @@ import { LoginComponent } from './login/login.component';
import
{
ProfileComponent
}
from
'
./profile/profile.component
'
;
import
{
ServiceComponent
}
from
'
./service/service.component
'
;
import
{
SshKeysComponent
}
from
'
./ssh-keys/ssh-keys.component
'
;
import
{
AccountComponent
}
from
'
./account/account.component
'
;
/*
const routes = [
...
...
@@ -55,6 +56,7 @@ const routes = [
ProfileComponent
,
ServiceComponent
,
SshKeysComponent
,
AccountComponent
,
],
imports
:
[
BrowserModule
,
...
...
@@ -95,6 +97,7 @@ const routes = [
entryComponents
:
[
ProfileComponent
,
SshKeysComponent
,
AccountComponent
,
],
})
export
class
AppModule
{
...
...
src/app/dialog.service.ts
View file @
ec1715e2
...
...
@@ -3,11 +3,17 @@ import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import
{
ProfileComponent
}
from
'
./profile/profile.component
'
;
import
{
SshKeysComponent
}
from
'
./ssh-keys/ssh-keys.component
'
;
import
{
AccountComponent
}
from
'
./account/account.component
'
;
@
Injectable
()
export
class
DialogService
{
profileDialog
:
MatDialogRef
<
any
>
;
sshKeysDialog
:
MatDialogRef
<
any
>
;
accountDialog
:
MatDialogRef
<
any
>
;
settings
=
{
width
:
'
80%
'
,
};
constructor
(
public
dialog
:
MatDialog
,
...
...
@@ -16,19 +22,21 @@ export class DialogService {
public
openProfile
()
{
this
.
profileDialog
=
this
.
dialog
.
open
(
ProfileComponent
,
{
width
:
'
80%
'
,
}
this
.
settings
,
);
}
public
openSshKeys
()
{
this
.
sshKeysDialog
=
this
.
dialog
.
open
(
SshKeysComponent
,
{
width
:
'
80%
'
,
}
this
.
settings
,
);
}
public
openAccount
()
{
this
.
accountDialog
=
this
.
dialog
.
open
(
AccountComponent
,
this
.
settings
,
);
}
}
src/app/login/login.component.html
View file @
ec1715e2
...
...
@@ -12,6 +12,9 @@
</form>
</span>
<span
*ngIf=
"userService.loggedIn"
>
<button
mat-button
mat-icon-button
(click)=
"dialog.openAccount()"
>
<mat-icon>
settings
</mat-icon>
</button>
<button
mat-button
mat-icon-button
(click)=
"dialog.openSshKeys()"
>
<mat-icon>
vpn_key
</mat-icon>
</button>
...
...
src/app/user.service.ts
View file @
ec1715e2
...
...
@@ -210,4 +210,18 @@ export class UserService {
}
);
}
public
deleteUser
()
{
return
this
.
http
.
delete
(
'
/backend/api/delete_user/
'
).
subscribe
(
(
data
)
=>
{
this
.
snackBar
.
open
(
'
Deleted user from server
'
);
this
.
updateData
(
data
);
},
(
err
)
=>
{
this
.
snackBar
.
open
(
'
Error deleting user from server
'
);
console
.
log
(
err
);
this
.
update
();
}
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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