diff --git a/src/App.vue b/src/App.vue index 2be2852..be5c4d0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,6 +4,7 @@ + + +
+ +
@@ -102,9 +123,12 @@ refreshTokenValidity: -1, showAlert: true, alertMessage: 'NO MESSAGE PROVIDED', + message: 'NO MESSAGE PROVIDED', langs: ['de', 'en', 'es'], dismissSecs: 5, dismissCountDown: 0, + messageDismissSecs: 5, + messageDismissCountDown: 0, autoRenewSession: true, main_style: {} }; @@ -114,10 +138,31 @@ this.isLoading = false; this.dismissCountDown = this.dismissSecs; this.alertMessage = msg; + this.makeToast(msg, 'error') }, countDownChanged(dismissCountDown) { this.dismissCountDown = dismissCountDown; }, + showMessage(msg, dismissTime=null) { + this.isLoading = false; + if(dismissTime == null) this.messageDismissCountDown = this.messageDismissSecs; + else { + this.messageDismissSecs = dismissTime; + this.messageDismissCountDown = dismissTime; + } + if(typeof msg === 'object' && msg !== null){ + if("time" in msg) { + this.messageDismissCountDown = msg['time']; + this.messageDismissSecs = msg['time']; + } + if("msg" in msg) msg = msg['msg']; + } + this.message = msg; + this.makeToast(msg, 'info') + }, + messageCountDownChanged(dismissCountDown) { + this.messageDismissCountDown = dismissCountDown; + }, logout() { this.$store.dispatch('logout', {revokeRefreshToken: true}); @@ -130,6 +175,24 @@ this.$i18n.locale=lang; localize(lang); }, + makeToast(message, variant = null, hide_time=5000, title = null) { + if(title == null){ + let now = new Date(); + if(variant == null){ + title = this.$t('message from') + " " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds(); + } else { + title = this.$t(variant) + " (" + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds() + ")"; + } + } + if(variant === 'error') variant = 'danger'; + this.$bvToast.toast(message, { + title: title, + toaster: 'b-toaster-bottom-right', + autoHideDelay: hide_time, + variant: variant, + appendToast: false + }) + }, }, mounted() { EventBus.$on('failedLoadingRecorders', (msg) => { @@ -141,6 +204,12 @@ EventBus.$on('failedRefreshingToken', (msg) => { this.refreshFailed = true; }); + EventBus.$on('errorMessage', (msg)=> { + this.showErrorMessage(msg); + }) + EventBus.$on('normalMessage', (msg)=> { + this.showMessage(msg); + }) this.$nextTick(() => { window.setInterval(() => { const tokenValidity = getRemainingJwtValiditySeconds(this.$store.state.access_token); diff --git a/src/api/Repository.js b/src/api/Repository.js index ca281b9..c44b289 100644 --- a/src/api/Repository.js +++ b/src/api/Repository.js @@ -50,6 +50,9 @@ api.interceptors.response.use(function (response) { return response; }, function (error) { if (401 === error.response.status || 422 === error.response.status) { + if(store.getters.isAuthenticated){ // if 401 even though the token is valid, the user might have been deleted, etc. + store.dispatch('resetToken'); + } Vue.swal({ title: "Session Expired", text: "Your token/session has expired. Would you like to be redirected to the login page?", @@ -65,8 +68,11 @@ api.interceptors.response.use(function (response) { } }); } else { - console.error(error); - return Promise.reject(error); + //console.error(error); + //console.error(error.response); + console.error(error.response.data.message); + //return Promise.reject(error); + return Promise.reject(error.response); } }); diff --git a/src/api/userRepository.ts b/src/api/userRepository.ts index 9928b5e..81211b0 100644 --- a/src/api/userRepository.ts +++ b/src/api/userRepository.ts @@ -17,6 +17,10 @@ export default { return Repository.get(`${resource}/${userId}`); }, + deleteUser(userId: number) { + return Repository.delete(`${resource}/${userId}`); + }, + createUser(userData: any) { return Repository.post(`${resource}`, userData); }, diff --git a/src/components/Admin.vue b/src/components/Admin.vue index ac30a22..5d72e96 100644 --- a/src/components/Admin.vue +++ b/src/components/Admin.vue @@ -6,16 +6,16 @@

Admin Tools

{{ errorMsg }}

- {{ $t('group') }} + {{ $t('groups') }}
- {{ $t('user') }} + {{ $t('users') }}
- {{ $t('permission') }} + {{ $t('permissions') }}
-
+
diff --git a/src/components/Admin/Group.vue b/src/components/Admin/Group.vue index 5af605c..bf92967 100644 --- a/src/components/Admin/Group.vue +++ b/src/components/Admin/Group.vue @@ -1,250 +1,172 @@ - + diff --git a/src/components/Admin/Groups.vue b/src/components/Admin/Groups.vue new file mode 100644 index 0000000..8a07c33 --- /dev/null +++ b/src/components/Admin/Groups.vue @@ -0,0 +1,259 @@ + + + + + + diff --git a/src/components/Admin/Permission.vue b/src/components/Admin/Permission.vue index 42c5828..6f1773d 100644 --- a/src/components/Admin/Permission.vue +++ b/src/components/Admin/Permission.vue @@ -64,7 +64,7 @@ permission: {name: '', description: ''}, sortColumn: '', currentPage: 1, - elementsPerPage: 5, + elementsPerPage: 10, }; }, methods: { diff --git a/src/components/Admin/User.vue b/src/components/Admin/User.vue index 2c38637..2418674 100644 --- a/src/components/Admin/User.vue +++ b/src/components/Admin/User.vue @@ -23,7 +23,7 @@

{{ $t('role') }}: {{ user.role }}{{ $t('no specifc role') }}

+ v-else>{{ $t('no specific role') }}

{{ $t('groups') }}: {{ g.name }},

{{ $t('permissions') }}: