F: season page: add mark episode/season as watched

This commit is contained in:
X4Lo committed 2025-02-18 20:28:55 +01:00
1 parent 30ad2fbf03
commit 09cd4b205a
13 files changed
+187 -63

No files matched your search

@@ -5,7 +5,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { Entry } from '../../../shared/models/entry.model'; import { Entry } from '../../../shared/models/entry.model';
import { EpisodeSeenDto } from '../../../shared/models/dtos/episode-seen.dto'; import { EpisodeSeenCreateDto } from '../../../shared/models/dtos/episode-seen.dto';
import { UserCollectionsModalComponent } from '../../../shared/components/modals/list-selection-modal/user-collections-modal.component'; import { UserCollectionsModalComponent } from '../../../shared/components/modals/list-selection-modal/user-collections-modal.component';
import { SeenModalComponent } from '../../../shared/components/modals/seen-modal/seen-modal.component'; import { SeenModalComponent } from '../../../shared/components/modals/seen-modal/seen-modal.component';
@@ -451,7 +451,7 @@ export class AlternateEntryPageComponent implements OnInit {
this.episodeSeenService.getEpisodeSeenByEntryId(this.entry.id).subscribe({ this.episodeSeenService.getEpisodeSeenByEntryId(this.entry.id).subscribe({
next: (data) => { next: (data) => {
let episodeSeens = [] as EpisodeSeenDto[]; let episodeSeens = [] as EpisodeSeenCreateDto[];
// mapping // mapping
data.forEach((item) => { data.forEach((item) => {
@@ -469,7 +469,7 @@ export class AlternateEntryPageComponent implements OnInit {
createdAt: item.createdAt, createdAt: item.createdAt,
updatedAt: item.updatedAt, updatedAt: item.updatedAt,
} as EpisodeSeenDto; } as EpisodeSeenCreateDto;
episodeSeens.push(e); episodeSeens.push(e);
}); });
@@ -479,7 +479,7 @@ export class AlternateEntryPageComponent implements OnInit {
this.filterEpisodesSeenHistory(); this.filterEpisodesSeenHistory();
}, },
error: (error) => { error: (error) => {
this.seenHistory = [] as EpisodeSeenDto[]; this.seenHistory = [] as EpisodeSeenCreateDto[];
this.filterEpisodesSeenHistory(); this.filterEpisodesSeenHistory();
console.log(`Error getting episodes watch history`, error); console.log(`Error getting episodes watch history`, error);
}, },
@@ -488,7 +488,7 @@ export class AlternateEntryPageComponent implements OnInit {
// ? filter episode seen history // ? filter episode seen history
filterEpisodesSeenHistory() { filterEpisodesSeenHistory() {
var temp = [] as EpisodeSeenDto[]; var temp = [] as EpisodeSeenCreateDto[];
temp = this.seenHistory; temp = this.seenHistory;
@@ -543,7 +543,7 @@ export class AlternateEntryPageComponent implements OnInit {
}); });
} }
editEpisodeSeen(episodeSeen: EpisodeSeenDto) { editEpisodeSeen(episodeSeen: EpisodeSeenCreateDto) {
if (episodeSeen == null) return; if (episodeSeen == null) return;
const dialogRef = this.dialog.open(EpisodeSeenModalComponent, { const dialogRef = this.dialog.open(EpisodeSeenModalComponent, {
@@ -563,7 +563,7 @@ export class AlternateEntryPageComponent implements OnInit {
}); });
} }
deleteEpisodeSeen(episodeSeen: EpisodeSeenDto) { deleteEpisodeSeen(episodeSeen: EpisodeSeenCreateDto) {
if (episodeSeen.id == null) return; if (episodeSeen.id == null) return;
const dialogRef = this.dialog.open(ConfirmModalComponent, { const dialogRef = this.dialog.open(ConfirmModalComponent, {
@@ -5,7 +5,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { Entry } from '../../../shared/models/entry.model'; import { Entry } from '../../../shared/models/entry.model';
import { EpisodeSeenDto } from '../../../shared/models/dtos/episode-seen.dto'; import { EpisodeSeenCreateDto } from '../../../shared/models/dtos/episode-seen.dto';
import { UserCollectionsModalComponent } from '../../../shared/components/modals/list-selection-modal/user-collections-modal.component'; import { UserCollectionsModalComponent } from '../../../shared/components/modals/list-selection-modal/user-collections-modal.component';
import { SeenModalComponent } from '../../../shared/components/modals/seen-modal/seen-modal.component'; import { SeenModalComponent } from '../../../shared/components/modals/seen-modal/seen-modal.component';
@@ -450,7 +450,7 @@ export class EntryPageComponent implements OnInit {
this.episodeSeenService.getEpisodeSeenByEntryId(this.entry.id).subscribe({ this.episodeSeenService.getEpisodeSeenByEntryId(this.entry.id).subscribe({
next: (data) => { next: (data) => {
let episodeSeens = [] as EpisodeSeenDto[]; let episodeSeens = [] as EpisodeSeenCreateDto[];
// mapping // mapping
data.forEach((item) => { data.forEach((item) => {
@@ -468,7 +468,7 @@ export class EntryPageComponent implements OnInit {
createdAt: item.createdAt, createdAt: item.createdAt,
updatedAt: item.updatedAt, updatedAt: item.updatedAt,
} as EpisodeSeenDto; } as EpisodeSeenCreateDto;
episodeSeens.push(e); episodeSeens.push(e);
}); });
@@ -478,7 +478,7 @@ export class EntryPageComponent implements OnInit {
this.filterEpisodesSeenHistory(); this.filterEpisodesSeenHistory();
}, },
error: (error) => { error: (error) => {
this.seenHistory = [] as EpisodeSeenDto[]; this.seenHistory = [] as EpisodeSeenCreateDto[];
this.filterEpisodesSeenHistory(); this.filterEpisodesSeenHistory();
console.log(`Error getting episodes watch history`, error); console.log(`Error getting episodes watch history`, error);
}, },
@@ -487,7 +487,7 @@ export class EntryPageComponent implements OnInit {
// ? filter episode seen history // ? filter episode seen history
filterEpisodesSeenHistory() { filterEpisodesSeenHistory() {
var temp = [] as EpisodeSeenDto[]; var temp = [] as EpisodeSeenCreateDto[];
temp = this.seenHistory; temp = this.seenHistory;
@@ -542,7 +542,7 @@ export class EntryPageComponent implements OnInit {
}); });
} }
editEpisodeSeen(episodeSeen: EpisodeSeenDto) { editEpisodeSeen(episodeSeen: EpisodeSeenCreateDto) {
if (episodeSeen == null) return; if (episodeSeen == null) return;
const dialogRef = this.dialog.open(EpisodeSeenModalComponent, { const dialogRef = this.dialog.open(EpisodeSeenModalComponent, {
@@ -562,7 +562,7 @@ export class EntryPageComponent implements OnInit {
}); });
} }
deleteEpisodeSeen(episodeSeen: EpisodeSeenDto) { deleteEpisodeSeen(episodeSeen: EpisodeSeenCreateDto) {
if (episodeSeen.id == null) return; if (episodeSeen.id == null) return;
const dialogRef = this.dialog.open(ConfirmModalComponent, { const dialogRef = this.dialog.open(ConfirmModalComponent, {
@@ -1,21 +1,23 @@
:host { :host {
--bg-opacity: 0.9; --bg-opacity: 0.3;
--bg-opacity-secondary: 0.5;
--bg-color: rgba(255, 255, 255, var(--bg-opacity)); --bg-color: rgba(255, 255, 255, var(--bg-opacity));
--text-color: #333; --text-color: #333;
--text-muted: #666; --text-muted: #666;
--border-color: #dee2e6; --border-color: #dee2e6;
--card-bg: rgba(255, 255, 255, 0.8); --card-bg: rgba(255, 255, 255, var(--bg-opacity-secondary));
--hover-bg: #e9ecef; --hover-bg: #e9ecef;
--shadow-color: rgba(0, 0, 0, 0.1); --shadow-color: rgba(0, 0, 0, 0.1);
} }
[data-bs-theme="dark"] :host { [data-bs-theme="dark"] :host {
--bg-opacity: 0.9; --bg-opacity: 0.3;
--bg-opacity-secondary: 0.5;
--bg-color: rgba(33, 37, 41, var(--bg-opacity)); --bg-color: rgba(33, 37, 41, var(--bg-opacity));
--text-color: #fff; --text-color: #fff;
--text-muted: #adb5bd; --text-muted: #adb5bd;
--border-color: #495057; --border-color: #495057;
--card-bg: rgba(33, 37, 41, 0.8); --card-bg: rgba(33, 37, 41, var(--bg-opacity-secondary));
--hover-bg: #495057; --hover-bg: #495057;
--shadow-color: rgba(0, 0, 0, 0.3); --shadow-color: rgba(0, 0, 0, 0.3);
} }
@@ -148,11 +150,11 @@
} }
.watch-history-section { .watch-history-section {
background: var(--card-bg); /* background: var(--card-bg); */
backdrop-filter: blur(5px); /* backdrop-filter: blur(5px); */
-webkit-backdrop-filter: blur(5px); /* -webkit-backdrop-filter: blur(5px); */
border-radius: 10px; border-radius: 10px;
padding: 20px; /* padding: 20px; */
color: var(--text-color); color: var(--text-color);
} }
@@ -183,16 +185,22 @@
.table { .table {
margin-bottom: 0; margin-bottom: 0;
color: var(--text-color); color: var(--text-color);
background-color: var(--bg-color-secondary);
} }
.table th { .table th {
border-top: none; border-top: none;
color: var(--text-color); color: var(--text-color);
background-color: var(--bg-color-secondary);
} }
.table td { .table td {
color: var(--text-color); color: var(--text-color);
border-color: var(--border-color); border-color: var(--border-color);
background-color: var(--bg-color-secondary);
align-items: center;
align-content: center;
padding: 5px;
} }
.btn-outline-primary { .btn-outline-primary {
@@ -1,5 +1,7 @@
<!-- Fixed Background --> <!-- Fixed Background -->
<div class="fixed-image" [style.background-image]="'url(http://localhost:4000/api/v1/media/entries/backdrops/original/1fb338bd-46ee-4caf-b736-f3c0e797ed88.jpg)'"></div> <div class="fixed-image"
[style.background-image]="'url(http://localhost:4000/api/v1/media/entries/backdrops/original/1fb338bd-46ee-4caf-b736-f3c0e797ed88.jpg)'">
</div>
<div class="container content-wrapper main-container"> <div class="container content-wrapper main-container">
<div class="row"> <div class="row">
@@ -49,13 +51,10 @@
<!-- Season Navigation --> <!-- Season Navigation -->
<div class="season-nav mb-4"> <div class="season-nav mb-4">
<div class="d-flex justify-content-between align-items-center"> <div class="d-flex justify-content-between align-items-center">
<h2 class="title">{{selectedSeason.name}}</h2> <h2 class="title">{{selectedSeason.name}} </h2>
<div class="season-actions"> <div class="season-actions">
<button class="btn btn-icon-only-success wh-48"> <button class="btn btn-icon-only-success wh-48" (click)="markSeasonAsWatched()">
<span class="material-symbols-outlined">playlist_add_check</span> <span class="material-symbols-outlined">check</span>
</button>
<button class="btn btn-icon-only-success wh-48" (click)="addToPlaylist()">
<span class="material-symbols-outlined">playlist_add</span>
</button> </button>
</div> </div>
</div> </div>
@@ -77,7 +76,9 @@
<!-- Episodes List --> <!-- Episodes List -->
<div class="episodes-section"> <div class="episodes-section">
<h3 class="mb-3">Episodes</h3> <h3 class="mb-3">
Episodes <span class="text-muted">({{selectedSeason.episodes.length}})</span>
</h3>
<div class="episode-cards"> <div class="episode-cards">
<div class="card mb-3" *ngFor="let episode of selectedSeason.episodes"> <div class="card mb-3" *ngFor="let episode of selectedSeason.episodes">
<div class="row g-0"> <div class="row g-0">
@@ -89,18 +90,25 @@
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<h5 class="card-title">{{episode.episode_number}}. {{episode.name}}</h5> <h5 class="card-title">{{episode.episode_number}}. {{episode.name}}</h5>
<div class="episode-actions"> <div class="episode-actions">
<button class="btn btn-sm btn-outline-primary me-2"> <button class="btn btn-icon-only-success wh-48" (click)="markEpisodeAsWatched(episode)">
<span class="material-symbols-outlined">check</span> <span class="material-symbols-outlined">check</span>
</button> </button>
<button class="btn btn-sm btn-outline-secondary"> <!-- <button class="btn btn-icon-only-success wh-48">
<span class="material-symbols-outlined">info</span> <span class="material-symbols-outlined">info</span>
</button> </button> -->
</div> </div>
</div> </div>
<p class="card-text">{{episode.overview}}</p> <p class="card-text">{{episode.overview}}</p>
<p class="card-text"> <p class="card-text">
<small class="text-muted">Air date: {{episode.air_date | date:'MMM dd, yyyy'}}</small> <small class="text-muted" *ngIf="episode.air_date">
<small class="text-muted" *ngIf="episode.runtime"> • Runtime: {{episode.runtime}} minutes</small> Air date: {{episode.air_date | date:'MMM dd, yyyy'}}
</small>
<small class="text-muted" *ngIf="episode.runtime"> • Runtime: {{episode.runtime |
betterMinutesFormat}}
</small>
<small class="text-muted" *ngIf="episode.date_first_seen">
• Seen: {{episode.date_first_seen | date:'MMM dd, yyyy'}}
</small>
</p> </p>
</div> </div>
</div> </div>
@@ -123,10 +131,10 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let history of watchHistory"> <tr *ngFor="let ep of watchHistory">
<td>Episode {{history.episode_number}}</td> <td>Episode {{ep.episode.episode_number}}</td>
<td>{{history.date_seen | date:'MMM dd, yyyy'}}</td> <td>{{ep.date_seen | date:'MMM dd, yyyy'}}</td>
<td>{{history.seen_with}}</td> <td>{{ep.seen_with}}</td>
<td> <td>
<button class="btn btn-sm btn-link"> <button class="btn btn-sm btn-link">
<span class="material-symbols-outlined">edit</span> <span class="material-symbols-outlined">edit</span>
@@ -3,7 +3,10 @@ import { EntryService } from '../../../core/services/entry.service';
import { Season } from '../../../shared/models/season.model'; import { Season } from '../../../shared/models/season.model';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { EpisodeSeenService } from '../../../core/services/episode-seen.service'; import { EpisodeSeenService } from '../../../core/services/episode-seen.service';
import { EpisodeSeenDto } from '../../../shared/models/dtos/episode-seen.dto'; import { MatDialog } from '@angular/material/dialog';
import { SeenModalComponent } from '../../../shared/components/modals/seen-modal/seen-modal.component';
import { Episode } from '../../../shared/models/episode.models';
import { EpisodeSeen } from '../../../shared/models/episode-seen.model';
@Component({ @Component({
selector: 'app-season-page', selector: 'app-season-page',
@@ -15,12 +18,13 @@ export class SeasonPageComponent implements OnInit {
seasonNumber!: number; seasonNumber!: number;
seasons: Season[] = []; seasons: Season[] = [];
selectedSeason!: Season; selectedSeason!: Season;
watchHistory: EpisodeSeenDto[] = []; watchHistory: EpisodeSeen[] = [];
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private entryService: EntryService, private entryService: EntryService,
private episodeSeenService: EpisodeSeenService private episodeSeenService: EpisodeSeenService,
private dialog: MatDialog
) {} ) {}
ngOnInit() { ngOnInit() {
@@ -44,6 +48,7 @@ export class SeasonPageComponent implements OnInit {
this.episodeSeenService.getEpisodeSeenByEntryId(this.entryId).subscribe({ this.episodeSeenService.getEpisodeSeenByEntryId(this.entryId).subscribe({
next: (result) => { next: (result) => {
this.watchHistory = result; this.watchHistory = result;
console.log(this.watchHistory);
}, },
}); });
}); });
@@ -51,12 +56,84 @@ export class SeasonPageComponent implements OnInit {
posterPath(path: string | undefined) { posterPath(path: string | undefined) {
if (path) { if (path) {
return `https://image.tmdb.org/t/p/w300` + path; return `https://image.tmdb.org/t/p/w780` + path;
} }
return 'assets/images/default/default-poster.png'; return 'assets/images/default/default-poster.png';
} }
markAsWatched() {} async markEpisodeAsWatched(episode: Episode) {
addToPlaylist() {} const dialogRef = this.dialog.open(SeenModalComponent, {
width: '400px',
});
await dialogRef.afterClosed().subscribe((result) => {
if (!result || !result.watchDate) return;
const watchDate = result.watchDate;
const watchedWith = result.watchedWith.split('\n').join(', ');
this.episodeSeenService
.createEpisodeSeen(
this.selectedSeason.entry_id,
episode.id,
watchDate,
watchedWith
)
.subscribe({
next: (episodeSeen) => {
if (episodeSeen.date_seen > episode.date_last_seen)
episode.date_last_seen = episodeSeen.date_seen;
if (episodeSeen.date_seen < episode.date_first_seen)
episode.date_first_seen = episodeSeen.date_seen;
},
error: (error) => {
console.log(`Couldn't mark episode as seen:`, error);
// TODO show notification
},
complete: () => {},
});
});
}
async markSeasonAsWatched() {
const dialogRef = this.dialog.open(SeenModalComponent, {
width: '400px',
data: {
hideSeenWith: true,
title: 'Mark Season As Watched'
}
});
await dialogRef.afterClosed().subscribe((result) => {
if (!result || !result.watchDate) return;
const watchDate = result.watchDate;
this.selectedSeason.episodes.forEach((episode) => {
const sub = this.episodeSeenService
.createEpisodeSeen(
this.selectedSeason.entry_id,
episode.id,
watchDate,
''
)
.subscribe({
next: (episodeSeen) => {
if (episodeSeen.date_seen > episode.date_last_seen)
episode.date_last_seen = episodeSeen.date_seen;
if (episodeSeen.date_seen < episode.date_first_seen)
episode.date_first_seen = episodeSeen.date_seen;
},
error: (error) => {
console.log(`Couldn't mark episode as seen:`, error);
// TODO show notification
},
complete: () => {
sub.unsubscribe();
},
});
});
});
}
} }
@@ -13,7 +13,7 @@ import { Season } from '../../../models/season.model';
import { SeasonService } from '../../../../core/services/season.service'; import { SeasonService } from '../../../../core/services/season.service';
import { Episode } from '../../../models/episode.models'; import { Episode } from '../../../models/episode.models';
import { EpisodeSeenService } from '../../../../core/services/episode-seen.service'; import { EpisodeSeenService } from '../../../../core/services/episode-seen.service';
import { EpisodeSeenDto } from '../../../models/dtos/episode-seen.dto'; import { EpisodeSeenCreateDto } from '../../../models/dtos/episode-seen.dto';
@Component({ @Component({
selector: 'app-episode-seen-modal', selector: 'app-episode-seen-modal',
@@ -41,7 +41,7 @@ export class EpisodeSeenModalComponent {
public entryId: number = 0; public entryId: number = 0;
public watchDate: string = ''; public watchDate: string = '';
public watchedWith: string = ''; public watchedWith: string = '';
public episodeSeen: EpisodeSeenDto = {} as EpisodeSeenDto; public episodeSeen: EpisodeSeenCreateDto = {} as EpisodeSeenCreateDto;
public seasons: Season[] = []; public seasons: Season[] = [];
public selectedSeason: Season | null = {} as Season; public selectedSeason: Season | null = {} as Season;
@@ -1,11 +1,11 @@
<div class="card border-top border-3 border-primary rounded-0" style="margin-bottom: 0 !important;"> <div class="card border-top border-3 border-primary rounded-0" style="margin-bottom: 0 !important;">
<div class="modal-header card-header py-3 px-4"> <div class="modal-header card-header py-3 px-4">
<h5 class="mb-0 text-primary">Watch Details</h5> <h5 class="mb-0 text-primary">{{title}}</h5>
<button type="button" class="btn-close" (click)="onClose()" aria-label="Close"></button> <button type="button" class="btn-close" (click)="onClose()" aria-label="Close"></button>
</div> </div>
<div class="card-body p-4 pt-1"> <div class="card-body p-4 pt-1">
<form class="row g-3"> <form class="row g-3">
<div class="col-md-12"> <div class="col-md-12" *ngIf="!hideSeenWith">
<label class="form-label">Seen With</label> <label class="form-label">Seen With</label>
<textarea class="form-control rounded-0" [(ngModel)]="watchedWith" [ngModelOptions]="{ standalone: true }" <textarea class="form-control rounded-0" [(ngModel)]="watchedWith" [ngModelOptions]="{ standalone: true }"
placeholder="Enter names" rows="3"></textarea> placeholder="Enter names" rows="3"></textarea>
@@ -9,7 +9,6 @@ import {
animate, animate,
} from '@angular/animations'; } from '@angular/animations';
import { formatDate } from '@angular/common'; import { formatDate } from '@angular/common';
import flatpickr from 'flatpickr';
@Component({ @Component({
selector: 'app-seen-modal', selector: 'app-seen-modal',
@@ -34,6 +33,9 @@ import flatpickr from 'flatpickr';
], ],
}) })
export class SeenModalComponent implements OnInit { export class SeenModalComponent implements OnInit {
title: string = 'Watch Details';
hideSeenWith: boolean = false;
public watchDate: string = ''; public watchDate: string = '';
public watchedWith: string = ''; public watchedWith: string = '';
@@ -43,8 +45,19 @@ export class SeenModalComponent implements OnInit {
) {} ) {}
ngOnInit(): void { ngOnInit(): void {
if (!this.data || !this.data.watchDate) { if (this.data.title) {
// ? no initial data was passed: populate date field with current date this.title = this.data.title;
}
if (this.data.watchedWith)
this.watchedWith = this.data.watchedWith.split(', ').join('\n');
if (this.data.hideSeenWith) {
this.hideSeenWith = this.data.hideSeenWith;
}
// ? no initial data was passed: populate date field with current date
if (!this.data.watchDate) {
this.watchDate = formatDate(new Date(), 'yyyy-MM-dd', 'en-US'); this.watchDate = formatDate(new Date(), 'yyyy-MM-dd', 'en-US');
} else { } else {
// ? if data is passed, populate fields // ? if data is passed, populate fields
@@ -53,17 +66,7 @@ export class SeenModalComponent implements OnInit {
'yyyy-MM-dd', 'yyyy-MM-dd',
'en-US' 'en-US'
); );
this.watchedWith = this.data.watchedWith.split(', ').join('\n');
} }
// flatpickr('#myDatepicker', {
// inline: true,
// defaultDate: this.watchDate,
// altInput: true,
// allowInput: false,
// altFormat: 'F j, Y',
// dateFormat: 'Y-m-d',
// });
} }
onConfirm(): void { onConfirm(): void {
@@ -1,4 +1,4 @@
export interface EpisodeSeenDto { export interface EpisodeSeenCreateDto {
id: number; id: number;
entryId: number; entryId: number;
@@ -1,9 +1,13 @@
import { Episode } from "./episode.models";
export interface EpisodeSeen { export interface EpisodeSeen {
id: number; id: number;
entry_id: number; entry_id: number;
episode_id: number; episode_id: number;
episode: Episode;
date_seen: Date; date_seen: Date;
seen_with: string; seen_with: string;
@@ -1,4 +1,5 @@
import { EpisodeSeen } from "./episode-seen.model"; import { EpisodeSeen } from "./episode-seen.model";
import { Season } from "./season.model";
export interface Episode { export interface Episode {
id: number; id: number;
@@ -7,6 +8,7 @@ export interface Episode {
imdb_id: string; imdb_id: string;
season_id: number; season_id: number;
season: Season;
episodeSeen: EpisodeSeen[]; episodeSeen: EpisodeSeen[];
@@ -0,0 +1,19 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'betterMinutesFormat',
})
export class BetterMinutesFormatPipe implements PipeTransform {
transform(value: number | String): string {
const minutes = Number.parseInt(value.toString()) || 0;
if (minutes == 0) return `0m`;
if (minutes < 60) return `${minutes}m`;
const hours = Math.floor(minutes / 60);
const remainingMinutes = minutes % 60;
if (remainingMinutes == 0) return `${hours}h`;
return `${hours}h${remainingMinutes}m`;
}
}
+3
View File
@@ -22,6 +22,7 @@ import { ToastrModule } from 'ngx-toastr';
import { StopScrollDirective } from './directives/stop-scroll.directive'; import { StopScrollDirective } from './directives/stop-scroll.directive';
import { ContextMenuTriggerDirective } from './directives/context-menu-trigger.directive'; import { ContextMenuTriggerDirective } from './directives/context-menu-trigger.directive';
import { ContextMenuComponent } from './components/context-menu/context-menu.component'; import { ContextMenuComponent } from './components/context-menu/context-menu.component';
import { BetterMinutesFormatPipe } from './pipes/minutes-format/bettter-minutes-format.pipe';
@NgModule({ @NgModule({
imports: [ imports: [
@@ -38,6 +39,7 @@ import { ContextMenuComponent } from './components/context-menu/context-menu.com
DateFormatPipe, DateFormatPipe,
FloatFormatPipe, FloatFormatPipe,
MinutesFormatPipe, MinutesFormatPipe,
BetterMinutesFormatPipe,
// * directives // * directives
StopScrollDirective, StopScrollDirective,
@@ -60,6 +62,7 @@ import { ContextMenuComponent } from './components/context-menu/context-menu.com
DateFormatPipe, DateFormatPipe,
FloatFormatPipe, FloatFormatPipe,
MinutesFormatPipe, MinutesFormatPipe,
BetterMinutesFormatPipe,
// * directives // * directives
StopScrollDirective, StopScrollDirective,