summaryrefslogtreecommitdiff
path: root/pse-dashboard/src/logger.js
diff options
context:
space:
mode:
authorOrangerot <purple@orangerot.dev>2024-06-19 00:14:49 +0200
committerOrangerot <purple@orangerot.dev>2024-06-27 12:11:14 +0200
commit5b8851b6c268d0e93c158908fbfae9f8473db5ff (patch)
tree7010eb85d86fa2da06ea4ffbcdb01a685d502ae8 /pse-dashboard/src/logger.js
Initial commitHEADmain
Diffstat (limited to 'pse-dashboard/src/logger.js')
-rw-r--r--pse-dashboard/src/logger.js84
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")});
+ }
+ }
+}
+
+