import React from 'react';
import { Glyphicon, Button, OverlayTrigger, Tooltip } from 'react-bootstrap';
import './DatasetFooter.css';
import { getDownloadURLByDatasetId } from "../../../api/icat/icatPlus.js"

class DatasetFooter extends React.Component {
    getStorageStatus() {

        const tooltip = (
            <Tooltip id="tooltip">
                <strong>Dataset is available for downloading</strong> <br />Click on Download to start the download.
        </Tooltip>
        );

        var downloadURL = getDownloadURLByDatasetId(this.props.sessionId, this.props.dataset.id);
        /** Button download **/
        return <OverlayTrigger placement="left" overlay={tooltip}>
            <a style={{ color: '#FFFFFF' }} href={downloadURL}><Button bsStyle="primary">
                <span className="glyphicon glyphicon-download-alt"></span> Download
        </Button></a>
        </OverlayTrigger>;
    }


    render() {
        return (
            <div className="container-fluid">
                <div className="pull-left">
                    <span> <Glyphicon glyph="folder-open" /> {this.props.location}</span>
                </div>
                <div className="pull-right">
                    {this.getStorageStatus()}
                </div>
            </div>


        );
    }
}

export default DatasetFooter;