summaryrefslogtreecommitdiff
path: root/src/store/modules/Settings/SmtpStore.js
diff options
context:
space:
mode:
authorVitalii Lysak <v.lysak@dunice.net>2022-09-19 17:02:28 +0300
committerVitalii Lysak <v.lysak@dunice.net>2022-09-19 17:02:28 +0300
commit30f4e9777b157fe7023a9cf02c7d53737d2e2974 (patch)
tree975f963652021cec858f1c08b3a589432562b770 /src/store/modules/Settings/SmtpStore.js
parent8a20e665fe0242d8fe075766a7fcfb46b820d12b (diff)
downloadwebui-vue-30f4e9777b157fe7023a9cf02c7d53737d2e2974.tar.xz
upd syslog and smtp
Diffstat (limited to 'src/store/modules/Settings/SmtpStore.js')
-rw-r--r--src/store/modules/Settings/SmtpStore.js74
1 files changed, 67 insertions, 7 deletions
diff --git a/src/store/modules/Settings/SmtpStore.js b/src/store/modules/Settings/SmtpStore.js
index 88fad25c..195f245a 100644
--- a/src/store/modules/Settings/SmtpStore.js
+++ b/src/store/modules/Settings/SmtpStore.js
@@ -3,22 +3,72 @@ import i18n from '@/i18n';
const SmtpStore = {
namespaced: true,
- state: { smtp: {} },
- getters: { smtpSettings: (state) => state.smtp },
+ state: {
+ settings: {},
+ subscribers: [],
+ },
+ getters: {
+ settings: (state) => state.settings,
+ subscribers: (state) => state.subscribers,
+ },
mutations: {
- saveSmtpSettings: (state, data) => (state.smtp = data),
+ saveSettings: (state, data) => (state.settings = data),
+ setSubscribers: (state, data) => (state.subscribers = data),
},
actions: {
- async setSmtpSettings({ commit }, payload) {
- let url = `/redfish/v1/Smtp/ChangeParameters`;
+ async deleteSubscriber({ dispatch }, email) {
+ return await api
+ .get(`/redfish/v1/Smtp/DeleteMails&${email}`)
+ .then(async () => {
+ await dispatch('getSubscribers');
+ return i18n.t('pageTransfer.smtp.deleteSubscriberSuсcess');
+ })
+ .catch((error) => {
+ console.log(error);
+ throw new Error(i18n.t('pageTransfer.smtp.deleteSubscriberError'));
+ });
+ },
+
+ async addSubscriber({ dispatch }, payload) {
+ return await api
+ .get(`/redfish/v1/Smtp/AddMails&${payload.email}`)
+ .then(async () => {
+ await dispatch('getSubscribers');
+ return i18n.t('pageTransfer.smtp.saveSubscriberSuсcess');
+ })
+ .catch((error) => {
+ console.log(error);
+ throw new Error(i18n.t('pageTransfer.smtp.saveSubscriberError'));
+ });
+ },
+
+ async getSubscribers({ commit }) {
+ return await api
+ .get('/redfish/v1/Smtp/GetMails')
+ .then(({ data: { mails = [] } = {} }) =>
+ mails.map((host) => {
+ return {
+ host,
+ };
+ })
+ )
+ .then((subscribers) => commit('setSubscribers', subscribers))
+ .catch((error) => {
+ console.log(error);
+ throw new Error(i18n.t('pageUserManagement.toast.errorLoadUsers'));
+ });
+ },
+
+ async setSettings({ dispatch }, payload) {
+ let url = `/redfish/v1/Smtp/SetSettings`;
for (let key in payload) {
url += `&${key}=${payload[key]}`;
}
return await api
.get(url)
- .then(() => {
- commit('saveSmtpSettings', payload);
+ .then(async () => {
+ await dispatch('getSettings');
return i18n.t('pageTransfer.saveSmtpSuсcess');
})
.catch((error) => {
@@ -26,6 +76,16 @@ const SmtpStore = {
throw new Error(i18n.t('pageTransfer.saveSmtpError'));
});
},
+
+ async getSettings({ commit }) {
+ return await api
+ .get('/redfish/v1/Smtp/GetSettings')
+ .then(({ data = {} }) => {
+ commit('saveSettings', data);
+ })
+ .catch((error) => console.log(error));
+ },
+
async sendTestMessage(_, payload) {
let url = `/redfish/v1/Smtp/SendMail`;
for (let key in payload) {