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. |
IBM602-PC0F1E3C\Arundathi | 129dae2 | 2018-07-12 16:22:11 +0530 | [diff] [blame] | 5 | |
| 6 | Copyright (C) 2018 IBM Intellectual Property. All rights reserved. |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 7 | =================================================================== |
| 8 | |
| 9 | Unless otherwise specified, all software contained herein is licensed |
| 10 | under the Apache License, Version 2.0 (the License); |
| 11 | you may not use this software except in compliance with the License. |
| 12 | You may obtain a copy of the License at |
| 13 | |
| 14 | http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | |
| 16 | Unless required by applicable law or agreed to in writing, software |
| 17 | distributed under the License is distributed on an "AS IS" BASIS, |
| 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 | See the License for the specific language governing permissions and |
| 20 | limitations under the License. |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 21 | ============LICENSE_END============================================ |
| 22 | */ |
| 23 | |
| 24 | |
IBM602-PC0F1E3C\Arundathi | 129dae2 | 2018-07-12 16:22:11 +0530 | [diff] [blame] | 25 | import { Component, OnInit, OnDestroy } from '@angular/core'; |
| 26 | import { Http } from '@angular/http'; |
| 27 | import { Subscription } from 'rxjs/Subscription'; |
Arundathi Patil | 465d29e | 2018-07-18 15:41:05 +0530 | [diff] [blame] | 28 | import { Observable } from 'rxjs/Observable'; |
| 29 | import { NotificationsService } from 'angular2-notifications'; |
IBM602-PC0F1E3C\Arundathi | 129dae2 | 2018-07-12 16:22:11 +0530 | [diff] [blame] | 30 | import { saveAs } from 'file-saver'; |
| 31 | import { ModalDismissReasons, NgbModal } from '@ng-bootstrap/ng-bootstrap'; |
Arundathi Patil | 465d29e | 2018-07-18 15:41:05 +0530 | [diff] [blame] | 32 | import { DialogService } from 'ng2-bootstrap-modal'; |
| 33 | import { ConfirmComponent } from '../shared/confirmModal/confirm.component'; |
| 34 | import { appConstants } from '../../constants/app-constants'; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 35 | |
| 36 | @Component({ |
| 37 | selector: 'app-help', |
| 38 | templateUrl: './aboutus.component.html', |
| 39 | styleUrls: ['./aboutus.component.css'] |
| 40 | }) |
IBM602-PC0F1E3C\Arundathi | 129dae2 | 2018-07-12 16:22:11 +0530 | [diff] [blame] | 41 | export class AboutUsComponent implements OnInit, OnDestroy { |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 42 | |
| 43 | public releaseName: any; |
| 44 | public versionNo: any; |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 45 | public contactUsMail: any; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 46 | public data: any; |
| 47 | closeResult: string; |
IBM602-PC0F1E3C\Arundathi | 129dae2 | 2018-07-12 16:22:11 +0530 | [diff] [blame] | 48 | versionLogSubscription: Subscription; |
Arundathi Patil | 465d29e | 2018-07-18 15:41:05 +0530 | [diff] [blame] | 49 | options = { |
| 50 | timeOut: 1000, |
| 51 | showProgressBar: true, |
| 52 | pauseOnHover: true, |
| 53 | clickToClose: true, |
| 54 | maxLength: 200 |
| 55 | }; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 56 | |
Arundathi Patil | 465d29e | 2018-07-18 15:41:05 +0530 | [diff] [blame] | 57 | constructor(private http: Http, private modalService: NgbModal, private dialogService: DialogService, private notificationsService: NotificationsService) { |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | ngOnInit() { |
| 61 | this.versionNo = require('./appVersion.json').versionNo; |
| 62 | this.releaseName = require('./appVersion.json').releaseName; |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 63 | this.contactUsMail = require('../cdt.application.properties.json').CONTACT_US; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 64 | } |
| 65 | |
IBM602-PC0F1E3C\Arundathi | 129dae2 | 2018-07-12 16:22:11 +0530 | [diff] [blame] | 66 | ngOnDestroy() { |
| 67 | if (this.versionLogSubscription) { |
| 68 | this.versionLogSubscription.unsubscribe(); |
| 69 | } |
| 70 | } |
| 71 | |
Arundathi Patil | 465d29e | 2018-07-18 15:41:05 +0530 | [diff] [blame] | 72 | versionLogFile(): Observable<any> { |
| 73 | return this.http.get('app/about-us/versionLog.txt'); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | open(content) { |
Arundathi Patil | 465d29e | 2018-07-18 15:41:05 +0530 | [diff] [blame] | 77 | this.versionLogSubscription = this.versionLogFile() |
| 78 | .subscribe((res) => { |
| 79 | this.data = res.text(); |
| 80 | this.dialogService.addDialog(ConfirmComponent, { |
| 81 | title: 'VERSION CHANGE LOG', |
| 82 | message: this.data, |
| 83 | cancelButtonText: 'CLOSE', |
| 84 | confirmButtonText: 'DOWNLOAD' |
| 85 | }).subscribe(isConfirmed => { |
| 86 | if (isConfirmed) { |
| 87 | this.downloadLogFile() |
| 88 | } else { |
| 89 | // do nothing |
| 90 | } |
| 91 | }); |
| 92 | |
| 93 | }, |
| 94 | (error)=>{ |
| 95 | this.notificationsService.error(appConstants.errors.error, 'unable to fetch change log details'); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 96 | }); |
| 97 | } |
| 98 | |
| 99 | downloadLogFile() { |
| 100 | var blob = new Blob([this.data], { |
| 101 | type: 'text/plain;charset=utf-8' |
| 102 | }); |
| 103 | saveAs(blob, 'versionLog.txt'); |
| 104 | } |
| 105 | |
| 106 | private getDismissReason(reason: any): string { |
| 107 | if (reason === ModalDismissReasons.ESC) { |
| 108 | return 'by pressing ESC'; |
| 109 | } else if (reason === ModalDismissReasons.BACKDROP_CLICK) { |
| 110 | return 'by clicking on a backdrop'; |
| 111 | } else { |
| 112 | return `with: ${reason}`; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | } |