aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/about-us/aboutus.component.ts
diff options
context:
space:
mode:
authorArundathi Patil <arundpil@in.ibm.com>2018-07-18 15:41:05 +0530
committerTakamune Cho <tc012c@att.com>2018-07-24 14:43:16 +0000
commit465d29eba2c191e768963a1987819b8f72e9e7c8 (patch)
treeb438e3f54b156ce7f520f075e159daa523e8f379 /src/app/about-us/aboutus.component.ts
parent63db30487e65a978e745216e3d89e7f30385205e (diff)
Made use of ng2-bootstrap-modal.
This will remove all the duplicate code of ng-bootstrap popup. Made following changes to the below files, 1. app.module.ts: a. added the confirm modal component to declarations and entryComponents section because component will be created dynamically. b. imported BootstrapModalModule from ng2-bootstrap-modal 2. vnfs.module.ts: a. removed the confirm modal component from declarations and entryComponents section as it is already declared as part of app.module.ts. 3. confirm.component.ts: a. added two more varibles 'cancelButtonText' and 'confirmButtonText' to ConfirmModel interface. these values will be sent by the caller code and the button lables will be set dynamically. b. implemented cancel method that sets the modal result value to false, this is called on click of close button. 4. about.component.ts: a. Made use of confirm.component.ts. b. on click of 'view change log' buton we are calling open() method which inturn opens the confirm modal component. 5. about.component.html: a. Removed call to versionLogFile() method as this method is called from open() method. b. Removed the ng-template code of ng-bootstrap which is no more required. Issue-ID: APPC-1088 Change-Id: I9de545debed145ef35e31807acd1e9bd9cc2bad4 Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
Diffstat (limited to 'src/app/about-us/aboutus.component.ts')
-rw-r--r--src/app/about-us/aboutus.component.ts44
1 files changed, 35 insertions, 9 deletions
diff --git a/src/app/about-us/aboutus.component.ts b/src/app/about-us/aboutus.component.ts
index c983c7b..fe75e41 100644
--- a/src/app/about-us/aboutus.component.ts
+++ b/src/app/about-us/aboutus.component.ts
@@ -25,8 +25,13 @@ limitations under the License.
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Http } from '@angular/http';
import { Subscription } from 'rxjs/Subscription';
+import { Observable } from 'rxjs/Observable';
+import { NotificationsService } from 'angular2-notifications';
import { saveAs } from 'file-saver';
import { ModalDismissReasons, NgbModal } from '@ng-bootstrap/ng-bootstrap';
+import { DialogService } from 'ng2-bootstrap-modal';
+import { ConfirmComponent } from '../shared/confirmModal/confirm.component';
+import { appConstants } from '../../constants/app-constants';
@Component({
selector: 'app-help',
@@ -41,8 +46,15 @@ export class AboutUsComponent implements OnInit, OnDestroy {
public data: any;
closeResult: string;
versionLogSubscription: Subscription;
-
- constructor(private http: Http, private modalService: NgbModal) {
+ options = {
+ timeOut: 1000,
+ showProgressBar: true,
+ pauseOnHover: true,
+ clickToClose: true,
+ maxLength: 200
+ };
+
+ constructor(private http: Http, private modalService: NgbModal, private dialogService: DialogService, private notificationsService: NotificationsService) {
}
ngOnInit() {
@@ -57,16 +69,30 @@ export class AboutUsComponent implements OnInit, OnDestroy {
}
}
- versionLogFile() {
- this.versionLogSubscription = this.http.get('app/about-us/versionLog.txt')
- .subscribe(res => this.data = res.text());
+ versionLogFile(): Observable<any> {
+ return this.http.get('app/about-us/versionLog.txt');
}
open(content) {
- this.modalService.open(content).result.then((result) => {
- this.closeResult = `Closed with: ${result}`;
- }, (reason) => {
- this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
+ this.versionLogSubscription = this.versionLogFile()
+ .subscribe((res) => {
+ this.data = res.text();
+ this.dialogService.addDialog(ConfirmComponent, {
+ title: 'VERSION CHANGE LOG',
+ message: this.data,
+ cancelButtonText: 'CLOSE',
+ confirmButtonText: 'DOWNLOAD'
+ }).subscribe(isConfirmed => {
+ if (isConfirmed) {
+ this.downloadLogFile()
+ } else {
+ // do nothing
+ }
+ });
+
+ },
+ (error)=>{
+ this.notificationsService.error(appConstants.errors.error, 'unable to fetch change log details');
});
}