Initial Commit - NG UI
[osm/NG-UI.git] / src / app / packages / PackagesComponent.ts
1 /*
2  Copyright 2020 TATA ELXSI
3
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
7
8     http://www.apache.org/licenses/LICENSE-2.0
9
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.
15
16  Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
17 */
18 /**
19  * @file Packages-Component.ts.
20  */
21 import { Component, Injector } from '@angular/core';
22 import { Router, RouterEvent } from '@angular/router';
23 /**
24  * Creating Component
25  * @Component takes PackagesComponent.html as template url
26  */
27 @Component({
28     selector: 'app-packages',
29     templateUrl: './PackagesComponent.html',
30     styleUrls: ['./PackagesComponent.scss']
31 })
32 /** Exporting a class @exports PackagesComponent */
33 export class PackagesComponent{
34     /** Invoke service injectors @public */
35     public injector: Injector;
36
37     /** Holds teh instance of AuthService class of type AuthService @private */
38     private router: Router;
39
40     // creates packages component
41     constructor(injector: Injector) {
42         this.injector = injector;
43         this.router = this.injector.get(Router);
44         this.router.events.subscribe((event: RouterEvent) => {
45             this.redirectToList(event.url);
46         });
47     }
48
49     /** Return to list NS Package List */
50     public redirectToList(getURL: string): void {
51         if (getURL === '/packages') {
52             this.router.navigate(['/packages/ns']).catch();
53         }
54     }
55 }