Skip to content
Extraits de code Groupes Projets
Valider aaaf4dc7 rédigé par Brieuc Dubois's avatar Brieuc Dubois
Parcourir les fichiers

frontend: remaining times

parent f2964c30
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
class:rounded-tr-xl={!isSender} class:rounded-tr-xl={!isSender}
> >
<div class="font-bold mb-1 capitalize"> <div class="font-bold mb-1 capitalize">
{message.user.email} {message.user.nickname}
</div> </div>
<div class="max-w-3xl">{message.content}</div> <div class="max-w-3xl">{message.content}</div>
<div class="text-right text-gray-500"> <div class="text-right text-gray-500">
......
...@@ -218,6 +218,11 @@ export default class Session { ...@@ -218,6 +218,11 @@ export default class Session {
return true; return true;
} }
remainTime(): number {
const now = new Date();
return this._end_time.getTime() - now.getTime();
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
static parse(json: any): Session | null { static parse(json: any): Session | null {
if (json === null || json === undefined) { if (json === null || json === undefined) {
......
...@@ -83,3 +83,13 @@ export function displayTime(date: Date): string { ...@@ -83,3 +83,13 @@ export function displayTime(date: Date): string {
return hours + ':' + minutes; return hours + ':' + minutes;
} }
export function displayDuration(start: Date, end: Date): string {
const duration = end.getTime() - start.getTime();
const hours = Math.floor(duration / (1000 * 60 * 60));
const minutes = Math.floor((duration % (1000 * 60 * 60)) / (1000 * 60));
if (hours === 0) return minutes + 'm';
else return hours + 'h ' + minutes + 'm';
}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import Session, { sessions } from '$lib/types/session'; import Session, { sessions } from '$lib/types/session';
import { requireLogin } from '$lib/utils/login'; import { requireLogin } from '$lib/utils/login';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { displayDate } from '$lib/utils/date'; import { displayDate, displayDuration } from '$lib/utils/date';
import JWTSession from '$lib/stores/JWTSession'; import JWTSession from '$lib/stores/JWTSession';
import { Eye, EyeSlash, Icon, Trash, User } from 'svelte-hero-icons'; import { Eye, EyeSlash, Icon, Trash, User } from 'svelte-hero-icons';
import { _ } from '$lib/services/i18n'; import { _ } from '$lib/services/i18n';
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<thead class="bg-gray-200 uppercase text-sm"> <thead class="bg-gray-200 uppercase text-sm">
<tr> <tr>
<th class="py-2 px-6">#</th> <th class="py-2 px-6">#</th>
<th class="py-2 px-6">{$_('home.date')}</th> <th class="py-2 px-6">{$_('home.remainingDuration')}</th>
<th class="py-2 px-6">{$_('home.participants')}</th> <th class="py-2 px-6">{$_('home.participants')}</th>
{#if JWTSession.user()?.is_tutor} {#if JWTSession.user()?.is_tutor}
<th class="py-2 px-6">{$_('home.actions')}</th> <th class="py-2 px-6">{$_('home.actions')}</th>
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
> >
<td class="py-3 px-6" class:line-through={!session.is_active}>{session.id}</td> <td class="py-3 px-6" class:line-through={!session.is_active}>{session.id}</td>
<td class="py-3 px-6" class:line-through={!session.is_active} <td class="py-3 px-6" class:line-through={!session.is_active}
>{displayDate(session.start_time)}{displayDate(session.end_time)}</td >{displayDuration(new Date(), session.end_time)}</td
> >
<td class="py-3 px-6" class:line-through={!session.is_active}>{session.usersList()}</td> <td class="py-3 px-6" class:line-through={!session.is_active}>{session.usersList()}</td>
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
"add": "Add", "add": "Add",
"deleteSessionConfirm": "Are you sure you want to delete this session? This action cannot be undone.", "deleteSessionConfirm": "Are you sure you want to delete this session? This action cannot be undone.",
"createSession": "Create a new session", "createSession": "Create a new session",
"participantPlaceholder": "Please select" "participantPlaceholder": "Please select",
"remainingDuration": "Remaining duration"
}, },
"utils": { "utils": {
"month": { "month": {
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
"add": "Ajouter", "add": "Ajouter",
"deleteSessionConfirm": "Êtes-vous sûr de vouloir supprimer cette session ? Cette action est irréversible.", "deleteSessionConfirm": "Êtes-vous sûr de vouloir supprimer cette session ? Cette action est irréversible.",
"createSession": "Créer une nouvelle session", "createSession": "Créer une nouvelle session",
"participantPlaceholder": "Selectionnez" "participantPlaceholder": "Selectionnez",
"remainingDuration": "Durée restante"
}, },
"utils": { "utils": {
"month": { "month": {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter