2 Copyright 2020 TATA ELXSI
4 Licensed under the Apache License, Version 2.0 (the 'License');
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
16 Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
19 * @file change password component
21 import { Component, Injector, OnInit } from '@angular/core';
22 import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
23 import { TranslateService } from '@ngx-translate/core';
24 import { AddEditUserComponent } from 'AddEditUserComponent';
25 import { MODALCLOSERESPONSEDATA } from 'CommonModel';
26 import { SharedService } from 'SharedService';
30 * @Component takes ChangePasswordComponent.html as template url
33 templateUrl: './ChangePasswordComponent.html',
34 styleUrls: ['./ChangePasswordComponent.scss']
36 /** Exporting a class @exports ChangePasswordComponent */
37 export class ChangePasswordComponent implements OnInit {
38 /** To inject services @public */
39 public injector: Injector;
41 /** handle translate @public */
42 public translateService: TranslateService;
44 /** Contains edit type data @public */
45 public editType: string = 'changePassword';
47 /** Contains all methods related to shared @private */
48 private sharedService: SharedService;
50 /** Instance of the modal service @private */
51 private modalService: NgbModal;
53 constructor(injector: Injector) {
54 this.injector = injector;
55 this.translateService = this.injector.get(TranslateService);
56 this.sharedService = this.injector.get(SharedService);
57 this.modalService = this.injector.get(NgbModal);
60 /** Lifecyle Hooks the trigger before component is instantiate @public */
61 public ngOnInit(): void {
62 // eslint-disable-next-line security/detect-non-literal-fs-filename
63 const modalRef: NgbModalRef = this.modalService.open(AddEditUserComponent, { backdrop: 'static', keyboard: false });
64 modalRef.componentInstance.userID = sessionStorage.getItem('user_id');
65 if (this.editType === 'changePassword') {
66 modalRef.componentInstance.userTitle = this.translateService.instant('PAGE.USERS.EDITCREDENTIALS');
68 modalRef.componentInstance.userType = this.editType;
69 modalRef.result.then((result: MODALCLOSERESPONSEDATA): void => {
71 this.sharedService.callData();
73 }).catch((err: Error): void => { // catch error