dialog.service.ts 1.63 KB
Newer Older
1 2 3 4 5
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';
Lukas Burgey's avatar
Lukas Burgey committed
6
import { AccountComponent } from './account/account.component';
Lukas Burgey's avatar
Lukas Burgey committed
7
import { QuestionnaireComponent } from './questionnaire/questionnaire.component';
8 9 10
import { CredentialsComponent } from './credentials/credentials.component';

import * as t from '../types/types.module';
11 12 13 14 15

@Injectable()
export class DialogService {
  profileDialog: MatDialogRef<any>;
  sshKeysDialog: MatDialogRef<any>;
Lukas Burgey's avatar
Lukas Burgey committed
16
  accountDialog: MatDialogRef<any>;
Lukas Burgey's avatar
Lukas Burgey committed
17
  questionnaireDialog: MatDialogRef<any>;
18
  credentialsDialog: MatDialogRef<any>;
Lukas Burgey's avatar
Lukas Burgey committed
19 20 21 22

  settings = {
    width: '80%',
  };
23 24 25 26 27 28 29 30

  constructor(
    public dialog: MatDialog,
  ) { }

  public openProfile() {
    this.profileDialog = this.dialog.open(
      ProfileComponent,
Lukas Burgey's avatar
Lukas Burgey committed
31
      this.settings,
32 33 34 35 36 37
    );
  }

  public openSshKeys() {
    this.sshKeysDialog = this.dialog.open(
      SshKeysComponent,
Lukas Burgey's avatar
Lukas Burgey committed
38
      this.settings,
39 40 41
    );
  }

Lukas Burgey's avatar
Lukas Burgey committed
42 43 44 45 46 47
  public openAccount() {
    this.accountDialog = this.dialog.open(
      AccountComponent,
      this.settings,
    );
  }
Lukas Burgey's avatar
Lukas Burgey committed
48

49
  public openQuestionnaire(stateItem: t.DeploymentStateItem) {
Lukas Burgey's avatar
Lukas Burgey committed
50 51 52 53
    this.questionnaireDialog = this.dialog.open(
      QuestionnaireComponent,
      {
        data: {
54 55 56 57 58 59 60 61 62 63 64 65
          stateItem: stateItem,
        }
      }
    );
  }

  public openCredentials(stateItem: t.DeploymentStateItem) {
    this.credentialsDialog = this.dialog.open(
      CredentialsComponent,
      {
        data: {
          stateItem: stateItem,
Lukas Burgey's avatar
Lukas Burgey committed
66 67 68 69
        }
      }
    );
  }
70
}