Skip to content

Commit

Permalink
fix issue #757 - Folder size indicator show "k" when over 1,000 (#769)
Browse files Browse the repository at this point in the history
* fix issue #757 - Folder size indicator show "k" when over 1,000

* reduce complexity to respect codeclimate

* issue 757: create a pipe

Co-authored-by: Jean-Michel Dagenais <jm@obkio.com>
  • Loading branch information
jmdagenais and Jean-Michel Dagenais committed Oct 31, 2022
1 parent 728ccfd commit b56b6c0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import { FileSearchPipe } from './pipes/file-search.pipe';
import { FileSizeFilterPipe } from './pipes/file-size-filter.pipe';
import { FileSizePipe } from './pipes/file-size.pipe';
import { FolderArrowsPipe } from './pipes/folder-arrows.pipe';
import { FolderSizePipe } from './pipes/folder-size.pipe';
import { FolderViewPipe } from './pipes/folder-view.pipe';
import { FuzzySearchPipe } from './pipes/fuzzy-search.pipe';
import { HideOfflinePipe } from './pipes/hide-offline.pipe';
Expand Down Expand Up @@ -128,6 +129,7 @@ import { YearPipe } from './pipes/year.pipe';
FileSizePipe,
FilmstripComponent,
FolderArrowsPipe,
FolderSizePipe,
FolderViewPipe,
FullViewComponent,
FuzzySearchPipe,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<div *ngIf="video.cleanName === '*FOLDER*' && video.fileName !== '*UP*'" class="folder-icon">
<app-icon [icon]="'icon-folder-blank'"></app-icon>
<div class="items-in-folder">{{ video.fileSizeDisplay }}</div>
<div class="items-in-folder">{{ video.fileSizeDisplay | folderSize }}</div>
</div>

<span
Expand Down
14 changes: 7 additions & 7 deletions src/app/components/views/thumbnail/thumbnail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import type { VideoClickEmit, RightClickEmit } from '../../../../../interfaces/s
selector: 'app-thumbnail',
templateUrl: './thumbnail.component.html',
styleUrls: [
'../clip-and-preview.scss',
'../time-and-rez.scss',
'./thumbnail.component.scss',
'../selected.scss'
],
animations: [ textAppear,
metaAppear ]
'../clip-and-preview.scss',
'../time-and-rez.scss',
'./thumbnail.component.scss',
'../selected.scss'
],
animations: [textAppear,
metaAppear]
})
export class ThumbnailComponent implements OnInit, OnDestroy {

Expand Down
15 changes: 15 additions & 0 deletions src/app/pipes/folder-size.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'folderSize'
})
export class FolderSizePipe implements PipeTransform {
transform(value: any, ...args: any[]): any {
const fileCount = parseInt(value, 10);
if (fileCount >= 1000) {
return Math.floor(fileCount / 1000) + 'k';
} else {
return value;
}
}
}

0 comments on commit b56b6c0

Please sign in to comment.