Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
32cf647
Add image-image component
Jun 22, 2021
4e961af
Add image-image-component in app.module
Jun 22, 2021
ad2f657
Update image-image template
Jun 22, 2021
4cd43fd
Add image-image component in app-routing-module
Jun 23, 2021
fdfa59b
Add image-image icon in edition_config
Jun 23, 2021
532a659
Update image-panel template
Jun 23, 2021
1f22665
Update image-panel component
Jun 23, 2021
729200e
Update image-image component
Jun 24, 2021
240847e
Update osd component
Jun 25, 2021
2be71e3
Update image-panel template
Jun 25, 2021
0954320
Update image-panel component
Jun 25, 2021
e079d3a
Update image-panel template
Jun 25, 2021
c758c7d
Update osd component
Jun 28, 2021
cc4d663
Add imgImg icon in icon style component
Jul 1, 2021
7914c1a
Update fonts in assets
Jul 1, 2021
79d7175
Add msDesc selector in image panel template
Sep 25, 2021
d71f043
Update image-image component
Jan 5, 2022
068157b
Update osd component
Jan 5, 2022
ed7f86f
Update image-panel template
Jan 5, 2022
2b0bd39
Add width in ng-select
Jan 13, 2022
6acd64e
Add width to the image selector
Jan 25, 2022
b9db170
Delete pageImg output from osd component
Jan 25, 2022
8aeff48
Update changelog
Jan 26, 2022
9553d1f
Delete manifestResourcetoTileSource function
May 30, 2022
48ef7d0
Update image-panel component template
May 31, 2022
3f61923
Add comma in image-panel component
May 31, 2022
941d331
Update image-image component template
May 31, 2022
10a1a62
Update image-panel component
May 31, 2022
82e5cbf
Update image-image component
May 31, 2022
33664d9
Add comma in image-text component
May 31, 2022
5135637
Update image-panel template
Jul 3, 2022
285085e
Update image-panel component
Jul 3, 2022
439fe69
Update image-panel component
Jul 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Sampling declaration visualization
- Project description visualization
- Encoding description visualization
- Image-image visualization
- Critical edition navigation
- Project Info modal
- Notes statement visualization
Expand Down
2 changes: 2 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { CollationComponent } from './view-modes/collation/collation.component';
import { ImageImageComponent } from './view-modes/image-image/image-image.component';
import { ImageTextComponent } from './view-modes/image-text/image-text.component';
import { ReadingTextComponent } from './view-modes/reading-text/reading-text.component';
import { TextSourcesComponent } from './view-modes/text-sources/text-sources.component';
Expand All @@ -11,6 +12,7 @@ const appRoutes: Routes = [
{ path: 'imageText', component: ImageTextComponent },
{ path: 'readingText', component: ReadingTextComponent },
{ path: 'textText', component: TextTextComponent },
{ path: 'imageImage', component: ImageImageComponent },
{ path: 'collation', component: CollationComponent },
{ path: 'textSources', component: TextSourcesComponent },
{ path: 'textVersions', component: TextVersionsComponent },
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ import { XMLParsers } from './services/xml-parsers/xml-parsers';
import { ShortcutsComponent } from './shortcuts/shortcuts.component';
import { MsDescSectionComponent } from './ui-components/ms-desc-section/ms-desc-section.component';
import { CollationComponent } from './view-modes/collation/collation.component';
import { ImageImageComponent } from './view-modes/image-image/image-image.component';
import { ImageTextComponent } from './view-modes/image-text/image-text.component';
import { ReadingTextComponent } from './view-modes/reading-text/reading-text.component';
import { TextSourcesComponent } from './view-modes/text-sources/text-sources.component';
Expand Down Expand Up @@ -161,6 +162,7 @@ export function initializeApp(appConfig: AppConfig) {
HtmlAttributesDirective,
HumanizePipe,
IdentifierComponent,
ImageImageComponent,
ImagePanelComponent,
ImageTextComponent,
LbComponent,
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/osd/osd.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class OsdComponent implements AfterViewInit, OnDestroy {
@Input() set page(v: number) {
if (v !== this._page) {
this._page = v;
this.pageChange.next(this._page);
this.pageChange.next(this._page + 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the +1?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saramaenza can answer to @szenzaro? Why do you need the +1?

}
}

Expand Down Expand Up @@ -174,4 +174,5 @@ export class OsdComponent implements AfterViewInit, OnDestroy {
ngOnDestroy(): void {
this.subscriptions.forEach((s) => s.unsubscribe());
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line

}
30 changes: 21 additions & 9 deletions src/app/panels/image-panel/image-panel.component.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
<evt-panel [showSecondaryContent]="msDescOpen"
[hideHeader]="false"
[hideFooter]="true">
<evt-panel [showSecondaryContent]="isSecondaryContentOpened()">
<div header-left>
<!-- TODO: Add dropdowns for navigation -->
<evt-ms-desc-selector #msDesc (selectionChange)="setMsDescID($event)" (msDescOpen)="setMsDescOpen($event)"></evt-ms-desc-selector>
<ng-select
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you restore the TODO comment?

class="mr-1 imgSelect"
bindLabel="label"
bindValue="label"
[searchable]="true"
[clearable]="false"
[ngModel]="currentImg"
(change)="toggleImg($event)">
<ng-option [value]="item" *ngFor="let item of images;">
{{ item.label || item.url.split('/').pop().split('.')[0] }}
</ng-option>
</ng-select>
<evt-ms-desc-selector (selectionChange)="setMsDescID($event)" (msDescOpen)="isMsDescOpen($event)"></evt-ms-desc-selector>
</div>
<div content>
<evt-osd
*ngIf="viewerData"
[viewerData]="viewerData">
[viewerData]="viewerData"
[page]="imageIndex"
(pageChange)="eventPageImg($event)">
</evt-osd>
<p *ngIf="!viewerData">Found no source file</p>
</div>

<div secondary-content>
<div *ngIf="msDescOpen">
<evt-ms-desc [data]="currentMsDesc$ | async"></evt-ms-desc>
<div *ngIf="(msDesc$ | async) as msDescs">
<div *ngFor="let msDesc of msDescs">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the async binding directly in the loop:

<div *ngFor="let msDesc of msDescs$ | async">

FYI, if you need to add a level to handle logic (like you did here), but don't need additional HTML you can use ng-container.

<evt-ms-desc *ngIf="msDesc.id == msDescID" [data]="msDesc"></evt-ms-desc>
</div>
</div>
</div>
</evt-panel>
2 changes: 1 addition & 1 deletion src/app/panels/image-panel/image-panel.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('ImagePanelComponent', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ ImagePanelComponent ]
declarations: [ ImagePanelComponent ],
})
.compileComponents();
}));
Expand Down
79 changes: 64 additions & 15 deletions src/app/panels/image-panel/image-panel.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component, Input } from '@angular/core';
import { BehaviorSubject, combineLatest } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { HttpClient } from '@angular/common/http';
import { ChangeDetectorRef, Component, Input } from '@angular/core';
import { ViewerDataType } from '../../models/evt-models';
import { EVTModelService } from '../../services/evt-model.service';

