@@ -36,13 +36,15 @@ class BandwidthStatusCard extends React.Component {
36
36
const { bandwidthText, hasError} = this . state ;
37
37
if ( ! hasError ) {
38
38
const { setBandwidth} = this . props ;
39
- if ( bandwidthText )
39
+ if ( bandwidthText ) {
40
40
setBandwidth ( bandwidthText ) ;
41
+ this . toggleShowChangeBandwidth ( ) ;
42
+ }
41
43
else {
42
44
setBandwidth ( "0M" ) ;
43
45
}
44
46
} else {
45
- toast . error ( "Error in form " ) ;
47
+ toast . error ( "Please check the errors before submitting " ) ;
46
48
}
47
49
} ;
48
50
@@ -53,10 +55,22 @@ class BandwidthStatusCard extends React.Component {
53
55
*/
54
56
changeBandwidthInput = ( e ) => {
55
57
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
+ }
57
71
this . setState ( {
58
72
bandwidthText : inputValue ,
59
- hasError : ( inputValue !== "" ? ! validateInput : false )
73
+ hasError : ! validateInput
60
74
} )
61
75
} ;
62
76
@@ -94,15 +108,14 @@ class BandwidthStatusCard extends React.Component {
94
108
</ p >
95
109
< Form onSubmit = { this . setBandwidth } className = { showChangeBandwidth ? "" : "d-none" } >
96
110
< 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 >
98
112
< Col sm = { 7 } >
99
113
< Input type = "text" value = { bandwidthText }
100
114
valid = { ! hasError } invalid = { hasError }
101
115
id = "bandwidthValue" onChange = { this . changeBandwidthInput } >
102
116
</ Input >
103
117
< 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 >
106
119
107
120
</ Col >
108
121
</ FormGroup >
0 commit comments