Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 1 | /* |
| 2 | ============LICENSE_START========================================== |
| 3 | =================================================================== |
| 4 | Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. |
| 5 | =================================================================== |
| 6 | |
| 7 | Unless otherwise specified, all software contained herein is licensed |
| 8 | under the Apache License, Version 2.0 (the License); |
| 9 | you may not use this software except in compliance with the License. |
| 10 | You may obtain a copy of the License at |
| 11 | |
| 12 | http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | |
| 14 | Unless required by applicable law or agreed to in writing, software |
| 15 | distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | See the License for the specific language governing permissions and |
| 18 | limitations under the License. |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 19 | ============LICENSE_END============================================ |
| 20 | */ |
| 21 | |
| 22 | |
| 23 | import {Component, OnInit} from '@angular/core'; |
| 24 | import {Http} from '@angular/http'; |
| 25 | import {saveAs} from 'file-saver'; |
| 26 | import {ModalDismissReasons, NgbModal} from '@ng-bootstrap/ng-bootstrap'; |
| 27 | |
| 28 | @Component({ |
| 29 | selector: 'app-help', |
| 30 | templateUrl: './aboutus.component.html', |
| 31 | styleUrls: ['./aboutus.component.css'] |
| 32 | }) |
| 33 | export class AboutUsComponent implements OnInit { |
| 34 | |
| 35 | public releaseName: any; |
| 36 | public versionNo: any; |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame^] | 37 | public contactUsMail: any; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 38 | public data: any; |
| 39 | closeResult: string; |
| 40 | |
| 41 | constructor(private http: Http, private modalService: NgbModal) { |
| 42 | } |
| 43 | |
| 44 | ngOnInit() { |
| 45 | this.versionNo = require('./appVersion.json').versionNo; |
| 46 | this.releaseName = require('./appVersion.json').releaseName; |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame^] | 47 | this.contactUsMail = require('../cdt.application.properties.json').CONTACT_US; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | versionLogFile() { |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 51 | this.http.get('app/about-us/versionLog.txt') |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 52 | .subscribe(res => this.data = res.text()); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | open(content) { |
| 56 | this.modalService.open(content).result.then((result) => { |
| 57 | this.closeResult = `Closed with: ${result}`; |
| 58 | }, (reason) => { |
| 59 | this.closeResult = `Dismissed ${this.getDismissReason(reason)}`; |
| 60 | }); |
| 61 | } |
| 62 | |
| 63 | downloadLogFile() { |
| 64 | var blob = new Blob([this.data], { |
| 65 | type: 'text/plain;charset=utf-8' |
| 66 | }); |
| 67 | saveAs(blob, 'versionLog.txt'); |
| 68 | } |
| 69 | |
| 70 | private getDismissReason(reason: any): string { |
| 71 | if (reason === ModalDismissReasons.ESC) { |
| 72 | return 'by pressing ESC'; |
| 73 | } else if (reason === ModalDismissReasons.BACKDROP_CLICK) { |
| 74 | return 'by clicking on a backdrop'; |
| 75 | } else { |
| 76 | return `with: ${reason}`; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | } |