summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/components/messageModal/message-modal.service.ts
blob: e1f85bdb011d3b105650771f5e2c2bbe01a80c8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import {Injectable} from "@angular/core";
import {MessageBoxService} from '../messageBox/messageBox.service';
import {MessageBoxData} from '../messageBox/messageBox.data';
import {SdcUiCommon} from "onap-ui-angular";
import {MessageModalModel} from "./message-modal.model";

@Injectable()
export class MessageModal {
  static showMessageModal(message: MessageModalModel): void {
    setTimeout(() => {
        let messageBoxData: MessageBoxData = new MessageBoxData(
          message.title,
          message.text,
          this.getModalType(message),
          SdcUiCommon.ModalSize.medium,
          message.buttons);
        MessageBoxService.openModal.next(messageBoxData);
      }
      , 500);
  };


  static getModalType = (message: MessageModalModel): string => {
    switch (message.type) {
      case "error": {
        return SdcUiCommon.ModalType.error
      }
      case "info": {
        return  SdcUiCommon.ModalType.info;
      }
      case "success":  {
        return  SdcUiCommon.ModalType.success;
      }
    }
  };
}