blob: cd6aa7a5d382c6b54fec156ec6a42f0a0da7f1d8 [file] [log] [blame]
Sean Condon2aa86092018-07-16 09:04:05 +01001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { Component, Input, Output, EventEmitter } from '@angular/core';
17import { trigger, state, style, animate, transition } from '@angular/animations';
18import { LogService } from '../../../log.service';
19
20/**
21 * ONOS GUI -- Layer -- Confirm Component
22 *
23 * Replaces Flash Service in old GUI.
24 * Provides a mechanism to present a confirm dialog to the screen
25 *
26 * To use add an element to the template like
27 * <onos-confirm message="Performing something dangerous. Would you like to proceed"></onos-flash>
28 *
29 * An event is raised with either OK or Cancel
30 */
31@Component({
32 selector: 'onos-confirm',
33 templateUrl: './confirm.component.html',
34 styleUrls: [
35 './confirm.component.css',
36 './confirm.theme.css',
37 '../dialog.css',
38 '../dialog.theme.css',
39 '../../widget/panel.css',
40 '../../widget/panel-theme.css'
41 ],
42 animations: [
43 trigger('confirmDlgState', [
44 state('true', style({
45 transform: 'translateX(-100%)',
46 opacity: '100'
47 })),
48 state('false', style({
49 transform: 'translateX(0%)',
50 opacity: '0'
51 })),
52 transition('0 => 1', animate('100ms ease-in')),
53 transition('1 => 0', animate('100ms ease-out'))
54 ])
55 ]
56})
57export class ConfirmComponent {
58 @Input() message: string;
59 @Input() warning: string;
60 @Output() chosen: EventEmitter<boolean> = new EventEmitter();
61
62 constructor(
63 private log: LogService,
64 ) {
65 this.log.debug('ConfirmComponent constructed');
66 }
67
68 /**
69 * When OK or Cancel is pressed, send an event to parent with choice
70 */
71 choice(chosen: boolean): void {
72 this.chosen.emit(chosen);
73 }
74}