diff --git a/src/modals/login.ts b/src/modals/login.ts index 41d6c6c..371a9fe 100644 --- a/src/modals/login.ts +++ b/src/modals/login.ts @@ -1,5 +1,6 @@ -import { App, ButtonComponent, Modal, Setting } from "obsidian"; +import { App, ButtonComponent, Modal, Setting, setIcon, setTooltip } from "obsidian"; import KSyncPlugin from "src/main"; +import { WarningModal } from "./warning"; export class LoginModal extends Modal { private login: string; diff --git a/src/modals/warning.ts b/src/modals/warning.ts new file mode 100644 index 0000000..a8a9f9e --- /dev/null +++ b/src/modals/warning.ts @@ -0,0 +1,24 @@ +import { App, Component, MarkdownRenderer, Modal } from "obsidian"; +import KSyncPlugin from "src/main"; + +export class WarningModal extends Modal { + public plugin: KSyncPlugin; + public text: string; + constructor(app: App, plugin: KSyncPlugin, text: string) { + super(app); + + this.plugin = plugin; + this.text = text; + } + + async onOpen() { + const { contentEl } = this; + MarkdownRenderer.render(this.app, `# ${this.text}`, contentEl, "", new Component()); + } + + onClose() { + const { contentEl } = this; + + contentEl.empty(); + } +} \ No newline at end of file diff --git a/src/services/account.ts b/src/services/account.ts index 671dd65..a604e20 100644 --- a/src/services/account.ts +++ b/src/services/account.ts @@ -1,4 +1,5 @@ import KSyncPlugin from "src/main"; +import { WarningModal } from "src/modals/warning"; export class Account { public plugin: KSyncPlugin; @@ -36,11 +37,13 @@ export class Account { login: email, password: password })).data + if(!data) return new WarningModal(this.plugin.app, this.plugin, "Сервер не ответил").open(); + if(data.error) return new WarningModal(this.plugin.app, this.plugin, "Неправильный Логин или пароль").open(); this.plugin.settings.token = data.token this.plugin.saveSettings() const user = await this.GetData(); - this.plugin.logger.info("Используем аккаунт "+user.email) + this.plugin.logger.info(`Входим в аккаунт ${user.email}`) this.data = user; } diff --git a/styles.css b/styles.css index b41376a..a79cee0 100644 --- a/styles.css +++ b/styles.css @@ -15,6 +15,21 @@ If your plugin does not need CSS, delete this file. border-radius: var(--input-radius); } +.warning { + width: 100%; + height: fit-content; + border: var(--input-border-width) solid var(--background-modifier-border); + border-radius: var(--input-radius); + background-color: var(--color-red); + padding: 5px; + margin-bottom: 5px; +} + +.warning .text { + margin: 15px; + font-size: var(--font-ui-large); +} + .log-list { list-style-type: none; padding: 5px;