3552068399cc2210f100f80d683a5bb27881e50f
[sdc/sdc-workflow-designer.git] /
1 /**
2  * Copyright (c) 2017 ZTE Corporation.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * and the Apache License 2.0 which both accompany this distribution,
6  * and are available at http://www.eclipse.org/legal/epl-v10.html
7  * and http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Contributors:
10  *     ZTE - initial API and implementation and/or initial documentation
11  */
12
13 import { Component, OnInit } from '@angular/core';
14
15 import { Notice } from '../../model/notice';
16 import { NoticeType } from '../../model/notice-type.enum';
17 import { NoticeService } from '../../services/notice.service';
18
19 @Component({
20   selector: 'wfm-notice',
21   templateUrl: './global-notice.component.html',
22   styleUrls: ['./global-notice.component.css']
23 })
24 export class GlobalNoticeComponent implements OnInit {
25   public notices: Notice[] = [];
26   public noticeType = NoticeType;
27
28   constructor(private noticeService: NoticeService) { }
29
30   ngOnInit() {
31     // const t = new Notice(NoticeType.success, 'success');
32     // const t1 = new Notice(NoticeType.info, 'info');
33     // const t2 = new Notice(NoticeType.warning, 'warning');
34     // const t3 = new Notice(NoticeType.danger, 'danger');
35     // this.notices.push(t);
36     // this.notices.push(t1);
37     // this.notices.push(t2);
38     // this.notices.push(t3);
39     this.noticeService.showNotice$.subscribe(notice => {
40       this.notices.push(notice);
41     });
42   }
43
44   public onClosed(index: number): void {
45     this.notices.splice(index, 1);
46   }
47
48 }