Skip to content
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

Show video icon on thumbnail if the asset is video. #629

Merged
merged 1 commit into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@
src="/assets/images/location.svg"
class="located"
></ion-icon>
<img *ngIf="thumbnailUrl$ | async as thumbnailUrl" [src]="thumbnailUrl" />
<ion-icon *ngIf="isVideo$ | async" name="videocam" class="is-video"></ion-icon>
<img
*ngIf="thumbnailUrl$ | async as thumbnailUrl"
loading="lazy"
decoding="async"
[src]="thumbnailUrl"
/>
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,34 @@
ion-icon {
color: white;
z-index: 10;
position: absolute;
opacity: 0.3;
}

ion-icon.collecting {
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
opacity: 0.3;
font-size: 24px;
}

ion-icon.uploaded {
position: absolute;
bottom: 9px;
left: 5px;
font-size: 13px;
opacity: 0.3;
}

ion-icon.located {
position: absolute;
bottom: 8px;
left: 23px;
font-size: 16px;
opacity: 0.3;
}

ion-icon.is-video {
top: 8px;
right: 8px;
font-size: 16px;
}

img {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export class CaptureItemComponent {
map(proof => isValidGeolocation(proof))
);

readonly isVideo$ = this.proof$.pipe(
concatMap(proof => proof.getFirstAssetMeta()),
map(meta => meta.mimeType.startsWith('video'))
);

constructor(
private readonly captureService: CaptureService,
private readonly router: Router,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
"
[routerLink]="['post-capture-details', { id: postCapture.id }]"
>
<ng-container *ngIf="postCapture.parsed_meta.mime_type as mimeType">
<ion-icon
*ngIf="mimeType | startsWith: 'video'"
name="videocam"
class="is-video"
></ion-icon
></ng-container>
<ion-img [src]="postCapture.asset_file_thumbnail"></ion-img>
</mat-grid-tile>
</mat-grid-list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ ion-segment {
overflow: hidden;
border-radius: 4px;
}

ion-icon.is-video {
color: white;
z-index: 10;
position: absolute;
opacity: 0.3;
top: 8px;
right: 8px;
font-size: 16px;
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/app/shared/pipes/starts-with/starts-with.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { StartsWithPipe } from './starts-with.pipe';

describe('StartsWithPipe', () => {
it('create an instance', () => {
const pipe = new StartsWithPipe();
expect(pipe).toBeTruthy();
});
});
11 changes: 11 additions & 0 deletions src/app/shared/pipes/starts-with/starts-with.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'startsWith',
})
export class StartsWithPipe implements PipeTransform {
// eslint-disable-next-line class-methods-use-this
transform(value: string, prefix: string) {
return value.startsWith(prefix);
}
}
2 changes: 2 additions & 0 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import { MediaComponent } from './components/media/media.component';
import { MigratingDialogComponent } from './components/migrating-dialog/migrating-dialog.component';
import { CapacitorPluginsModule } from './core/capacitor-plugins/capacitor-plugins.module';
import { MaterialModule } from './core/material/material.module';
import { StartsWithPipe } from './pipes/starts-with/starts-with.pipe';

const declarations = [
MigratingDialogComponent,
AvatarComponent,
MediaComponent,
StartsWithPipe,
];

const imports = [
Expand Down