|
645 | 645 |
|
646 | 646 | });
|
647 | 647 |
|
648 |
| - /** |
649 |
| - * Simple RaisedButton executing the applyButtonAction |
650 |
| - */ |
651 |
| - var InputButton = React.createClass({ |
| 648 | + var ActionRunnerMixin = { |
652 | 649 |
|
653 | 650 | propTypes:{
|
654 |
| - attributes:React.PropTypes.object, |
| 651 | + attributes:React.PropTypes.object.isRequired, |
655 | 652 | applyButtonAction:React.PropTypes.func,
|
656 | 653 | actionCallback:React.PropTypes.func
|
657 | 654 | },
|
658 | 655 |
|
659 |
| - applyButton:function(){ |
| 656 | + applyAction:function(callback){ |
660 | 657 | var choicesValue = this.props.attributes['choices'].split(":");
|
661 | 658 | var firstPart = choicesValue.shift();
|
662 | 659 | if(firstPart == "run_client_action" && global.pydio){
|
|
672 | 669 | if(this.props.attributes['name'].indexOf("/") !== -1){
|
673 | 670 | parameters['button_key'] = PathUtils.getDirname(this.props.attributes['name']);
|
674 | 671 | }
|
675 |
| - var callback = this.props.actionCallback; |
676 |
| - if(!callback){ |
677 |
| - callback = function(transport){ |
678 |
| - var text = transport.responseText; |
679 |
| - if(text.startsWith('SUCCESS:')){ |
680 |
| - global.pydio.displayMessage('SUCCESS', transport.responseText.replace('SUCCESS:', '')); |
681 |
| - }else{ |
682 |
| - global.pydio.displayMessage('ERROR', transport.responseText.replace('ERROR:', '')); |
683 |
| - } |
684 |
| - }; |
685 |
| - } |
686 | 672 | this.props.applyButtonAction(parameters, callback);
|
687 | 673 | }
|
| 674 | + } |
| 675 | + |
| 676 | + }; |
| 677 | + |
| 678 | + /** |
| 679 | + * Simple RaisedButton executing the applyButtonAction |
| 680 | + */ |
| 681 | + var InputButton = React.createClass({ |
| 682 | + |
| 683 | + mixins:[ActionRunnerMixin], |
| 684 | + |
| 685 | + |
| 686 | + applyButton:function(){ |
| 687 | + |
| 688 | + var callback = this.props.actionCallback; |
| 689 | + if(!callback){ |
| 690 | + callback = function(transport){ |
| 691 | + var text = transport.responseText; |
| 692 | + if(text.startsWith('SUCCESS:')){ |
| 693 | + global.pydio.displayMessage('SUCCESS', transport.responseText.replace('SUCCESS:', '')); |
| 694 | + }else{ |
| 695 | + global.pydio.displayMessage('ERROR', transport.responseText.replace('ERROR:', '')); |
| 696 | + } |
| 697 | + }; |
| 698 | + } |
| 699 | + this.applyAction(callback); |
| 700 | + |
688 | 701 | },
|
689 | 702 |
|
690 | 703 | render:function(){
|
|
698 | 711 | }
|
699 | 712 | });
|
700 | 713 |
|
| 714 | + |
| 715 | + var MonitoringLabel = React.createClass({ |
| 716 | + |
| 717 | + mixins:[ActionRunnerMixin], |
| 718 | + |
| 719 | + getInitialState:function(){ |
| 720 | + let loadingMessage = 'Loading'; |
| 721 | + if(this.context && this.context.getMessage){ |
| 722 | + loadingMessage = this.context.getMessage(466, ''); |
| 723 | + }else if(global.pydio && global.pydio.MessageHash){ |
| 724 | + loadingMessage = global.pydio.MessageHash[466]; |
| 725 | + } |
| 726 | + return {status:loadingMessage}; |
| 727 | + }, |
| 728 | + |
| 729 | + componentDidMount:function(){ |
| 730 | + var callback = function(transport){ |
| 731 | + this.setState({status:transport.responseText}); |
| 732 | + }.bind(this); |
| 733 | + this._poller = function(){ |
| 734 | + this.applyAction(callback); |
| 735 | + }.bind(this); |
| 736 | + this._poller(); |
| 737 | + this._pe = global.setInterval(this._poller, 10000); |
| 738 | + }, |
| 739 | + |
| 740 | + componentWillUnmount:function(){ |
| 741 | + if(this._pe){ |
| 742 | + global.clearInterval(this._pe); |
| 743 | + } |
| 744 | + }, |
| 745 | + |
| 746 | + render: function(){ |
| 747 | + return (<div>{this.state.status}</div>); |
| 748 | + } |
| 749 | + |
| 750 | + |
| 751 | + }); |
| 752 | + |
| 753 | + |
701 | 754 | /**
|
702 | 755 | * UI to drop a file (or click to browse), used by the InputImage component.
|
703 | 756 | */
|
|
1664 | 1717 | case 'button':
|
1665 | 1718 | value = <InputButton {...props}/>;
|
1666 | 1719 | break;
|
| 1720 | + case 'monitor': |
| 1721 | + value = <MonitoringLabel {...props}/>; |
| 1722 | + break; |
1667 | 1723 | case 'image':
|
1668 | 1724 | value = <InputImage {...props}/>;
|
1669 | 1725 | break;
|
|
1831 | 1887 | PydioForm.InputBoolean = InputBoolean;
|
1832 | 1888 | PydioForm.InputInteger = InputInteger;
|
1833 | 1889 | PydioForm.InputButton = InputButton;
|
| 1890 | + PydioForm.MonitoringLabel = MonitoringLabel; |
1834 | 1891 | PydioForm.InputSelectBox = InputSelectBox;
|
1835 | 1892 | PydioForm.InputImage = InputImage;
|
1836 | 1893 | PydioForm.FormPanel = PydioFormPanel;
|
|
0 commit comments