-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/image image component #164
base: develop
Are you sure you want to change the base?
Conversation
[manifestURL]="manifest"> | ||
[manifestURL]="manifest" | ||
[page]="imageIndex" | ||
(data)="eventHandler($event)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are vinding to page change event use that instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
page change event does not consider the page change through arrows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make the buttons fire that event instead
}); | ||
this._imageIndex = 0; | ||
this.currentImg = this.images[this.page].label; | ||
this.cdref.detectChanges(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually such errors is due to an improper initialisation.
} | ||
} | ||
|
||
isMsDescOpen(event: boolean){ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
} | ||
} | ||
|
||
setMsDescID(event: string){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check naming, of parameters, you call event
boolean, strings and actual events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be a setter
} | ||
|
||
private initGridster() { | ||
this.layoutOptions = { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
public imagePanel2Item: GridsterItem = { cols: 1, rows: 1, y: 0, x: 1 }; | ||
|
||
ngOnInit() { | ||
this.initGridster(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
96ab1fc
to
3e05ba6
Compare
@@ -112,12 +114,14 @@ 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the +1
?
There was a problem hiding this comment.
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
?
22265c0
to
43dc59f
Compare
43dc59f
to
477c9a0
Compare
11ba834
to
8aeff48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you added a new icon, you should update also the file evt-icons-project.json
into src/assets/fonts
, otherwise new future icons addition will override yours!
@@ -112,12 +114,14 @@ 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); |
There was a problem hiding this comment.
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
?
@@ -174,4 +174,5 @@ export class OsdComponent implements AfterViewInit, OnDestroy { | |||
ngOnDestroy(): void { | |||
this.subscriptions.forEach((s) => s.unsubscribe()); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line
<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 |
There was a problem hiding this comment.
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?
<div *ngIf="msDescOpen"> | ||
<evt-ms-desc [data]="currentMsDesc$ | async"></evt-ms-desc> | ||
<div *ngIf="(msDesc$ | async) as msDescs"> | ||
<div *ngFor="let msDesc of msDescs"> |
There was a problem hiding this comment.
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
.
private _imageIndex: number; | ||
public manifest; | ||
public imagePath; | ||
public filename; |
There was a problem hiding this comment.
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.
public imagePath; | ||
public filename; | ||
|
||
toggleImg(event){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add space before "{"
} | ||
else { | ||
this.currentImg = 'Error loading'; | ||
} | ||
} |
There was a problem hiding this comment.
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.
} | ||
|
||
isMsDescOpen(event: boolean){ |
There was a problem hiding this comment.
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.
public imagePanel2Item: GridsterItem = { cols: 1, rows: 1, y: 0, x: 1 }; | ||
|
||
ngOnInit() { | ||
this.initGridster(); |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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
No description provided.