2024-01-20 17:53:21 +01:00
|
|
|
import {Component, OnDestroy, OnInit} from '@angular/core';
|
2023-12-04 11:22:35 +01:00
|
|
|
import {CommonModule} from '@angular/common';
|
|
|
|
import {RouterOutlet} from '@angular/router';
|
2023-12-04 11:01:56 +01:00
|
|
|
import {FormsModule} from "@angular/forms";
|
|
|
|
|
2023-12-04 11:22:35 +01:00
|
|
|
|
2024-01-20 17:53:21 +01:00
|
|
|
interface Topic {
|
|
|
|
id: number, // numéro du sujet
|
2023-12-04 11:01:56 +01:00
|
|
|
title: string, // titre du sujet à aborder
|
|
|
|
duration: number, // nombre de minutes du sujet
|
2024-01-20 17:53:21 +01:00
|
|
|
author: string,// auteur du sujet qui anime la discussion
|
|
|
|
startDate: Date, // date de début du sujet
|
|
|
|
endDate: Date,// date de fin du sujet
|
|
|
|
finished: boolean,// si le sujet est terminé
|
|
|
|
spentSeconds: number, // nombre de secondes passées au sujet
|
2023-12-04 11:01:56 +01:00
|
|
|
}
|
2023-12-04 11:22:35 +01:00
|
|
|
|
2023-12-04 11:01:56 +01:00
|
|
|
@Component({
|
|
|
|
selector: 'app-root',
|
|
|
|
standalone: true,
|
|
|
|
imports: [CommonModule, RouterOutlet, FormsModule],
|
|
|
|
templateUrl: './app.component.html',
|
2023-12-04 11:22:35 +01:00
|
|
|
styleUrl: './app.component.scss',
|
2023-12-04 11:01:56 +01:00
|
|
|
})
|
2024-01-20 17:53:21 +01:00
|
|
|
export class AppComponent implements OnInit, OnDestroy {
|
2023-12-04 11:01:56 +01:00
|
|
|
title = 'odj';
|
2024-01-20 17:53:21 +01:00
|
|
|
subjects: Array<Topic> = [];
|
|
|
|
currentSubjectId = 0;
|
|
|
|
// startTime: string = "20:30";
|
|
|
|
startTime: string = "17:00";
|
2023-12-04 11:01:56 +01:00
|
|
|
endTime: string = "22:00";
|
|
|
|
pasteLand: string = "* Présentation du suivi sur Nextcloud - 5min (tykayn)\n" +
|
|
|
|
"* Réduction de bus factor - 5min (tykayn)\n" +
|
|
|
|
"* Réunion avec Wikimedia France - 5min (tykayn)\n" +
|
2024-01-20 17:53:21 +01:00
|
|
|
"";
|
2023-12-04 11:01:56 +01:00
|
|
|
|
|
|
|
hints: string = " - le pad des notes de réunion https://annuel.framapad.org/p/N_IDAQXYLHswlpU2s3oE\n" +
|
|
|
|
"\t - canal spécial pour le SOTM fr sur telegram https://t.me/SOTM2023-Marseille\n" +
|
|
|
|
"\t - canal général sur telegram https://t.me/osm-fr\n" +
|
|
|
|
"\t - espace de canaux sur matrix https://app.element.io/#/room/#osmfr:matrix.org\n" +
|
|
|
|
"\t - le forum section CA https://forum.openstreetmap.fr/c/openstreetmap-france/ca/53\n" +
|
|
|
|
"\t - le github osm-france https://github.com/osm-fr/ \n" +
|
|
|
|
"\t - les réunions mensuelles du CA https://osmvideo.cloud68.co/user/fre-aux-yuh \n" +
|
|
|
|
"\t - le nextcloud osm https://nextcloud.openstreetmap.fr\n" +
|
|
|
|
"\t - les status des services en ligne https://stats.uptimerobot.com/mQX5Vi5YW2";
|
2024-01-20 17:53:21 +01:00
|
|
|
|
2023-12-04 11:01:56 +01:00
|
|
|
resteTopicMinutes: any = 10;
|
2023-12-04 11:22:35 +01:00
|
|
|
showDebug: boolean = false;
|
2024-01-20 17:53:21 +01:00
|
|
|
private startDate: Date = new Date();
|
|
|
|
private endDate: Date = new Date();
|
|
|
|
private topicChangeDate: Date = new Date();
|
|
|
|
|
|
|
|
|
|
|
|
updateTopicChangeDate(): void {
|
|
|
|
const currentTime = new Date();
|
|
|
|
const timeDifferenceInMilliseconds = this.topicChangeDate.getTime() - currentTime.getTime();
|
|
|
|
const timeDifferenceInSeconds = Math.abs(timeDifferenceInMilliseconds / 1000);
|
|
|
|
|
|
|
|
console.log(`Spent ${timeDifferenceInSeconds} seconds`);
|
|
|
|
this.subjects[this.currentSubjectId].spentSeconds += timeDifferenceInSeconds;
|
|
|
|
this.topicChangeDate = currentTime;
|
|
|
|
}
|
2023-12-04 11:01:56 +01:00
|
|
|
|
2023-12-04 11:22:35 +01:00
|
|
|
parseTheListOfTopicsInPasteLand() {
|
2023-12-04 11:01:56 +01:00
|
|
|
|
2023-12-04 11:22:35 +01:00
|
|
|
let newTopics: any = []
|
2023-12-04 11:01:56 +01:00
|
|
|
let topics: any = this.pasteLand.split('*')
|
2024-01-20 17:53:21 +01:00
|
|
|
let accumulatedDuration: number = 0;
|
|
|
|
let ii = 0;
|
2023-12-04 11:22:35 +01:00
|
|
|
|
2024-01-20 17:53:21 +01:00
|
|
|
topics.forEach((topic: string) => {
|
|
|
|
let boom = topic.split('-')
|
2023-12-04 11:22:35 +01:00
|
|
|
if (boom[0]) {
|
2024-01-20 17:53:21 +01:00
|
|
|
accumulatedDuration += this.findMinutesDurationInDescription(topic) | 0
|
|
|
|
|
2023-12-04 11:22:35 +01:00
|
|
|
newTopics.push({
|
2024-01-20 17:53:21 +01:00
|
|
|
id: ii,
|
2023-12-04 11:22:35 +01:00
|
|
|
title: boom[0],
|
|
|
|
duration: 15,
|
2024-01-20 17:53:21 +01:00
|
|
|
author: '',
|
|
|
|
startDate: this.getStartDateAfterDuration(accumulatedDuration + ''),
|
|
|
|
endDate: this.getEndDateAfterDuration(accumulatedDuration + ''),
|
2023-12-04 11:22:35 +01:00
|
|
|
})
|
|
|
|
}
|
2024-01-20 17:53:21 +01:00
|
|
|
ii += 1;
|
2023-12-04 11:01:56 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
this.subjects = newTopics
|
|
|
|
}
|
2023-12-04 11:22:35 +01:00
|
|
|
|
2024-01-20 17:53:21 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new Date object set to the specified time in the current time zone.
|
|
|
|
*
|
|
|
|
* @param {string} hour - A string representation of the hour, in 24-hour format.
|
|
|
|
* @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') {
|
|
|
|
let [hour, minute] = hourInput.split(":");
|
|
|
|
let date = new Date();
|
|
|
|
date.setHours(parseInt(hour));
|
|
|
|
date.setMinutes(minuteInput ? parseInt(minuteInput) : parseInt(minute));
|
|
|
|
return date;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes the remaining time for a given topic, based on the current time and the start and end times of the topic.
|
|
|
|
*
|
|
|
|
* @param {Topic} topic - The topic for which to compute the remaining time.
|
|
|
|
*/
|
|
|
|
computeResteTopicMinutes(topic: Topic): void {
|
|
|
|
let currentSubjectDuration = topic.duration; // The duration of the current subject, in minutes
|
|
|
|
let currentSubjectStartTime = new Date(this.startTime); // The start time of the current subject
|
|
|
|
let currentSubjectEndTime = new Date(currentSubjectStartTime.getTime() + currentSubjectDuration * 60000); // The end time of the current subject
|
|
|
|
|
|
|
|
let remainingTime = currentSubjectEndTime.getTime() - new Date().getTime(); // The remaining time, in milliseconds
|
|
|
|
this.resteTopicMinutes = Math.floor(remainingTime / 60000); // The remaining time, in minutes
|
|
|
|
}
|
|
|
|
|
|
|
|
interval: any;
|
|
|
|
|
2023-12-04 11:22:35 +01:00
|
|
|
ngOnInit() {
|
2023-12-04 11:01:56 +01:00
|
|
|
this.parseTheListOfTopicsInPasteLand()
|
2024-01-20 17:53:21 +01:00
|
|
|
|
|
|
|
this.startDate = this.makeDateFromHourToday(this.startTime + '');
|
|
|
|
this.endDate = this.makeDateFromHourToday(this.endTime + '');
|
|
|
|
|
|
|
|
// this.interval = setInterval(() => {
|
|
|
|
this.updateProgressEveryPeriod();
|
|
|
|
// }, 1 * 1000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy(): void {
|
|
|
|
clearInterval(this.interval);
|
2023-12-04 11:01:56 +01:00
|
|
|
}
|
2023-12-04 11:22:35 +01:00
|
|
|
|
|
|
|
nextSubject() {
|
2024-01-20 17:53:21 +01:00
|
|
|
this.updateTopicChangeDate()
|
2023-12-04 11:22:35 +01:00
|
|
|
this.currentSubjectId++
|
|
|
|
}
|
2024-01-20 17:53:21 +01:00
|
|
|
|
|
|
|
findMinutesDurationInDescription(topic: string): number {
|
|
|
|
let durationRegex = /-\s(\d+)min/g;
|
|
|
|
let matches = durationRegex.exec(topic);
|
|
|
|
if (matches) {
|
|
|
|
return parseInt(matches[1]);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
private getEndDateAfterDuration(accumulatedDuration: string) {
|
|
|
|
return this.makeDateFromHourToday(accumulatedDuration)
|
|
|
|
}
|
|
|
|
|
|
|
|
private getStartDateAfterDuration(accumulatedDuration: string) {
|
|
|
|
return this.makeDateFromHourToday(accumulatedDuration)
|
|
|
|
}
|
|
|
|
|
|
|
|
isTopicRunning(topic: Topic) {
|
|
|
|
let now = new Date();
|
|
|
|
return now >= topic.startDate && now <= topic.endDate && !topic.finished;
|
|
|
|
}
|
|
|
|
|
|
|
|
countRemainingMinutes(topic: Topic) {
|
|
|
|
let now = new Date();
|
|
|
|
return Math.floor((topic.endDate.getTime() - now.getTime()) / 60000);
|
|
|
|
}
|
|
|
|
|
|
|
|
getPercentProgressTimeForTopic(topic: Topic) {
|
|
|
|
let now = new Date();
|
|
|
|
return Math.floor((now.getTime() - topic.startDate.getTime()) / (topic.endDate.getTime() - topic.startDate.getTime()) * 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
finishTopic(currentSubjectId: number) {
|
|
|
|
this.subjects[currentSubjectId].finished = true
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* only had one second to the current topic
|
|
|
|
*/
|
|
|
|
updateProgressEveryPeriod() {
|
|
|
|
this.subjects[this.currentSubjectId].spentSeconds += 1;
|
|
|
|
console.log('ajout au topic', this.currentSubjectId)
|
|
|
|
}
|
|
|
|
|
|
|
|
convertTextToHTMLLinks(text: string): string {
|
|
|
|
let urlRegex = /(https?:\/\/[^\s<]+[^<.,:;\"\'\]\s])(?!["\])\s])/g;
|
|
|
|
let matches = urlRegex.exec(text);
|
|
|
|
while (matches) {
|
|
|
|
let url = matches[1];
|
|
|
|
let linkText = url;
|
|
|
|
if (url.length > 30) {
|
|
|
|
linkText = url.substring(0, 30) + "...";
|
|
|
|
}
|
|
|
|
text = text.replace(url, `<a href="${url}">${linkText}</a>`);
|
|
|
|
matches = urlRegex.exec(text);
|
|
|
|
}
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
previousSubject() {
|
|
|
|
this.updateTopicChangeDate()
|
|
|
|
this.currentSubjectId < 1 ? this.currentSubjectId = 0 : this.currentSubjectId -= 1;
|
|
|
|
}
|
2023-12-04 11:01:56 +01:00
|
|
|
}
|