From 8980f4c4c4c9c624290b7b319cc7b205e0e6cfb4 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Sat, 25 Jan 2025 18:08:31 +0100 Subject: [PATCH] Added contacts plugin into core. No more module federation at the moment, it does not seem very stable yet. --- docker-compose.yml | 12 +- docker/Dockerfile.dev | 1 - docker/Dockerfile.front.dev | 2 +- frontend/package.json | 1 - frontend/src/api/contacts.js | 28 + .../src/components/contacts/CategoryForm.vue | 106 +++ .../contacts/ContactCategoriesForm.vue | 78 ++ .../src/components/contacts/ContactForm.vue | 254 ++++++ .../src/components/contacts/ContactList.vue | 178 +++++ .../src/components/contacts/EmailField.vue | 65 ++ .../components/contacts/PhoneNumberField.vue | 60 ++ frontend/src/components/shared/AppsMenu.vue | 3 - frontend/src/components/shared/NavBar.vue | 16 +- frontend/src/components/shared/UserMenu.vue | 26 +- .../src/layouts/account/AccountLayout.vue | 33 + frontend/src/layouts/admin/AdminLayout.vue | 119 +++ .../src/layouts/connected/ConnectedLayout.vue | 147 +--- frontend/src/layouts/user/UserLayout.vue | 10 + frontend/src/router/index.js | 43 +- frontend/src/stores/auth.store.js | 4 +- frontend/src/stores/contacts.store.js | 20 + frontend/src/stores/global.store.js | 6 +- frontend/src/stores/index.js | 2 + frontend/src/stores/layout.store.js | 20 + frontend/src/views/contacts/AddressBook.vue | 89 +++ .../src/views/login/LoginCallbackView.vue | 6 +- frontend/vite.config.js | 20 +- frontend/yarn.lock | 744 ++++++------------ modoboa/contacts/__init__.py | 1 + modoboa/contacts/apps.py | 8 + modoboa/contacts/constants.py | 25 + modoboa/contacts/factories.py | 80 ++ modoboa/contacts/forms.py | 59 ++ modoboa/contacts/handlers.py | 65 ++ modoboa/contacts/importer/__init__.py | 35 + .../contacts/importer/backends/__init__.py | 58 ++ modoboa/contacts/importer/backends/outlook.py | 53 ++ modoboa/contacts/lib/__init__.py | 0 modoboa/contacts/lib/carddav.py | 423 ++++++++++ .../contacts/locale/br/LC_MESSAGES/django.po | 99 +++ .../contacts/locale/en/LC_MESSAGES/django.po | 93 +++ .../contacts/locale/es/LC_MESSAGES/django.po | 99 +++ .../contacts/locale/fr/LC_MESSAGES/django.po | 95 +++ .../contacts/locale/it/LC_MESSAGES/django.po | 99 +++ .../locale/pl_PL/LC_MESSAGES/django.po | 96 +++ modoboa/contacts/management/__init__.py | 0 .../contacts/management/commands/__init__.py | 0 .../management/commands/import_contacts.py | 59 ++ modoboa/contacts/migrations/0001_initial.py | 152 ++++ .../migrations/0002_auto_20180124_2311.py | 37 + .../migrations/0003_auto_20181005_1415.py | 63 ++ .../migrations/0004_auto_20181005_1415.py | 30 + .../migrations/0005_auto_20181005_1445.py | 25 + .../migrations/0006_alter_phonenumber_type.py | 29 + .../migrations/0007_alter_contact_address.py | 18 + modoboa/contacts/migrations/__init__.py | 0 modoboa/contacts/mocks.py | 117 +++ modoboa/contacts/models.py | 196 +++++ modoboa/contacts/serializers.py | 220 ++++++ modoboa/contacts/settings.py | 28 + .../modoboa_contacts/webpack-stats.json | 6 + modoboa/contacts/tasks.py | 106 +++ .../templates/modoboa_contacts/index.html | 30 + modoboa/contacts/test_data/outlook_export.csv | 2 + modoboa/contacts/test_data/unknown_export.csv | 2 + modoboa/contacts/tests.py | 399 ++++++++++ modoboa/contacts/urls.py | 14 + modoboa/contacts/viewsets.py | 112 +++ modoboa/core/api/v2/viewsets.py | 9 + modoboa/urls_api_v2.py | 1 + test_project/test_project/settings.py | 3 +- 71 files changed, 4432 insertions(+), 707 deletions(-) create mode 100644 frontend/src/api/contacts.js create mode 100644 frontend/src/components/contacts/CategoryForm.vue create mode 100644 frontend/src/components/contacts/ContactCategoriesForm.vue create mode 100644 frontend/src/components/contacts/ContactForm.vue create mode 100644 frontend/src/components/contacts/ContactList.vue create mode 100644 frontend/src/components/contacts/EmailField.vue create mode 100644 frontend/src/components/contacts/PhoneNumberField.vue delete mode 100644 frontend/src/components/shared/AppsMenu.vue create mode 100644 frontend/src/layouts/account/AccountLayout.vue create mode 100644 frontend/src/layouts/admin/AdminLayout.vue create mode 100644 frontend/src/layouts/user/UserLayout.vue create mode 100644 frontend/src/stores/contacts.store.js create mode 100644 frontend/src/stores/layout.store.js create mode 100644 frontend/src/views/contacts/AddressBook.vue create mode 100644 modoboa/contacts/__init__.py create mode 100644 modoboa/contacts/apps.py create mode 100644 modoboa/contacts/constants.py create mode 100644 modoboa/contacts/factories.py create mode 100644 modoboa/contacts/forms.py create mode 100644 modoboa/contacts/handlers.py create mode 100644 modoboa/contacts/importer/__init__.py create mode 100644 modoboa/contacts/importer/backends/__init__.py create mode 100644 modoboa/contacts/importer/backends/outlook.py create mode 100644 modoboa/contacts/lib/__init__.py create mode 100644 modoboa/contacts/lib/carddav.py create mode 100644 modoboa/contacts/locale/br/LC_MESSAGES/django.po create mode 100644 modoboa/contacts/locale/en/LC_MESSAGES/django.po create mode 100644 modoboa/contacts/locale/es/LC_MESSAGES/django.po create mode 100644 modoboa/contacts/locale/fr/LC_MESSAGES/django.po create mode 100644 modoboa/contacts/locale/it/LC_MESSAGES/django.po create mode 100644 modoboa/contacts/locale/pl_PL/LC_MESSAGES/django.po create mode 100644 modoboa/contacts/management/__init__.py create mode 100644 modoboa/contacts/management/commands/__init__.py create mode 100644 modoboa/contacts/management/commands/import_contacts.py create mode 100644 modoboa/contacts/migrations/0001_initial.py create mode 100644 modoboa/contacts/migrations/0002_auto_20180124_2311.py create mode 100644 modoboa/contacts/migrations/0003_auto_20181005_1415.py create mode 100644 modoboa/contacts/migrations/0004_auto_20181005_1415.py create mode 100644 modoboa/contacts/migrations/0005_auto_20181005_1445.py create mode 100644 modoboa/contacts/migrations/0006_alter_phonenumber_type.py create mode 100644 modoboa/contacts/migrations/0007_alter_contact_address.py create mode 100644 modoboa/contacts/migrations/__init__.py create mode 100644 modoboa/contacts/mocks.py create mode 100644 modoboa/contacts/models.py create mode 100644 modoboa/contacts/serializers.py create mode 100644 modoboa/contacts/settings.py create mode 100644 modoboa/contacts/static/modoboa_contacts/webpack-stats.json create mode 100644 modoboa/contacts/tasks.py create mode 100644 modoboa/contacts/templates/modoboa_contacts/index.html create mode 100644 modoboa/contacts/test_data/outlook_export.csv create mode 100644 modoboa/contacts/test_data/unknown_export.csv create mode 100644 modoboa/contacts/tests.py create mode 100644 modoboa/contacts/urls.py create mode 100644 modoboa/contacts/viewsets.py diff --git a/docker-compose.yml b/docker-compose.yml index b5aed85e7..f4a85ad2a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,12 +12,12 @@ services: DB: "SQLITE" DEBUG: "True" REDIS_HOST: redis - PYTHONPATH: "..:/modoboa_user" + PYTHONPATH: ".." + PYTHONUNBUFFERED: 1 command: > sh -c "cd test_project; python3 manage.py rqworker dkim modoboa" volumes: - .:/code - - ../modoboa-user:/modoboa_user api: container_name: modoboa_api @@ -33,7 +33,8 @@ services: DB: "SQLITE" DEBUG: "True" REDIS_HOST: redis - PYTHONPATH: "..:/modoboa_user" + PYTHONPATH: ".." + PYTHONUNBUFFERED: 1 command: > sh -c "cd test_project python3 manage.py migrate @@ -42,7 +43,6 @@ services: python3 manage.py runserver_plus 0.0.0.0:8000 --cert-file cert.crt" volumes: - .:/code - - ../modoboa-user:/modoboa_user api-unsecured: container_name: modoboa_api_unsecured @@ -58,13 +58,13 @@ services: DB: "SQLITE" DEBUG: "True" REDIS_HOST: redis - PYTHONPATH: "..:/modoboa_user" + PYTHONPATH: ".." + PYTHONUNBUFFERED: 1 command: > sh -c "cd test_project python3 manage.py runserver_plus 0.0.0.0:8001" volumes: - .:/code - - ../modoboa-user:/modoboa_user front: container_name: modoboa_front diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.dev index 3f41f171f..9d71df25f 100644 --- a/docker/Dockerfile.dev +++ b/docker/Dockerfile.dev @@ -13,7 +13,6 @@ RUN apk add --update openssl librrd python3-dev libffi-dev gcc g++ musl-dev libx RUN python3 -m venv $VIRTUAL_ENV WORKDIR /tmp COPY requirements.txt /tmp -COPY user-requirements.txt /tmp COPY test-requirements.txt /tmp COPY dev-requirements.txt /tmp RUN python -m pip install -U pip diff --git a/docker/Dockerfile.front.dev b/docker/Dockerfile.front.dev index 6d3a0b90b..0dff8b433 100644 --- a/docker/Dockerfile.front.dev +++ b/docker/Dockerfile.front.dev @@ -7,4 +7,4 @@ RUN apk add --no-cache --update gettext \ WORKDIR $HOME -RUN yarn install +RUN yarn install --dev diff --git a/frontend/package.json b/frontend/package.json index 49a4c7a43..af54d4be1 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -34,7 +34,6 @@ "vuetify": "^3.6.12" }, "devDependencies": { - "@module-federation/vite": "^1.1.3", "@vitejs/plugin-basic-ssl": "^1.1.0", "@vitejs/plugin-vue": "^5.0.5", "eslint": "^9.6.0", diff --git a/frontend/src/api/contacts.js b/frontend/src/api/contacts.js new file mode 100644 index 000000000..304825f74 --- /dev/null +++ b/frontend/src/api/contacts.js @@ -0,0 +1,28 @@ +import repository from './repository' + +export default { + getContacts(params) { + return repository.get('/contacts/', { params }) + }, + createContact(data) { + return repository.post('/contacts/', data) + }, + updateContact(contactId, data) { + return repository.patch(`/contacts/${contactId}/`, data) + }, + deleteContact(contactId) { + return repository.delete(`/contacts/${contactId}/`) + }, + getCategories() { + return repository.get('/categories/') + }, + addCategory(data) { + return repository.post('/categories/', data) + }, + updateCategory(categoryId, data) { + return repository.patch(`/categories/${categoryId}/`, data) + }, + deleteCategory(categoryId) { + return repository.delete(`/categories/${categoryId}/`) + }, +} diff --git a/frontend/src/components/contacts/CategoryForm.vue b/frontend/src/components/contacts/CategoryForm.vue new file mode 100644 index 000000000..41186a812 --- /dev/null +++ b/frontend/src/components/contacts/CategoryForm.vue @@ -0,0 +1,106 @@ + + + diff --git a/frontend/src/components/contacts/ContactCategoriesForm.vue b/frontend/src/components/contacts/ContactCategoriesForm.vue new file mode 100644 index 000000000..88ee1f100 --- /dev/null +++ b/frontend/src/components/contacts/ContactCategoriesForm.vue @@ -0,0 +1,78 @@ + + + diff --git a/frontend/src/components/contacts/ContactForm.vue b/frontend/src/components/contacts/ContactForm.vue new file mode 100644 index 000000000..5eb7795fc --- /dev/null +++ b/frontend/src/components/contacts/ContactForm.vue @@ -0,0 +1,254 @@ + + + diff --git a/frontend/src/components/contacts/ContactList.vue b/frontend/src/components/contacts/ContactList.vue new file mode 100644 index 000000000..e33f75cd5 --- /dev/null +++ b/frontend/src/components/contacts/ContactList.vue @@ -0,0 +1,178 @@ + + + diff --git a/frontend/src/components/contacts/EmailField.vue b/frontend/src/components/contacts/EmailField.vue new file mode 100644 index 000000000..c7507d899 --- /dev/null +++ b/frontend/src/components/contacts/EmailField.vue @@ -0,0 +1,65 @@ + + + diff --git a/frontend/src/components/contacts/PhoneNumberField.vue b/frontend/src/components/contacts/PhoneNumberField.vue new file mode 100644 index 000000000..7bb16c079 --- /dev/null +++ b/frontend/src/components/contacts/PhoneNumberField.vue @@ -0,0 +1,60 @@ + + + diff --git a/frontend/src/components/shared/AppsMenu.vue b/frontend/src/components/shared/AppsMenu.vue deleted file mode 100644 index c0ca32f9a..000000000 --- a/frontend/src/components/shared/AppsMenu.vue +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/frontend/src/components/shared/NavBar.vue b/frontend/src/components/shared/NavBar.vue index f2b629960..82a58787c 100644 --- a/frontend/src/components/shared/NavBar.vue +++ b/frontend/src/components/shared/NavBar.vue @@ -3,7 +3,7 @@ v-model="drawer" :rail="rail" permanent - :color="mainColor" + :color="color" app >
@@ -77,11 +77,15 @@ diff --git a/frontend/src/layouts/account/AccountLayout.vue b/frontend/src/layouts/account/AccountLayout.vue new file mode 100644 index 000000000..6568bccd5 --- /dev/null +++ b/frontend/src/layouts/account/AccountLayout.vue @@ -0,0 +1,33 @@ + + + diff --git a/frontend/src/layouts/admin/AdminLayout.vue b/frontend/src/layouts/admin/AdminLayout.vue new file mode 100644 index 000000000..45ece8171 --- /dev/null +++ b/frontend/src/layouts/admin/AdminLayout.vue @@ -0,0 +1,119 @@ + + + diff --git a/frontend/src/layouts/connected/ConnectedLayout.vue b/frontend/src/layouts/connected/ConnectedLayout.vue index 4dbbdf333..26e059418 100644 --- a/frontend/src/layouts/connected/ConnectedLayout.vue +++ b/frontend/src/layouts/connected/ConnectedLayout.vue @@ -1,6 +1,6 @@