Commit 7c9287b1 authored by Lukas Burgey's avatar Lukas Burgey

Rework dialogues

parent ab93a051
......@@ -2,7 +2,7 @@
<div *ngIf="credentialCount > 0" style="margin-bottom: 50px;">
<h2>Credentials</h2>
<p>
For access to the service {{ stateItem.service.name }} at {{ stateItem.service.site.name }} additional credentials are needed.
For access to the service {{ stateItem.service?.name }} at {{ stateItem.service.site?.name }} additional credentials are needed.
The additional credentials are listed below.
</p>
<mat-table [dataSource]="table">
......
......@@ -15,39 +15,33 @@ import { DeploymentState, Service, CredentialState } from '../../types/types.mod
export class CredentialsComponent implements OnInit {
public columns = ["name", "value"];
public stateItem$: Observable<DeploymentState>;
public credentialCount: number = 0;
public table: MatTableDataSource<any>;
constructor(
public userService: UserService,
public lang: LanguageService,
@Inject(MAT_DIALOG_DATA) public data: any,
@Inject(MAT_DIALOG_DATA) public stateItem$: Observable<DeploymentState>,
) {
if (data) {
this.stateItem$ = data.stateItem$;
}
stateItem$.subscribe(
(stateItem: DeploymentState) => {
const credentialList = [];
for (const key in stateItem.credentials) {
if (stateItem.credentials.hasOwnProperty(key)) {
credentialList.push(
{
name: key,
value: stateItem.credentials[key],
}
);
}
}
this.credentialCount = credentialList.length;
this.table = new MatTableDataSource(credentialList);
}
);
}
ngOnInit() {
if (this.stateItem$) {
this.stateItem$.subscribe(
(stateItem: DeploymentState) => {
const credentialList = [];
for (const key in stateItem.credentials) {
if (stateItem.credentials.hasOwnProperty(key)) {
credentialList.push(
{
name: key,
value: stateItem.credentials[key],
}
);
}
}
this.credentialCount = credentialList.length;
this.table = new MatTableDataSource(credentialList);
}
);
}
}
}
......@@ -47,19 +47,17 @@ export class DialogService {
);
}
public openQuestionnaire(stateItem: DeploymentState) {
public openQuestionnaire(state: Observable<DeploymentState>) {
this.questionnaireDialog = this.dialog.open(
QuestionnaireComponent,
this.settingsData(stateItem),
this.settingsData(state),
);
}
public openCredentials(stateItem$: Observable<DeploymentState>) {
public openCredentials(state: Observable<DeploymentState>) {
this.credentialsDialog = this.dialog.open(
CredentialsComponent,
this.settingsData({
stateItem$: stateItem$,
}),
this.settingsData(state),
);
}
......
......@@ -19,10 +19,7 @@ export class QuestionnaireComponent implements OnInit {
public userService: UserService,
@Inject(MAT_DIALOG_DATA) public state$: Observable<DeploymentState>,
) {
}
ngOnInit() {
this.state$.subscribe(
state$.subscribe(
(state: DeploymentState) => {
let answers = undefined;
......@@ -47,6 +44,9 @@ export class QuestionnaireComponent implements OnInit {
);
}
ngOnInit() {
}
sendAnswers(state: DeploymentState, answers: JSONObject) {
this.userService.sentQuestionnaire(state.id, answers);
}
......
......@@ -12,9 +12,9 @@
</span>
</td>
<ng-container *ngIf="(state$ | async) as stateItem; else noStateItem">
<td class="spaced" [matTooltip]="tooltip(stateItem)">
<span [ngSwitch]="stateItem.state" class="spaced">
<ng-container *ngIf="(state$ | async) as state; else noStateItem">
<td [matTooltip]="tooltip(state)">
<span [ngSwitch]="state.state" class="spaced">
<mat-icon *ngSwitchCase="'deployed'">call_made</mat-icon>
<mat-icon *ngSwitchCase="'questionnaire'">warning</mat-icon>
<mat-progress-spinner *ngSwitchCase="'deployment_pending'" diameter="24" mode="indeterminate"></mat-progress-spinner>
......@@ -24,36 +24,38 @@
<mat-icon *ngSwitchCase="'rejected'" mat-icon-button>error</mat-icon>
<mat-icon *ngSwitchDefault mat-icon-button>call_received</mat-icon>
</span>
{{ lang.printState(stateItem.state) }}
{{ lang.printState(state.state) }}
</td>
<td class="spaced">
<span [ngSwitch]="stateItem.state">
<button *ngSwitchCase="'deployed'" (click)="dialog.openCredentials(userService.subscribeStateFor(service))" mat-raised-button class="mat-elevation-z6">
Credentials
</button>
<button *ngSwitchCase="'questionnaire'" (click)="dialog.openQuestionnaire(stateItem)" mat-raised-button class="mat-elevation-z6">
<!-- state dependent buttons -->
<td *ngIf="state.state == 'deployed'">
<button (click)="dialog.openCredentials(state$)" mat-raised-button class="mat-elevation-z6">
Credentials
</button>
</td>
<td *ngIf="state.state == 'questionnaire'">
<button (click)="dialog.openQuestionnaire(state$)" mat-raised-button class="mat-elevation-z6">
Questionnaire
</button>
<button *ngSwitchCase="'failed'" (click)="dialog.openMessage(stateItem)" mat-raised-button class="mat-elevation-z6">
Failure
</button>
<button *ngSwitchCase="'rejected'" (click)="dialog.openMessage(stateItem)" mat-raised-button class="mat-elevation-z6">
Rejected
</button>
</span>
</td>
<td *ngIf="stateItem.answers != undefined" matTooltip="Change previously submitted answers" class="spaced">
<span>
<button (click)="dialog.openQuestionnaire(state$)" mat-icon-button>
<mat-icon>edit</mat-icon>
</button>
</span>
<td *ngIf="state.state == 'failed'">
<button (click)="dialog.openMessage(state)" mat-raised-button class="mat-elevation-z6">
Failure
</button>
</td>
<td class="spaced">
<span *ngIf="!stateItem.is_pending && stateItem.is_credential_pending" class="spaced">
<td *ngIf="state.state == 'rejected'">
<button (click)="dialog.openMessage(state)" mat-raised-button class="mat-elevation-z6">
Rejected
</button>
</td>
<td *ngIf="(state.questionnaire | ObjKeys).length > 0 && state.state != 'not_deployed'"
matTooltip="Change previously submitted answers">
<button (click)="dialog.openQuestionnaire(state$)" mat-icon-button>
<mat-icon>edit</mat-icon>
</button>
</td>
<td *ngIf="!state.is_pending && state.is_credential_pending" class="spaced">
<span>
<mat-progress-spinner diameter="24" mode="indeterminate"></mat-progress-spinner>
SSH Keys pending
</span>
......
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