summaryrefslogtreecommitdiff
path: root/pse-dashboard/src/logger.js
blob: 8398fd807f6d41fca719e43f350af6ab63a2f540 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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")});
        }
    }
}