Add session timeout in Policies page

This patchset will provide the option to configure the session timeout
for the WebUI. The functionality will provide the below timeout options
to configure.
    1. 30 minutes
    2. 1 hour
    3. 2 hours
    4. 4 hours
    5. 8 hours
    6. 1 Day
For the API, redfish is having the following resource.
URL - /redfish/v1/SessionService
Method
    - GET (to get the configured timeout)
    - PATCH (to configure the timeout value)
Property - { "SessionTimeout": 1800 }

When the user idles up until the configured session timeout, after that
any API call from this session will get 401 status and the web UI will
gets logged out.

Change-Id: Ic7c6b4817e560ca4ceb983dc5e2af51f3ae08cf5
Signed-off-by: Kirankumar Ballapalli <kirankumarb@ami.com>
diff --git a/src/views/SecurityAndAccess/Policies/Policies.vue b/src/views/SecurityAndAccess/Policies/Policies.vue
index 1dc197c..3ebfee4 100644
--- a/src/views/SecurityAndAccess/Policies/Policies.vue
+++ b/src/views/SecurityAndAccess/Policies/Policies.vue
@@ -103,6 +103,30 @@
             </b-form-checkbox>
           </b-col>
         </b-row>
+        <b-row class="setting-section">
+          <b-col class="d-flex align-items-center justify-content-between">
+            <dl class="mt-3 mr-3 w-75">
+              <dt>{{ $t('pagePolicies.webSessionTimeOut') }}</dt>
+              <dd>
+                {{ $t('pagePolicies.webSessionTimeOutDescription') }}
+              </dd>
+            </dl>
+          </b-col>
+          <b-col lg="3" class="session-timeout">
+            <b-form-select
+              id="session-timeout-options"
+              v-model="sessionTimeoutState"
+              :options="sessionTimeOutOptions"
+              @change="saveSessionTimeoutValue"
+            >
+              <template #first>
+                <b-form-select-option :value="null" disabled>
+                  {{ $t('global.form.selectAnOption') }}
+                </b-form-select-option>
+              </template>
+            </b-form-select>
+          </b-col>
+        </b-row>
       </b-col>
     </b-row>
   </b-container>
@@ -126,6 +150,14 @@
     return {
       modifySSHPolicyDisabled:
         process.env.VUE_APP_MODIFY_SSH_POLICY_DISABLED === 'true',
+      sessionTimeOutOptions: [
+        { value: 1800, text: this.$t('pagePolicies.options.30minutes') },
+        { value: 3600, text: this.$t('pagePolicies.options.1hour') },
+        { value: 7200, text: this.$t('pagePolicies.options.2hours') },
+        { value: 14400, text: this.$t('pagePolicies.options.4hours') },
+        { value: 28800, text: this.$t('pagePolicies.options.8hours') },
+        { value: 86400, text: this.$t('pagePolicies.options.1day') },
+      ],
     };
   },
   computed: {
@@ -169,12 +201,21 @@
         return newValue;
       },
     },
+    sessionTimeoutState: {
+      get() {
+        return this.$store.getters['policies/getSessionTimeoutValue'];
+      },
+      set(newValue) {
+        return newValue;
+      },
+    },
   },
   created() {
     this.startLoader();
     Promise.all([
       this.$store.dispatch('policies/getBiosStatus'),
       this.$store.dispatch('policies/getNetworkProtocolStatus'),
+      this.$store.dispatch('policies/getSessionTimeout'),
     ]).finally(() => this.endLoader());
   },
   methods: {
@@ -202,6 +243,12 @@
         .then((message) => this.successToast(message))
         .catch(({ message }) => this.errorToast(message));
     },
+    saveSessionTimeoutValue(sessionTimeoutState) {
+      this.$store
+        .dispatch('policies/saveSessionTimeoutValue', sessionTimeoutState)
+        .then((message) => this.successToast(message))
+        .catch(({ message }) => this.errorToast(message));
+    },
   },
 };
 </script>
@@ -210,4 +257,7 @@
 .setting-section {
   border-bottom: 1px solid gray('300');
 }
+.session-timeout {
+  align-self: center;
+}
 </style>