79597: Remove GridThumbnailComponent

This commit is contained in:
Yura Bondarenko
2021-05-27 09:21:00 +02:00
parent 4f38821bb3
commit 6cbd9dc920
5 changed files with 1 additions and 129 deletions

View File

@@ -1,3 +0,0 @@
<div class="thumbnail">
<img [src]="src | dsSafeUrl" (error)="errorHandler($event)" />
</div>

View File

@@ -1,50 +0,0 @@
import { DebugElement } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { Bitstream } from '../../../core/shared/bitstream.model';
import { SafeUrlPipe } from '../../utils/safe-url-pipe';
import { GridThumbnailComponent } from './grid-thumbnail.component';
describe('GridThumbnailComponent', () => {
let comp: GridThumbnailComponent;
let fixture: ComponentFixture<GridThumbnailComponent>;
let de: DebugElement;
let el: HTMLElement;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [GridThumbnailComponent, SafeUrlPipe]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(GridThumbnailComponent);
comp = fixture.componentInstance; // BannerComponent test instance
de = fixture.debugElement.query(By.css('div.thumbnail'));
el = de.nativeElement;
});
it('should display image', () => {
const thumbnail = new Bitstream();
thumbnail._links = {
self: { href: 'self.url' },
bundle: { href: 'bundle.url' },
format: { href: 'format.url' },
content: { href: 'content.url' },
};
comp.thumbnail = thumbnail;
fixture.detectChanges();
const image: HTMLElement = de.query(By.css('img')).nativeElement;
expect(image.getAttribute('src')).toBe(comp.thumbnail._links.content.href);
});
it('should display placeholder', () => {
const thumbnail = new Bitstream();
comp.thumbnail = thumbnail;
fixture.detectChanges();
const image: HTMLElement = de.query(By.css('img')).nativeElement;
expect(image.getAttribute('src')).toBe(comp.defaultImage);
});
});

View File

@@ -1,72 +0,0 @@
import {
Component,
Input,
OnChanges,
OnInit,
SimpleChanges,
} from '@angular/core';
import { Bitstream } from '../../../core/shared/bitstream.model';
import { hasValue } from '../../empty.util';
/**
* This component renders a given Bitstream as a thumbnail.
* One input parameter of type Bitstream is expected.
* If no Bitstream is provided, a holderjs image will be rendered instead.
*/
@Component({
selector: 'ds-grid-thumbnail',
styleUrls: ['./grid-thumbnail.component.scss'],
templateUrl: './grid-thumbnail.component.html',
})
export class GridThumbnailComponent implements OnInit, OnChanges {
@Input() thumbnail: Bitstream;
data: any = {};
/**
* The default 'holder.js' image
*/
@Input() defaultImage? =
'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMjYwIiBoZWlnaHQ9IjE4MCIgdmlld0JveD0iMCAwIDI2MCAxODAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjwhLS0KU291cmNlIFVSTDogaG9sZGVyLmpzLzEwMCV4MTgwL3RleHQ6Tm8gVGh1bWJuYWlsCkNyZWF0ZWQgd2l0aCBIb2xkZXIuanMgMi42LjAuCkxlYXJuIG1vcmUgYXQgaHR0cDovL2hvbGRlcmpzLmNvbQooYykgMjAxMi0yMDE1IEl2YW4gTWFsb3BpbnNreSAtIGh0dHA6Ly9pbXNreS5jbwotLT48ZGVmcz48c3R5bGUgdHlwZT0idGV4dC9jc3MiPjwhW0NEQVRBWyNob2xkZXJfMTVmNzJmMmFlMGIgdGV4dCB7IGZpbGw6I0FBQUFBQTtmb250LXdlaWdodDpib2xkO2ZvbnQtZmFtaWx5OkFyaWFsLCBIZWx2ZXRpY2EsIE9wZW4gU2Fucywgc2Fucy1zZXJpZiwgbW9ub3NwYWNlO2ZvbnQtc2l6ZToxM3B0IH0gXV0+PC9zdHlsZT48L2RlZnM+PGcgaWQ9ImhvbGRlcl8xNWY3MmYyYWUwYiI+PHJlY3Qgd2lkdGg9IjI2MCIgaGVpZ2h0PSIxODAiIGZpbGw9IiNFRUVFRUUiLz48Zz48dGV4dCB4PSI3Mi4yNDIxODc1IiB5PSI5NiI+Tm8gVGh1bWJuYWlsPC90ZXh0PjwvZz48L2c+PC9zdmc+';
src: string;
errorHandler(event) {
event.currentTarget.src = this.defaultImage;
}
/**
* Initialize the src
*/
ngOnInit(): void {
this.src = this.defaultImage;
this.checkThumbnail(this.thumbnail);
}
/**
* If the old input is undefined and the new one is a bitsream then set src
*/
ngOnChanges(changes: SimpleChanges): void {
if (
!hasValue(changes.thumbnail.previousValue) &&
hasValue(changes.thumbnail.currentValue)
) {
this.checkThumbnail(changes.thumbnail.currentValue);
}
}
/**
* check if the Bitstream has any content than set the src
*/
checkThumbnail(thumbnail: Bitstream) {
if (
hasValue(thumbnail) &&
hasValue(thumbnail._links) &&
thumbnail._links.content.href
) {
this.src = thumbnail._links.content.href;
}
}
}

View File

@@ -46,7 +46,6 @@ import { ThumbnailComponent } from '../thumbnail/thumbnail.component';
import { SearchFormComponent } from './search-form/search-form.component';
import { SearchResultGridElementComponent } from './object-grid/search-result-grid-element/search-result-grid-element.component';
import { ViewModeSwitchComponent } from './view-mode-switch/view-mode-switch.component';
import { GridThumbnailComponent } from './object-grid/grid-thumbnail/grid-thumbnail.component';
import { VarDirective } from './utils/var.directive';
import { AuthNavMenuComponent } from './auth-nav-menu/auth-nav-menu.component';
import { LogOutComponent } from './log-out/log-out.component';
@@ -54,8 +53,7 @@ import { FormComponent } from './form/form.component';
import { DsDynamicOneboxComponent } from './form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component';
import { DsDynamicScrollableDropdownComponent } from './form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component';
import {
DsDynamicFormControlContainerComponent,
dsDynamicFormControlMapFn
DsDynamicFormControlContainerComponent, dsDynamicFormControlMapFn,
} from './form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component';
import { DsDynamicFormComponent } from './form/builder/ds-dynamic-form-ui/ds-dynamic-form.component';
import { DragClickDirective } from './utils/drag-click.directive';
@@ -340,7 +338,6 @@ const COMPONENTS = [
SidebarFilterComponent,
SidebarFilterSelectedOptionComponent,
ThumbnailComponent,
GridThumbnailComponent,
UploaderComponent,
FileDropzoneNoUploaderComponent,
ItemListPreviewComponent,