Commit ed1d192a authored by Lukas Burgey's avatar Lukas Burgey

Make some minor changes

parent db59f40d
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</ng-container> </ng-container>
<ng-container matColumnDef="info"> <ng-container matColumnDef="info">
<mat-header-cell *matHeaderCellDef>Info</mat-header-cell> <mat-header-cell *matHeaderCellDef>Info</mat-header-cell>
<mat-cell *matCellDef="let element">{{ element.info }}</mat-cell> <mat-cell *matCellDef="let element">{{ element.info | json }}</mat-cell>
</ng-container> </ng-container>
<mat-header-row *matHeaderRowDef="columns"></mat-header-row> <mat-header-row *matHeaderRowDef="columns"></mat-header-row>
<mat-row *matRowDef="let row; columns: columns;"></mat-row> <mat-row *matRowDef="let row; columns: columns;"></mat-row>
......
<div> <div>
<span *ngIf="userService.userState ? false : true"> <span *ngIf="userService.loggedIn() ? false : true">
<form *ngIf="idps" <form *ngIf="idps"
(ngSubmit)="userService.login(selectedIdP)" #loginForm="ngForm"> (ngSubmit)="userService.login(selectedIdP)" #loginForm="ngForm">
<mat-form-field> <mat-form-field>
...@@ -12,16 +12,19 @@ ...@@ -12,16 +12,19 @@
<button mat-raised-button [disabled]="!loginForm.form.valid" color="accent" type="submit">Login</button> <button mat-raised-button [disabled]="!loginForm.form.valid" color="accent" type="submit">Login</button>
</form> </form>
</span> </span>
<span *ngIf="userService.userState"> <span *ngIf="userService.loggedIn()">
<button mat-button mat-icon-button (click)="dialog.openAccount()"> <button mat-button mat-icon-button (click)="dialog.openAccount()">
<mat-icon>settings</mat-icon> <mat-icon>settings</mat-icon>
</button> </button>
<button mat-button mat-icon-button (click)="dialog.openSshKeys()"> <button mat-button mat-icon-button (click)="dialog.openSshKeys()">
<mat-icon>vpn_key</mat-icon> <mat-icon>vpn_key</mat-icon>
</button> </button>
<button mat-button (click)="dialog.openProfile()"> <button *ngIf="userService.user != null" mat-button (click)="dialog.openProfile()">
{{ userService.user?.email }} {{ userService.user?.email }}
</button> </button>
<button *ngIf="userService.user == null" mat-button (click)="dialog.openProfile()">
Profile
</button>
<button mat-raised-button color="accent" (click)="userService.logout()">Logout</button> <button mat-raised-button color="accent" (click)="userService.logout()">Logout</button>
</span> </span>
</div> </div>
...@@ -18,6 +18,7 @@ export class LoginComponent { ...@@ -18,6 +18,7 @@ export class LoginComponent {
public userService: UserService, public userService: UserService,
public dialog: DialogService, public dialog: DialogService,
) { ) {
if (!userService.loggedIn()) {
this.userService.getIdPPreference().subscribe( this.userService.getIdPPreference().subscribe(
(allAuthInfo: AllAuthInfo) => { (allAuthInfo: AllAuthInfo) => {
if (allAuthInfo === null) { if (allAuthInfo === null) {
...@@ -27,5 +28,6 @@ export class LoginComponent { ...@@ -27,5 +28,6 @@ export class LoginComponent {
this.selectedIdP = allAuthInfo.selected; this.selectedIdP = allAuthInfo.selected;
} }
); );
}
} }
} }
...@@ -251,7 +251,6 @@ export class UserService { ...@@ -251,7 +251,6 @@ export class UserService {
return this.http.post('/backend/api/questionnaire?id='+String(stateItemID), answers).subscribe( return this.http.post('/backend/api/questionnaire?id='+String(stateItemID), answers).subscribe(
(data: t.UserState) => { (data: t.UserState) => {
this.snackBar.open('Uploaded questionnaire'); this.snackBar.open('Uploaded questionnaire');
//this.snackBar.open('Deployed key ' + key.name);
this.updateUserState(data); this.updateUserState(data);
}, },
(err) => { (err) => {
...@@ -263,10 +262,12 @@ export class UserService { ...@@ -263,10 +262,12 @@ export class UserService {
} }
public deleteUser() { public deleteUser() {
return this.http.delete('/backend/api/delete_user/').subscribe( return this.http.delete('/backend/api/delete_user').subscribe(
(data: t.UserState) => { (data: {deleted: boolean}) => {
this.snackBar.open('Deleted user from server'); if (data && data.deleted) {
this.updateUserState(data); this._logout();
this.snackBar.open('Deleted user from server');
}
}, },
(err) => { (err) => {
this.snackBar.open('Error deleting user from server'); this.snackBar.open('Error deleting user from server');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment