xref: /openbmc/webui-vue/src/store/modules/Operations/FactoryResetStore.js (revision de23ea23d88451a2fa2774ec72053772603c23ae)
1import api from '@/store/api';
2import i18n from '@/i18n';
3
4const FactoryResetStore = {
5  namespaced: true,
6  actions: {
7    async resetToDefaults() {
8      return await api
9        .post(
10          `${await this.dispatch('global/getBmcPath')}/Actions/Manager.ResetToDefaults`,
11          {
12            ResetType: 'ResetAll',
13          },
14        )
15        .then(() =>
16          i18n.global.t('pageFactoryReset.toast.resetToDefaultsSuccess'),
17        )
18        .catch((error) => {
19          console.log('Factory Reset: ', error);
20          throw new Error(
21            i18n.global.t('pageFactoryReset.toast.resetToDefaultsError'),
22          );
23        });
24    },
25    async resetBios() {
26      return await api
27        .post(
28          `${await this.dispatch('global/getSystemPath')}/Bios/Actions/Bios.ResetBios`,
29        )
30        .then(() => i18n.global.t('pageFactoryReset.toast.resetBiosSuccess'))
31        .catch((error) => {
32          console.log('Factory Reset: ', error);
33          throw new Error(
34            i18n.global.t('pageFactoryReset.toast.resetBiosError'),
35          );
36        });
37    },
38  },
39};
40
41export default FactoryResetStore;
42