async fetchData(): Promise<void> {
   try {
     this.setState({ isLoading: true });
     const datasetUsers = await getDatasetAccessList(this.props.dataset.name);
     this.setState({ datasetUsers });
   } catch (error) {
     handleGenericError(error);
   } finally {
     this.setState({ isLoading: false });
   }
 }
Esempio n. 2
0
 async fetchData(): Promise<void> {
   try {
     this.setState({ isLoading: true });
     const datasets = await getDatasets();
     const transformedDatasets = transformDatasets(datasets);
     this.setState({
       datasets: transformedDatasets,
     });
   } catch (error) {
     handleGenericError(error);
   } finally {
     this.setState({ isLoading: false });
   }
 }
Esempio n. 3
0
  handleCheckDatasets = async (): Promise<void> => {
    if (this.state.isLoading) return;

    try {
      this.setState({ isLoading: true });
      const datastores = await getDatastores();
      await Promise.all(datastores.map(datastore => triggerDatasetCheck(datastore.url)));
      await this.fetchData();
    } catch (error) {
      handleGenericError(error);
    } finally {
      this.setState({ isLoading: false });
    }
  };
Esempio n. 4
0
 async transfer() {
   const annotationId = this.props.annotationId;
   if (!annotationId) {
     throw new Error("No annotation id provided");
   }
   try {
     this.setState({ isLoading: true });
     const updatedAnnotation = await transferTask(annotationId, this.state.currentUserIdValue);
     this.props.onChange(updatedAnnotation);
   } catch (error) {
     handleGenericError(error);
   } finally {
     this.setState({ isLoading: false });
   }
 }
Esempio n. 5
0
 onOk: async () => {
   try {
     this.setState({
       isLoading: true,
     });
     const updatedProject = await increaseProjectTaskInstances(project.name);
     this.setState({
       projects: this.state.projects.map(p => (p.id === project.id ? updatedProject : p)),
     });
   } catch (error) {
     handleGenericError(error);
   } finally {
     this.setState({ isLoading: false });
   }
 },
Esempio n. 6
0
  async fetchData() {
    try {
      this.setState({ isLoading: true });
      const users = await getUsers();
      const activeUsers = users.filter(u => u.isActive);
      const sortedUsers = _.sortBy(activeUsers, "lastName");

      this.setState({
        users: sortedUsers,
      });
    } catch (error) {
      handleGenericError(error);
    } finally {
      this.setState({ isLoading: false });
    }
  }
Esempio n. 7
0
      onOk: async () => {
        this.setState({
          isLoading: true,
        });

        try {
          await deleteProject(project.name);
          this.setState({
            projects: this.state.projects.filter(p => p.id !== project.id),
          });
        } catch (error) {
          handleGenericError(error);
        } finally {
          this.setState({ isLoading: false });
        }
      },
  async fetchData(): Promise<void> {
    const isFinished = this.state.showFinishedTasks;
    const url = this.props.userId
      ? `/api/users/${this.props.userId}/tasks?isFinished=${isFinished.toString()}`
      : `/api/user/tasks?isFinished=${isFinished.toString()}`;

    try {
      this.setState({ isLoading: true });
      const annotationsWithTasks = await Request.receiveJSON(url);
      const tasks = annotationsWithTasks.map(convertAnnotationToTaskWithAnnotationType);

      this.setState({
        [isFinished ? "finishedTasks" : "unfinishedTasks"]: tasks,
      });
    } catch (error) {
      handleGenericError(error);
    } finally {
      this.setState({ isLoading: false });
    }
  }