diff --git a/nav-app/src/app/classes/stix/stix-object.ts b/nav-app/src/app/classes/stix/stix-object.ts index 5fc3fd358..0b8a12e5c 100644 --- a/nav-app/src/app/classes/stix/stix-object.ts +++ b/nav-app/src/app/classes/stix/stix-object.ts @@ -59,6 +59,7 @@ export abstract class StixObject { let thatVersion = that.version.split('.'); for (let i = 0; i < Math.max(thisVersion.length, thatVersion.length); i++) { + if (thisVersion.length == thatVersion.length && thisVersion.length < i) return 0; if (thisVersion.length < i) return -1; if (thatVersion.length < i) return 1; if (+thisVersion[i] == +thatVersion[i]) continue; diff --git a/nav-app/src/app/services/icons.service.spec.ts b/nav-app/src/app/services/icons.service.spec.ts index d1256f9de..d1cbe57a9 100644 --- a/nav-app/src/app/services/icons.service.spec.ts +++ b/nav-app/src/app/services/icons.service.spec.ts @@ -1,6 +1,6 @@ import { TestBed, inject } from '@angular/core/testing'; -import { IconsService } from './icons.service'; +import { Icons, IconsService } from './icons.service'; describe('IconsService', () => { let service: IconsService; @@ -15,15 +15,8 @@ describe('IconsService', () => { })); it('should register', inject([IconsService], (service: IconsService) => { - enum Icons { - SORT_ALPHABETICAL_ASC = 'ic_sort_alphabetically_ascending', - SORT_ALPHABETICAL_DESC = 'ic_sort_alphabetically_descending', - SORT_NUMERICAL_ASC = 'ic_sort_numerically_ascending', - SORT_NUMERICAL_DESC = 'ic_sort_numerically_descending', - UNFOLD_MORE_ALT = 'ic_unfold_more_alt', - NON_STICKY_TOOLBAR = 'ic_push_pin_gray', - } - service.registerIcons() - expect(service.getIcons()).toEqual(Icons); + spyOn(service.matIconRegistry, 'addSvgIcon'); + service.registerIcons(); + expect(service.matIconRegistry.addSvgIcon).toHaveBeenCalledTimes(Object.values(Icons).length); })); }); diff --git a/nav-app/src/app/services/icons.service.ts b/nav-app/src/app/services/icons.service.ts index eca33e831..e705072d3 100644 --- a/nav-app/src/app/services/icons.service.ts +++ b/nav-app/src/app/services/icons.service.ts @@ -6,10 +6,9 @@ import { DomSanitizer } from '@angular/platform-browser'; providedIn: 'root', }) export class IconsService { - constructor( - private matIconRegistry: MatIconRegistry, - private domSanitizer: DomSanitizer - ) {} + constructor(public matIconRegistry: MatIconRegistry, private domSanitizer: DomSanitizer) { + // intentionally left blank + } public registerIcons(): void { this.loadIcons(Object.values(Icons), 'assets/icons'); @@ -20,10 +19,6 @@ export class IconsService { this.matIconRegistry.addSvgIcon(key, this.domSanitizer.bypassSecurityTrustResourceUrl(`${iconUrl}/${key}.svg`)); }); } - - public getIcons(): object{ - return Icons; - } } export enum Icons { diff --git a/nav-app/src/app/tabs/tabs.component.ts b/nav-app/src/app/tabs/tabs.component.ts index 55c26dae1..0d5e31ba4 100755 --- a/nav-app/src/app/tabs/tabs.component.ts +++ b/nav-app/src/app/tabs/tabs.component.ts @@ -42,14 +42,13 @@ export class TabsComponent implements AfterViewInit { public layerLinkURLs: string[] = []; public customizedConfig: any[] = []; public bannerContent: string; - public subscription = new Subscription(); + public subscription: Subscription; public copiedRecently: boolean = false; // true if copyLayerLink is called, reverts to false after 2 seconds public loadData: any = { url: undefined, version: undefined, identifier: undefined, }; - public glayerVersion = globals.layerVersion; // user input for layer-layer operations public opSettings: any = { @@ -760,7 +759,7 @@ export class TabsComponent implements AfterViewInit { let viewModel: ViewModel; viewModel = self.viewModelsService.newViewModel('loading layer...', undefined); let layerVersionStr = viewModel.deserializeDomainVersionID(obj); - self.versionMismatchWarning(layerVersionStr, this.glayerVersion).then((res) => { + self.versionMismatchWarning(layerVersionStr).then((res) => { let isCustom = 'customDataURL' in obj; if (!isCustom) { if (!self.dataService.getDomain(viewModel.domainVersionID)) { @@ -793,9 +792,9 @@ export class TabsComponent implements AfterViewInit { * (for major mismatches) * @param {string} layerVersionStr the uploaded layer version */ - private async versionMismatchWarning(layerVersionStr: string, glayerVersion: string): Promise { + private async versionMismatchWarning(layerVersionStr: string): Promise { return new Promise((resolve, reject) => { - let globalVersionSplit = glayerVersion.split('.'); + let globalVersionSplit = globals.layerVersion.split('.'); let layerVersion = layerVersionStr.split('.'); // if minor version change, snackbar will be displayed if (layerVersion[0] === globalVersionSplit[0] && layerVersion[1] !== globalVersionSplit[1]) { @@ -845,7 +844,7 @@ export class TabsComponent implements AfterViewInit { let viewModel = self.viewModelsService.newViewModel('loading layer...', undefined); try { let layerVersionStr = viewModel.deserializeDomainVersionID(res); - await self.versionMismatchWarning(layerVersionStr, this.glayerVersion); + await self.versionMismatchWarning(layerVersionStr); if (!self.dataService.getDomain(viewModel.domainVersionID)) { throw new Error(`Error: '${viewModel.domain}' (v${viewModel.version}) is an invalid domain.`); }