summaryrefslogtreecommitdiff
path: root/src/store/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/store/modules')
-rw-r--r--src/store/modules/Settings/SmtpStore.js100
-rw-r--r--src/store/modules/Settings/SnmpStore.js73
-rw-r--r--src/store/modules/Settings/SyslogStore.js36
3 files changed, 209 insertions, 0 deletions
diff --git a/src/store/modules/Settings/SmtpStore.js b/src/store/modules/Settings/SmtpStore.js
new file mode 100644
index 00000000..195f245a
--- /dev/null
+++ b/src/store/modules/Settings/SmtpStore.js
@@ -0,0 +1,100 @@
+import api from '@/store/api';
+import i18n from '@/i18n';
+
+const SmtpStore = {
+ namespaced: true,
+ state: {
+ settings: {},
+ subscribers: [],
+ },
+ getters: {
+ settings: (state) => state.settings,
+ subscribers: (state) => state.subscribers,
+ },
+ mutations: {
+ saveSettings: (state, data) => (state.settings = data),
+ setSubscribers: (state, data) => (state.subscribers = data),
+ },
+ actions: {
+ 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(async () => {
+ await dispatch('getSettings');
+ return i18n.t('pageTransfer.saveSmtpSuсcess');
+ })
+ .catch((error) => {
+ console.log(error);
+ 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) {
+ url += `&${key}=${payload[key]}`;
+ }
+
+ return await api.get(url);
+ },
+ },
+};
+
+export default SmtpStore;
diff --git a/src/store/modules/Settings/SnmpStore.js b/src/store/modules/Settings/SnmpStore.js
new file mode 100644
index 00000000..3fda494f
--- /dev/null
+++ b/src/store/modules/Settings/SnmpStore.js
@@ -0,0 +1,73 @@
+import api from '@/store/api';
+import i18n from '@/i18n';
+
+const SnmpStore = {
+ namespaced: true,
+ state: { subscribers: [] },
+ getters: { subscribers: (state) => state.subscribers },
+ mutations: {
+ setSubscribers: (state, data) => (state.subscribers = data),
+ },
+ actions: {
+ async deleteSubscriber({ dispatch }, index) {
+ return await api
+ .delete(`/redfish/v1/EventService/Subscriptions/${index}`)
+ .then(async () => {
+ await dispatch('getSubscribers');
+ return i18n.t('pageTransfer.snmp.deleteSubscriberSuсcess');
+ })
+ .catch((error) => {
+ console.log(error);
+ throw new Error(i18n.t('pageTransfer.snmp.deleteSubscriberError'));
+ });
+ },
+ async addSubscriber({ dispatch }, payload) {
+ return await api
+ .post('/redfish/v1/EventService/Subscriptions', payload)
+ .then(async () => {
+ await dispatch('getSubscribers');
+ return i18n.t('pageTransfer.snmp.saveSubscriberSuсcess');
+ })
+ .catch((error) => {
+ console.log(error);
+ throw new Error(i18n.t('pageTransfer.snmp.saveSubscriberError'));
+ });
+ },
+ async getSubscribers({ commit }) {
+ return await api
+ .get('/redfish/v1/EventService/Subscriptions')
+ .then(({ data: { Members } }) => {
+ return Members.filter((member) =>
+ member['@odata.id'].includes('snmp')
+ );
+ })
+ .then((members) => {
+ return api.all(members.map((member) => api.get(member['@odata.id'])));
+ })
+ .then((subscribersRow) => {
+ return subscribersRow.map((subscriberRow) => {
+ return subscriberRow.data;
+ });
+ })
+ .then((data) => {
+ return data.map((subscriber) => {
+ const host = subscriber.Destination.split('/')[2].split(':')[0];
+ const port = subscriber.Destination.split('/')[2].split(':')[1];
+ return {
+ ...subscriber,
+ host,
+ port,
+ };
+ });
+ })
+ .then((subscribers) => commit('setSubscribers', subscribers))
+ .catch((error) => {
+ console.log(error);
+ const message = i18n.t('pageUserManagement.toast.errorLoadUsers');
+ throw new Error(message);
+ });
+ },
+ },
+};
+
+export default SnmpStore;
diff --git a/src/store/modules/Settings/SyslogStore.js b/src/store/modules/Settings/SyslogStore.js
new file mode 100644
index 00000000..f0b0eb59
--- /dev/null
+++ b/src/store/modules/Settings/SyslogStore.js
@@ -0,0 +1,36 @@
+import api from '@/store/api';
+import i18n from '@/i18n';
+
+const SyslogStore = {
+ namespaced: true,
+ state: { settings: {} },
+ getters: { settings: (state) => state.settings },
+ mutations: {
+ saveSettings: (state, data) => (state.settings = data),
+ },
+ actions: {
+ async saveSettings({ dispatch }, payload) {
+ return await api
+ .post('/redfish/v1/Syslog/Actions/Syslog.UpdateConfig', payload)
+ .then(async () => {
+ await dispatch('getSettings');
+ return i18n.t('pageTransfer.syslog.saveSettingsSuсcess');
+ })
+ .catch((error) => {
+ console.log(error);
+ throw new Error(i18n.t('pageTransfer.syslog.saveSettingsError'));
+ });
+ },
+
+ async getSettings({ commit }) {
+ return await api
+ .get('/redfish/v1/Syslog')
+ .then(({ data: { Configuration = {} } = {} }) => {
+ commit('saveSettings', Configuration);
+ })
+ .catch((error) => console.log(error));
+ },
+ },
+};
+
+export default SyslogStore;