blob: fe75e4124756b1cd29e7d25321ad36eae6e70293 [file] [log] [blame]
Skip Wonnell2c977e22018-03-01 08:30:15 -06001/*
2============LICENSE_START==========================================
3===================================================================
4Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
IBM602-PC0F1E3C\Arundathi129dae22018-07-12 16:22:11 +05305
6Copyright (C) 2018 IBM Intellectual Property. All rights reserved.
Skip Wonnell2c977e22018-03-01 08:30:15 -06007===================================================================
8
9Unless otherwise specified, all software contained herein is licensed
10under the Apache License, Version 2.0 (the License);
11you may not use this software except in compliance with the License.
12You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16Unless required by applicable law or agreed to in writing, software
17distributed under the License is distributed on an "AS IS" BASIS,
18WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19See the License for the specific language governing permissions and
20limitations under the License.
Skip Wonnell2c977e22018-03-01 08:30:15 -060021============LICENSE_END============================================
22*/
23
24
IBM602-PC0F1E3C\Arundathi129dae22018-07-12 16:22:11 +053025import { Component, OnInit, OnDestroy } from '@angular/core';
26import { Http } from '@angular/http';
27import { Subscription } from 'rxjs/Subscription';
Arundathi Patil465d29e2018-07-18 15:41:05 +053028import { Observable } from 'rxjs/Observable';
29import { NotificationsService } from 'angular2-notifications';
IBM602-PC0F1E3C\Arundathi129dae22018-07-12 16:22:11 +053030import { saveAs } from 'file-saver';
31import { ModalDismissReasons, NgbModal } from '@ng-bootstrap/ng-bootstrap';
Arundathi Patil465d29e2018-07-18 15:41:05 +053032import { DialogService } from 'ng2-bootstrap-modal';
33import { ConfirmComponent } from '../shared/confirmModal/confirm.component';
34import { appConstants } from '../../constants/app-constants';
Skip Wonnell2c977e22018-03-01 08:30:15 -060035
36@Component({
37 selector: 'app-help',
38 templateUrl: './aboutus.component.html',
39 styleUrls: ['./aboutus.component.css']
40})
IBM602-PC0F1E3C\Arundathi129dae22018-07-12 16:22:11 +053041export class AboutUsComponent implements OnInit, OnDestroy {
Skip Wonnell2c977e22018-03-01 08:30:15 -060042
43 public releaseName: any;
44 public versionNo: any;
sj108sf27d5542018-04-02 14:46:25 +053045 public contactUsMail: any;
Skip Wonnell2c977e22018-03-01 08:30:15 -060046 public data: any;
47 closeResult: string;
IBM602-PC0F1E3C\Arundathi129dae22018-07-12 16:22:11 +053048 versionLogSubscription: Subscription;
Arundathi Patil465d29e2018-07-18 15:41:05 +053049 options = {
50 timeOut: 1000,
51 showProgressBar: true,
52 pauseOnHover: true,
53 clickToClose: true,
54 maxLength: 200
55 };
Skip Wonnell2c977e22018-03-01 08:30:15 -060056
Arundathi Patil465d29e2018-07-18 15:41:05 +053057 constructor(private http: Http, private modalService: NgbModal, private dialogService: DialogService, private notificationsService: NotificationsService) {
Skip Wonnell2c977e22018-03-01 08:30:15 -060058 }
59
60 ngOnInit() {
61 this.versionNo = require('./appVersion.json').versionNo;
62 this.releaseName = require('./appVersion.json').releaseName;
sj108sf27d5542018-04-02 14:46:25 +053063 this.contactUsMail = require('../cdt.application.properties.json').CONTACT_US;
Skip Wonnell2c977e22018-03-01 08:30:15 -060064 }
65
IBM602-PC0F1E3C\Arundathi129dae22018-07-12 16:22:11 +053066 ngOnDestroy() {
67 if (this.versionLogSubscription) {
68 this.versionLogSubscription.unsubscribe();
69 }
70 }
71
Arundathi Patil465d29e2018-07-18 15:41:05 +053072 versionLogFile(): Observable<any> {
73 return this.http.get('app/about-us/versionLog.txt');
Skip Wonnell2c977e22018-03-01 08:30:15 -060074 }
75
76 open(content) {
Arundathi Patil465d29e2018-07-18 15:41:05 +053077 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 Wonnell2c977e22018-03-01 08:30:15 -060096 });
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}