summaryrefslogtreecommitdiff
path: root/src/store/modules
diff options
context:
space:
mode:
authorDixsie Wolmers <dixsie@ibm.com>2020-06-05 15:00:06 +0300
committerDerick Montague <derick.montague@ibm.com>2020-07-10 04:13:23 +0300
commit739e459610d92a6fd3021a65398ecb4517cced89 (patch)
tree247ad85d6e7924f838a1c59efc20b65b6e4812ad /src/store/modules
parent2f8bbbfe198087497c475029c573727e0711eb04 (diff)
downloadwebui-vue-739e459610d92a6fd3021a65398ecb4517cced89.tar.xz
Add date and time settings
Adds ablity to change date and time manually, or configure using NTP servers. - If NTP is selected, user is required to enter at least one NTP address - Date and time are ISO formatted Signed-off-by: Dixsie Wolmers <dixsie@ibm.com> Change-Id: I0d67c80487fdd815eacc3539ccd702b23618260e
Diffstat (limited to 'src/store/modules')
-rw-r--r--src/store/modules/Configuration/DateTimeSettingsStore.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/store/modules/Configuration/DateTimeSettingsStore.js b/src/store/modules/Configuration/DateTimeSettingsStore.js
new file mode 100644
index 00000000..9da0cb41
--- /dev/null
+++ b/src/store/modules/Configuration/DateTimeSettingsStore.js
@@ -0,0 +1,68 @@
+import api from '../../api';
+import i18n from '@/i18n';
+
+const DateTimeStore = {
+ namespaced: true,
+ state: {
+ ntpServers: [],
+ isNtpProtocolEnabled: null
+ },
+ getters: {
+ ntpServers: state => state.ntpServers,
+ isNtpProtocolEnabled: state => state.isNtpProtocolEnabled
+ },
+ mutations: {
+ setNtpServers: (state, ntpServers) => (state.ntpServers = ntpServers),
+ setIsNtpProtocolEnabled: (state, isNtpProtocolEnabled) =>
+ (state.isNtpProtocolEnabled = isNtpProtocolEnabled)
+ },
+ actions: {
+ async getNtpData({ commit }) {
+ return await api
+ .get('/redfish/v1/Managers/bmc/NetworkProtocol')
+ .then(response => {
+ const ntpServers = response.data.NTP.NTPServers;
+ const isNtpProtocolEnabled = response.data.NTP.ProtocolEnabled;
+ commit('setNtpServers', ntpServers);
+ commit('setIsNtpProtocolEnabled', isNtpProtocolEnabled);
+ })
+ .catch(error => {
+ console.log(error);
+ });
+ },
+ async updateDateTimeSettings(_, dateTimeForm) {
+ const ntpData = {
+ NTP: {
+ ProtocolEnabled: dateTimeForm.ntpProtocolEnabled
+ }
+ };
+
+ if (dateTimeForm.ntpProtocolEnabled) {
+ ntpData.NTP.NTPServers = dateTimeForm.ntpServersArray;
+ }
+ return await api
+ .patch(`/redfish/v1/Managers/bmc/NetworkProtocol`, ntpData)
+ .then(() => {
+ if (!dateTimeForm.ntpProtocolEnabled) {
+ const dateTimeData = {
+ DateTime: dateTimeForm.updatedDateTime
+ };
+ api.patch(`/redfish/v1/Managers/bmc`, dateTimeData);
+ }
+ })
+ .then(() => {
+ return i18n.t(
+ 'pageDateTimeSettings.toast.successSaveDateTimeSettings'
+ );
+ })
+ .catch(error => {
+ console.log(error);
+ throw new Error(
+ i18n.t('pageDateTimeSettings.toast.errorSaveDateTimeSettings')
+ );
+ });
+ }
+ }
+};
+
+export default DateTimeStore;