diff --git a/ordre-du-jour/odj/src/app/app.component.html b/ordre-du-jour/odj/src/app/app.component.html
index 297b97af..195ec9a1 100644
--- a/ordre-du-jour/odj/src/app/app.component.html
+++ b/ordre-du-jour/odj/src/app/app.component.html
@@ -101,7 +101,7 @@
{{ subjects[currentSubjectId].title }}
{{ subjects[currentSubjectId].duration }} min, par {{ subjects[currentSubjectId].author }}
- Reste: {{ countRemainingMinutes(subjects[currentSubjectId]) }} min
+
@@ -120,9 +120,35 @@
+
+
+
+
+ topic duration:
{{subjects[currentSubjectId].duration}} min
+ topic start:
+ {{subjects[currentSubjectId].startDate| date: 'HH:mm'}}
+
+ topic end:
+ {{subjects[currentSubjectId].endDate| date: 'HH:mm'}}
+
+ temps passé:
+ {{round(subjects[currentSubjectId].spentSeconds)}}
+
+ secondes max:
+ {{
+ Math.floor(
+ getSecondsBetweenTwoDates(
+ null,
+ subjects[currentSubjectId].endDate
+ )
+ - subjects[currentSubjectId].spentSeconds
+ )
+ }}
+
- avancement: {{ getPercentProgressTimeForTopic(subjects[currentSubjectId]) }} %
+
+
diff --git a/ordre-du-jour/odj/src/app/app.component.ts b/ordre-du-jour/odj/src/app/app.component.ts
index 6c5affbc..9248c696 100644
--- a/ordre-du-jour/odj/src/app/app.component.ts
+++ b/ordre-du-jour/odj/src/app/app.component.ts
@@ -45,6 +45,7 @@ export class AppComponent implements OnInit, OnDestroy {
statsExplication: string = ''
hints: string = "";
+ Math:Math = Math
showDebug: boolean = true;
startDate: Date = new Date();
@@ -52,7 +53,6 @@ export class AppComponent implements OnInit, OnDestroy {
private topicChangeDate: Date = new Date();
-
updateTopicChangeDate(): void {
const currentTime = new Date();
const timeDifferenceInMilliseconds = this.topicChangeDate.getTime() - currentTime.getTime();
@@ -81,19 +81,20 @@ export class AppComponent implements OnInit, OnDestroy {
topics.forEach((topic: string) => {
let boom = topic.split('-')
if (boom[0]) {
- accumulatedDuration += this.findMinutesDurationInDescription(topic) | 0
+ let duration = this.findMinutesDurationInDescription(topic) | 0
+ accumulatedDuration += duration
newTopics.push({
id: ii,
title: boom[0],
- duration: 15,
+ duration: duration,
spentSeconds: 0,
author: this.findAuthorInDescription(topic),
notes: '',
finished: false,
- startDate: this.getStartDateAfterDuration(accumulatedDuration + ''),
- endDate: this.getEndDateAfterDuration(accumulatedDuration + ''),
+ startDate: this.getEndDateAfterDuration(accumulatedDuration, this.startDate),
+ endDate: this.getEndDateAfterDuration(duration + accumulatedDuration, this.startDate),
})
}
ii += 1;
@@ -110,11 +111,15 @@ export class AppComponent implements OnInit, OnDestroy {
* @param {string} [minute='00'] - A string representation of the minute (00-59).
* @returns {Date} A new Date object set to the specified time.
*/
- makeDateFromHourToday(hourInput: string, minuteInput: string = '00') {
+ makeDateFromHourToday(hourInput: string){
let [hour, minute] = hourInput.split(":");
let date = new Date();
+ if (!minute) {
+ return date;
+ }
date.setHours(parseInt(hour));
- date.setMinutes(minuteInput ? parseInt(minuteInput) : parseInt(minute));
+ date.setMinutes(parseInt(minute));
+ console.log('hourInput', hourInput, date)
return date;
}
@@ -137,8 +142,8 @@ export class AppComponent implements OnInit, OnDestroy {
ngOnInit() {
this.parseTheListOfTopicsInPasteLand()
- this.startDate = this.makeDateFromHourToday(this.startTime + '');
- this.endDate = this.makeDateFromHourToday(this.endTime + '');
+ this.startDate = this.makeDateFromHourToday(this.startTime);
+ this.endDate = this.makeDateFromHourToday(this.endTime);
}
@@ -149,8 +154,8 @@ export class AppComponent implements OnInit, OnDestroy {
nextSubject() {
this.updateTopicChangeDate()
- if(this.currentSubjectId < this.subjects.length-1) {
- this.currentSubjectId++
+ if (this.currentSubjectId < this.subjects.length - 1) {
+ this.currentSubjectId++
}
}
@@ -163,11 +168,12 @@ export class AppComponent implements OnInit, OnDestroy {
return 0;
}
- private getEndDateAfterDuration(accumulatedDuration: string) {
- return this.makeDateFromHourToday(accumulatedDuration)
+ private getEndDateAfterDuration(minutes: number, startDate: Date) {
+
+ return new Date(startDate.getTime() + minutes * 60000);
}
- private getStartDateAfterDuration(accumulatedDuration: string) {
+ getStartDateAfterDuration(accumulatedDuration: string) {
return this.makeDateFromHourToday(accumulatedDuration)
}
@@ -183,6 +189,8 @@ export class AppComponent implements OnInit, OnDestroy {
getPercentProgressTimeForTopic(topic: Topic) {
let now = new Date();
+ console.log('topic démarré', topic.startDate.getTime())
+ console.log('topic va se finir', topic.endDate.getTime(), topic.endDate.getTime() - topic.startDate.getTime())
return Math.floor((now.getTime() - topic.startDate.getTime()) / (topic.endDate.getTime() - topic.startDate.getTime()) * 100);
}
@@ -252,8 +260,8 @@ export class AppComponent implements OnInit, OnDestroy {
this.statsExplication = `Temps passé: ${this.round(totalSeconds)}
Moyenne par sujet: ${this.round(averageSeconds)}
- Sujet le plus long: ${longestTopic.title.replace('*','')} (${this.round(longestSeconds)} )
- Sujet le plus court : ${shortestTopic.title.replace('*','')} (${this.round(shortestSeconds)})`;
+ Sujet le plus long: ${longestTopic.title.replace('*', '')} (${this.round(longestSeconds)} )
+ Sujet le plus court : ${shortestTopic.title.replace('*', '')} (${this.round(shortestSeconds)})`;
}
@@ -286,38 +294,38 @@ export class AppComponent implements OnInit, OnDestroy {
if (this.animator) {
compteRendu += `Animation: ${this.animator}.\n`;
}
- compteRendu += `Statistiques:\n
+ compteRendu += `Statistiques:\n
${this.statsExplication}.`;
for (const topic of this.subjects) {
compteRendu += `* ${topic.title}-`;
compteRendu += ` ${topic.duration} min`;
compteRendu += ` (${topic.author})\n`;
compteRendu += ` ${topic.notes}\n`;
- if(topic.spentSeconds){
+ if (topic.spentSeconds) {
- compteRendu += `Temps écoulé : ${this.round(topic.spentSeconds)}\n\n`;
+ compteRendu += `Temps écoulé : ${this.round(topic.spentSeconds)}\n\n`;
}
}
this.compteRendu = compteRendu
return compteRendu
}
- /**
+ /**
* returns each present person for each line with a dash at the beggining if missing
*/
- formatPresentLines(){
+ formatPresentLines() {
let lines = ''
- if (this.presents) {
- lines += this.presents.split('\n').map(line => {
- if(!line.length){
- return '';
- }
- if (!line.startsWith('- ')) {
- return `- ${line}`;
- }
- return line;
- }).join('\n') + '\n'
- }
+ if (this.presents) {
+ lines += this.presents.split('\n').map(line => {
+ if (!line.length) {
+ return '';
+ }
+ if (!line.startsWith('- ')) {
+ return `- ${line}`;
+ }
+ return line;
+ }).join('\n') + '\n'
+ }
return lines.trim();
}
@@ -347,7 +355,14 @@ export class AppComponent implements OnInit, OnDestroy {
lien.click();
}
- getMinutesBetweenTwoDates(date1: Date, date2: Date) {
+ getMinutesBetweenTwoDates(date1: Date = new Date(), date2: Date) {
return Math.floor((date2.getTime() - date1.getTime()) / 60000);
}
+
+ getSecondsBetweenTwoDates(date1: Date | null, date2: Date) {
+ if (!date1) {
+ date1 = new Date()
+ }
+ return Math.floor((date2.getTime() - date1.getTime()) / 1000);
+ }
}