diff --git a/scilog/src/app/app.module.ts b/scilog/src/app/app.module.ts index 11a18713..2d3ac952 100644 --- a/scilog/src/app/app.module.ts +++ b/scilog/src/app/app.module.ts @@ -58,7 +58,6 @@ import { AddLogbookComponent } from './overview/add-logbook/add-logbook.componen import { AddCollectionComponent } from './overview/add-collection/add-collection.component'; import { MatLegacySlideToggleModule as MatSlideToggleModule } from '@angular/material/legacy-slide-toggle'; import { MatLegacyAutocompleteModule as MatAutocompleteModule } from '@angular/material/legacy-autocomplete'; -import { LogbookSearchPipe } from './overview/logbook-search.pipe'; import { NavigationButtonComponent } from './logbook/navigation-button/navigation-button.component'; import { SnippetContentComponent } from '@shared/snippet/snippet-content/snippet-content.component'; import { CookieService } from 'ngx-cookie-service'; @@ -117,7 +116,6 @@ const appConfigInitializerFn = (appConfig: AppConfigService) => { CollectionWidgetComponent, AddLogbookComponent, AddCollectionComponent, - LogbookSearchPipe, NavigationButtonComponent, SnippetContentComponent, SnippetViewerComponent, diff --git a/scilog/src/app/overview/logbook-icon-scroll-service.service.spec.ts b/scilog/src/app/overview/logbook-icon-scroll-service.service.spec.ts deleted file mode 100644 index 1447b5ea..00000000 --- a/scilog/src/app/overview/logbook-icon-scroll-service.service.spec.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { LogbookDataService } from '@shared/remote-data.service'; - -import { LogbookIconScrollService } from './logbook-icon-scroll-service.service'; -import { IDatasource } from 'ngx-ui-scroll'; - -describe('LogbookIconScrollServiceService', () => { - let service: LogbookIconScrollService; - - beforeEach(() => { - const logbookDataServiceSpy = jasmine.createSpyObj("LogbookDataService", ["getDataBuffer"]); - logbookDataServiceSpy.getDataBuffer.and.resolveTo([1, 2, 3, 4, 5, 6, 7]); - - TestBed.configureTestingModule({ - providers: [ - {provide: LogbookDataService, useValue: logbookDataServiceSpy} - ], - }); - service = TestBed.inject(LogbookIconScrollService); - }); - - it('should be created', () => { - expect(service).toBeTruthy(); - }); - - it('should test getData', async () => { - service['datasource'] = {adapter: {relax: async () => ({})}} as IDatasource; - expect(await service.getData(0, 10, {})).toEqual([[1, 2, 3], [4, 5, 6], [7]]); - }); - - it('should test getDataBuffer after decoration', async () => { - expect(service['isLoaded']).toEqual(false); - spyOn(service, 'getData').and.resolveTo([]); - await service.getDataBuffer(1, 2, 3); - expect(service['isLoaded']).toEqual(true); - }); - -}); diff --git a/scilog/src/app/overview/logbook-icon-scroll-service.service.ts b/scilog/src/app/overview/logbook-icon-scroll-service.service.ts deleted file mode 100644 index f51a06db..00000000 --- a/scilog/src/app/overview/logbook-icon-scroll-service.service.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { Injectable } from '@angular/core'; -import { LogbookDataService } from '@shared/remote-data.service'; -import { SearchScrollBaseService } from '@shared/search-scroll.service'; -import { Datasource } from 'ngx-ui-scroll'; - -@Injectable({ - providedIn: 'root' -}) -export class LogbookIconScrollService extends SearchScrollBaseService { - - groupSize = 3; - constructor(protected dataService: LogbookDataService) { - super(); - } - - protected setupDatasource() { - const bufferSize = (this.groupSize + 1) * 3; - if (this.datasource != null) { - this.datasource.adapter.reset(new Datasource({ - get: async (index: number, count: number) => { - return this.getDataBuffer(index, count, this.config); - }, - - settings: { - minIndex: 0, - startIndex: this.startIndex, - bufferSize: bufferSize, - padding: 0.5, - } - })); - } else { - this.datasource = new Datasource({ - get: async (index: number, count: number) => { - return this.getDataBuffer(index, count, this.config); - }, - - settings: { - minIndex: 0, - startIndex: this.startIndex, - bufferSize: bufferSize, - padding: 0.5, - } - }); - } - } - - getDataBuffer(index: number, count: number, config: any) { - return this.getData(index, count, config); - } - - async getData(index: number, count: number, config: any) { - const buffer = await this.dataService.getDataBuffer(index, count, config); - this.datasource.adapter.relax(); - const groupedBuffer = []; - while (buffer.length) groupedBuffer.push(buffer.splice(0, this.groupSize)); - return groupedBuffer - } -} diff --git a/scilog/src/app/overview/logbook-search.pipe.spec.ts b/scilog/src/app/overview/logbook-search.pipe.spec.ts deleted file mode 100644 index 47c9c5fa..00000000 --- a/scilog/src/app/overview/logbook-search.pipe.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { LogbookSearchPipe } from './logbook-search.pipe'; - -describe('LogbookSearchPipe', () => { - it('create an instance', () => { - const pipe = new LogbookSearchPipe(); - expect(pipe).toBeTruthy(); - }); -}); diff --git a/scilog/src/app/overview/logbook-search.pipe.ts b/scilog/src/app/overview/logbook-search.pipe.ts deleted file mode 100644 index 104356a5..00000000 --- a/scilog/src/app/overview/logbook-search.pipe.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { Pipe, PipeTransform } from '@angular/core'; -import {Logbooks} from '@model/logbooks'; - -@Pipe({ - name: 'logbookSearch' -}) -export class LogbookSearchPipe implements PipeTransform { - - transform(logbooks: Logbooks[], searchString: string): any { - if (searchString.length == 0){ - return logbooks; - } - if ((typeof logbooks != 'undefined') || (searchString.length > 0)){ - return logbooks.filter((logbook:Logbooks) => { - let searchMatch = false; - for (const key in logbook) { - if (Object.prototype.hasOwnProperty.call(logbook, key)) { - const element = logbook[key]; - if (typeof element == "string"){ - if (searchMatch = element.toLowerCase().includes(searchString.toLowerCase())){ - break; - } - } - } - } - return searchMatch; - }); - } - return null - } - -}