From e9a59c75670461a80156554a4dfa04bab5eaf42c Mon Sep 17 00:00:00 2001
From: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Date: Thu, 30 Apr 2020 12:16:30 -0700
Subject: Add loading bar to LDAP page

Signed-off-by: Yoshie Muranaka <yoshiemuranaka@gmail.com>
Change-Id: I19f34986e05298a42f1739632a5786d03371e47c
---
 src/views/AccessControl/Ldap/TableRoleGroups.vue | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

(limited to 'src/views/AccessControl/Ldap/TableRoleGroups.vue')

diff --git a/src/views/AccessControl/Ldap/TableRoleGroups.vue b/src/views/AccessControl/Ldap/TableRoleGroups.vue
index a851a033..63b73a2e 100644
--- a/src/views/AccessControl/Ldap/TableRoleGroups.vue
+++ b/src/views/AccessControl/Ldap/TableRoleGroups.vue
@@ -94,6 +94,7 @@ import TableRowAction from '@/components/Global/TableRowAction';
 import BVTableSelectableMixin from '@/components/Mixins/BVTableSelectableMixin';
 import BVToastMixin from '@/components/Mixins/BVToastMixin';
 import ModalAddRoleGroup from './ModalAddRoleGroup';
+import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
 
 export default {
   components: {
@@ -105,7 +106,7 @@ export default {
     TableRowAction,
     TableToolbar
   },
-  mixins: [BVTableSelectableMixin, BVToastMixin],
+  mixins: [BVTableSelectableMixin, BVToastMixin, LoadingBarMixin],
   data() {
     return {
       activeRoleGroup: null,
@@ -180,12 +181,14 @@ export default {
         )
         .then(deleteConfirmed => {
           if (deleteConfirmed) {
+            this.startLoader();
             this.$store
               .dispatch('ldap/deleteRoleGroup', {
                 roleGroups: this.selectedRows
               })
               .then(success => this.successToast(success))
-              .catch(({ message }) => this.errorToast(message));
+              .catch(({ message }) => this.errorToast(message))
+              .finally(() => this.endLoader());
           }
         });
     },
@@ -207,10 +210,12 @@ export default {
             )
             .then(deleteConfirmed => {
               if (deleteConfirmed) {
+                this.startLoader();
                 this.$store
                   .dispatch('ldap/deleteRoleGroup', { roleGroups: [row] })
                   .then(success => this.successToast(success))
-                  .catch(({ message }) => this.errorToast(message));
+                  .catch(({ message }) => this.errorToast(message))
+                  .finally(() => this.endLoader());
               }
             });
           break;
@@ -223,16 +228,19 @@ export default {
     saveRoleGroup({ addNew, groupName, groupPrivilege }) {
       this.activeRoleGroup = null;
       const data = { groupName, groupPrivilege };
+      this.startLoader();
       if (addNew) {
         this.$store
           .dispatch('ldap/addNewRoleGroup', data)
           .then(success => this.successToast(success))
-          .catch(({ message }) => this.errorToast(message));
+          .catch(({ message }) => this.errorToast(message))
+          .finally(() => this.endLoader());
       } else {
         this.$store
           .dispatch('ldap/saveRoleGroup', data)
           .then(success => this.successToast(success))
-          .catch(({ message }) => this.errorToast(message));
+          .catch(({ message }) => this.errorToast(message))
+          .finally(() => this.endLoader());
       }
     }
   }
-- 
cgit v1.2.3

