mirror of
https://github.com/cdloh/obsidian-cron.git
synced 2026-07-22 07:40:30 +00:00
Compare commits
No commits in common. "master" and "1.0.0" have entirely different histories.
7 changed files with 43 additions and 83 deletions
21
LICENSE.md
21
LICENSE.md
|
|
@ -1,21 +0,0 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023 Callum Loh
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "cron",
|
||||
"name": "Cron",
|
||||
"version": "1.1.2",
|
||||
"version": "1.0.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Simple CRON / schedular plugin to regularly run user scripts or Obsidian commands.",
|
||||
"author": "Callum Loh",
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "obsidian-cron-plugin",
|
||||
"version": "1.1.2",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "obsidian-cron-plugin",
|
||||
"version": "1.1.2",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.11.6",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "obsidian-cron-plugin",
|
||||
"version": "1.1.2",
|
||||
"version": "1.0.0",
|
||||
"description": "Simple CRON / Schedular plugin to regularly run user scripts or Obsidian commands for Obsidian (https://obsidian.md)",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import CronAPI from './api';
|
|||
export interface CronSettings {
|
||||
cronInterval: number;
|
||||
runOnStartup: boolean
|
||||
enableMobile: boolean
|
||||
watchObsidianSync: boolean
|
||||
crons: Array<CRONJob>,
|
||||
locks: { [key: string]: CronLock }
|
||||
|
|
@ -26,7 +25,6 @@ export interface CRONJob {
|
|||
const DEFAULT_SETTINGS: CronSettings = {
|
||||
cronInterval: 15,
|
||||
runOnStartup: true,
|
||||
enableMobile: true,
|
||||
watchObsidianSync: true,
|
||||
crons: [],
|
||||
locks: {}
|
||||
|
|
@ -57,7 +55,6 @@ export default class Cron extends Plugin {
|
|||
this.api = CronAPI.get(this)
|
||||
this.app.workspace.onLayoutReady(() => {
|
||||
if(this.settings.runOnStartup) {
|
||||
if(this.app.isMobile && !this.settings.enableMobile) { return }
|
||||
this.runCron()
|
||||
}
|
||||
})
|
||||
|
|
@ -123,7 +120,6 @@ export default class Cron extends Plugin {
|
|||
|
||||
public loadInterval() {
|
||||
clearInterval(this.interval)
|
||||
if(this.app.isMobile && !this.settings.enableMobile) { return }
|
||||
this.interval = window.setInterval(async () => { await this.runCron() }, this.settings.cronInterval * 60 * 1000)
|
||||
this.registerInterval(this.interval)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ export default class CronSettingTab extends PluginSettingTab {
|
|||
}
|
||||
|
||||
display(): void {
|
||||
const { containerEl } = this;
|
||||
const {containerEl} = this;
|
||||
|
||||
containerEl.empty();
|
||||
containerEl.createEl('h2', { text: 'Settings for Cron.' });
|
||||
containerEl.createEl('h2', {text: 'Settings for Cron.'});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Cron Interval')
|
||||
|
|
@ -23,7 +23,7 @@ export default class CronSettingTab extends PluginSettingTab {
|
|||
.addText(text => text
|
||||
.setValue(this.plugin.settings.cronInterval.toString())
|
||||
.onChange(async (value) => {
|
||||
if (value == "") { return }
|
||||
if(value == "") {return}
|
||||
this.plugin.settings.cronInterval = parseInt(value);
|
||||
await this.plugin.saveSettings();
|
||||
this.plugin.loadInterval();
|
||||
|
|
@ -52,25 +52,14 @@ export default class CronSettingTab extends PluginSettingTab {
|
|||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Enable Obsidian on Mobile')
|
||||
.setDesc('Whether or not to load jobs at all on Mobile devices. If disabled even jobs with mobile enabled will not run.')
|
||||
.addToggle(toggle => toggle
|
||||
.setValue(this.plugin.settings.enableMobile)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.enableMobile = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
const desc = document.createDocumentFragment();
|
||||
desc.append(
|
||||
"List of CRON Jobs to run. Jobs will not be ran until all 3 fields have been filled",
|
||||
desc.createEl("br"),
|
||||
"Cron Frequency is a cron schedule expression. Use ",
|
||||
desc.createEl("a", {
|
||||
href: "https://crontab.guru/",
|
||||
text: "crontab guru",
|
||||
href: "https://crontab.guru/",
|
||||
text: "crontab guru",
|
||||
}),
|
||||
" for help with creating cron schedule expressions."
|
||||
);
|
||||
|
|
@ -82,7 +71,7 @@ export default class CronSettingTab extends PluginSettingTab {
|
|||
this.addCommandSearch()
|
||||
}
|
||||
|
||||
addCommandSearch(): void {
|
||||
addCommandSearch (): void {
|
||||
|
||||
this.plugin.settings.crons.forEach((cronjob, index) => {
|
||||
const jobSetting = new Setting(this.containerEl)
|
||||
|
|
@ -97,17 +86,17 @@ export default class CronSettingTab extends PluginSettingTab {
|
|||
.inputEl.addClass('cron-plugin-text-input')
|
||||
)
|
||||
.addSearch((cb) => {
|
||||
new CommandSuggest(cb.inputEl);
|
||||
cb.setPlaceholder("Command")
|
||||
.setValue(cronjob.job)
|
||||
.onChange(async (command) => {
|
||||
if (!command) { return }
|
||||
new CommandSuggest(cb.inputEl);
|
||||
cb.setPlaceholder("Command")
|
||||
.setValue(cronjob.job)
|
||||
.onChange(async (command) => {
|
||||
if(!command) { return }
|
||||
|
||||
this.plugin.settings.crons[index].job = command;
|
||||
await this.plugin.saveSettings();
|
||||
this.plugin.loadCrons();
|
||||
})
|
||||
.inputEl.addClass('cron-plugin-text-input')
|
||||
this.plugin.settings.crons[index].job = command;
|
||||
await this.plugin.saveSettings();
|
||||
this.plugin.loadCrons();
|
||||
})
|
||||
.inputEl.addClass('cron-plugin-text-input')
|
||||
})
|
||||
.addText(text => text
|
||||
.setPlaceholder("CronJob frequency")
|
||||
|
|
@ -130,34 +119,33 @@ export default class CronSettingTab extends PluginSettingTab {
|
|||
})
|
||||
})
|
||||
|
||||
const jobLocked = this.plugin.settings.locks[cronjob.id] && this.plugin.settings.locks[cronjob.id].locked
|
||||
jobSetting.addExtraButton((button) => {
|
||||
button.setIcon(jobLocked ? "lucide-lock" : "lucide-unlock")
|
||||
.setTooltip("Toggle job lock (clear lock if accidentally left locked)")
|
||||
.onClick(() => {
|
||||
this.plugin.settings.locks[cronjob.id].locked = !jobLocked;
|
||||
this.plugin.saveSettings();
|
||||
// refresh
|
||||
this.display()
|
||||
})
|
||||
})
|
||||
const jobLocked = this.plugin.settings.locks[cronjob.name] && this.plugin.settings.locks[cronjob.name].locked
|
||||
jobSetting.addExtraButton((button) => {
|
||||
button.setIcon(jobLocked ? "lucide-lock" : "lucide-unlock")
|
||||
.setTooltip("Toggle job lock (clear lock if accidentally left locked)")
|
||||
.onClick(() => {
|
||||
this.plugin.settings.locks[cronjob.id].locked = !jobLocked;
|
||||
this.plugin.saveSettings();
|
||||
// refresh
|
||||
this.display()
|
||||
})
|
||||
})
|
||||
|
||||
jobSetting.addExtraButton((button) => {
|
||||
button.setIcon(cronjob.settings.disableSyncCheck ? "paused" : "lucide-check-circle-2")
|
||||
.setTooltip("Toggle Sync check for this job. Presently: " + (cronjob.settings.disableSyncCheck ? "disabled" : "enabled"))
|
||||
.onClick(() => {
|
||||
this.plugin.settings.crons[index].settings.disableSyncCheck = !cronjob.settings.disableSyncCheck;
|
||||
this.plugin.saveSettings();
|
||||
// Force refresh
|
||||
this.display();
|
||||
});
|
||||
})
|
||||
jobSetting.addExtraButton((button) => {
|
||||
button.setIcon(cronjob.settings.disableSyncCheck ? "paused" : "lucide-check-circle-2")
|
||||
.setTooltip("Toggle Sync check for this job. Presently: " + (cronjob.settings.disableSyncCheck ? "disabled" : "enabled"))
|
||||
.onClick(() => {
|
||||
this.plugin.settings.crons[index].settings.disableSyncCheck = !cronjob.settings.disableSyncCheck;
|
||||
this.plugin.saveSettings();
|
||||
// Force refresh
|
||||
this.display();
|
||||
});
|
||||
})
|
||||
.addExtraButton((button) => {
|
||||
button.setIcon("cross")
|
||||
.setTooltip("Delete Job")
|
||||
.onClick(() => {
|
||||
this.plugin.settings.crons.splice(index, 1)
|
||||
delete this.plugin.jobs[cronjob.id]
|
||||
delete this.plugin.settings.locks[cronjob.id]
|
||||
this.plugin.saveSettings();
|
||||
// Force refresh
|
||||
|
|
@ -165,7 +153,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) => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
{
|
||||
"0.0.1": "0.15.0",
|
||||
"1.0.0": "0.15.0",
|
||||
"1.1.0": "0.15.0",
|
||||
"1.1.1": "0.15.0",
|
||||
"1.1.2": "0.15.0"
|
||||
"1.0.0": "0.15.0"
|
||||
}
|
||||
Loading…
Reference in a new issue