57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import { App, PluginSettingTab, Setting } from "obsidian";
|
|
import LimitlessPlugin from "./main.ts";
|
|
|
|
export interface LimitlessPluginSettings {
|
|
apiKey: string;
|
|
lifelogsDir: string;
|
|
latestLog?: string;
|
|
}
|
|
|
|
export const DEFAULT_SETTINGS: LimitlessPluginSettings = {
|
|
apiKey: "",
|
|
lifelogsDir: "",
|
|
latestLog: undefined,
|
|
};
|
|
|
|
export class LimitlessSettingTab extends PluginSettingTab {
|
|
plugin: LimitlessPlugin;
|
|
|
|
constructor(app: App, plugin: LimitlessPlugin) {
|
|
super(app, plugin);
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
display(): void {
|
|
const { containerEl } = this;
|
|
|
|
containerEl.empty();
|
|
|
|
new Setting(containerEl)
|
|
.setName("API Key")
|
|
.setDesc("It's a secret")
|
|
.addText((text) => {
|
|
text.inputEl.type = "password";
|
|
|
|
return text
|
|
.setPlaceholder("Enter your secret")
|
|
.setValue(this.plugin.settings.apiKey)
|
|
.onChange(async (value) => {
|
|
this.plugin.settings.apiKey = value;
|
|
await this.plugin.saveSettings();
|
|
});
|
|
});
|
|
|
|
new Setting(containerEl)
|
|
.setName("Lifelogs Directory")
|
|
.setDesc("The directory where you want Lifelogs placed")
|
|
.addText((text) => {
|
|
return text
|
|
.setPlaceholder("Lifelogs")
|
|
.setValue(this.plugin.settings.lifelogsDir)
|
|
.onChange(async (value) => {
|
|
this.plugin.settings.lifelogsDir = value;
|
|
await this.plugin.saveSettings();
|
|
});
|
|
});
|
|
}
|
|
}
|