Skip to content

Commit 13b1dba

Browse files
committed
Added DHCP NTP Servers list
- Added DHCP NTP Servers list on GUI - JIRA story- https://jsw.ibm.com/browse/PFEBMC-2786 Signed-off-by: Vedangi Mittal <vedangimittal3004@gmail.com>
1 parent a345287 commit 13b1dba

File tree

3 files changed

+92
-2
lines changed

3 files changed

+92
-2
lines changed

Diff for: src/locales/en-US.json

+1
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@
409409
"mfaMessage": "Changing date and time will affect MFA users."
410410
},
411411
"configureSettings": "Configure settings",
412+
"viewDhcpNtp": "View DHCP NTP servers",
412413
"form": {
413414
"date": "Date",
414415
"manual": "Manual",

Diff for: src/store/modules/Settings/DateTimeStore.js

+7
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ const DateTimeStore = {
66
state: {
77
ntpServers: [],
88
isNtpProtocolEnabled: null,
9+
networkSuppliedServers: [],
910
},
1011
getters: {
1112
ntpServers: (state) => state.ntpServers,
1213
isNtpProtocolEnabled: (state) => state.isNtpProtocolEnabled,
14+
networkSuppliedServers: (state) => state.networkSuppliedServers,
1315
},
1416
mutations: {
1517
setNtpServers: (state, ntpServers) => (state.ntpServers = ntpServers),
1618
setIsNtpProtocolEnabled: (state, isNtpProtocolEnabled) =>
1719
(state.isNtpProtocolEnabled = isNtpProtocolEnabled),
20+
setNetworkSuppliedServers: (state, networkSuppliedServers) =>
21+
(state.networkSuppliedServers = networkSuppliedServers),
1822
},
1923
actions: {
2024
async getNtpData({ commit }) {
@@ -23,8 +27,11 @@ const DateTimeStore = {
2327
.then((response) => {
2428
const ntpServers = response.data.NTP.NTPServers;
2529
const isNtpProtocolEnabled = response.data.NTP.ProtocolEnabled;
30+
const networkSuppliedServers =
31+
response.data.NTP.NetworkSuppliedServers;
2632
commit('setNtpServers', ntpServers);
2733
commit('setIsNtpProtocolEnabled', isNtpProtocolEnabled);
34+
commit('setNetworkSuppliedServers', networkSuppliedServers);
2835
})
2936
.catch((error) => {
3037
console.log(error);

Diff for: src/views/Settings/DateTime/DateTime.vue

+84-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,40 @@
3131
</b-col>
3232
</b-row>
3333
</page-section>
34+
<page-section v-show="show">
35+
<b-button v-b-toggle.collapse-dhcp-ntp variant="link" class="mt-3">
36+
<icon-chevron />
37+
{{ $t('pageDateTime.viewDhcpNtp') }}
38+
</b-button>
39+
40+
<b-collapse id="collapse-dhcp-ntp">
41+
<b-row
42+
v-for="(group, rowIndex) in chunkedDhcpNtp"
43+
:key="rowIndex"
44+
class="mt-3 ml-3"
45+
>
46+
<b-col
47+
v-for="(item, colIndex) in group"
48+
:key="colIndex"
49+
sm="6"
50+
lg="4"
51+
xl="3"
52+
>
53+
<b-form-group
54+
:label="`Server ${rowIndex * 3 + colIndex + 1}`"
55+
:label-for="`${colIndex + 1}`"
56+
>
57+
<b-form-input
58+
:id="`${colIndex + 1}`"
59+
class="custom-form-group"
60+
:disabled="true"
61+
:placeholder="item"
62+
/>
63+
</b-form-group>
64+
</b-col>
65+
</b-row>
66+
</b-collapse>
67+
</page-section>
3468
<page-section :section-title="$t('pageDateTime.configureSettings')">
3569
<b-row>
3670
<b-col md="8" xl="6">
@@ -237,6 +271,7 @@
237271
<script>
238272
import Alert from '@/components/Global/Alert';
239273
import IconCalendar from '@carbon/icons-vue/es/calendar/20';
274+
import IconChevron from '@carbon/icons-vue/es/chevron--up/20';
240275
import PageTitle from '@/components/Global/PageTitle';
241276
import PageSection from '@/components/Global/PageSection';
242277
@@ -253,7 +288,7 @@ const isoTimeRegex = /^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/;
253288
254289
export default {
255290
name: 'DateTime',
256-
components: { Alert, IconCalendar, PageTitle, PageSection },
291+
components: { Alert, IconCalendar, IconChevron, PageTitle, PageSection },
257292
mixins: [
258293
BVToastMixin,
259294
LoadingBarMixin,
@@ -276,6 +311,8 @@ export default {
276311
ntp: { firstAddress: '', secondAddress: '', thirdAddress: '' },
277312
},
278313
loading,
314+
show: false,
315+
dhcpNtp: [],
279316
};
280317
},
281318
validations() {
@@ -313,7 +350,11 @@ export default {
313350
};
314351
},
315352
computed: {
316-
...mapState('dateTime', ['ntpServers', 'isNtpProtocolEnabled']),
353+
...mapState('dateTime', [
354+
'ntpServers',
355+
'isNtpProtocolEnabled',
356+
'networkSuppliedServers',
357+
]),
317358
bmcTime() {
318359
return this.$store.getters['global/bmcTime'];
319360
},
@@ -343,6 +384,20 @@ export default {
343384
serverStatus() {
344385
return this.$store.getters['global/serverStatus'];
345386
},
387+
networkSuppliedServers() {
388+
this.$store.getters['dateTime/networkSuppliedServers'].map((server) =>
389+
this.dhcpNtp.push(server)
390+
);
391+
return this.dhcpNtp;
392+
},
393+
chunkedDhcpNtp() {
394+
const chunkSize = 3;
395+
const result = [];
396+
for (let i = 0; i < this.dhcpNtp.length; i += chunkSize) {
397+
result.push(this.dhcpNtp.slice(i, i + chunkSize));
398+
}
399+
return result;
400+
},
346401
},
347402
watch: {
348403
ntpServers() {
@@ -367,6 +422,7 @@ export default {
367422
this.$store.dispatch('dateTime/getNtpData'),
368423
this.$store.dispatch('userManagement/getAccountSettings'),
369424
]).finally(() => {
425+
this.showCollapse();
370426
this.setInitialNtpValues();
371427
this.endLoader();
372428
});
@@ -486,6 +542,32 @@ export default {
486542
);
487543
return new Date(utcDate);
488544
},
545+
showCollapse() {
546+
this.dhcpNtp.push('1.2.3.4');
547+
this.dhcpNtp.push('1.2.3.5');
548+
this.dhcpNtp.push('1.2.3.6');
549+
this.dhcpNtp.push('1.2.3.7');
550+
this.dhcpNtp.push('1.2.3.8');
551+
this.dhcpNtp.push('1.2.3.9');
552+
if (this.networkSuppliedServers.length == 0) {
553+
this.show = false;
554+
} else {
555+
this.show = true;
556+
}
557+
},
489558
},
490559
};
491560
</script>
561+
<style lang="scss" scoped>
562+
.btn.collapsed {
563+
svg {
564+
transform: rotate(180deg);
565+
}
566+
}
567+
.custom-form-group::placeholder {
568+
color: black !important;
569+
}
570+
li {
571+
list-style-type: none;
572+
}
573+
</style>

0 commit comments

Comments
 (0)