feat(admin): provide reset cron button

This commit is contained in:
SabreCat
2022-08-30 15:35:50 -05:00
parent bc5813fd10
commit 09d6dae75c
2 changed files with 17 additions and 0 deletions

View File

@@ -36,6 +36,12 @@
("auth.timestamps.loggedin" and "lastCron" dates are different). ("auth.timestamps.loggedin" and "lastCron" dates are different).
</span> </span>
</div> </div>
<button
class="btn btn-primary"
@click="resetCron()"
>
Reset Cron to Yesterday
</button>
<div class="subsection-start"> <div class="subsection-start">
Time zone: Time zone:
<strong>{{ hero.preferences.timezoneOffset | formatTimeZone }}</strong> <strong>{{ hero.preferences.timezoneOffset | formatTimeZone }}</strong>
@@ -218,6 +224,10 @@ export default {
await this.saveHero({ hero: this.hero, msg: 'API Token' }); await this.saveHero({ hero: this.hero, msg: 'API Token' });
this.tokenModified = true; this.tokenModified = true;
}, },
resetCron () {
this.hero.resetCron = true;
this.saveHero({ hero: this.hero, msg: 'Last Cron', clearData: true });
},
}, },
}; };
</script> </script>

View File

@@ -331,6 +331,13 @@ api.updateHero = {
hero.apiToken = common.uuid(); hero.apiToken = common.uuid();
} }
if (updateData.resetCron) {
// Set last cron to yesterday. Quick approach so we don't need moment() for one line
const yesterday = new Date(new Date().setDate(new Date().getDate() - 1));
hero.lastCron = yesterday;
hero.auth.timestamps.loggedin = yesterday; // so admin panel doesn't gripe about mismatch
}
const savedHero = await hero.save(); const savedHero = await hero.save();
const heroJSON = savedHero.toJSON(); const heroJSON = savedHero.toJSON();
heroJSON.secret = savedHero.getSecretData(); heroJSON.secret = savedHero.getSecretData();