blob: bef9f47b351934b2ae056da1149baf72ef01fe6a [file] [log] [blame]
Dixsie Wolmersf65ee342020-01-22 19:47:56 -06001import api from '../../api';
2
3const PowerCapStore = {
4 namespaced: true,
5 state: {
6 powerCapData: null,
7 powerCapValue: 'Not enabled'
8 },
9 getters: {
10 powerCapData: state => state.powerCapData,
11 powerCapValue: state => state.powerCapValue
12 },
13 mutations: {
14 setPowerCapData: (state, powerCapData) =>
15 (state.powerCapData = powerCapData),
16 setPowerCapValue: (state, powerCapValue) =>
17 (state.powerCapValue = powerCapValue)
18 },
19 actions: {
20 getPowerCapData({ commit }) {
21 api
22 .get('/xyz/openbmc_project/control/host0/power_cap')
23 .then(response => {
24 const powerCapData = response.data.data;
25 if (powerCapData.PowerCapEnable) {
26 commit('setPowerCapValue', powerCapData.PowerCap + ' W');
27 }
28 })
29 .catch(error => {
30 console.log('Power cap error', error);
31 });
32 }
33 }
34};
35
36export default PowerCapStore;