X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=webapp%2Fsrc%2Fapp%2Fpages%2Fconfirm%2Fconfirm-modal%2Fconfirm-modal.component.ts;fp=webapp%2Fsrc%2Fapp%2Fpages%2Fconfirm%2Fconfirm-modal%2Fconfirm-modal.component.ts;h=3282d6bc06efa4645be2b0ed86c8b7408d0a510d;hb=265469335019c494c1d61da9a0acea3ab7504ae8;hp=0000000000000000000000000000000000000000;hpb=89563054ea6305c7270dcc6ab6fa5b286eb5f742;p=src%2Fxds%2Fxds-agent.git diff --git a/webapp/src/app/pages/confirm/confirm-modal/confirm-modal.component.ts b/webapp/src/app/pages/confirm/confirm-modal/confirm-modal.component.ts new file mode 100644 index 0000000..3282d6b --- /dev/null +++ b/webapp/src/app/pages/confirm/confirm-modal/confirm-modal.component.ts @@ -0,0 +1,94 @@ +/** +* @license +* Copyright (C) 2017 "IoT.bzh" +* Author Sebastien Douheret +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { Component, OnInit, Input } from '@angular/core'; +import { DomSanitizer } from '@angular/platform-browser'; +import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; + +export enum EType { + YesNo = 1, + OKCancel, + OK, +} + +@Component({ + selector: 'xds-confirm-modal', + template: ` +
+ + + + + +
+ `, +}) + +export class ConfirmModalComponent implements OnInit { + @Input() title; + @Input() footer = ''; + @Input() type; + @Input() question; + + bodyQuestion = ''; + textBtn: Array = ['', '', '']; + + constructor( + private modalRef: NgbActiveModal, + private sanitizer: DomSanitizer, + ) { } + + ngOnInit() { + switch (this.type) { + case EType.OK: + this.textBtn = [ 'OK', '', '' ]; + break; + + case EType.OKCancel: + this.textBtn = [ 'OK', 'Cancel', '' ]; + break; + + default: + case EType.YesNo: + this.textBtn = [ 'Yes', 'No', '' ]; + break; + } + } + + onClick(txt: string): void { + this.modalRef.close(txt.toLowerCase()); + } +}