From 739e459610d92a6fd3021a65398ecb4517cced89 Mon Sep 17 00:00:00 2001 From: Dixsie Wolmers Date: Fri, 5 Jun 2020 07:00:06 -0500 Subject: 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 Change-Id: I0d67c80487fdd815eacc3539ccd702b23618260e --- src/components/AppNavigation/AppNavigation.vue | 3 + src/locales/en-US.json | 75 +++-- src/router/index.js | 8 + src/store/index.js | 2 + .../modules/Configuration/DateTimeSettingsStore.js | 68 ++++ .../DateTimeSettings/DateTimeSettings.vue | 352 +++++++++++++++++++++ src/views/Configuration/DateTimeSettings/index.js | 2 + 7 files changed, 484 insertions(+), 26 deletions(-) create mode 100644 src/store/modules/Configuration/DateTimeSettingsStore.js create mode 100644 src/views/Configuration/DateTimeSettings/DateTimeSettings.vue create mode 100644 src/views/Configuration/DateTimeSettings/index.js (limited to 'src') diff --git a/src/components/AppNavigation/AppNavigation.vue b/src/components/AppNavigation/AppNavigation.vue index 1dfba11e..175b0aa0 100644 --- a/src/components/AppNavigation/AppNavigation.vue +++ b/src/components/AppNavigation/AppNavigation.vue @@ -59,6 +59,9 @@ + + {{ $t('appNavigation.dateTimeSettings') }} + {{ $t('appNavigation.firmware') }} diff --git a/src/locales/en-US.json b/src/locales/en-US.json index f0494c76..2a418040 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -25,7 +25,7 @@ }, "calendar": { "openDatePicker": "Open date picker", - "useCursorKeysToNavigateCalendarDates" : "Use cursor keys to navigate calendar dates" + "useCursorKeysToNavigateCalendarDates": "Use cursor keys to navigate calendar dates" }, "form": { "dateMustBeAfter": "Date must be after %{date}", @@ -73,6 +73,7 @@ "accessControl": "Access Control", "configuration": "Configuration", "control": "Control", + "dateTimeSettings": "@:appPageTitle.dateTimeSettings", "eventLogs": "@:appPageTitle.eventLogs", "firmware": "@:appPageTitle.firmware", "hardwareStatus": "@:appPageTitle.hardwareStatus", @@ -92,6 +93,7 @@ "sslCertificates": "@:appPageTitle.sslCertificates" }, "appPageTitle": { + "dateTimeSettings": "Date and time settings", "eventLogs": "Event logs", "firmware": "Firmware", "hardwareStatus": "Hardware status", @@ -101,7 +103,7 @@ "managePowerUsage": "Manage power usage", "networkSettings": "Network settings", "overview": "Overview", - "profileSettings":"Profile settings", + "profileSettings": "Profile settings", "rebootBmc": "Reboot BMC", "sensors": "Sensors", "serialOverLan": "Serial over LAN console", @@ -111,6 +113,27 @@ "sslCertificates": "SSL Certificates", "unauthorized": "Unauthorized" }, + "pageDateTimeSettings": { + "alert": { + "message": "To change how date and time are displayed (either UTC or browser offset) throughout the application, visit ", + "link": "Profile Settings" + }, + "configureSettings": "Configure settings", + "form": { + "date": "Date", + "manual": "Manual", + "time": "Time", + "ntpServers": { + "server1": "Server 1", + "server2": "Server 2", + "server3": "Server 3" + } + }, + "toast": { + "errorSaveDateTimeSettings": "Error saving date and time settings.", + "successSaveDateTimeSettings": "Successfully saved date and time settings." + } + }, "pageEventLogs": { "modal": { "deleteTitle": "Delete log | Delete logs", @@ -138,30 +161,30 @@ "chassis": "Chassis", "system": "System", "table": { - "assetTag": "Asset tag", - "chassisType": "Chassis type", - "connectTypesSupported": "Connect types supported", - "description": "Description", - "efficiencyPercent": "Efficiency percent", - "firmwareVersion": "Firmware version", - "graphicalConsole": "Graphical console", - "health": "Health", - "id": "ID", - "indicatorLed": "Indicator LED", - "manufacturer": "Manufacturer", - "maxConcurrentSessions": "Max concurrent sessions", - "model": "Model", - "partNumber": "Part number", - "powerInputWatts": "Power input watts", - "powerState": "Power state", - "serialConsole": "Serial console", - "serialNumber": "Serial number", - "serviceEnabled": "Service enabled", - "serviceEntryPointUuid": "Service entry point UUID", - "statusHealthRollup": "Status (Health rollup)", - "statusState": "Status (State)", - "systemType": "System type", - "uuid": "UUID" + "assetTag": "Asset tag", + "chassisType": "Chassis type", + "connectTypesSupported": "Connect types supported", + "description": "Description", + "efficiencyPercent": "Efficiency percent", + "firmwareVersion": "Firmware version", + "graphicalConsole": "Graphical console", + "health": "Health", + "id": "ID", + "indicatorLed": "Indicator LED", + "manufacturer": "Manufacturer", + "maxConcurrentSessions": "Max concurrent sessions", + "model": "Model", + "partNumber": "Part number", + "powerInputWatts": "Power input watts", + "powerState": "Power state", + "serialConsole": "Serial console", + "serialNumber": "Serial number", + "serviceEnabled": "Service enabled", + "serviceEntryPointUuid": "Service entry point UUID", + "statusHealthRollup": "Status (Health rollup)", + "statusState": "Status (State)", + "systemType": "System type", + "uuid": "UUID" } }, "pageLdap": { diff --git a/src/router/index.js b/src/router/index.js index a3d28063..3d8c646a 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -81,6 +81,14 @@ const routes = [ title: 'appPageTitle.sslCertificates' } }, + { + path: '/configuration/date-time-settings', + name: 'date-time-settings', + component: () => import('@/views/Configuration/DateTimeSettings'), + meta: { + title: 'appPageTitle.dateTimeSettings' + } + }, { path: '/control/manage-power-usage', name: 'manage-power-usage', diff --git a/src/store/index.js b/src/store/index.js index 6ad05390..392344d0 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -22,6 +22,7 @@ import ChassisStore from './modules/Health/ChassisStore'; import BmcStore from './modules/Health/BmcStore'; import WebSocketPlugin from './plugins/WebSocketPlugin'; +import DateTimeStore from './modules/Configuration/DateTimeSettingsStore'; Vue.use(Vuex); @@ -32,6 +33,7 @@ export default new Vuex.Store({ modules: { global: GlobalStore, authentication: AuthenticationStore, + dateTime: DateTimeStore, ldap: LdapStore, localUsers: LocalUserManagementStore, firmware: FirmwareStore, 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; diff --git a/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue b/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue new file mode 100644 index 00000000..d7b97d1a --- /dev/null +++ b/src/views/Configuration/DateTimeSettings/DateTimeSettings.vue @@ -0,0 +1,352 @@ + + + + + diff --git a/src/views/Configuration/DateTimeSettings/index.js b/src/views/Configuration/DateTimeSettings/index.js new file mode 100644 index 00000000..c8b5c08f --- /dev/null +++ b/src/views/Configuration/DateTimeSettings/index.js @@ -0,0 +1,2 @@ +import DateTimeSettings from './DateTimeSettings.vue'; +export default DateTimeSettings; -- cgit v1.2.3