diff --git a/uvdat/core/rest/serializers.py b/uvdat/core/rest/serializers.py index 48f1e851..3c46f208 100644 --- a/uvdat/core/rest/serializers.py +++ b/uvdat/core/rest/serializers.py @@ -28,6 +28,12 @@ class Meta: fields = ['id', 'username', 'email', 'first_name', 'last_name', 'is_superuser'] +class DatasetSerializer(serializers.ModelSerializer): + class Meta: + model = Dataset + fields = '__all__' + + class ProjectPermissionsSerializer(serializers.Serializer): owner_id = serializers.IntegerField() collaborator_ids = serializers.ListField(child=serializers.IntegerField()) @@ -40,6 +46,7 @@ class ProjectSerializer(serializers.ModelSerializer): collaborators = serializers.SerializerMethodField('get_collaborators') followers = serializers.SerializerMethodField('get_followers') item_counts = serializers.SerializerMethodField('get_item_counts') + datasets = DatasetSerializer(many=True) def get_center(self, obj): # Web client expects Lon, Lat @@ -81,12 +88,6 @@ class Meta: fields = '__all__' -class DatasetSerializer(serializers.ModelSerializer): - class Meta: - model = Dataset - fields = '__all__' - - class FileItemSerializer(serializers.ModelSerializer): class Meta: model = FileItem diff --git a/web/src/components/ProjectConfig.vue b/web/src/components/ProjectConfig.vue index 3492bd16..d55828c6 100644 --- a/web/src/components/ProjectConfig.vue +++ b/web/src/components/ProjectConfig.vue @@ -10,7 +10,6 @@ import DatasetList from "./DatasetList.vue"; import AccessControl from "./AccessControl.vue"; import { getDatasets, - getProjectDatasets, createProject, deleteProject, patchProject, @@ -111,12 +110,10 @@ export default { function selectProject(v: Record) { if (selectedProject.value?.id != v.id) { - getProjectDatasets(v.id as number).then((data) => { - projDatasets.value = data; - }); selectedProject.value = availableProjects.value.find( (p) => p.id == v.id ); + projDatasets.value = selectedProject.value?.datasets; } } @@ -191,10 +188,8 @@ export default { patchProject(selectedProject.value.id, { datasets: ids, }).then((project) => { - getProjectDatasets(project.id).then((datasets) => { - projDatasets.value = datasets; - saving.value = false; - }); + projDatasets.value = project.datasets; + saving.value = false; }); } }