glad-web 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/web.js +6 -8
- package/lib/schedule/job-store.js +19 -2
- package/package.json +1 -1
package/lib/commands/web.js
CHANGED
|
@@ -385,11 +385,11 @@ async function webCommand(options) {
|
|
|
385
385
|
});
|
|
386
386
|
|
|
387
387
|
// Frontend routes
|
|
388
|
-
const
|
|
389
|
-
const
|
|
388
|
+
const assetsDir = path.resolve(__dirname, '../../assets');
|
|
389
|
+
const webDir = path.join(__dirname, '../web');
|
|
390
390
|
|
|
391
391
|
const sendLogo = (req, res) => {
|
|
392
|
-
res.sendFile(
|
|
392
|
+
res.sendFile('logo.svg', { root: assetsDir }, error => {
|
|
393
393
|
if (error && !res.headersSent) res.status(404).send('Not found');
|
|
394
394
|
});
|
|
395
395
|
};
|
|
@@ -405,11 +405,9 @@ async function webCommand(options) {
|
|
|
405
405
|
});
|
|
406
406
|
|
|
407
407
|
app.get(['/gitgraph.js', /.*\/gitgraph\.js$/], (req, res) => {
|
|
408
|
-
|
|
409
|
-
res.
|
|
410
|
-
}
|
|
411
|
-
res.status(404).send('Not found');
|
|
412
|
-
}
|
|
408
|
+
res.sendFile('gitgraph.js', { root: webDir }, error => {
|
|
409
|
+
if (error && !res.headersSent) res.status(404).send('Not found');
|
|
410
|
+
});
|
|
413
411
|
});
|
|
414
412
|
|
|
415
413
|
app.get(['/logo.svg', /.*\/logo\.svg$/], sendLogo);
|
|
@@ -52,6 +52,7 @@ function normalizeJob(input, existing = null, options = {}) {
|
|
|
52
52
|
const now = Date.now();
|
|
53
53
|
const schedule = input.schedule || {};
|
|
54
54
|
const target = input.target || {};
|
|
55
|
+
const hasStoredNextRunAt = existing && typeof existing.nextRunAt === 'number';
|
|
55
56
|
const job = {
|
|
56
57
|
id: existing?.id || input.id || uuidv4(),
|
|
57
58
|
name: String(input.name || existing?.name || 'Scheduled Task').trim() || 'Scheduled Task',
|
|
@@ -73,7 +74,13 @@ function normalizeJob(input, existing = null, options = {}) {
|
|
|
73
74
|
lastSessionId: existing?.lastSessionId || input.lastSessionId || null,
|
|
74
75
|
running: Boolean(existing?.running || false)
|
|
75
76
|
};
|
|
76
|
-
|
|
77
|
+
|
|
78
|
+
if (options.recomputeNextRunAt || !hasStoredNextRunAt) {
|
|
79
|
+
job.nextRunAt = job.enabled ? computeNextRunAt(job.schedule, now) : null;
|
|
80
|
+
} else {
|
|
81
|
+
job.nextRunAt = existing.nextRunAt;
|
|
82
|
+
}
|
|
83
|
+
|
|
77
84
|
return job;
|
|
78
85
|
}
|
|
79
86
|
|
|
@@ -102,7 +109,17 @@ class JobStore {
|
|
|
102
109
|
const jobs = this.list();
|
|
103
110
|
const index = jobs.findIndex(job => job.id === id);
|
|
104
111
|
if (index === -1) return null;
|
|
105
|
-
|
|
112
|
+
const existing = jobs[index];
|
|
113
|
+
const nextSchedule = {
|
|
114
|
+
time: String(input.schedule?.time || existing.schedule?.time || '09:00'),
|
|
115
|
+
weekdays: normalizeWeekdays(input.schedule?.weekdays ?? existing.schedule?.weekdays ?? [1, 2, 3, 4, 5])
|
|
116
|
+
};
|
|
117
|
+
const scheduleChanged = JSON.stringify(nextSchedule) !== JSON.stringify(existing.schedule);
|
|
118
|
+
const enabledChanged = Boolean(input.enabled ?? existing.enabled ?? true) !== Boolean(existing.enabled);
|
|
119
|
+
jobs[index] = normalizeJob(input, existing, {
|
|
120
|
+
touch: true,
|
|
121
|
+
recomputeNextRunAt: scheduleChanged || enabledChanged
|
|
122
|
+
});
|
|
106
123
|
this.saveAll(jobs);
|
|
107
124
|
return jobs[index];
|
|
108
125
|
}
|