Skip to content

Commit

Permalink
Staging to use pagination template
Browse files Browse the repository at this point in the history
  • Loading branch information
hudson-newey committed Oct 3, 2024
1 parent 425e3ce commit 1feeeb1
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 55 deletions.
66 changes: 28 additions & 38 deletions src/app/components/annotations/pages/search/search.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,47 +24,37 @@ <h1>Annotations Search</h1>
</div>
</div>

<hr />
<hr>

<div class="annotations-grid my-2">
@for (item of searchResults; track $index) {
<div class="preview-item border">
@if (item) {
<oe-spectrogram
[id]="'spectrogram-' + item.id"
[src]="item.audioLink"
scaling="stretch"
color-map="audacity"
></oe-spectrogram>
<div>
<p>
Displaying <span class="fw-bold">{{ pageSize }}</span> of
<span class="fw-bold">all {{ totalModels }}</span> audio events.
</p>

<div class="annotations-grid my-2">
@for (verificationModel of searchResults; track $index) {
<div>
@if (verificationModel) {
<baw-audio-event-card
[audioEvent]="verificationModel"
></baw-audio-event-card>
}
</div>
}
</div>
}
</div>

@if (searchResults.length === 0) {
<h2 class="no-results-error">
No {{ searchParameters.onlyUnverified ? "unverified" : "" }} annotations found
</h2>
}

<div class="annotation-grid-controls">
<div class="preview-controls my-2">
<button
type="button"
class="btn btn-secondary me-2"
[disabled]="searchResults.length === 0"
(click)="pagePreviewPrevious()"
>
Previous Page
</button>
@if (searchResults.length === 0) {
<h2 class="no-results-error">
No {{ searchParameters.onlyUnverified ? "unverified" : "" }} annotations
found
</h2>
}

<button
type="button"
class="btn btn-secondary"
[disabled]="searchResults.length === 0"
(click)="pagePreviewNext()"
>
Next Page
</button>
</div>
<ngb-pagination
class="d-flex justify-content-center mt-4"
[(page)]="previewPage"
[collectionSize]="searchResults.length"
>
</ngb-pagination>
</div>
16 changes: 2 additions & 14 deletions src/app/components/annotations/pages/search/search.component.scss
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
$gap-size: 0.5em;

.annotations-grid {
display: flex;
justify-content: start;
justify-content: space-evenly;
flex-wrap: wrap;
flex-direction: row;

position: relative;
gap: $gap-size;
gap: 1em;
min-height: 2rem;
}

.preview-item {
display: inline-block;
flex: 0 0 calc(20% - $gap-size);

position: relative;
min-width: calc(20% - $gap-size);
min-height: 133px;
}

.annotation-grid-controls {
position: relative;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ class AnnotationSearchComponent extends PageComponent implements OnInit {
super();
}

public previewPage = 1;
public previewSize = 15;
protected searchResults: Verification[] = Array.from({ length: this.previewSize });
public paginationInfo: Paging;
protected searchResults: Verification[] = Array.from({ length: 15 });
protected searchParameters: AnnotationSearchParameters;
protected verificationRoute: StrongRoute;
protected project: Project;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="card p-2">
<oe-axes>
<oe-indicator>
<oe-spectrogram
[id]="'spectrogram-' + audioEvent.id"
[src]="audioEvent.audioLink"
scaling="stretch"
color-map="audacity"
></oe-spectrogram>
</oe-indicator>
</oe-axes>

<div class="card-header">
<h5 class="card-title text-truncate">{{ audioEvent.tags }}</h5>
</div>

<div class="card-body">
<a class="info-line" [href]="audioEvent.listenViewUrl">{{
audioEvent.startTimeSeconds | date
}}</a>
<a class="info-line" [href]="audioEvent.viewUrl">More information</a>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.info-line {
display: block;
width: 100%;
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component, Input } from "@angular/core";
import { Verification } from "@models/Verification";

@Component({
selector: "baw-audio-event-card",
templateUrl: "audio-event-card.component.html",
styleUrl: "audio-event-card.component.scss",
})
export class AudioEventCardComponent {
@Input({ required: true }) public audioEvent: Verification;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";
import { AudioEventCardComponent } from "./audio-event-card.component";

@NgModule({
declarations: [AudioEventCardComponent],
imports: [CommonModule],
exports: [AudioEventCardComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AudioEventCardModule {}
2 changes: 2 additions & 0 deletions src/app/components/shared/shared.components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import { TimeSinceComponent } from "./datetime-formats/time-since/time-since.com
import { DurationComponent } from "./datetime-formats/duration/duration.component";
import { ZonedDateTimeComponent } from "./datetime-formats/datetime/zoned-datetime/zoned-datetime.component";
import { DatetimeComponent } from "./datetime-formats/datetime/datetime/datetime.component";
import { AudioEventCardModule } from "./audio-event-card/audio-event-card.module";

export const sharedComponents = [
AnnotationDownloadComponent,
Expand Down Expand Up @@ -114,6 +115,7 @@ export const sharedModules = [
LoadingModule,
MenuModule,
ModelCardsModule,
AudioEventCardModule,
PipesModule,
ProgressModule,
StepperModule,
Expand Down

0 comments on commit 1feeeb1

Please sign in to comment.