Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feat/import model 146 #233

Merged
merged 15 commits into from
Oct 6, 2021

Conversation

mvergez
Copy link
Contributor

@mvergez mvergez commented Sep 6, 2021

Objectif

  • Permettre de charger à l'étape 2 un fichier JSON contenant les correspondances des champs
  • Permettre de charger à l'étape 3 un fichier JSON contenant les correspondances des nomenclatures

Ces fichiers peuvent être crées à la main ou exportés depuis le rapport d'import (voir #158). Exemple d'un fichier :

[
    {
        "source_field": "true",
        "target_field": "unique_id_sinp_generate"
    },
    {
        "source_field": "dateobs",
        "target_field": "date_min"
    },
    {
        "source_field": "true",
        "target_field": "altitudes_generate"
    }
]

Implémentation

Première implémentation : chargement depuis le front d'un fichier json et remplacement direct des champs par son contenu.
Si aucun champ n'a été mappé une erreur (via un toaster) est affichée.

Closes #146

Maxime Vergez and others added 15 commits September 6, 2021 16:03
Added an import button to import fields from a json (that can be
exported from the report or can be generated by hand, only need
source field and target field normally)
Clears all the fields when a json file is loaded
Added comment and better display of errors
Add nomenclature import (not working for now)
Did some refactor : added a FileService to read json data and to
simplify the code
Moved code section to a function to be able to reuse it for the
load from json functionnality
Implemented this functionnality. Need to test
Model import is now done thanks to a modal when the user can
provide the model name and the json file
Add modal to import mapping fields from json
When creating a new model, the form is automatically filled in
but cleared afterwards... Try to fix this
Removed ForbiddenName directive since the API call make a toaster
appear if the name is already taken
Changed the file service to take a File as an input and not an
event
Removed some lines in the save mapping to try to fix the "empty
 form bug"
When the user imports a json, a new model is created and the
form is filled. BUT: the select widget must be refresh to select
the new model and since it is done concurrently, the json load
was not done. Fix this by reading the json at the end. It will
be more difficult with nomenclatures...
Removed the forbiddenModelName.directive.ts which is not used
anymore
Fixed the nomenclature field import via json. Find that there is a
subscribe in the content-mapping.service.ts which is not advised.
So replaced it with a map and call subscribe in the component
directly. Cleaner and there are no race between the form fields
actualisation and their cleaning. First clean the fill the fields
with the json file data
Close the modal when the user finishes to import the json for the
nomenclature fields. Like it is done for the mapping fields
Removed edit slider in import modal since we do not want model
edition with a json
Did the same thing for the field-mapping.service.ts as it was done
for the content-mapping.service.ts: change subscribe to map since
subscribe is generally done in the component and not the service
@mvergez
Copy link
Contributor Author

mvergez commented Sep 8, 2021

Seconde implémentation : la création d'un nouveau modèle (de champs et de nomenclatures) se fait par l'intermédiaire d'une modale où l'utilisateur renseigne le nom du modèle à créer ainsi que le fichier json.
Exemple :
image

@mvergez mvergez mentioned this pull request Sep 8, 2021
@DonovanMaillard DonovanMaillard merged commit 3d17387 into PnX-SI:project-FLA_NS Oct 6, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants