From 814d6fa0ab2c939a2c5abf0f1566bf6faa2253d0 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Sun, 31 Mar 2024 17:44:26 -0500 Subject: [PATCH] Refactoring requests made with axios to use dedicated request services --- assets/vue/components/StudentViewButton.vue | 12 +-- .../components/resource_links/EditLinks.vue | 83 +++++++------------ assets/vue/components/social/Actions.vue | 24 +++--- assets/vue/constants/entity/userreluser.js | 23 +++++ assets/vue/services/adminService.js | 10 +-- assets/vue/services/baseService.js | 69 ++++++++++++--- assets/vue/services/cToolIntroService.js | 33 ++++++++ assets/vue/services/courseRelUserService.js | 13 +++ assets/vue/services/courseService.js | 27 +++--- assets/vue/services/messageTagService.js | 26 ++++++ assets/vue/services/permissionService.js | 11 +++ assets/vue/services/resourceLinkService.js | 8 +- .../sessionRelCourseRelUserService.js | 13 +++ assets/vue/services/sessionRelUserService.js | 11 +-- assets/vue/services/sessionService.js | 12 ++- assets/vue/services/socialService.js | 23 +++++ assets/vue/services/userRelUserService.js | 50 +++++++++++ assets/vue/services/userService.js | 31 +++++++ assets/vue/services/usergroupService.js | 60 ++++++++++---- assets/vue/store/cidReq.js | 8 +- .../ccalendarevent/CCalendarEventList.vue | 2 +- assets/vue/views/ctoolintro/Create.vue | 27 +++--- assets/vue/views/ctoolintro/Update.vue | 12 ++- assets/vue/views/message/MessageCreate.vue | 32 ++----- assets/vue/views/message/MessageShow.vue | 24 ++---- assets/vue/views/usergroup/List.vue | 45 +++------- .../vue/views/userreluser/UserRelUserAdd.vue | 22 ++--- .../views/userreluser/UserRelUserSearch.vue | 22 ++--- 28 files changed, 476 insertions(+), 257 deletions(-) create mode 100644 assets/vue/constants/entity/userreluser.js create mode 100644 assets/vue/services/cToolIntroService.js create mode 100644 assets/vue/services/courseRelUserService.js create mode 100644 assets/vue/services/messageTagService.js create mode 100644 assets/vue/services/permissionService.js create mode 100644 assets/vue/services/sessionRelCourseRelUserService.js create mode 100644 assets/vue/services/userRelUserService.js create mode 100644 assets/vue/services/userService.js diff --git a/assets/vue/components/StudentViewButton.vue b/assets/vue/components/StudentViewButton.vue index 3dfd9e6480..db9acee187 100644 --- a/assets/vue/components/StudentViewButton.vue +++ b/assets/vue/components/StudentViewButton.vue @@ -15,10 +15,10 @@ import { computed } from "vue" import { useI18n } from "vue-i18n" import { useStore } from "vuex" import { usePlatformConfig } from "../store/platformConfig" -import axios from "axios" import { storeToRefs } from "pinia" import { useCidReqStore } from "../store/cidReq" import { useSecurityStore } from "../store/securityStore" +import permissionService from "../services/permissionService" const emit = defineEmits(["change"]) @@ -30,15 +30,11 @@ const securityStore = useSecurityStore() const isStudentView = computed({ async set() { - try { - const { data } = await axios.get(`${window.location.origin}/toggle_student_view`) + const studentView = await permissionService.toogleStudentView() - platformConfigStore.studentView = data + platformConfigStore.studentView = studentView - emit("change", data) - } catch (e) { - console.log(e) - } + emit("change", studentView) }, get() { return platformConfigStore.isStudentViewActive diff --git a/assets/vue/components/resource_links/EditLinks.vue b/assets/vue/components/resource_links/EditLinks.vue index 76daf00ceb..565e1cc0a2 100644 --- a/assets/vue/components/resource_links/EditLinks.vue +++ b/assets/vue/components/resource_links/EditLinks.vue @@ -27,12 +27,17 @@