xref: /openbmc/webui-vue/src/views/SecurityAndAccess/Policies/Policies.vue (revision b440616c23b61166ae6d87839a70eec31bdca235)
1<template>
2  <b-container fluid="xl">
3    <page-title />
4    <b-row>
5      <b-col md="8">
6        <page-section :section-title="$t('pagePolicies.networkServices')">
7          <b-row class="setting-section">
8            <b-col class="d-flex align-items-center justify-content-between">
9              <dl class="mr-3 w-75">
10                <dt>{{ $t('pagePolicies.ssh') }}</dt>
11                <dd>
12                  {{ $t('pagePolicies.sshDescription') }}
13                </dd>
14              </dl>
15              <b-form-checkbox
16                id="sshSwitch"
17                v-model="sshProtocolState"
18                data-test-id="policies-toggle-bmcShell"
19                switch
20                @change="changeSshProtocolState"
21              >
22                <span class="sr-only">
23                  {{ $t('pagePolicies.ssh') }}
24                </span>
25                <span v-if="sshProtocolState">
26                  {{ $t('global.status.enabled') }}
27                </span>
28                <span v-else>{{ $t('global.status.disabled') }}</span>
29              </b-form-checkbox>
30            </b-col>
31          </b-row>
32          <b-row class="setting-section">
33            <b-col class="d-flex align-items-center justify-content-between">
34              <dl class="mt-3 mr-3 w-75">
35                <dt>{{ $t('pagePolicies.ipmi') }}</dt>
36                <dd>
37                  {{ $t('pagePolicies.ipmiDescription') }}
38                </dd>
39              </dl>
40              <b-form-checkbox
41                id="ipmiSwitch"
42                v-model="ipmiProtocolState"
43                data-test-id="polices-toggle-networkIpmi"
44                switch
45                @change="changeIpmiProtocolState"
46              >
47                <span class="sr-only">
48                  {{ $t('pagePolicies.ipmi') }}
49                </span>
50                <span v-if="ipmiProtocolState">
51                  {{ $t('global.status.enabled') }}
52                </span>
53                <span v-else>{{ $t('global.status.disabled') }}</span>
54              </b-form-checkbox>
55            </b-col>
56          </b-row>
57        </page-section>
58      </b-col>
59    </b-row>
60  </b-container>
61</template>
62
63<script>
64import PageSection from '@/components/Global/PageSection';
65import PageTitle from '@/components/Global/PageTitle';
66
67import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
68import BVToastMixin from '@/components/Mixins/BVToastMixin';
69
70export default {
71  name: 'Policies',
72  components: { PageTitle, PageSection },
73  mixins: [LoadingBarMixin, BVToastMixin],
74  beforeRouteLeave(to, from, next) {
75    this.hideLoader();
76    next();
77  },
78  computed: {
79    sshProtocolState: {
80      get() {
81        return this.$store.getters['policies/sshProtocolEnabled'];
82      },
83      set(newValue) {
84        return newValue;
85      },
86    },
87    ipmiProtocolState: {
88      get() {
89        return this.$store.getters['policies/ipmiProtocolEnabled'];
90      },
91      set(newValue) {
92        return newValue;
93      },
94    },
95  },
96  created() {
97    this.startLoader();
98    this.$store
99      .dispatch('policies/getNetworkProtocolStatus')
100      .finally(() => this.endLoader());
101  },
102  methods: {
103    changeIpmiProtocolState(state) {
104      this.$store
105        .dispatch('policies/saveIpmiProtocolState', state)
106        .then((message) => this.successToast(message))
107        .catch(({ message }) => this.errorToast(message));
108    },
109    changeSshProtocolState(state) {
110      this.$store
111        .dispatch('policies/saveSshProtocolState', state)
112        .then((message) => this.successToast(message))
113        .catch(({ message }) => this.errorToast(message));
114    },
115  },
116};
117</script>
118
119<style lang="scss" scoped>
120.setting-section {
121  border-bottom: 1px solid gray('300');
122}
123</style>
124