1f67f769fSSandeepa Singh<template> 2f67f769fSSandeepa Singh <b-container fluid="xl"> 3f67f769fSSandeepa Singh <page-title /> 4f67f769fSSandeepa Singh <b-row> 5f67f769fSSandeepa Singh <b-col md="8" xl="6"> 6f67f769fSSandeepa Singh <alert variant="info" class="mb-4"> 7f67f769fSSandeepa Singh <span> 8f67f769fSSandeepa Singh {{ $t('pageDateTime.alert.message') }} 9f67f769fSSandeepa Singh <b-link to="/profile-settings"> 10f67f769fSSandeepa Singh {{ $t('pageDateTime.alert.link') }}</b-link 11f67f769fSSandeepa Singh > 12f67f769fSSandeepa Singh </span> 13f67f769fSSandeepa Singh </alert> 14f67f769fSSandeepa Singh </b-col> 15f67f769fSSandeepa Singh </b-row> 16f67f769fSSandeepa Singh <page-section> 17f67f769fSSandeepa Singh <b-row> 18f67f769fSSandeepa Singh <b-col lg="3"> 19f67f769fSSandeepa Singh <dl> 20f67f769fSSandeepa Singh <dt>{{ $t('pageDateTime.form.date') }}</dt> 21de23ea23SSurya V <dd v-if="bmcTime">{{ $filters.formatDate(bmcTime) }}</dd> 22f67f769fSSandeepa Singh <dd v-else>--</dd> 23f67f769fSSandeepa Singh </dl> 24f67f769fSSandeepa Singh </b-col> 25f67f769fSSandeepa Singh <b-col lg="3"> 26f67f769fSSandeepa Singh <dl> 27f67f769fSSandeepa Singh <dt>{{ $t('pageDateTime.form.time.label') }}</dt> 28de23ea23SSurya V <dd v-if="bmcTime">{{ $filters.formatTime(bmcTime) }}</dd> 29f67f769fSSandeepa Singh <dd v-else>--</dd> 30f67f769fSSandeepa Singh </dl> 31f67f769fSSandeepa Singh </b-col> 32f67f769fSSandeepa Singh </b-row> 33f67f769fSSandeepa Singh </page-section> 34f67f769fSSandeepa Singh <page-section :section-title="$t('pageDateTime.configureSettings')"> 35f67f769fSSandeepa Singh <b-form novalidate @submit.prevent="submitForm"> 36f67f769fSSandeepa Singh <b-form-group 37f67f769fSSandeepa Singh label="Configure date and time" 38f67f769fSSandeepa Singh :disabled="loading" 39f67f769fSSandeepa Singh label-sr-only 40f67f769fSSandeepa Singh > 41f67f769fSSandeepa Singh <b-form-radio 42f67f769fSSandeepa Singh v-model="form.configurationSelected" 43f67f769fSSandeepa Singh value="manual" 44f67f769fSSandeepa Singh data-test-id="dateTime-radio-configureManual" 45f67f769fSSandeepa Singh > 46f67f769fSSandeepa Singh {{ $t('pageDateTime.form.manual') }} 47f67f769fSSandeepa Singh </b-form-radio> 48f67f769fSSandeepa Singh <b-row class="mt-3 ml-3"> 49f67f769fSSandeepa Singh <b-col sm="6" lg="4" xl="3"> 50f67f769fSSandeepa Singh <b-form-group 51f67f769fSSandeepa Singh :label="$t('pageDateTime.form.date')" 52f67f769fSSandeepa Singh label-for="input-manual-date" 53f67f769fSSandeepa Singh > 54f67f769fSSandeepa Singh <b-form-text id="date-format-help">YYYY-MM-DD</b-form-text> 55f67f769fSSandeepa Singh <b-input-group> 56f67f769fSSandeepa Singh <b-form-input 57f67f769fSSandeepa Singh id="input-manual-date" 58f67f769fSSandeepa Singh v-model="form.manual.date" 59de23ea23SSurya V :state="getValidationState(v$.form.manual.date)" 60f67f769fSSandeepa Singh :disabled="ntpOptionSelected" 61f67f769fSSandeepa Singh data-test-id="dateTime-input-manualDate" 62f67f769fSSandeepa Singh class="form-control-with-button" 63de23ea23SSurya V @blur="v$.form.manual.date.$touch()" 64f67f769fSSandeepa Singh /> 65f67f769fSSandeepa Singh <b-form-invalid-feedback role="alert"> 661b89e594SSurya Venkatesan <div v-if="v$.form.manual.date.pattern.$invalid"> 67f67f769fSSandeepa Singh {{ $t('global.form.invalidFormat') }} 68f67f769fSSandeepa Singh </div> 691b89e594SSurya Venkatesan <div v-if="v$.form.manual.date.required.$invalid"> 70f67f769fSSandeepa Singh {{ $t('global.form.fieldRequired') }} 71f67f769fSSandeepa Singh </div> 72f67f769fSSandeepa Singh </b-form-invalid-feedback> 73f67f769fSSandeepa Singh <b-form-datepicker 74f67f769fSSandeepa Singh v-model="form.manual.date" 75f67f769fSSandeepa Singh class="btn-datepicker btn-icon-only" 76f67f769fSSandeepa Singh button-only 77f67f769fSSandeepa Singh right 78f67f769fSSandeepa Singh :hide-header="true" 79f67f769fSSandeepa Singh :locale="locale" 80f67f769fSSandeepa Singh :label-help=" 81f67f769fSSandeepa Singh $t('global.calendar.useCursorKeysToNavigateCalendarDates') 82f67f769fSSandeepa Singh " 83f67f769fSSandeepa Singh :title="$t('global.calendar.selectDate')" 84f67f769fSSandeepa Singh :disabled="ntpOptionSelected" 85f67f769fSSandeepa Singh button-variant="link" 86f67f769fSSandeepa Singh aria-controls="input-manual-date" 87f67f769fSSandeepa Singh > 88f67f769fSSandeepa Singh <template #button-content> 89f67f769fSSandeepa Singh <icon-calendar /> 90f67f769fSSandeepa Singh <span class="sr-only"> 91f67f769fSSandeepa Singh {{ $t('global.calendar.selectDate') }} 92f67f769fSSandeepa Singh </span> 93f67f769fSSandeepa Singh </template> 94f67f769fSSandeepa Singh </b-form-datepicker> 95f67f769fSSandeepa Singh </b-input-group> 96f67f769fSSandeepa Singh </b-form-group> 97f67f769fSSandeepa Singh </b-col> 98f67f769fSSandeepa Singh <b-col sm="6" lg="4" xl="3"> 99f67f769fSSandeepa Singh <b-form-group 100f67f769fSSandeepa Singh :label="$t('pageDateTime.form.time.timezone', { timezone })" 101f67f769fSSandeepa Singh label-for="input-manual-time" 102f67f769fSSandeepa Singh > 103f67f769fSSandeepa Singh <b-form-text id="time-format-help">HH:MM</b-form-text> 104f67f769fSSandeepa Singh <b-input-group> 105f67f769fSSandeepa Singh <b-form-input 106f67f769fSSandeepa Singh id="input-manual-time" 107f67f769fSSandeepa Singh v-model="form.manual.time" 108de23ea23SSurya V :state="getValidationState(v$.form.manual.time)" 109f67f769fSSandeepa Singh :disabled="ntpOptionSelected" 110f67f769fSSandeepa Singh data-test-id="dateTime-input-manualTime" 111de23ea23SSurya V @blur="v$.form.manual.time.$touch()" 112f67f769fSSandeepa Singh /> 113f67f769fSSandeepa Singh <b-form-invalid-feedback role="alert"> 1141b89e594SSurya Venkatesan <div v-if="v$.form.manual.time.pattern.$invalid"> 115f67f769fSSandeepa Singh {{ $t('global.form.invalidFormat') }} 116f67f769fSSandeepa Singh </div> 1171b89e594SSurya Venkatesan <div v-if="v$.form.manual.time.required.$invalid"> 118f67f769fSSandeepa Singh {{ $t('global.form.fieldRequired') }} 119f67f769fSSandeepa Singh </div> 120f67f769fSSandeepa Singh </b-form-invalid-feedback> 121f67f769fSSandeepa Singh </b-input-group> 122f67f769fSSandeepa Singh </b-form-group> 123f67f769fSSandeepa Singh </b-col> 124f67f769fSSandeepa Singh </b-row> 125f67f769fSSandeepa Singh <b-form-radio 126f67f769fSSandeepa Singh v-model="form.configurationSelected" 127f67f769fSSandeepa Singh value="ntp" 128f67f769fSSandeepa Singh data-test-id="dateTime-radio-configureNTP" 129f67f769fSSandeepa Singh > 130f67f769fSSandeepa Singh NTP 131f67f769fSSandeepa Singh </b-form-radio> 132f67f769fSSandeepa Singh <b-row class="mt-3 ml-3"> 133f67f769fSSandeepa Singh <b-col sm="6" lg="4" xl="3"> 134f67f769fSSandeepa Singh <b-form-group 135f67f769fSSandeepa Singh :label="$t('pageDateTime.form.ntpServers.server1')" 136f67f769fSSandeepa Singh label-for="input-ntp-1" 137f67f769fSSandeepa Singh > 138f67f769fSSandeepa Singh <b-input-group> 139f67f769fSSandeepa Singh <b-form-input 140f67f769fSSandeepa Singh id="input-ntp-1" 141f67f769fSSandeepa Singh v-model="form.ntp.firstAddress" 142de23ea23SSurya V :state="getValidationState(v$.form.ntp.firstAddress)" 143f67f769fSSandeepa Singh :disabled="manualOptionSelected" 144f67f769fSSandeepa Singh data-test-id="dateTime-input-ntpServer1" 145de23ea23SSurya V @blur="v$.form.ntp.firstAddress.$touch()" 146f67f769fSSandeepa Singh /> 147f67f769fSSandeepa Singh <b-form-invalid-feedback role="alert"> 1481b89e594SSurya Venkatesan <div v-if="v$.form.ntp.firstAddress.required.$invalid"> 149f67f769fSSandeepa Singh {{ $t('global.form.fieldRequired') }} 150f67f769fSSandeepa Singh </div> 151f67f769fSSandeepa Singh </b-form-invalid-feedback> 152f67f769fSSandeepa Singh </b-input-group> 153f67f769fSSandeepa Singh </b-form-group> 154f67f769fSSandeepa Singh </b-col> 155f67f769fSSandeepa Singh <b-col sm="6" lg="4" xl="3"> 156f67f769fSSandeepa Singh <b-form-group 157f67f769fSSandeepa Singh :label="$t('pageDateTime.form.ntpServers.server2')" 158f67f769fSSandeepa Singh label-for="input-ntp-2" 159f67f769fSSandeepa Singh > 160f67f769fSSandeepa Singh <b-input-group> 161f67f769fSSandeepa Singh <b-form-input 162f67f769fSSandeepa Singh id="input-ntp-2" 163f67f769fSSandeepa Singh v-model="form.ntp.secondAddress" 164f67f769fSSandeepa Singh :disabled="manualOptionSelected" 165f67f769fSSandeepa Singh data-test-id="dateTime-input-ntpServer2" 166f67f769fSSandeepa Singh /> 167f67f769fSSandeepa Singh </b-input-group> 168f67f769fSSandeepa Singh </b-form-group> 169f67f769fSSandeepa Singh </b-col> 170f67f769fSSandeepa Singh <b-col sm="6" lg="4" xl="3"> 171f67f769fSSandeepa Singh <b-form-group 172f67f769fSSandeepa Singh :label="$t('pageDateTime.form.ntpServers.server3')" 173f67f769fSSandeepa Singh label-for="input-ntp-3" 174f67f769fSSandeepa Singh > 175f67f769fSSandeepa Singh <b-input-group> 176f67f769fSSandeepa Singh <b-form-input 177f67f769fSSandeepa Singh id="input-ntp-3" 178f67f769fSSandeepa Singh v-model="form.ntp.thirdAddress" 179f67f769fSSandeepa Singh :disabled="manualOptionSelected" 180f67f769fSSandeepa Singh data-test-id="dateTime-input-ntpServer3" 181f67f769fSSandeepa Singh /> 182f67f769fSSandeepa Singh </b-input-group> 183f67f769fSSandeepa Singh </b-form-group> 184f67f769fSSandeepa Singh </b-col> 185f67f769fSSandeepa Singh </b-row> 186f67f769fSSandeepa Singh <b-button 187f67f769fSSandeepa Singh variant="primary" 188f67f769fSSandeepa Singh type="submit" 189f67f769fSSandeepa Singh data-test-id="dateTime-button-saveSettings" 190f67f769fSSandeepa Singh > 191f67f769fSSandeepa Singh {{ $t('global.action.saveSettings') }} 192f67f769fSSandeepa Singh </b-button> 193f67f769fSSandeepa Singh </b-form-group> 194f67f769fSSandeepa Singh </b-form> 195f67f769fSSandeepa Singh </page-section> 196f67f769fSSandeepa Singh </b-container> 197f67f769fSSandeepa Singh</template> 198f67f769fSSandeepa Singh 199f67f769fSSandeepa Singh<script> 200f67f769fSSandeepa Singhimport Alert from '@/components/Global/Alert'; 201f67f769fSSandeepa Singhimport IconCalendar from '@carbon/icons-vue/es/calendar/20'; 202f67f769fSSandeepa Singhimport PageTitle from '@/components/Global/PageTitle'; 203f67f769fSSandeepa Singhimport PageSection from '@/components/Global/PageSection'; 204f67f769fSSandeepa Singh 205f67f769fSSandeepa Singhimport BVToastMixin from '@/components/Mixins/BVToastMixin'; 206f67f769fSSandeepa Singhimport LoadingBarMixin, { loading } from '@/components/Mixins/LoadingBarMixin'; 207f67f769fSSandeepa Singhimport LocalTimezoneLabelMixin from '@/components/Mixins/LocalTimezoneLabelMixin'; 208f67f769fSSandeepa Singhimport VuelidateMixin from '@/components/Mixins/VuelidateMixin.js'; 2097d6b44cbSEd Tanousimport { useVuelidate } from '@vuelidate/core'; 210f67f769fSSandeepa Singh 211f67f769fSSandeepa Singhimport { mapState } from 'vuex'; 2121b89e594SSurya Venkatesanimport { requiredIf } from '@vuelidate/validators'; 2131b89e594SSurya Venkatesanimport { helpers } from 'vuelidate/lib/validators'; 214de23ea23SSurya Vimport { useI18n } from 'vue-i18n'; 215f67f769fSSandeepa Singh 216*b2ca5a5aSHuy Le Anhconst isoDateRegex = /([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$)/; 217f67f769fSSandeepa Singhconst isoTimeRegex = /^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/; 218f67f769fSSandeepa Singh 219f67f769fSSandeepa Singhexport default { 220f67f769fSSandeepa Singh name: 'DateTime', 221f67f769fSSandeepa Singh components: { Alert, IconCalendar, PageTitle, PageSection }, 222f67f769fSSandeepa Singh mixins: [ 223f67f769fSSandeepa Singh BVToastMixin, 224f67f769fSSandeepa Singh LoadingBarMixin, 225f67f769fSSandeepa Singh LocalTimezoneLabelMixin, 226f67f769fSSandeepa Singh VuelidateMixin, 227f67f769fSSandeepa Singh ], 228f67f769fSSandeepa Singh beforeRouteLeave(to, from, next) { 229f67f769fSSandeepa Singh this.hideLoader(); 230f67f769fSSandeepa Singh next(); 231f67f769fSSandeepa Singh }, 2327d6b44cbSEd Tanous setup() { 2337d6b44cbSEd Tanous return { 2347d6b44cbSEd Tanous v$: useVuelidate(), 2357d6b44cbSEd Tanous }; 2367d6b44cbSEd Tanous }, 237f67f769fSSandeepa Singh data() { 238f67f769fSSandeepa Singh return { 239de23ea23SSurya V $t: useI18n().t, 240f67f769fSSandeepa Singh locale: this.$store.getters['global/languagePreference'], 241f67f769fSSandeepa Singh form: { 242f67f769fSSandeepa Singh configurationSelected: 'manual', 243f67f769fSSandeepa Singh manual: { 244f67f769fSSandeepa Singh date: '', 245f67f769fSSandeepa Singh time: '', 246f67f769fSSandeepa Singh }, 247f67f769fSSandeepa Singh ntp: { firstAddress: '', secondAddress: '', thirdAddress: '' }, 248f67f769fSSandeepa Singh }, 249f67f769fSSandeepa Singh loading, 250f67f769fSSandeepa Singh }; 251f67f769fSSandeepa Singh }, 252f67f769fSSandeepa Singh validations() { 253f67f769fSSandeepa Singh return { 254f67f769fSSandeepa Singh form: { 255f67f769fSSandeepa Singh manual: { 256f67f769fSSandeepa Singh date: { 257f67f769fSSandeepa Singh required: requiredIf(function () { 258f67f769fSSandeepa Singh return this.form.configurationSelected === 'manual'; 259f67f769fSSandeepa Singh }), 260f67f769fSSandeepa Singh pattern: helpers.regex('pattern', isoDateRegex), 261f67f769fSSandeepa Singh }, 262f67f769fSSandeepa Singh time: { 263f67f769fSSandeepa Singh required: requiredIf(function () { 264f67f769fSSandeepa Singh return this.form.configurationSelected === 'manual'; 265f67f769fSSandeepa Singh }), 266f67f769fSSandeepa Singh pattern: helpers.regex('pattern', isoTimeRegex), 267f67f769fSSandeepa Singh }, 268f67f769fSSandeepa Singh }, 269f67f769fSSandeepa Singh ntp: { 270f67f769fSSandeepa Singh firstAddress: { 271f67f769fSSandeepa Singh required: requiredIf(function () { 272f67f769fSSandeepa Singh return this.form.configurationSelected === 'ntp'; 273f67f769fSSandeepa Singh }), 274f67f769fSSandeepa Singh }, 275f67f769fSSandeepa Singh }, 276f67f769fSSandeepa Singh }, 277f67f769fSSandeepa Singh }; 278f67f769fSSandeepa Singh }, 279f67f769fSSandeepa Singh computed: { 280f67f769fSSandeepa Singh ...mapState('dateTime', ['ntpServers', 'isNtpProtocolEnabled']), 281f67f769fSSandeepa Singh bmcTime() { 282f67f769fSSandeepa Singh return this.$store.getters['global/bmcTime']; 283f67f769fSSandeepa Singh }, 284f67f769fSSandeepa Singh ntpOptionSelected() { 285f67f769fSSandeepa Singh return this.form.configurationSelected === 'ntp'; 286f67f769fSSandeepa Singh }, 287f67f769fSSandeepa Singh manualOptionSelected() { 288f67f769fSSandeepa Singh return this.form.configurationSelected === 'manual'; 289f67f769fSSandeepa Singh }, 290f67f769fSSandeepa Singh isUtcDisplay() { 291f67f769fSSandeepa Singh return this.$store.getters['global/isUtcDisplay']; 292f67f769fSSandeepa Singh }, 293f67f769fSSandeepa Singh timezone() { 294f67f769fSSandeepa Singh if (this.isUtcDisplay) { 295f67f769fSSandeepa Singh return 'UTC'; 296f67f769fSSandeepa Singh } 297f67f769fSSandeepa Singh return this.localOffset(); 298f67f769fSSandeepa Singh }, 299f67f769fSSandeepa Singh }, 300f67f769fSSandeepa Singh watch: { 301f67f769fSSandeepa Singh ntpServers() { 302f67f769fSSandeepa Singh this.setNtpValues(); 303f67f769fSSandeepa Singh }, 304f67f769fSSandeepa Singh manualDate() { 305f67f769fSSandeepa Singh this.emitChange(); 306f67f769fSSandeepa Singh }, 307f67f769fSSandeepa Singh bmcTime() { 308de23ea23SSurya V this.form.manual.date = this.$filters.formatDate( 3098132399cSEd Tanous this.$store.getters['global/bmcTime'], 310f67f769fSSandeepa Singh ); 311de23ea23SSurya V this.form.manual.time = this.$filters 312f67f769fSSandeepa Singh .formatTime(this.$store.getters['global/bmcTime']) 313f67f769fSSandeepa Singh .slice(0, 5); 314f67f769fSSandeepa Singh }, 315f67f769fSSandeepa Singh }, 316f67f769fSSandeepa Singh created() { 317f67f769fSSandeepa Singh this.startLoader(); 318f67f769fSSandeepa Singh this.setNtpValues(); 319f67f769fSSandeepa Singh Promise.all([ 320f67f769fSSandeepa Singh this.$store.dispatch('global/getBmcTime'), 321f67f769fSSandeepa Singh this.$store.dispatch('dateTime/getNtpData'), 322f67f769fSSandeepa Singh ]).finally(() => this.endLoader()); 323f67f769fSSandeepa Singh }, 324f67f769fSSandeepa Singh methods: { 325f67f769fSSandeepa Singh emitChange() { 326de23ea23SSurya V if (this.v$.$invalid) return; 327de23ea23SSurya V this.v$.$reset(); //reset to re-validate on blur 328f67f769fSSandeepa Singh this.$emit('change', { 329f67f769fSSandeepa Singh manualDate: this.manualDate ? new Date(this.manualDate) : null, 330f67f769fSSandeepa Singh }); 331f67f769fSSandeepa Singh }, 332f67f769fSSandeepa Singh setNtpValues() { 333f67f769fSSandeepa Singh this.form.configurationSelected = this.isNtpProtocolEnabled 334f67f769fSSandeepa Singh ? 'ntp' 335f67f769fSSandeepa Singh : 'manual'; 336f67f769fSSandeepa Singh [ 337f67f769fSSandeepa Singh this.form.ntp.firstAddress = '', 338f67f769fSSandeepa Singh this.form.ntp.secondAddress = '', 339f67f769fSSandeepa Singh this.form.ntp.thirdAddress = '', 340f67f769fSSandeepa Singh ] = [this.ntpServers[0], this.ntpServers[1], this.ntpServers[2]]; 341f67f769fSSandeepa Singh }, 342f67f769fSSandeepa Singh submitForm() { 343de23ea23SSurya V this.v$.$touch(); 344de23ea23SSurya V if (this.v$.$invalid) return; 345f67f769fSSandeepa Singh this.startLoader(); 346f67f769fSSandeepa Singh 347f67f769fSSandeepa Singh let dateTimeForm = {}; 348f67f769fSSandeepa Singh let isNTPEnabled = this.form.configurationSelected === 'ntp'; 349f67f769fSSandeepa Singh 350f67f769fSSandeepa Singh if (!isNTPEnabled) { 351f67f769fSSandeepa Singh const isUtcDisplay = this.$store.getters['global/isUtcDisplay']; 352f67f769fSSandeepa Singh let date; 353f67f769fSSandeepa Singh 354f67f769fSSandeepa Singh dateTimeForm.ntpProtocolEnabled = false; 355f67f769fSSandeepa Singh 356f67f769fSSandeepa Singh if (isUtcDisplay) { 357f67f769fSSandeepa Singh // Create UTC Date 358f67f769fSSandeepa Singh date = this.getUtcDate(this.form.manual.date, this.form.manual.time); 359f67f769fSSandeepa Singh } else { 360f67f769fSSandeepa Singh // Create local Date 361f67f769fSSandeepa Singh date = new Date(`${this.form.manual.date} ${this.form.manual.time}`); 362f67f769fSSandeepa Singh } 363f67f769fSSandeepa Singh 364f67f769fSSandeepa Singh dateTimeForm.updatedDateTime = date.toISOString(); 365f67f769fSSandeepa Singh } else { 366f67f769fSSandeepa Singh dateTimeForm.ntpProtocolEnabled = true; 367f67f769fSSandeepa Singh 36884ec88f9SKenneth const ntpArray = [ 369f67f769fSSandeepa Singh this.form.ntp.firstAddress, 370f67f769fSSandeepa Singh this.form.ntp.secondAddress, 371f67f769fSSandeepa Singh this.form.ntp.thirdAddress, 372f67f769fSSandeepa Singh ]; 37384ec88f9SKenneth 37484ec88f9SKenneth // Filter the ntpArray to remove empty strings, 37584ec88f9SKenneth // per Redfish spec there should be no empty strings or null on the ntp array. 37684ec88f9SKenneth const ntpArrayFiltered = ntpArray.filter((x) => x); 37784ec88f9SKenneth 37884ec88f9SKenneth dateTimeForm.ntpServersArray = [...ntpArrayFiltered]; 37984ec88f9SKenneth 38084ec88f9SKenneth [this.ntpServers[0], this.ntpServers[1], this.ntpServers[2]] = [ 38184ec88f9SKenneth ...dateTimeForm.ntpServersArray, 38284ec88f9SKenneth ]; 38384ec88f9SKenneth 38484ec88f9SKenneth this.setNtpValues(); 385f67f769fSSandeepa Singh } 386f67f769fSSandeepa Singh 387f67f769fSSandeepa Singh this.$store 388f67f769fSSandeepa Singh .dispatch('dateTime/updateDateTime', dateTimeForm) 389f67f769fSSandeepa Singh .then((success) => { 390f67f769fSSandeepa Singh this.successToast(success); 391f67f769fSSandeepa Singh if (!isNTPEnabled) return; 392f67f769fSSandeepa Singh // Shift address up if second address is empty 393f67f769fSSandeepa Singh // to avoid refreshing after delay when updating NTP 394f67f769fSSandeepa Singh if (!this.form.ntp.secondAddress && this.form.ntp.thirdAddres) { 395f67f769fSSandeepa Singh this.form.ntp.secondAddress = this.form.ntp.thirdAddres; 396f67f769fSSandeepa Singh this.form.ntp.thirdAddress = ''; 397f67f769fSSandeepa Singh } 398f67f769fSSandeepa Singh }) 399f67f769fSSandeepa Singh .then(() => { 400f67f769fSSandeepa Singh this.$store.dispatch('global/getBmcTime'); 401f67f769fSSandeepa Singh }) 402f67f769fSSandeepa Singh .catch(({ message }) => this.errorToast(message)) 403f67f769fSSandeepa Singh .finally(() => { 404de23ea23SSurya V this.v$.form.$reset(); 405f67f769fSSandeepa Singh this.endLoader(); 406f67f769fSSandeepa Singh }); 407f67f769fSSandeepa Singh }, 408f67f769fSSandeepa Singh getUtcDate(date, time) { 409f67f769fSSandeepa Singh // Split user input string values to create 410f67f769fSSandeepa Singh // a UTC Date object 411f67f769fSSandeepa Singh const datesArray = date.split('-'); 412f67f769fSSandeepa Singh const timeArray = time.split(':'); 413f67f769fSSandeepa Singh let utcDate = Date.UTC( 414f67f769fSSandeepa Singh datesArray[0], // User input year 415f67f769fSSandeepa Singh //UTC expects zero-index month value 0-11 (January-December) 416f67f769fSSandeepa Singh //for reference https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC#Parameters 417f67f769fSSandeepa Singh parseInt(datesArray[1]) - 1, // User input month 418f67f769fSSandeepa Singh datesArray[2], // User input day 419f67f769fSSandeepa Singh timeArray[0], // User input hour 4208132399cSEd Tanous timeArray[1], // User input minute 421f67f769fSSandeepa Singh ); 422f67f769fSSandeepa Singh return new Date(utcDate); 423f67f769fSSandeepa Singh }, 424f67f769fSSandeepa Singh }, 425f67f769fSSandeepa Singh}; 426f67f769fSSandeepa Singh</script> 427