Skip to content

Commit

Permalink
Refactor to support multiple services
Browse files Browse the repository at this point in the history
  • Loading branch information
joethei committed Feb 16, 2024
1 parent 1a54460 commit 6521aeb
Show file tree
Hide file tree
Showing 8 changed files with 477 additions and 243 deletions.
59 changes: 59 additions & 0 deletions src/ServiceConfigurationModal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {Modal, Setting} from "obsidian";
import TTSPlugin from "./main";

export class ServiceConfigurationModal extends Modal {
plugin: TTSPlugin;

constructor(plugin: TTSPlugin) {
super(plugin.app);
this.plugin = plugin;
}

display(service?: string): void {

const { contentEl } = this;

contentEl.empty();

new Setting(contentEl)
.setName('Service')
.setDesc('test')
.addDropdown((dropdown) => {
dropdown.addOption('openai', 'OpenAI');
dropdown.addOption('microsoft', 'Microsoft Azure');

dropdown.setValue(service);

dropdown.onChange(async(value) => {
this.display(value);
})
});

if (service === 'openai') {
new Setting(contentEl)
.setName('API Key')
.setDesc('API key for OpenAI')
.addText(async text => {
text
.setValue(this.plugin.settings.services.openai.key)
.onChange(async value => {
this.plugin.settings.services.openai.key = value;
await this.plugin.saveSettings();
});
})
;


}

}

onOpen(): void {
//@ts-ignore
this.setTitle('Add new service');
this.display();

}


}
64 changes: 0 additions & 64 deletions src/TTSService.ts

This file was deleted.

156 changes: 0 additions & 156 deletions src/TTSServiceImplementation.ts

This file was deleted.

Loading

0 comments on commit 6521aeb

Please sign in to comment.