File
Implements
Index
Properties
|
|
Methods
|
|
Outputs
|
|
Constructor
constructor(resourceService: ResourceService, router: Router, http: HttpClient)
|
|
Parameters :
Name |
Type |
Optional |
resourceService |
ResourceService
|
No
|
router |
Router
|
No
|
http |
HttpClient
|
No
|
|
Outputs
closeAccountMergeModal
|
Type : EventEmitter
|
|
Methods
initiateMerge
|
initiateMerge()
|
|
|
ngOnDestroy
|
ngOnDestroy()
|
|
|
redirect
|
redirect(redirectUrl)
|
|
Parameters :
Name |
Optional |
redirectUrl |
No
|
|
setTelemetryData
|
setTelemetryData()
|
|
|
Public
http
|
Type : HttpClient
|
|
modal
|
Decorators :
@ViewChild('modal')
|
|
Public
router
|
Type : Router
|
|
import {Component, EventEmitter, OnInit, Output, ViewChild, OnDestroy} from '@angular/core';
import {ResourceService} from '../../services';
import {Router} from '@angular/router';
import {IInteractEventEdata} from '@sunbird/telemetry';
import {HttpOptions} from '@sunbird/shared';
import {HttpClient} from '@angular/common/http';
@Component({
selector: 'app-account-merge-modal',
templateUrl: './account-merge-modal.component.html'
})
export class AccountMergeModalComponent implements OnInit, OnDestroy {
@Output() closeAccountMergeModal = new EventEmitter<any>();
@ViewChild('modal') modal;
instance: string;
mergeIntractEdata: IInteractEventEdata;
public telemetryCdata: Array<{}> = [];
constructor(public resourceService: ResourceService, public router: Router,
public http: HttpClient) {
this.http = http;
this.instance = (<HTMLInputElement>document.getElementById('instance'))
? (<HTMLInputElement>document.getElementById('instance')).value.toUpperCase() : 'SUNBIRD';
}
ngOnInit() {
this.setTelemetryData();
}
closeModal() {
this.closeAccountMergeModal.emit();
this.modal.deny();
}
setTelemetryData() {
this.telemetryCdata = [
{id: 'user:account:merge', type: 'Feature'}, {id: 'SB-13927', type: 'Task'}
];
setTimeout(() => {
this.mergeIntractEdata = {
id: 'merge-account-button',
type: 'click',
pageid: this.router.url.split('/')[1],
};
}, 500);
}
initiateMerge() {
const httpOptions: HttpOptions = {
headers: {
'Content-Type': 'application/json'
}
};
this.http.get('/user/session/save?redirectUri=' + this.router.url)
.subscribe((data: any) => {
if (data.responseCode === 'OK' && data.result && data.result.status === 'SUCCESS' && data.result.redirectUrl) {
this.redirect(data.result.redirectUrl);
} else {
this.closeModal();
}
}, (error) => {
this.closeModal();
});
}
redirect(redirectUrl) {
this.closeModal();
window.location.href = redirectUrl;
}
ngOnDestroy() {
if (this.modal.deny) {
this.modal.deny();
}
}
}
<app-modal-wrapper [config]="{disableClose: true, size: 'normal', panelClass: 'material-modal'}" (dismiss)="closeModal()" #modal>
<ng-template sbModalContent>
<div class="sb-mat__modal">
<!--Header-->
<div mat-dialog-title class="mb-0">
<div class="title">{{resourceService.frmelmnts?.lbl?.mergeAccount }}</div>
</div>
<!--/Header-->
<!--Content-->
<div class="sb-mat__modal__content">
<div class="sb-merge-account-modal">
<p class="mb-8"> {{resourceService.messages?.imsg?.m0060 | interpolate:'{instance}': instance }}
<b>{{resourceService.frmelmnts?.btn?.merge | titlecase}}</b> {{resourceService.messages?.imsg?.m0061}}:
</p>
<ul class="m-0">
<li class="mb-8">
{{resourceService.messages?.imsg?.m0063}}
</li>
<li class="mb-8">
{{resourceService.messages?.imsg?.m0064}}
</li>
</ul>
<p>{{resourceService.messages?.imsg?.m0062}} <b>{{resourceService.frmelmnts?.btn?.cancel}}</b></p>
</div>
</div>
<!--/Content-->
<!--Actions-->
<div class="sb-mat__modal__actions">
<button class="sb-btn sb-btn-normal sb-btn-outline-primary" tabindex="0" (click)="closeModal()">
{{resourceService.frmelmnts?.btn?.cancel}}
</button>
<button appTelemetryInteract [telemetryInteractEdata]="mergeIntractEdata"
[telemetryInteractCdata]="telemetryCdata" class="sb-btn sb-btn-normal sb-btn-primary ml-8" tabindex="0"
(click)="initiateMerge()">
{{resourceService.frmelmnts?.btn?.merge}}
</button>
</div>
<!--/Actions-->
</div>
</ng-template>
</app-modal-wrapper>
Legend
Html element with directive