diff options
Diffstat (limited to 'pse-dashboard/src/logger.js')
-rw-r--r-- | pse-dashboard/src/logger.js | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/pse-dashboard/src/logger.js b/pse-dashboard/src/logger.js new file mode 100644 index 0000000..8398fd8 --- /dev/null +++ b/pse-dashboard/src/logger.js @@ -0,0 +1,84 @@ +import { reactive } from 'vue' +import i18n from '@/i18n' +// import { useI18n } from 'vue-i18n' + +// const { t } = i18n.global; +export const Logger = reactive({ + items: [], + append(item) { + this.items.push(item); + }, + delete(item) { + this.items = this.items.filter(e => e != item); + } +}); + + +// error {type: "success" | "info" | "warning" | "danger", message: String, lifetime: number} +export function useLogger() { + // const { t } = useI18n(); + const { t } = i18n.global; + + return { + append(item) { + Logger.append(item); + }, + delete(item) { + Logger.delete(item); + }, + passwordRequirementsError() { + Logger.append({type: "warning", message: t('form.password')}) + }, + passwordRequirements() { + Logger.append({type: "warning", message: t("error.passwordRequirements")}); + }, + passwordChanged() { + Logger.append({type: "success", message: t("error.passwordChanged")}); + }, + accountDeleted() { + Logger.append({type: "info", message: t("error.accountDeleted")}); + }, + gpodderImport() { + Logger.append({type: "info", message: t("error.gpodderImport")}); + }, + passwordReset() { + Logger.append({type: "info", message: t("error.passwordReset")}); + }, + passwordForgot() { + Logger.append({type: "info", message: t("error.passwordForgot")}); + }, + subscriptionAdded() { + Logger.append({type: "info", message: t("error.subscriptionAdded")}); + }, + accountCreated() { + Logger.append({type: "success", message: t("error.accountCreated")}); + }, + copiedPodcast() { + Logger.append({type: "info", message: t("error.copiedPodcast")}); + }, + copiedPodcastError() { + Logger.append({type: "warning", message: t("error.copiedPodcastError")}); + }, + + badRequestError() { + Logger.append({type: "danger", message: t("error.400BadRequest")}); + }, + unauthorizedError() { + Logger.append({type: "danger", message: t("error.401Unauthorized")}); + }, + notFoundError() { + Logger.append({type: "danger", message: t("error.404NotFound")}); + }, + connectionLostError() { + Logger.append({type: "danger", message: t("error.connectionLost")}); + }, + axiosError() { + Logger.append({type: "danger", message: t("error.axiosError")}); + }, + pageNotFound() { + Logger.append({type: "warning", message: t("error.pageNotFound")}); + } + } +} + + |