Commit 159804b5 authored by Lukas Burgey's avatar Lukas Burgey

Handle when the user has not yet uploaded a key

parent eef0cde5
......@@ -24,6 +24,7 @@ import { CookieService } from 'ngx-cookie-service';
import { UserService } from './user.service';
import { SnackBarService } from './snackbar.service';
import { DialogService } from './dialog.service';
import { AppComponent } from './app.component';
import { MgmtComponent } from './mgmt/mgmt.component';
......@@ -81,6 +82,7 @@ const routes = [
CookieService,
UserService,
SnackBarService,
DialogService,
JsonPipe,
],
bootstrap: [AppComponent],
......
import { TestBed, inject } from '@angular/core/testing';
import { DialogService } from './dialog.service';
describe('DialogService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [DialogService]
});
});
it('should be created', inject([DialogService], (service: DialogService) => {
expect(service).toBeTruthy();
}));
});
import { Injectable } from '@angular/core';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import { ProfileComponent } from './profile/profile.component';
import { SshKeysComponent } from './ssh-keys/ssh-keys.component';
@Injectable()
export class DialogService {
profileDialog: MatDialogRef<any>;
sshKeysDialog: MatDialogRef<any>;
constructor(
public dialog: MatDialog,
) { }
public openProfile() {
this.profileDialog = this.dialog.open(
ProfileComponent,
{
width: '80%',
}
);
}
public openSshKeys() {
this.sshKeysDialog = this.dialog.open(
SshKeysComponent,
{
width: '80%',
}
);
}
}
......@@ -2,10 +2,10 @@
<button mat-raised-button color="accent" (click)="userService.login()">Login</button>
</span>
<span *ngIf="userService.loggedIn">
<button mat-button mat-icon-button (click)="openSshKeys()">
<button mat-button mat-icon-button (click)="dialog.openSshKeys()">
<mat-icon>vpn_key</mat-icon>
</button>
<button mat-button (click)="openProfile()">
<button mat-button (click)="dialog.openProfile()">
{{ userService.user?.username }}
</button>
<button mat-raised-button color="accent" (click)="userService.logout()">Logout</button>
......
import { Component } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ProfileComponent } from '../profile/profile.component';
import { SshKeysComponent } from '../ssh-keys/ssh-keys.component';
import { DialogService } from '../dialog.service';
import { UserService } from '../user.service';
@Component({
......@@ -15,24 +13,6 @@ export class LoginComponent {
constructor(
public userService: UserService,
public dialog: MatDialog,
public dialog: DialogService,
) { }
public openProfile() {
this.profileDialog = this.dialog.open(
ProfileComponent,
{
width: '80%',
}
);
}
public openSshKeys() {
this.profileDialog = this.dialog.open(
SshKeysComponent,
{
width: '80%',
}
);
}
}
......@@ -19,14 +19,19 @@
</ul>
<mat-action-row>
<span style="margin-right: 15px">
Deployed keys:
</span><br/>
<mat-checkbox *ngFor="let key of userService.user.ssh_keys"
style="margin-right: 10px"
[checked]="isDeployed(key)"
(change)="deploymentChange(key)">
{{ key.name }}
</mat-checkbox>
<div *ngIf="userService.user.ssh_keys.length > 0">
<span style="margin-right: 15px">
Deployed keys:
</span><br/>
<mat-checkbox *ngFor="let key of userService.user.ssh_keys"
style="margin-right: 8px"
[checked]="isDeployed(key)"
(change)="deploymentChange(key)">
{{ key.name }}
</mat-checkbox>
</div>
<div *ngIf="userService.user.ssh_keys.length === 0">
<button mat-icon-button (click)="dialog.openSshKeys()"><mat-icon>vpn_key</mat-icon></button>
</div>
</mat-action-row>
</mat-expansion-panel>
......@@ -2,6 +2,8 @@ import { Component, OnInit, Input } from '@angular/core';
import { MatCheckboxChange } from '@angular/material/checkbox';
import { UserService } from '../user.service';
import { DialogService } from '../dialog.service';
import { SshKeysComponent } from '../ssh-keys/ssh-keys.component';
@Component({
selector: 'app-service',
......@@ -13,6 +15,7 @@ export class ServiceComponent implements OnInit {
constructor(
public userService: UserService,
public dialog: DialogService,
) {
}
......
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