Expand All @@ -12,24 +11,74 @@ import { EVTModelService } from '../../services/evt-model.service';
export class ImagePanelComponent {
@Input() viewerData: ViewerDataType;

currentMsDescId$ = new BehaviorSubject(undefined);
currentMsDesc$ = combineLatest([this.evtModelService.msDesc$, this.currentMsDescId$]).pipe(
filter(([msDesc, currentId]) => !!msDesc && !!currentId),
map(([msDesc, currentId]) => msDesc.find(m => m.id === currentId)),
);

msDescOpen = false;
get imageIndex() { return this._imageIndex; }

constructor(
private evtModelService: EVTModelService,
public evtModelService: EVTModelService,
public http: HttpClient,
private cdref: ChangeDetectorRef,
) {
}
public msDesc$ = this.evtModelService.msDesc$;
public showSecondaryContent = false;
public selectedPage;
public msDescID = '';
public value: number;
public images = [];
public currentImg: string;
// tslint:disable-next-line: variable-name
private _imageIndex: number;
public manifest;
public imagePath;
public filename;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move all these property before the contructor.


toggleImg(event){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add space before "{"

this._imageIndex = this.images.indexOf(event);
}

eventPageImg(pageImg: number){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of this method is not very explanatory. Can you find another one?

if (this.viewerData?.type === 'manifest'){
this.currentImg = this.images[pageImg - 1].label;
}
if (this.viewerData?.type === 'default' || this.viewerData?.type === 'graphics'){
this.currentImg = this.images[pageImg - 1].url.split('/').pop().split('.')[0];
}
this.cdref.detectChanges();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you call explicitly change detection?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added change detection because otherwise the error "ERROR Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checking" would appear in the console, since every time the image name is updated without the page being refreshed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can try to use Observable for currentImage and let the async method handle it.

}

setMsDescOpen(isOpen: boolean) {
this.msDescOpen = isOpen;
// tslint:disable-next-line: use-lifecycle-interface
ngOnChanges() {
if (this.viewerData?.type === 'manifest'){
this.manifest = this.viewerData.value?.manifestURL;
// tslint:disable-next-line: no-any
this.http.get(`${this.manifest}`).subscribe((item: any) => {
item.sequences.forEach((value) => {
this.images.push(...value.canvases);
});
this.currentImg = this.images[0].label;
});
}
if (this.viewerData?.type === 'default' || this.viewerData?.type === 'graphics'){
this.images = this.viewerData?.value?.xmlImages;
this.imagePath = this.viewerData?.value?.xmlImages[0]?.url;
this.filename = this.imagePath.split('/').pop().split('.')[0];
this.currentImg = this.filename;
}
else {
this.currentImg = 'Error loading';
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the logic here depends on viewerData. You can try to change the @Input prop into a setter/getter and move this logic inside it.

private _vd: ViewerDataType;
@Input() set viewerData(vd: ViewerDataType) {
   // Your logic goes here
}
get viewerData() {
   return this._vd;
}

NB: The getter is only needed if you access viewerData elsewhere, otherwise you can omit it.


setMsDescID(msDescId: string) {
this.currentMsDescId$.next(msDescId);
isSecondaryContentOpened(): boolean {
return this.showSecondaryContent;
}

isMsDescOpen(event: boolean){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be just this.msDescOpen why do you need the other lines?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird to have a check on the internal state that depends on an event that is a boolean.
Check this function again, it is probably overcomplicated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of this method suggests a return value. If you don't need a return value probably you should change the name of the method.

this.showSecondaryContent = event;
}

setMsDescID(idMsDesc: string){
this.msDescID = idMsDesc;
}

}
4 changes: 4 additions & 0 deletions src/app/ui-components/icon/icon.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
content: "\e91c";
}

.evt-icon-imgImg:before {
content: "\e92b";
}

.evt-icon-txt:before {
content: "\e92e";
}
Expand Down
8 changes: 8 additions & 0 deletions src/app/view-modes/image-image/image-image.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<gridster [options]="layoutOptions">
<gridster-item [item]="imagePanel1Item">
<evt-image-panel [viewerData]="imageViewer$ | async"></evt-image-panel>
</gridster-item>
<gridster-item [item]="imagePanel2Item">
<evt-image-panel [viewerData]="imageViewer$ | async"></evt-image-panel>
</gridster-item>
</gridster>
Empty file.
25 changes: 25 additions & 0 deletions src/app/view-modes/image-image/image-image.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ImageImageComponent } from './image-image.component';

describe('ImageImageComponent', () => {
let component: ImageImageComponent;
let fixture: ComponentFixture<ImageImageComponent>;

beforeEach(async() => {
await TestBed.configureTestingModule({
declarations: [ ImageImageComponent ],
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ImageImageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
64 changes: 64 additions & 0 deletions src/app/view-modes/image-image/image-image.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Component, OnInit } from '@angular/core';
import { DisplayGrid, GridsterConfig, GridsterItem, GridType } from 'angular-gridster2';
import { map } from 'rxjs/operators';
import { AppConfig } from '../../app.config';
import { Surface, ViewerDataType, XMLImagesValues } from '../../models/evt-models';
import { ViewerSource } from '../../models/evt-polymorphic-models';
import { EVTModelService } from '../../services/evt-model.service';

@Component({
selector: 'evt-image-image',
templateUrl: './image-image.component.html',
styleUrls: ['./image-image.component.scss'],
})
export class ImageImageComponent implements OnInit {
public layoutOptions: GridsterConfig = {};
public imagePanel1Item: GridsterItem = { cols: 1, rows: 1, y: 0, x: 0 };
public imagePanel2Item: GridsterItem = { cols: 1, rows: 1, y: 0, x: 1 };

public imageViewer$ = this.evtModelService.surfaces$.pipe(
map((surface) => this.getImageViewerType(AppConfig.evtSettings.files.editionImagesSource, surface)),
);

constructor(
private evtModelService: EVTModelService,
) {
}

getImageViewerType(editionImages, surface: Surface[]): ViewerDataType {
for (const key of Object.keys(editionImages)) {
if (editionImages[key].enabled) {
return ViewerSource.getDataType(key, surface);
}
}
const xmlImages: XMLImagesValues[] = [];
this.evtModelService.pages$.pipe().subscribe(
(pages) => pages.map(page => xmlImages.push({ url: page.facsUrl }),
));

return { type: 'default', value: { xmlImages } };
}

ngOnInit() {
this.initGridster();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to set layout options here or is it enough to set at construction time?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably move it in the constructor!

}

private initGridster() {
this.layoutOptions = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can put this at line 10.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you move it at line 15 (15 is the new 10 XD), you can remove the method initGridster

gridType: GridType.Fit,
displayGrid: DisplayGrid.None,
margin: 0,
maxCols: 2,
maxRows: 1,
draggable: {
enabled: true,
ignoreContent: true,
dragHandleClass: 'panel-header',
},
resizable: {
enabled: false,
},
};
}

}
2 changes: 1 addition & 1 deletion src/app/view-modes/image-text/image-text.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('ImageTextComponent', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ ImageTextComponent ]
declarations: [ ImageTextComponent ],
})
.compileComponents();
}));
Expand Down
6 changes: 6 additions & 0 deletions src/assets/config/edition_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@
"id": "textText",
"label": "Text Text"
},
{
"icon": "imgImg",
"iconSet": "evt",
"id": "imageImage",
"label": "Image Image"
},
{
"icon": "collation",
"iconSet": "evt",
Expand Down
Binary file modified src/assets/fonts/evt-icons.eot
Binary file not shown.
5 changes: 5 additions & 0 deletions src/assets/fonts/evt-icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/fonts/evt-icons.ttf
Binary file not shown.
Binary file modified src/assets/fonts/evt-icons.woff
Binary file not shown.
4 changes: 4 additions & 0 deletions src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ body {
}
}

.imgSelect {
width: 10rem;
}

.overflow-y-auto {
overflow-y: auto;
}
Expand Down