good time
This commit is contained in:
parent
e76ef0b241
commit
95be931ec8
|
@ -101,7 +101,7 @@
|
||||||
{{ subjects[currentSubjectId].title }}
|
{{ subjects[currentSubjectId].title }}
|
||||||
</h1>
|
</h1>
|
||||||
<p>{{ subjects[currentSubjectId].duration }} min, par {{ subjects[currentSubjectId].author }}</p>
|
<p>{{ subjects[currentSubjectId].duration }} min, par {{ subjects[currentSubjectId].author }}</p>
|
||||||
<p>Reste: {{ countRemainingMinutes(subjects[currentSubjectId]) }} min</p>
|
<!-- <p>Reste: {{ countRemainingMinutes(subjects[currentSubjectId]) }} min</p>-->
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,9 +120,35 @@
|
||||||
<button class="btn btn-primary" (click)="updateProgressEveryPeriod()">
|
<button class="btn btn-primary" (click)="updateProgressEveryPeriod()">
|
||||||
up temps
|
up temps
|
||||||
</button>
|
</button>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<div class="timeseries">
|
||||||
|
topic duration:<br> {{subjects[currentSubjectId].duration}} min
|
||||||
|
topic start:<br>
|
||||||
|
{{subjects[currentSubjectId].startDate| date: 'HH:mm'}}
|
||||||
|
<br>
|
||||||
|
topic end:<br>
|
||||||
|
{{subjects[currentSubjectId].endDate| date: 'HH:mm'}}
|
||||||
|
<br>
|
||||||
|
temps passé:
|
||||||
|
{{round(subjects[currentSubjectId].spentSeconds)}}
|
||||||
|
<br>
|
||||||
|
secondes max:
|
||||||
|
{{
|
||||||
|
Math.floor(
|
||||||
|
getSecondsBetweenTwoDates(
|
||||||
|
null,
|
||||||
|
subjects[currentSubjectId].endDate
|
||||||
|
)
|
||||||
|
- subjects[currentSubjectId].spentSeconds
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>avancement: {{ getPercentProgressTimeForTopic(subjects[currentSubjectId]) }} %</p>
|
|
||||||
|
<!-- <p>avancement: {{ getPercentProgressTimeForTopic(subjects[currentSubjectId]) }} %</p>-->
|
||||||
</div>
|
</div>
|
||||||
<div class="stats">
|
<div class="stats">
|
||||||
<h2>
|
<h2>
|
||||||
|
|
|
@ -45,6 +45,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
statsExplication: string = ''
|
statsExplication: string = ''
|
||||||
|
|
||||||
hints: string = "";
|
hints: string = "";
|
||||||
|
Math:Math = Math
|
||||||
|
|
||||||
showDebug: boolean = true;
|
showDebug: boolean = true;
|
||||||
startDate: Date = new Date();
|
startDate: Date = new Date();
|
||||||
|
@ -52,7 +53,6 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
private topicChangeDate: Date = new Date();
|
private topicChangeDate: Date = new Date();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
updateTopicChangeDate(): void {
|
updateTopicChangeDate(): void {
|
||||||
const currentTime = new Date();
|
const currentTime = new Date();
|
||||||
const timeDifferenceInMilliseconds = this.topicChangeDate.getTime() - currentTime.getTime();
|
const timeDifferenceInMilliseconds = this.topicChangeDate.getTime() - currentTime.getTime();
|
||||||
|
@ -81,19 +81,20 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
topics.forEach((topic: string) => {
|
topics.forEach((topic: string) => {
|
||||||
let boom = topic.split('-')
|
let boom = topic.split('-')
|
||||||
if (boom[0]) {
|
if (boom[0]) {
|
||||||
accumulatedDuration += this.findMinutesDurationInDescription(topic) | 0
|
let duration = this.findMinutesDurationInDescription(topic) | 0
|
||||||
|
accumulatedDuration += duration
|
||||||
|
|
||||||
|
|
||||||
newTopics.push({
|
newTopics.push({
|
||||||
id: ii,
|
id: ii,
|
||||||
title: boom[0],
|
title: boom[0],
|
||||||
duration: 15,
|
duration: duration,
|
||||||
spentSeconds: 0,
|
spentSeconds: 0,
|
||||||
author: this.findAuthorInDescription(topic),
|
author: this.findAuthorInDescription(topic),
|
||||||
notes: '',
|
notes: '',
|
||||||
finished: false,
|
finished: false,
|
||||||
startDate: this.getStartDateAfterDuration(accumulatedDuration + ''),
|
startDate: this.getEndDateAfterDuration(accumulatedDuration, this.startDate),
|
||||||
endDate: this.getEndDateAfterDuration(accumulatedDuration + ''),
|
endDate: this.getEndDateAfterDuration(duration + accumulatedDuration, this.startDate),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
ii += 1;
|
ii += 1;
|
||||||
|
@ -110,11 +111,15 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
* @param {string} [minute='00'] - A string representation of the minute (00-59).
|
* @param {string} [minute='00'] - A string representation of the minute (00-59).
|
||||||
* @returns {Date} A new Date object set to the specified time.
|
* @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 [hour, minute] = hourInput.split(":");
|
||||||
let date = new Date();
|
let date = new Date();
|
||||||
|
if (!minute) {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
date.setHours(parseInt(hour));
|
date.setHours(parseInt(hour));
|
||||||
date.setMinutes(minuteInput ? parseInt(minuteInput) : parseInt(minute));
|
date.setMinutes(parseInt(minute));
|
||||||
|
console.log('hourInput', hourInput, date)
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,8 +142,8 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.parseTheListOfTopicsInPasteLand()
|
this.parseTheListOfTopicsInPasteLand()
|
||||||
|
|
||||||
this.startDate = this.makeDateFromHourToday(this.startTime + '');
|
this.startDate = this.makeDateFromHourToday(this.startTime);
|
||||||
this.endDate = this.makeDateFromHourToday(this.endTime + '');
|
this.endDate = this.makeDateFromHourToday(this.endTime);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -149,8 +154,8 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
nextSubject() {
|
nextSubject() {
|
||||||
this.updateTopicChangeDate()
|
this.updateTopicChangeDate()
|
||||||
if(this.currentSubjectId < this.subjects.length-1) {
|
if (this.currentSubjectId < this.subjects.length - 1) {
|
||||||
this.currentSubjectId++
|
this.currentSubjectId++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,11 +168,12 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getEndDateAfterDuration(accumulatedDuration: string) {
|
private getEndDateAfterDuration(minutes: number, startDate: Date) {
|
||||||
return this.makeDateFromHourToday(accumulatedDuration)
|
|
||||||
|
return new Date(startDate.getTime() + minutes * 60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getStartDateAfterDuration(accumulatedDuration: string) {
|
getStartDateAfterDuration(accumulatedDuration: string) {
|
||||||
return this.makeDateFromHourToday(accumulatedDuration)
|
return this.makeDateFromHourToday(accumulatedDuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,6 +189,8 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
getPercentProgressTimeForTopic(topic: Topic) {
|
getPercentProgressTimeForTopic(topic: Topic) {
|
||||||
let now = new Date();
|
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);
|
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)}
|
this.statsExplication = `Temps passé: ${this.round(totalSeconds)}
|
||||||
Moyenne par sujet: ${this.round(averageSeconds)}
|
Moyenne par sujet: ${this.round(averageSeconds)}
|
||||||
Sujet le plus long: ${longestTopic.title.replace('*','')} (${this.round(longestSeconds)} )
|
Sujet le plus long: ${longestTopic.title.replace('*', '')} (${this.round(longestSeconds)} )
|
||||||
Sujet le plus court : ${shortestTopic.title.replace('*','')} (${this.round(shortestSeconds)})`;
|
Sujet le plus court : ${shortestTopic.title.replace('*', '')} (${this.round(shortestSeconds)})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -286,38 +294,38 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
if (this.animator) {
|
if (this.animator) {
|
||||||
compteRendu += `Animation: ${this.animator}.\n`;
|
compteRendu += `Animation: ${this.animator}.\n`;
|
||||||
}
|
}
|
||||||
compteRendu += `Statistiques:\n
|
compteRendu += `Statistiques:\n
|
||||||
${this.statsExplication}.`;
|
${this.statsExplication}.`;
|
||||||
for (const topic of this.subjects) {
|
for (const topic of this.subjects) {
|
||||||
compteRendu += `* ${topic.title}-`;
|
compteRendu += `* ${topic.title}-`;
|
||||||
compteRendu += ` ${topic.duration} min`;
|
compteRendu += ` ${topic.duration} min`;
|
||||||
compteRendu += ` (${topic.author})\n`;
|
compteRendu += ` (${topic.author})\n`;
|
||||||
compteRendu += ` ${topic.notes}\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
|
this.compteRendu = compteRendu
|
||||||
return compteRendu
|
return compteRendu
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns each present person for each line with a dash at the beggining if missing
|
* returns each present person for each line with a dash at the beggining if missing
|
||||||
*/
|
*/
|
||||||
formatPresentLines(){
|
formatPresentLines() {
|
||||||
let lines = ''
|
let lines = ''
|
||||||
if (this.presents) {
|
if (this.presents) {
|
||||||
lines += this.presents.split('\n').map(line => {
|
lines += this.presents.split('\n').map(line => {
|
||||||
if(!line.length){
|
if (!line.length) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if (!line.startsWith('- ')) {
|
if (!line.startsWith('- ')) {
|
||||||
return `- ${line}`;
|
return `- ${line}`;
|
||||||
}
|
}
|
||||||
return line;
|
return line;
|
||||||
}).join('\n') + '\n'
|
}).join('\n') + '\n'
|
||||||
}
|
}
|
||||||
return lines.trim();
|
return lines.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,7 +355,14 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
lien.click();
|
lien.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
getMinutesBetweenTwoDates(date1: Date, date2: Date) {
|
getMinutesBetweenTwoDates(date1: Date = new Date(), date2: Date) {
|
||||||
return Math.floor((date2.getTime() - date1.getTime()) / 60000);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue