Commit 3370ee72 authored by lukas.burgey's avatar lukas.burgey

Change answers type

parent 26525422
......@@ -4,7 +4,7 @@ import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { Observable, BehaviorSubject } from 'rxjs';
import { UserService } from '../../user.service';
import { JSONObject, DeploymentState } from '../../types/types.module';
import { Answers, DeploymentState } from '../../types/types.module';
@Component({
selector: 'app-questionnaire',
......@@ -13,7 +13,7 @@ import { JSONObject, DeploymentState } from '../../types/types.module';
})
export class QuestionnaireComponent implements OnInit {
public answers$ = <BehaviorSubject<JSONObject>> new BehaviorSubject(undefined);
public answers$ = <BehaviorSubject<Answers>> new BehaviorSubject(undefined);
constructor(
public userService: UserService,
......@@ -22,7 +22,7 @@ export class QuestionnaireComponent implements OnInit {
state$.subscribe(
(state: DeploymentState) => {
let answers;
let answers: Answers;
// initialize the answers if needed
if (state.answers === undefined) {
......@@ -47,7 +47,7 @@ export class QuestionnaireComponent implements OnInit {
ngOnInit() {
}
sendAnswers(state: DeploymentState, answers: JSONObject) {
sendAnswers(state: DeploymentState, answers: Answers) {
this.userService.sentQuestionnaire(state.id, answers);
}
}
......@@ -89,6 +89,8 @@ export interface JSONObjectAny {
[key: string]: any;
}
export type Answers = JSONObjectAny;
export interface CredentialState {
credential: SSHKeyRef;
is_pending: boolean;
......@@ -97,7 +99,7 @@ export interface CredentialState {
}
export interface DeploymentState {
answers: JSONObjectAny | undefined;
answers: Answers | undefined;
credential_states: CredentialState[];
credentials: JSONObject;
id: number;
......
......@@ -11,7 +11,7 @@ import { SnackBarService } from './snackbar.service';
import { PreferencesService, Prefs } from './preferences/preferences.service';
import {
VO, User, Update, State, Deployment, DeploymentState, SSHKey, NewSSHKey, IdP, Service, Site, JSONObject, IdPInfo
VO, User, Update, State, Deployment, DeploymentState, SSHKey, NewSSHKey, IdP, Service, Site, Answers, IdPInfo
} from './types/types.module';
// TODO terrible name
......@@ -389,7 +389,7 @@ export class UserService {
);
}
public sentQuestionnaire(stateItemID: number, answers: JSONObject) {
public sentQuestionnaire(stateItemID: number, answers: Answers) {
return this.http.patch<DeploymentState>(
`/user/state/${ stateItemID }`,
{'answers': answers},
......
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