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 v-if="!modifySSHPolicyDisabled" 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  data() {
79    return {
80      modifySSHPolicyDisabled:
81        process.env.VUE_APP_MODIFY_SSH_POLICY_DISABLED === 'true',
82    };
83  },
84  computed: {
85    sshProtocolState: {
86      get() {
87        return this.$store.getters['policies/sshProtocolEnabled'];
88      },
89      set(newValue) {
90        return newValue;
91      },
92    },
93    ipmiProtocolState: {
94      get() {
95        return this.$store.getters['policies/ipmiProtocolEnabled'];
96      },
97      set(newValue) {
98        return newValue;
99      },
100    },
101  },
102  created() {
103    this.startLoader();
104    this.$store
105      .dispatch('policies/getNetworkProtocolStatus')
106      .finally(() => this.endLoader());
107  },
108  methods: {
109    changeIpmiProtocolState(state) {
110      this.$store
111        .dispatch('policies/saveIpmiProtocolState', state)
112        .then((message) => this.successToast(message))
113        .catch(({ message }) => this.errorToast(message));
114    },
115    changeSshProtocolState(state) {
116      this.$store
117        .dispatch('policies/saveSshProtocolState', state)
118        .then((message) => this.successToast(message))
119        .catch(({ message }) => this.errorToast(message));
120    },
121  },
122};
123</script>
124
125<style lang="scss" scoped>
126.setting-section {
127  border-bottom: 1px solid gray('300');
128}
129</style>
130