/* * Copyright 2007-2017 Charles du Jeu - Abstrium SAS * This file is part of Pydio. * * Pydio is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pydio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Pydio. If not, see . * * The latest code can be found at . */ import ColorPaper from '../board/ColorPaper' const React = require('react') const {CardTitle, CircularProgress} = require('material-ui') const {asGridItem} = require('pydio').requireLib('components') const {FileDropZone} = require('pydio').requireLib('form') const {NativeFileDropProvider} = require('pydio').requireLib('hoc'); const BinaryDropZone = NativeFileDropProvider(FileDropZone, (items, files, props) => {}); let QuickSendCard = React.createClass({ fileDroppedOrPicked: function(event, monitor = null){ let items, files; if(monitor){ let dataTransfer = monitor.getItem().dataTransfer; if (dataTransfer.items.length && dataTransfer.items[0] && (dataTransfer.items[0].getAsEntry || dataTransfer.items[0].webkitGetAsEntry)) { items = dataTransfer.items; } }else if(event.dataTransfer){ items = event.dataTransfer.items || []; files = event.dataTransfer.files; }else if(event.target){ files = event.target.files; } let uploadItems = []; if(window['UploaderModel'] && global.pydio.getController().getActionByName('upload')){ UploaderModel.Store.getInstance().handleDropEventResults(items, files, new AjxpNode('/'), uploadItems); } return uploadItems; }, onDrop: function(files, event, source){ const items = this.fileDroppedOrPicked(event); this.setState({uploadItems: items}); this.props.pydio.UI.openComponentInModal('WelcomeComponents', 'WorkspacePickerDialog', { onWorkspaceTouchTap: this.targetWorkspaceSelected.bind(this), legend : (files && files[0] ?
{this.props.pydio.MessageHash['user_home.89']}: {files[0].name}
: undefined) }); }, targetWorkspaceSelected: function(wsId){ const contextNode = new AjxpNode('/'); contextNode.getMetadata().set('repository_id', wsId); const {uploadItems} = this.state; if(window['UploaderModel'] && global.pydio.getController().getActionByName('upload')){ const instance = UploaderModel.Store.getInstance(); uploadItems.forEach((item) => { item.updateRepositoryId(wsId); item.observe('status', () => { this.setState({working:(item.getStatus() === 'loading') }); }); instance.pushFile(item); }); instance.processNext(); } }, render: function(){ const title = ; const working = this.state && this.state.working; return (
{this.props.pydio.MessageHash['user_home.88']}
{working && } {!working && }
); } }); QuickSendCard = asGridItem(QuickSendCard,global.pydio.MessageHash['user_home.93'],{gridWidth:2,gridHeight:10},[]); export {QuickSendCard as default}