Skip to content

Commit

Permalink
refactor: use index file for types, utils, enums and api services
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin-Guillemin committed Aug 30, 2024
1 parent 6fd0cc1 commit 3a96ffc
Show file tree
Hide file tree
Showing 48 changed files with 185 additions and 101 deletions.
2 changes: 1 addition & 1 deletion src/main/webapp/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<script setup lang="ts">
import LoginDialog from '@/components/dialogs/LoginDialog.vue';
import SettingsDialog from '@/components/dialogs/SettingsDialog.vue';
import { useAppStore, useConfigurationStore, useFileStore, useHomeStore } from '@/stores/index.ts';
import { useAppStore, useConfigurationStore, useFileStore, useHomeStore } from '@/stores';
import { watchOnce } from '@vueuse/core';
import { storeToRefs } from 'pinia';
import { useRouter } from 'vue-router';
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/src/components/BottomNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
-->

<script setup lang="ts">
import { useFileStore } from '@/stores/index.ts';
import { useFileStore } from '@/stores';
import { useI18n } from 'vue-i18n';
import { useDisplay } from 'vuetify';

Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/src/components/DurationSpan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
-->

<script setup lang="ts">
import { dateToDuration, formatedDuration } from '@/utils/dateFnsUtils.ts';
import { dateToDuration, formatedDuration } from '@/utils';
import { onUnmounted, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';

Expand Down
7 changes: 3 additions & 4 deletions src/main/webapp/src/components/FileMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
-->

<script setup lang="ts">
import { useAppStore, useConfigurationStore, useFileStore, useHomeStore } from '@/stores/index.ts';
import { Tabs } from '@/types/enums/Tabs.ts';
import { downloadFileOrBlob, toFile } from '@/utils/fileUtils.ts';
import { saveOnNextcloud } from '@/utils/nextcloudUtils.ts';
import { useAppStore, useConfigurationStore, useFileStore, useHomeStore } from '@/stores';
import { Tabs } from '@/types/enums';
import { downloadFileOrBlob, saveOnNextcloud, toFile } from '@/utils';
import { storeToRefs } from 'pinia';
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
-->

<script setup lang="ts">
import type { Confirmation } from '@/types/confirmationType.ts';
import type { Confirmation } from '@/types';
import { useI18n } from 'vue-i18n';

const { t } = useI18n();
Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/src/components/dialogs/FileDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
-->

<script setup lang="ts">
import { saveFile } from '@/services/api/fileService.ts';
import { useConfigurationStore, useFileStore, useHomeStore } from '@/stores/index.ts';
import { errorHandler } from '@/utils/axiosUtils.ts';
import { saveFile } from '@/services/api';
import { useConfigurationStore, useFileStore, useHomeStore } from '@/stores';
import { errorHandler } from '@/utils';
import debounce from 'lodash.debounce';
import { storeToRefs } from 'pinia';
import { computed, ref } from 'vue';
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/src/components/dialogs/LoginDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
-->

<script setup lang="ts">
import { useConfigurationStore } from '@/stores/index.ts';
import { initToken } from '@/utils/axiosUtils.ts';
import { useConfigurationStore } from '@/stores';
import { initToken } from '@/utils';
import debounce from 'lodash.debounce';
import { storeToRefs } from 'pinia';
import { computed, onMounted, ref } from 'vue';
Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/src/components/dialogs/RoomDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
-->

<script setup lang="ts">
import { useAppStore, useConfigurationStore, useHomeStore } from '@/stores/index.ts';
import type { RoomAction } from '@/types/roomActionType.ts';
import { charOTP } from '@/utils/stringUtils.ts';
import { useAppStore, useConfigurationStore, useHomeStore } from '@/stores';
import type { RoomAction } from '@/types';
import { charOTP } from '@/utils';
import debounce from 'lodash.debounce';
import { storeToRefs } from 'pinia';
import { computed, ref } from 'vue';
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/src/components/dialogs/SettingsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
-->

<script setup lang="ts">
import { useConfigurationStore } from '@/stores/index.ts';
import { Theme } from '@/types/enums/Theme.ts';
import { useConfigurationStore } from '@/stores';
import { Theme } from '@/types/enums';
import { usePreferredDark, useSessionStorage } from '@vueuse/core';
import { storeToRefs } from 'pinia';
import { computed, watch } from 'vue';
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/src/components/dialogs/ShareInRoomDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
-->

<script setup lang="ts">
import { useAppStore, useFileStore, useHomeStore } from '@/stores/index.ts';
import { charOTP } from '@/utils/stringUtils.ts';
import { useAppStore, useFileStore, useHomeStore } from '@/stores';
import { charOTP } from '@/utils';
import debounce from 'lodash.debounce';
import { storeToRefs } from 'pinia';
import { computed, ref } from 'vue';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
-->

<script setup lang="ts">
import { useConfigurationStore, useFileStore } from '@/stores/index.ts';
import { useConfigurationStore, useFileStore } from '@/stores';
import { storeToRefs } from 'pinia';
import { useI18n } from 'vue-i18n';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import ShareInRoomDialog from '@/components/dialogs/ShareInRoomDialog.vue';
import HistoriesTab from '@/components/drawers/information/tabs/HistoriesTab.vue';
import InformationTab from '@/components/drawers/information/tabs/InformationTab.vue';
import ShareTab from '@/components/drawers/information/tabs/ShareTab.vue';
import { useFileStore, useHomeStore } from '@/stores/index.ts';
import { Tabs } from '@/types/enums/Tabs.ts';
import { useFileStore, useHomeStore } from '@/stores';
import { Tabs } from '@/types/enums';
import debounce from 'lodash.debounce';
import { storeToRefs } from 'pinia';
import { computed, ref, watch } from 'vue';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
-->

<script setup lang="ts">
import { useFileStore } from '@/stores/index.ts';
import { useFileStore } from '@/stores';
import { format } from 'date-fns';
import { storeToRefs } from 'pinia';
import { useI18n } from 'vue-i18n';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
-->

<script setup lang="ts">
import { setFile } from '@/services/api/fileService.ts';
import { useFileStore, useHomeStore } from '@/stores/index.ts';
import type { FileBody } from '@/types/fileBodyType.ts';
import { errorHandler } from '@/utils/axiosUtils.ts';
import { setFile } from '@/services/api';
import { useFileStore, useHomeStore } from '@/stores';
import type { FileBody } from '@/types';
import { errorHandler } from '@/utils';
import { format } from 'date-fns';
import { storeToRefs } from 'pinia';
import { computed, onMounted, ref, watch } from 'vue';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
-->

<script setup lang="ts">
import { useFileStore, useHomeStore } from '@/stores/index.ts';
import type { Collaboration } from '@/types/collaborationType.ts';
import { Role, getRole } from '@/types/enums/Role.ts';
import { useFileStore, useHomeStore } from '@/stores';
import type { Collaboration } from '@/types';
import { Role, getRole } from '@/types/enums';
import { storeToRefs } from 'pinia';
import { ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/src/components/layouts/FilesLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<script setup lang="ts">
import DurationSpan from '@/components/DurationSpan.vue';
import FileMenu from '@/components/FileMenu.vue';
import { useHomeStore } from '@/stores/index.ts';
import type { File } from '@/types/fileType.ts';
import { useHomeStore } from '@/stores';
import type { File } from '@/types';
import { useSessionStorage } from '@vueuse/core';
import { storeToRefs } from 'pinia';
import { ref, watch } from 'vue';
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import 'regenerator-runtime/runtime.js';

import { createApp } from 'vue';

import { register as registerDirectives } from '@/directives/index.ts';
import { register as registerDirectives } from '@/directives';
import { register as registerFontAwsome } from '@/plugins/fontawsome.ts';
import '@/plugins/date-fns.ts';
import i18n from '@/plugins/i18n.ts';
import pinia from '@/plugins/pinia.ts';
import vuetify from '@/plugins/vuetify.ts';
import router from '@/router/index.ts';
import router from '@/router';
import Vue3Toasity, { type ToastContainerOptions } from 'vue3-toastify';

import 'vuetify/styles';
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/src/plugins/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as messages from '@/locales/index.ts';
import * as messages from '@/locales';
import { createI18n } from 'vue-i18n';

const config: {
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/src/plugins/pinia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { useAppStore, useConfigurationStore, useFileStore, useHomeStore } from '@/stores/index.ts';
import { useAppStore, useConfigurationStore, useFileStore, useHomeStore } from '@/stores';
import { acceptHMRUpdate, createPinia } from 'pinia';

if (import.meta.hot) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/src/plugins/vuetify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
import i18n from '@/plugins/i18n.ts';
import { Theme } from '@/types/enums/Theme.ts';
import { Theme } from '@/types/enums';
import DateFnsAdapter from '@date-io/date-fns';
import { enUS, fr } from 'date-fns/locale';
import { useI18n } from 'vue-i18n';
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Navigation } from '@/types/enums/Navigation.ts';
import { redirect } from '@/utils/routerUtils.ts';
import { Navigation } from '@/types/enums';
import { redirect } from '@/utils';
import { createRouter, createWebHistory } from 'vue-router';

const router = createRouter({
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/src/services/api/configurationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { instance as axios } from '@/utils/axiosUtils.ts';
import { axiosInstance as axios } from '@/utils';

const getConfiguration = async () => await axios.get('/api/config');

Expand Down
7 changes: 2 additions & 5 deletions src/main/webapp/src/services/api/fileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { CollaborationBody } from '@/types/collaborationBodyType.ts';
import type { FileBody } from '@/types/fileBodyType.ts';
import type { HistoryBody } from '@/types/historyBodyType.ts';
import type { MetadataBody } from '@/types/metadataBodyType.ts';
import { instance as axios } from '@/utils/axiosUtils.ts';
import type { CollaborationBody, FileBody, HistoryBody, MetadataBody } from '@/types';
import { axiosInstance as axios } from '@/utils';

const getFiles = async () => await axios.get('/api/file');

Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/src/services/api/handshakeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { instance as axios } from '@/utils/axiosUtils.ts';
import { axiosInstance as axios } from '@/utils';

const handshake = async () => await axios.get('/api/handshake');

Expand Down
20 changes: 20 additions & 0 deletions src/main/webapp/src/services/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright (C) 2023 GIP-RECIA, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export * from './configurationService.ts';
export * from './fileService.ts';
export * from './handshakeService.ts';
export * from './nextcloudService.ts';
2 changes: 1 addition & 1 deletion src/main/webapp/src/services/api/nextcloudService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { instance as axios } from '@/utils/nextcloudUtils.ts';
import { ncInstance as axios } from '@/utils';

const getNcFile = async (userID: string, fileUri: string) => await axios.get(`${userID}/${fileUri}`);

Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/src/stores/appStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import { useConfigurationStore } from './configurationStore.ts';
import { useFileStore } from './fileStore.ts';
import { interpolate } from '@/utils/stringUtils.ts';
import { interpolate } from '@/utils';
import { useSessionStorage } from '@vueuse/core';
import { defineStore, storeToRefs } from 'pinia';
import { computed, readonly, ref } from 'vue';
Expand Down
10 changes: 3 additions & 7 deletions src/main/webapp/src/stores/configurationStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { getConfiguration } from '@/services/api/configurationService.ts';
import type { AssociatedApp } from '@/types/associatedAppType.ts';
import type { Configuration } from '@/types/configurationType.ts';
import type { Soffit } from '@/types/soffitType.ts';
import { errorHandler, initToken } from '@/utils/axiosUtils.ts';
import { useEntTheme } from '@/utils/entUtils.ts';
import { setNextcloudUri } from '@/utils/nextcloudUtils.ts';
import { getConfiguration } from '@/services/api';
import type { AssociatedApp, Configuration, Soffit } from '@/types';
import { errorHandler, initToken, setNextcloudUri, useEntTheme } from '@/utils';
import { initAppsRoutes } from '@/utils/routerUtils.ts';
import { defineStore } from 'pinia';
import { computed, ref, watch } from 'vue';
Expand Down
9 changes: 4 additions & 5 deletions src/main/webapp/src/stores/fileStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
* limitations under the License.
*/
import { useConfigurationStore } from './configurationStore.ts';
import { getFile, getFiles, getPublic, getShared, getStarred } from '@/services/api/fileService.ts';
import { Navigation } from '@/types/enums/Navigation.ts';
import type { FileBody } from '@/types/fileBodyType.ts';
import type { File } from '@/types/fileType.ts';
import { errorHandler } from '@/utils/axiosUtils.ts';
import { getFile, getFiles, getPublic, getShared, getStarred } from '@/services/api';
import type { File, FileBody } from '@/types';
import { Navigation } from '@/types/enums';
import { errorHandler } from '@/utils';
import { differenceInMilliseconds } from 'date-fns';
import debounce from 'lodash.debounce';
import { defineStore, storeToRefs } from 'pinia';
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/src/stores/homeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
import { useFileStore } from './fileStore.ts';
import { Tabs } from '@/types/enums/Tabs.ts';
import { Tabs } from '@/types/enums';
import { useSessionStorage } from '@vueuse/core';
import { defineStore, storeToRefs } from 'pinia';
import { computed, ref } from 'vue';
Expand Down
8 changes: 4 additions & 4 deletions src/main/webapp/src/stores/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

export { useAppStore } from './appStore.ts';
export { useConfigurationStore } from './configurationStore.ts';
export { useFileStore } from './fileStore.ts';
export { useHomeStore } from './homeStore.ts';
export * from './appStore.ts';
export * from './configurationStore.ts';
export * from './fileStore.ts';
export * from './homeStore.ts';
2 changes: 1 addition & 1 deletion src/main/webapp/src/types/collaborationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { User } from '@/types/userType.ts';
import type { User } from './userType.ts';

export type Collaboration = {
user: User;
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/src/types/configurationType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { AssociatedApp } from '@/types/associatedAppType.ts';
import type { AssociatedApp } from './associatedAppType.ts';

export type Configuration = {
front: {
Expand Down
20 changes: 20 additions & 0 deletions src/main/webapp/src/types/enums/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright (C) 2023 GIP-RECIA, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export * from './Navigation.ts';
export * from './Role.ts';
export * from './Tabs.ts';
export * from './Theme.ts';
Loading

0 comments on commit 3a96ffc

Please sign in to comment.