Commit feb028cb authored by Vitali Stupin's avatar Vitali Stupin
Browse files

fixing lint warnings

parent 753f9357
...@@ -15,4 +15,4 @@ const routes: Routes = [ ...@@ -15,4 +15,4 @@ const routes: Routes = [
imports: [ RouterModule.forRoot(routes, {scrollPositionRestoration: 'enabled'}) ], imports: [ RouterModule.forRoot(routes, {scrollPositionRestoration: 'enabled'}) ],
exports: [ RouterModule ] exports: [ RouterModule ]
}) })
export class AppRoutingModule {} export class AppRoutingModule {}
\ No newline at end of file
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
<router-outlet></router-outlet> <router-outlet></router-outlet>
</div> </div>
\ No newline at end of file
import { TestBed, async } from '@angular/core/testing'; import { TestBed, async } from '@angular/core/testing';
import {RouterTestingModule} from '@angular/router/testing' import {RouterTestingModule} from '@angular/router/testing';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
describe('AppComponent', () => { describe('AppComponent', () => {
......
...@@ -42,4 +42,4 @@ export class AppModule { } ...@@ -42,4 +42,4 @@ export class AppModule { }
export function HttpLoaderFactory(http: HttpClient) { export function HttpLoaderFactory(http: HttpClient) {
// Providing path as a workaround for ngx-translate bug with --base-href option // Providing path as a workaround for ngx-translate bug with --base-href option
return new TranslateHttpLoader(http, './assets/i18n/'); return new TranslateHttpLoader(http, './assets/i18n/');
} }
\ No newline at end of file
export const MAX_LIMIT: number = 1000000; export const MAX_LIMIT = 1000000;
export const DEFAULT_LIMIT: number = 10; export const DEFAULT_LIMIT = 10;
export const INSTANCES = { export const INSTANCES = {
'EE': 'https://www.x-tee.ee/catalogue/EE/wsdls/', EE: 'https://www.x-tee.ee/catalogue/EE/wsdls/',
'ee-test': 'https://www.x-tee.ee/catalogue/ee-test/wsdls/', 'ee-test': 'https://www.x-tee.ee/catalogue/ee-test/wsdls/',
'ee-dev': 'https://www.x-tee.ee/catalogue/ee-dev/wsdls/' 'ee-dev': 'https://www.x-tee.ee/catalogue/ee-dev/wsdls/'
} };
export const API_SERVICE = 'index.json'; export const API_SERVICE = 'index.json';
export const LANGUAGES = { export const LANGUAGES = {
'EST': 'est', EST: 'est',
'ENG': 'eng' ENG: 'eng'
} };
export const PREVIEW_SIZE: number = 5 export const PREVIEW_SIZE = 5;
...@@ -7,4 +7,4 @@ ...@@ -7,4 +7,4 @@
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -10,16 +10,16 @@ export class HeaderComponent implements OnInit { ...@@ -10,16 +10,16 @@ export class HeaderComponent implements OnInit {
constructor(private languagesService: LanguagesService) { } constructor(private languagesService: LanguagesService) { }
getLangs():string[] { getLangs(): string[] {
return this.languagesService.getLangs() return this.languagesService.getLangs();
} }
getLang():string { getLang(): string {
return this.languagesService.getLang() return this.languagesService.getLang();
} }
setLang(lang: string) { setLang(lang: string) {
return this.languagesService.setLang(lang) return this.languagesService.setLang(lang);
} }
ngOnInit() {} ngOnInit() {}
......
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import {TranslateService} from "@ngx-translate/core"; import {TranslateService} from '@ngx-translate/core';
import { Title } from '@angular/platform-browser'; import { Title } from '@angular/platform-browser';
import { Subscription } from 'rxjs'; import { Subscription } from 'rxjs';
import { take } from 'rxjs/operators'; import { take } from 'rxjs/operators';
import { LANGUAGES } from './config' import { LANGUAGES } from './config';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class LanguagesService { export class LanguagesService {
private selectedLang = '' private selectedLang = '';
private translateSubscription: Subscription private translateSubscription: Subscription;
constructor( constructor(
private translate: TranslateService, private translate: TranslateService,
private title: Title private title: Title
) { ) {
this.selectedLang = this.getDefaultLang() this.selectedLang = this.getDefaultLang();
translate.setDefaultLang(LANGUAGES[this.selectedLang]) translate.setDefaultLang(LANGUAGES[this.selectedLang]);
this.updateTitle() this.updateTitle();
} }
updateTitle(): void { updateTitle(): void {
// Not subscribing if subscription already in progress // Not subscribing if subscription already in progress
if (!this.translateSubscription || this.translateSubscription.closed) { if (!this.translateSubscription || this.translateSubscription.closed) {
this.translateSubscription = this.translate.get('index.title').pipe(take(1)).subscribe((res: string) => { this.translateSubscription = this.translate.get('index.title').pipe(take(1)).subscribe((res: string) => {
this.title.setTitle(res) this.title.setTitle(res);
}); });
} }
} }
getDefaultLang(): string { getDefaultLang(): string {
if(window && window.localStorage && window.localStorage.getItem('lang')) { if (window && window.localStorage && window.localStorage.getItem('lang')) {
return window.localStorage.getItem('lang') return window.localStorage.getItem('lang');
} }
return Object.keys(LANGUAGES)[0] return Object.keys(LANGUAGES)[0];
} }
getLangs(): string[] { getLangs(): string[] {
return Object.keys(LANGUAGES) return Object.keys(LANGUAGES);
} }
getLang(): string { getLang(): string {
return this.selectedLang return this.selectedLang;
} }
setLang(lang: string): void { setLang(lang: string): void {
this.selectedLang = lang this.selectedLang = lang;
if(window && window.localStorage) { if (window && window.localStorage) {
window.localStorage.setItem('lang', this.selectedLang) window.localStorage.setItem('lang', this.selectedLang);
} }
this.translate.use(LANGUAGES[this.selectedLang]); this.translate.use(LANGUAGES[this.selectedLang]);
this.updateTitle() this.updateTitle();
} }
} }
...@@ -29,4 +29,4 @@ describe('SearchComponent', () => { ...@@ -29,4 +29,4 @@ describe('SearchComponent', () => {
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
}); });
\ No newline at end of file
...@@ -8,27 +8,27 @@ import { SubsystemsService } from '../../subsystems.service'; ...@@ -8,27 +8,27 @@ import { SubsystemsService } from '../../subsystems.service';
}) })
export class SearchComponent implements OnInit { export class SearchComponent implements OnInit {
limit: string limit: string;
nonEmpty: boolean nonEmpty: boolean;
filter: string filter: string;
constructor(private subsystemsService: SubsystemsService) { } constructor(private subsystemsService: SubsystemsService) { }
setNonEmpty(nonEmpty: boolean) { setNonEmpty(nonEmpty: boolean) {
this.subsystemsService.setNonEmpty(nonEmpty) this.subsystemsService.setNonEmpty(nonEmpty);
} }
setLimit(limit: string) { setLimit(limit: string) {
this.subsystemsService.setLimit(limit) this.subsystemsService.setLimit(limit);
} }
setFilter(filter: string) { setFilter(filter: string) {
this.subsystemsService.setFilter(filter) this.subsystemsService.setFilter(filter);
} }
ngOnInit() { ngOnInit() {
this.limit = this.subsystemsService.getLimit() this.limit = this.subsystemsService.getLimit();
this.nonEmpty = this.subsystemsService.getNonEmpty() this.nonEmpty = this.subsystemsService.getNonEmpty();
this.filter = this.subsystemsService.getfilter() this.filter = this.subsystemsService.getfilter();
} }
} }
.pointerCursor { .pointerCursor {
cursor: pointer; cursor: pointer;
} }
\ No newline at end of file
...@@ -23,4 +23,4 @@ ...@@ -23,4 +23,4 @@
{{'subsystem.moreMethods' | translate:{"count": getNotInPreview()} }} {{'subsystem.moreMethods' | translate:{"count": getNotInPreview()} }}
</p> </p>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -11,7 +11,7 @@ describe('SubsystemItemComponent', () => { ...@@ -11,7 +11,7 @@ describe('SubsystemItemComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
declarations: [ declarations: [
SubsystemItemComponent SubsystemItemComponent
], ],
imports: [ imports: [
TranslateModule.forRoot(), TranslateModule.forRoot(),
...@@ -27,14 +27,14 @@ describe('SubsystemItemComponent', () => { ...@@ -27,14 +27,14 @@ describe('SubsystemItemComponent', () => {
component = fixture.componentInstance; component = fixture.componentInstance;
component.subsystem = { component.subsystem = {
xRoadInstance: "XRD", xRoadInstance: 'XRD',
memberClass: "CLASS", memberClass: 'CLASS',
memberCode: "CODE", memberCode: 'CODE',
subsystemCode: "SUB", subsystemCode: 'SUB',
subsystemStatus: "OK", subsystemStatus: 'OK',
fullSubsystemName: "XRD/CLASS/CODE/SUB", fullSubsystemName: 'XRD/CLASS/CODE/SUB',
methods: [] methods: []
} };
fixture.detectChanges(); fixture.detectChanges();
}); });
...@@ -42,4 +42,4 @@ describe('SubsystemItemComponent', () => { ...@@ -42,4 +42,4 @@ describe('SubsystemItemComponent', () => {
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
}); });
\ No newline at end of file
...@@ -3,7 +3,7 @@ import { Subsystem } from '../../subsystem'; ...@@ -3,7 +3,7 @@ import { Subsystem } from '../../subsystem';
import { Method } from '../../method'; import { Method } from '../../method';
import { SubsystemsService } from '../../subsystems.service'; import { SubsystemsService } from '../../subsystems.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { PREVIEW_SIZE } from '../../config' import { PREVIEW_SIZE } from '../../config';
@Component({ @Component({
selector: 'app-subsystem-item', selector: 'app-subsystem-item',
...@@ -11,7 +11,7 @@ import { PREVIEW_SIZE } from '../../config' ...@@ -11,7 +11,7 @@ import { PREVIEW_SIZE } from '../../config'
styleUrls: ['./subsystem-item.component.css'] styleUrls: ['./subsystem-item.component.css']
}) })
export class SubsystemItemComponent implements OnInit { export class SubsystemItemComponent implements OnInit {
@Input() subsystem: Subsystem @Input() subsystem: Subsystem;
constructor( constructor(
private subsystemsService: SubsystemsService, private subsystemsService: SubsystemsService,
...@@ -19,18 +19,18 @@ export class SubsystemItemComponent implements OnInit { ...@@ -19,18 +19,18 @@ export class SubsystemItemComponent implements OnInit {
) { } ) { }
getApiUrlBase(): string { getApiUrlBase(): string {
return this.subsystemsService.getApiUrlBase() return this.subsystemsService.getApiUrlBase();
} }
getMethodsPreview(): Method[] { getMethodsPreview(): Method[] {
return this.subsystem.methods.length ? this.subsystem.methods.slice(0, PREVIEW_SIZE) : [] return this.subsystem.methods.length ? this.subsystem.methods.slice(0, PREVIEW_SIZE) : [];
} }
getNotInPreview(): number { getNotInPreview(): number {
if (this.subsystem.methods.length - PREVIEW_SIZE < 0) { if (this.subsystem.methods.length - PREVIEW_SIZE < 0) {
return 0 return 0;
} }
return this.subsystem.methods.length - PREVIEW_SIZE return this.subsystem.methods.length - PREVIEW_SIZE;
} }
showDetail() { showDetail() {
...@@ -39,7 +39,7 @@ export class SubsystemItemComponent implements OnInit { ...@@ -39,7 +39,7 @@ export class SubsystemItemComponent implements OnInit {
+ '/' + this.subsystem.memberClass + '/' + this.subsystem.memberClass
+ '/' + this.subsystem.memberCode + '/' + this.subsystem.memberCode
+ '/' + this.subsystem.subsystemCode + '/' + this.subsystem.subsystemCode
) );
} }
ngOnInit() {} ngOnInit() {}
......
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing' import { RouterTestingModule } from '@angular/router/testing';
import { SubsystemListComponent } from './subsystem-list.component'; import { SubsystemListComponent } from './subsystem-list.component';
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { Subsystem } from '../subsystem'; import { Subsystem } from '../subsystem';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs'; import { of } from 'rxjs';
@Component({selector: 'app-header', template: ''}) @Component({selector: 'app-header', template: ''})
class HeaderStubComponent {} class HeaderStubComponent {}
@Component({selector: 'app-search', template: ''}) @Component({selector: 'app-search', template: ''})
class SearchStubComponent {} class SearchStubComponent {}
@Component({selector: 'app-subsystem-item', template: ''}) @Component({selector: 'app-subsystem-item', template: ''})
class SubsystemItemStubComponent { class SubsystemItemStubComponent {
@Input() subsystem: Subsystem @Input() subsystem: Subsystem;
} }
describe('SubsystemListComponent', () => { describe('SubsystemListComponent', () => {
...@@ -41,8 +41,8 @@ describe('SubsystemListComponent', () => { ...@@ -41,8 +41,8 @@ describe('SubsystemListComponent', () => {
beforeEach(() => { beforeEach(() => {
// Mocks and spies // Mocks and spies
TestBed.get(ActivatedRoute).params = of({ TestBed.get(ActivatedRoute).params = of({
"instance": "EE" instance: 'EE'
}) });
fixture = TestBed.createComponent(SubsystemListComponent); fixture = TestBed.createComponent(SubsystemListComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
...@@ -51,4 +51,4 @@ describe('SubsystemListComponent', () => { ...@@ -51,4 +51,4 @@ describe('SubsystemListComponent', () => {
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
}); });
\ No newline at end of file
import { Component, OnInit, OnDestroy } from '@angular/core'; import { Component, OnInit, AfterViewInit, OnDestroy } from '@angular/core';
import { Subsystem } from '../subsystem'; import { Subsystem } from '../subsystem';
import { SubsystemsService } from '../subsystems.service'; import { SubsystemsService } from '../subsystems.service';
import { ActivatedRoute, Router, Scroll } from '@angular/router'; import { ActivatedRoute, Router, Scroll } from '@angular/router';
...@@ -11,15 +11,15 @@ import { filter } from 'rxjs/operators'; ...@@ -11,15 +11,15 @@ import { filter } from 'rxjs/operators';
templateUrl: './subsystem-list.component.html', templateUrl: './subsystem-list.component.html',
styleUrls: ['./subsystem-list.component.css'] styleUrls: ['./subsystem-list.component.css']
}) })
export class SubsystemListComponent implements OnInit, OnDestroy { export class SubsystemListComponent implements OnInit, AfterViewInit, OnDestroy {
subsystems: Subsystem[] subsystems: Subsystem[];
message: string = '' message = '';
scrollSubject: BehaviorSubject<any> = new BehaviorSubject(null); scrollSubject: BehaviorSubject<any> = new BehaviorSubject(null);
routerScrollSubscription: Subscription routerScrollSubscription: Subscription;
routeSubscription: Subscription routeSubscription: Subscription;
warningsSubscription: Subscription warningsSubscription: Subscription;
scrollSubjectSubscription: Subscription scrollSubjectSubscription: Subscription;
filteredSubsystems: BehaviorSubject<Subsystem[]> filteredSubsystems: BehaviorSubject<Subsystem[]>;
constructor( constructor(
private subsystemsService: SubsystemsService, private subsystemsService: SubsystemsService,
...@@ -30,51 +30,51 @@ export class SubsystemListComponent implements OnInit, OnDestroy { ...@@ -30,51 +30,51 @@ export class SubsystemListComponent implements OnInit, OnDestroy {
// Geting previous scroll position // Geting previous scroll position
this.routerScrollSubscription = this.router.events.pipe( this.routerScrollSubscription = this.router.events.pipe(
filter(e => e instanceof Scroll) filter(e => e instanceof Scroll)
).subscribe(async(e) => { ).subscribe(async (e) => {
if ((e as Scroll).position) { if ((e as Scroll).position) {
this.scrollSubject.next((e as Scroll).position) this.scrollSubject.next((e as Scroll).position);
} }
}); });
} }
getInstance(): string { getInstance(): string {
return this.subsystemsService.getInstance() return this.subsystemsService.getInstance();
} }
getInstances(): string[] { getInstances(): string[] {
return this.subsystemsService.getInstances() return this.subsystemsService.getInstances();
} }
switchInstance(instance: string): void { switchInstance(instance: string): void {
this.router.navigateByUrl('/' + instance) this.router.navigateByUrl('/' + instance);
} }
getApiUrl(): string { getApiUrl(): string {
return this.subsystemsService.getApiUrl() return this.subsystemsService.getApiUrl();
} }
ngOnInit() { ngOnInit() {
// Reset message on page load // Reset message on page load
this.message = '' this.message = '';
this.filteredSubsystems = this.subsystemsService.filteredSubsystemsSubject this.filteredSubsystems = this.subsystemsService.filteredSubsystemsSubject;
// Service will tell when data loading failed! // Service will tell when data loading failed!
this.warningsSubscription = this.subsystemsService.warnings.subscribe(signal => { this.warningsSubscription = this.subsystemsService.warnings.subscribe(signal => {
this.message = signal this.message = signal;
}); });
this.routeSubscription = this.route.params.subscribe( params => { this.routeSubscription = this.route.params.subscribe( params => {
// Reset message on navigation // Reset message on navigation
this.message = '' this.message = '';
// Redirect to default instance if instance is empty or invalid // Redirect to default instance if instance is empty or invalid
if (!this.subsystemsService.getInstances().includes(params['instance'])) { if (!this.subsystemsService.getInstances().includes(params.instance)) {
this.router.navigateByUrl('/' + this.subsystemsService.getDefaultInstance()) this.router.navigateByUrl('/' + this.subsystemsService.getDefaultInstance());
return return;
} }
// Only reload on switching of instance or when no instance is selected yet on service side // Only reload on switching of instance or when no instance is selected yet on service side
if (this.getInstance() == '' || this.getInstance() != params['instance']) { if (this.getInstance() === '' || this.getInstance() !== params.instance) {