@@ -36,13 +36,15 @@ class BandwidthStatusCard extends React.Component {
3636 const { bandwidthText, hasError} = this . state ;
3737 if ( ! hasError ) {
3838 const { setBandwidth} = this . props ;
39- if ( bandwidthText )
39+ if ( bandwidthText ) {
4040 setBandwidth ( bandwidthText ) ;
41+ this . toggleShowChangeBandwidth ( ) ;
42+ }
4143 else {
4244 setBandwidth ( "0M" ) ;
4345 }
4446 } else {
45- toast . error ( "Error in form " ) ;
47+ toast . error ( "Please check the errors before submitting " ) ;
4648 }
4749 } ;
4850
@@ -53,10 +55,22 @@ class BandwidthStatusCard extends React.Component {
5355 */
5456 changeBandwidthInput = ( e ) => {
5557 const inputValue = e . target . value ;
56- const validateInput = validateSizeSuffix ( inputValue ) ;
58+ let validateInput = false ;
59+ if ( inputValue === "" ) {
60+ validateInput = true ;
61+ } else if ( inputValue ) {
62+ const splitValue = inputValue . split ( ":" ) ;
63+ if ( splitValue . length === 1 ) {
64+ validateInput = validateSizeSuffix ( splitValue [ 0 ] ) ;
65+ } else if ( splitValue . length === 2 ) {
66+ const validateDownloadLimit = validateSizeSuffix ( splitValue [ 0 ] ) ;
67+ const validateUploadLimit = validateSizeSuffix ( splitValue [ 1 ] ) ;
68+ validateInput = validateDownloadLimit && validateUploadLimit ;
69+ }
70+ }
5771 this . setState ( {
5872 bandwidthText : inputValue ,
59- hasError : ( inputValue !== "" ? ! validateInput : false )
73+ hasError : ! validateInput
6074 } )
6175 } ;
6276
@@ -94,15 +108,14 @@ class BandwidthStatusCard extends React.Component {
94108 </ p >
95109 < Form onSubmit = { this . setBandwidth } className = { showChangeBandwidth ? "" : "d-none" } >
96110 < FormGroup row >
97- < Label for = "bandwidthValue" sm = { 5 } > Enter new max speed</ Label >
111+ < Label for = "bandwidthValue" sm = { 5 } > Enter new max speed (upload:download) </ Label >
98112 < Col sm = { 7 } >
99113 < Input type = "text" value = { bandwidthText }
100114 valid = { ! hasError } invalid = { hasError }
101115 id = "bandwidthValue" onChange = { this . changeBandwidthInput } >
102116 </ Input >
103117 < FormFeedback valid > Keep empty to reset.</ FormFeedback >
104- < FormFeedback > The bandwidth should be of the form 1M|2M|1G|1K|1.1K
105- etc</ FormFeedback >
118+ < FormFeedback > The bandwidth should be of the form 1M|2M|1G|1K|1.1K etc. Can also be specified as (upload:download)</ FormFeedback >
106119
107120 </ Col >
108121 </ FormGroup >
0 commit comments