Compare commits

...

2 Commits

Author SHA1 Message Date
Cedric Verstraeten
068063695e time table might be empty 2023-06-07 20:24:09 +02:00
Cedric Verstraeten
b1722844f3 fix config overriding 2023-06-07 20:19:50 +02:00
2 changed files with 15 additions and 9 deletions

View File

@@ -86,14 +86,18 @@ func OpenConfig(configuration *models.Configuration) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
var globalConfig models.Config
collection.FindOne(ctx, bson.M{
"type": "global",
}).Decode(&configuration.GlobalConfig)
}).Decode(&globalConfig)
configuration.GlobalConfig = globalConfig
var customConfig models.Config
collection.FindOne(ctx, bson.M{
"type": "config",
"name": os.Getenv("DEPLOYMENT_NAME"),
}).Decode(&configuration.CustomConfig)
}).Decode(&customConfig)
configuration.CustomConfig = customConfig
// We will merge both configs in a single config file.
// Read again from database but this store overwrite the same object.

View File

@@ -224,13 +224,15 @@ class Settings extends React.Component {
calculateTimetable(timetable) {
this.timetable = timetable;
for (let i = 0; i < timetable.length; i += 1) {
const time = timetable[i];
const { start1, start2, end1, end2 } = time;
this.timetable[i].start1Full = this.convertSecondsToHourMinute(start1);
this.timetable[i].start2Full = this.convertSecondsToHourMinute(start2);
this.timetable[i].end1Full = this.convertSecondsToHourMinute(end1);
this.timetable[i].end2Full = this.convertSecondsToHourMinute(end2);
if (this.timetable) {
for (let i = 0; i < timetable.length; i += 1) {
const time = timetable[i];
const { start1, start2, end1, end2 } = time;
this.timetable[i].start1Full = this.convertSecondsToHourMinute(start1);
this.timetable[i].start2Full = this.convertSecondsToHourMinute(start2);
this.timetable[i].end1Full = this.convertSecondsToHourMinute(end1);
this.timetable[i].end2Full = this.convertSecondsToHourMinute(end2);
}
}
}