mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Add setting to toggle auto configuring of khoj backend from Obsidian
- By default the obsidian plugin automatically configures the khoj backend to index the current vault - For more complex scenarios, users can manage their ~/.khoj/khoj.yml manually by toggling the auto-configure setting off in the khoj plugin settings Resolves #156
This commit is contained in:
@@ -48,12 +48,16 @@ export default class Khoj extends Plugin {
|
|||||||
// Load khoj obsidian plugin settings
|
// Load khoj obsidian plugin settings
|
||||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||||
|
|
||||||
// Load, configure khoj server settings
|
if (this.settings.autoConfigure) {
|
||||||
await configureKhojBackend(this.app.vault, this.settings);
|
// Load, configure khoj server settings
|
||||||
|
await configureKhojBackend(this.app.vault, this.settings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveSettings() {
|
async saveSettings() {
|
||||||
await configureKhojBackend(this.app.vault, this.settings, false)
|
if (this.settings.autoConfigure) {
|
||||||
.then(() => this.saveData(this.settings));
|
await configureKhojBackend(this.app.vault, this.settings, false);
|
||||||
}
|
}
|
||||||
|
this.saveData(this.settings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ export interface KhojSetting {
|
|||||||
resultsCount: number;
|
resultsCount: number;
|
||||||
khojUrl: string;
|
khojUrl: string;
|
||||||
connectedToBackend: boolean;
|
connectedToBackend: boolean;
|
||||||
|
autoConfigure: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_SETTINGS: KhojSetting = {
|
export const DEFAULT_SETTINGS: KhojSetting = {
|
||||||
resultsCount: 6,
|
resultsCount: 6,
|
||||||
khojUrl: 'http://localhost:8000',
|
khojUrl: 'http://localhost:8000',
|
||||||
connectedToBackend: false,
|
connectedToBackend: false,
|
||||||
|
autoConfigure: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
export class KhojSettingTab extends PluginSettingTab {
|
export class KhojSettingTab extends PluginSettingTab {
|
||||||
@@ -50,6 +52,15 @@ export class KhojSettingTab extends PluginSettingTab {
|
|||||||
this.plugin.settings.resultsCount = value;
|
this.plugin.settings.resultsCount = value;
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
}));
|
}));
|
||||||
|
new Setting(containerEl)
|
||||||
|
.setName('Auto Configure')
|
||||||
|
.setDesc('Automatically configure the Khoj backend')
|
||||||
|
.addToggle(toggle => toggle
|
||||||
|
.setValue(this.plugin.settings.autoConfigure)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
this.plugin.settings.autoConfigure = value;
|
||||||
|
await this.plugin.saveSettings();
|
||||||
|
}));
|
||||||
let indexVaultSetting = new Setting(containerEl);
|
let indexVaultSetting = new Setting(containerEl);
|
||||||
indexVaultSetting
|
indexVaultSetting
|
||||||
.setName('Index Vault')
|
.setName('Index Vault')
|
||||||
|
|||||||
Reference in New Issue
Block a user