import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import DicomStorePicker from './DicomStorePicker'; import DatasetPicker from './DatasetPicker'; import ProjectPicker from './ProjectPicker'; import LocationPicker from './LocationPicker'; import GoogleCloudApi from './api/GoogleCloudApi'; import './googleCloud.css'; class DatasetSelector extends Component { state = { project: null, location: null, dataset: null, unloading: false, }; static propTypes = { id: PropTypes.string, event: PropTypes.string, user: PropTypes.object, canClose: PropTypes.string, setServers: PropTypes.func.isRequired, }; onProjectSelect = project => { this.setState({ project, }); }; onLocationSelect = location => { this.setState({ location, }); }; onDatasetSelect = dataset => { this.setState({ dataset, }); }; onProjectClick = () => { this.setState({ dataset: null, location: null, project: null, }); }; onLocationClick = () => { this.setState({ dataset: null, location: null, }); }; onDatasetClick = () => { this.setState({ dataset: null, }); }; onDicomStoreSelect = dicomStoreJson => { const dicomStore = dicomStoreJson.name; const parts = dicomStore.split('/'); const result = { wadoUriRoot: GoogleCloudApi.urlBase + `/${dicomStore}/dicomWeb`, qidoRoot: GoogleCloudApi.urlBase + `/${dicomStore}/dicomWeb`, wadoRoot: GoogleCloudApi.urlBase + `/${dicomStore}/dicomWeb`, project: parts[1], location: parts[3], dataset: parts[5], dicomStore: parts[7], }; this.props.setServers(result); }; render() { const accessToken = this.props.user.access_token; const { project, location, dataset } = this.state; const { onProjectClick, onLocationClick, onDatasetClick, onProjectSelect, onLocationSelect, onDatasetSelect, onDicomStoreSelect, } = this; let projectBreadcrumbs = (