dialog.service.ts 1.93 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
import { CredentialsComponent } from './credentials/credentials.component';
Lukas Burgey's avatar
Lukas Burgey committed
9
import { MessageComponent } from './message/message.component';
10 11

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

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

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

  constructor(
    public dialog: MatDialog,
  ) { }

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

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

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

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

62
  public openCredentials(stateItem: t.DeploymentStateItem) {
63 64 65 66 67
    this.credentialsDialog = this.dialog.open(
      CredentialsComponent,
      {
        data: {
          stateItem: stateItem,
Lukas Burgey's avatar
Lukas Burgey committed
68 69 70 71
        }
      }
    );
  }
Lukas Burgey's avatar
Lukas Burgey committed
72 73 74 75 76 77 78 79 80 81 82

  public openMessage(stateItem: t.DeploymentStateItem) {
    this.messageDialog = this.dialog.open(
      MessageComponent,
      {
        data: {
          stateItem: stateItem,
        }
      }
    );
  }
83
}