added svcapi ui and camunda code
[it/otf.git] / otf-frontend / client / src / app / shared / modules / alert-modal / alert-modal.component.ts
1 /*  Copyright (c) 2019 AT&T Intellectual Property.                             #\r
2 #                                                                              #\r
3 #   Licensed under the Apache License, Version 2.0 (the "License");            #\r
4 #   you may not use this file except in compliance with the License.           #\r
5 #   You may obtain a copy of the License at                                    #\r
6 #                                                                              #\r
7 #       http://www.apache.org/licenses/LICENSE-2.0                             #\r
8 #                                                                              #\r
9 #   Unless required by applicable law or agreed to in writing, software        #\r
10 #   distributed under the License is distributed on an "AS IS" BASIS,          #\r
11 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #\r
12 #   See the License for the specific language governing permissions and        #\r
13 #   limitations under the License.                                             #\r
14 ##############################################################################*/\r
15 \r
16 \r
17 import {Component, Inject, OnInit} from '@angular/core';\r
18 import {MAT_DIALOG_DATA, MatDialogRef,} from '@angular/material';\r
19 \r
20 @Component({\r
21     selector: 'app-alert-modal',\r
22     templateUrl: './alert-modal.component.pug',\r
23     styleUrls: ['./alert-modal.component.scss']\r
24 })\r
25 export class AlertModalComponent implements OnInit {\r
26     public data;\r
27     public type;\r
28     public html;\r
29 \r
30     constructor(\r
31         public dialogRef: MatDialogRef<AlertModalComponent>,\r
32         @Inject(MAT_DIALOG_DATA) public input_data\r
33     ) {\r
34         this.data = this.input_data;\r
35         if (this.data.type.match(new RegExp('^warning$', 'i'))) {\r
36             this.type = 'warning';\r
37         } else if (this.data.type.match(new RegExp('^confirmation$', 'i'))) {\r
38             this.type = 'confirmation';\r
39         } else if (this.data.type.match(new RegExp('^alert$', 'i'))) {\r
40             this.type = 'alert';\r
41         } else if (this.data.type.match(new RegExp('^ok$', 'i'))) {\r
42             this.type = 'ok';\r
43         } else if (this.data.type.match(new RegExp('^userAdmin$', 'i'))) {\r
44             this.type = 'userAdmin';\r
45         } else {\r
46             this.type = 'info';\r
47         }\r
48     }\r
49 \r
50     ngOnInit() {\r
51         if(this.data.html){\r
52             this.html = this.data.html;\r
53         }\r
54     }\r
55 \r
56     okay() {\r
57         this.dialogRef.close();\r
58     }\r
59 \r
60     confirmed() {\r
61         this.dialogRef.close(true);\r
62     }\r
63 \r
64     canceled() {\r
65         this.dialogRef.close(false);\r
66     }\r
67 }\r