mirror of
https://github.com/cdloh/obsidian-cron.git
synced 2026-07-22 07:40:30 +00:00
parent
e548b24a72
commit
e505695003
1 changed files with 39 additions and 38 deletions
|
|
@ -12,10 +12,10 @@ export default class CronSettingTab extends PluginSettingTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
display(): void {
|
display(): void {
|
||||||
const {containerEl} = this;
|
const { containerEl } = this;
|
||||||
|
|
||||||
containerEl.empty();
|
containerEl.empty();
|
||||||
containerEl.createEl('h2', {text: 'Settings for Cron.'});
|
containerEl.createEl('h2', { text: 'Settings for Cron.' });
|
||||||
|
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('Cron Interval')
|
.setName('Cron Interval')
|
||||||
|
|
@ -23,7 +23,7 @@ export default class CronSettingTab extends PluginSettingTab {
|
||||||
.addText(text => text
|
.addText(text => text
|
||||||
.setValue(this.plugin.settings.cronInterval.toString())
|
.setValue(this.plugin.settings.cronInterval.toString())
|
||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
if(value == "") {return}
|
if (value == "") { return }
|
||||||
this.plugin.settings.cronInterval = parseInt(value);
|
this.plugin.settings.cronInterval = parseInt(value);
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
this.plugin.loadInterval();
|
this.plugin.loadInterval();
|
||||||
|
|
@ -69,8 +69,8 @@ export default class CronSettingTab extends PluginSettingTab {
|
||||||
desc.createEl("br"),
|
desc.createEl("br"),
|
||||||
"Cron Frequency is a cron schedule expression. Use ",
|
"Cron Frequency is a cron schedule expression. Use ",
|
||||||
desc.createEl("a", {
|
desc.createEl("a", {
|
||||||
href: "https://crontab.guru/",
|
href: "https://crontab.guru/",
|
||||||
text: "crontab guru",
|
text: "crontab guru",
|
||||||
}),
|
}),
|
||||||
" for help with creating cron schedule expressions."
|
" for help with creating cron schedule expressions."
|
||||||
);
|
);
|
||||||
|
|
@ -82,7 +82,7 @@ export default class CronSettingTab extends PluginSettingTab {
|
||||||
this.addCommandSearch()
|
this.addCommandSearch()
|
||||||
}
|
}
|
||||||
|
|
||||||
addCommandSearch (): void {
|
addCommandSearch(): void {
|
||||||
|
|
||||||
this.plugin.settings.crons.forEach((cronjob, index) => {
|
this.plugin.settings.crons.forEach((cronjob, index) => {
|
||||||
const jobSetting = new Setting(this.containerEl)
|
const jobSetting = new Setting(this.containerEl)
|
||||||
|
|
@ -97,17 +97,17 @@ export default class CronSettingTab extends PluginSettingTab {
|
||||||
.inputEl.addClass('cron-plugin-text-input')
|
.inputEl.addClass('cron-plugin-text-input')
|
||||||
)
|
)
|
||||||
.addSearch((cb) => {
|
.addSearch((cb) => {
|
||||||
new CommandSuggest(cb.inputEl);
|
new CommandSuggest(cb.inputEl);
|
||||||
cb.setPlaceholder("Command")
|
cb.setPlaceholder("Command")
|
||||||
.setValue(cronjob.job)
|
.setValue(cronjob.job)
|
||||||
.onChange(async (command) => {
|
.onChange(async (command) => {
|
||||||
if(!command) { return }
|
if (!command) { return }
|
||||||
|
|
||||||
this.plugin.settings.crons[index].job = command;
|
this.plugin.settings.crons[index].job = command;
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
this.plugin.loadCrons();
|
this.plugin.loadCrons();
|
||||||
})
|
})
|
||||||
.inputEl.addClass('cron-plugin-text-input')
|
.inputEl.addClass('cron-plugin-text-input')
|
||||||
})
|
})
|
||||||
.addText(text => text
|
.addText(text => text
|
||||||
.setPlaceholder("CronJob frequency")
|
.setPlaceholder("CronJob frequency")
|
||||||
|
|
@ -130,33 +130,34 @@ export default class CronSettingTab extends PluginSettingTab {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const jobLocked = this.plugin.settings.locks[cronjob.id] && this.plugin.settings.locks[cronjob.id].locked
|
const jobLocked = this.plugin.settings.locks[cronjob.id] && this.plugin.settings.locks[cronjob.id].locked
|
||||||
jobSetting.addExtraButton((button) => {
|
jobSetting.addExtraButton((button) => {
|
||||||
button.setIcon(jobLocked ? "lucide-lock" : "lucide-unlock")
|
button.setIcon(jobLocked ? "lucide-lock" : "lucide-unlock")
|
||||||
.setTooltip("Toggle job lock (clear lock if accidentally left locked)")
|
.setTooltip("Toggle job lock (clear lock if accidentally left locked)")
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
this.plugin.settings.locks[cronjob.id].locked = !jobLocked;
|
this.plugin.settings.locks[cronjob.id].locked = !jobLocked;
|
||||||
this.plugin.saveSettings();
|
this.plugin.saveSettings();
|
||||||
// refresh
|
// refresh
|
||||||
this.display()
|
this.display()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
jobSetting.addExtraButton((button) => {
|
jobSetting.addExtraButton((button) => {
|
||||||
button.setIcon(cronjob.settings.disableSyncCheck ? "paused" : "lucide-check-circle-2")
|
button.setIcon(cronjob.settings.disableSyncCheck ? "paused" : "lucide-check-circle-2")
|
||||||
.setTooltip("Toggle Sync check for this job. Presently: " + (cronjob.settings.disableSyncCheck ? "disabled" : "enabled"))
|
.setTooltip("Toggle Sync check for this job. Presently: " + (cronjob.settings.disableSyncCheck ? "disabled" : "enabled"))
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
this.plugin.settings.crons[index].settings.disableSyncCheck = !cronjob.settings.disableSyncCheck;
|
this.plugin.settings.crons[index].settings.disableSyncCheck = !cronjob.settings.disableSyncCheck;
|
||||||
this.plugin.saveSettings();
|
this.plugin.saveSettings();
|
||||||
// Force refresh
|
// Force refresh
|
||||||
this.display();
|
this.display();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.addExtraButton((button) => {
|
.addExtraButton((button) => {
|
||||||
button.setIcon("cross")
|
button.setIcon("cross")
|
||||||
.setTooltip("Delete Job")
|
.setTooltip("Delete Job")
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
this.plugin.settings.crons.splice(index, 1)
|
this.plugin.settings.crons.splice(index, 1)
|
||||||
|
delete this.plugin.jobs[cronjob.id]
|
||||||
delete this.plugin.settings.locks[cronjob.id]
|
delete this.plugin.settings.locks[cronjob.id]
|
||||||
this.plugin.saveSettings();
|
this.plugin.saveSettings();
|
||||||
// Force refresh
|
// Force refresh
|
||||||
|
|
@ -164,7 +165,7 @@ export default class CronSettingTab extends PluginSettingTab {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
jobSetting.controlEl.addClass("cron-plugin-job")
|
jobSetting.controlEl.addClass("cron-plugin-job")
|
||||||
});
|
});
|
||||||
|
|
||||||
new Setting(this.containerEl).addButton((cb) => {
|
new Setting(this.containerEl).addButton((cb) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue