Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
jflow
Commits
892f330b
Commit
892f330b
authored
Oct 03, 2014
by
Jerome Mariette
Browse files
size_limit ok from gui and cli
parent
1c5c29b5
Changes
3
Hide whitespace changes
Inline
Side-by-side
bin/jflow_server.py
View file @
892f330b
...
...
@@ -379,10 +379,7 @@ class JFlowServer (object):
if
key
!=
"type"
and
key
!=
"callback"
and
key
!=
"_"
:
value_key
=
key
break
try
:
create_test_function
(
eval
(
kwargs
[
"type"
]))(
kwargs
[
value_key
])
except
:
create_test_function
(
kwargs
[
"type"
])(
kwargs
[
value_key
])
create_test_function
(
kwargs
[
"type"
])(
kwargs
[
value_key
])
return
True
except
Exception
,
e
:
return
str
(
e
)
...
...
src/jflow/parameter.py
View file @
892f330b
...
...
@@ -75,11 +75,11 @@ def inputfile(file):
else
:
return
urlfile
(
file
)
def
create_test_function
(
type
):
try
:
type
=
type
.
encode
(
'ascii'
,
'ignore'
)
def
create_test_function
(
i
type
):
try
:
i
type
=
i
type
.
encode
(
'ascii'
,
'ignore'
)
except
:
pass
try
:
ctype
,
csizel
=
type
.
split
(
AbstractInputFile
.
SIZE_LIMIT_SPLITER
)
ctype
,
csizel
=
i
type
.
split
(
AbstractInputFile
.
SIZE_LIMIT_SPLITER
)
def
inner_function
(
ifile
):
# first eval the asked type
returned_value
=
eval
(
ctype
)(
ifile
)
...
...
@@ -105,7 +105,10 @@ def create_test_function(type):
inner_function
.
__name__
=
ctype
+
AbstractInputFile
.
SIZE_LIMIT_SPLITER
+
csizel
return
inner_function
except
:
return
type
if
type
(
itype
)
==
str
:
return
eval
(
itype
)
else
:
return
itype
class
MultipleParameters
(
object
):
def
__init__
(
self
,
types
,
required
,
choices
,
excludes
,
default
,
actions
):
...
...
src/js/jflow-wfform.js
View file @
892f330b
...
...
@@ -103,11 +103,20 @@ jQuery.validator.addMethod("exclude_required", function(value, element, options)
return
valid
;
},
jQuery
.
format
(
"
Please fill one and only one of these fields.
"
));
jQuery
.
validator
.
addMethod
(
"
maxfilesize
"
,
function
(
value
,
element
,
params
)
{
return
this
.
optional
(
element
)
||
$
(
element
).
data
(
"
data2upload
"
).
files
[
0
].
size
<
params
[
0
];
},
jQuery
.
format
(
"
Selected file exceeds size limits: {1}
"
));
jQuery
.
validator
.
addMethod
(
"
mparam
"
,
function
(
value
,
element
,
params
)
{
return
true
;
});
!
function
(
$
)
{
"
use strict
"
;
// jshint ;_;
var
TIMER
=
2000
,
timer
;
timer
,
SIZE_LIMIT_SPLITER
=
"
__sl
"
;
/* WFForm CLASS DEFINITION
* ========================= */
...
...
@@ -278,17 +287,46 @@ jQuery.validator.addMethod("exclude_required", function(value, element, options)
$
(
"
#
"
+
$
(
this
).
attr
(
"
class
"
)).
html
(
$
(
this
).
html
());
// if this is a local file, empty the field and add a browse behaviour
var
parts
=
$
(
this
).
attr
(
"
class
"
).
split
(
"
_
"
),
tid
=
parts
.
slice
(
1
,
parts
.
lenght
).
join
(
"
_
"
);
tid
=
parts
.
slice
(
1
,
parts
.
lenght
).
join
(
"
_
"
),
size
=
$
(
"
#
"
+
tid
).
rules
()[
"
mparam
"
].
type
.
split
(
SIZE_LIMIT_SPLITER
)[
1
];
$
(
"
#
"
+
tid
).
val
(
""
);
$
(
"
#
"
+
tid
).
rules
(
"
remove
"
,
"
remote maxfilesize
"
);
if
(
$
(
this
).
html
()
==
"
local file
"
)
{
$
(
"
#urlfile_btn_
"
+
tid
).
show
();
$
(
"
#
"
+
tid
).
prop
(
'
readonly
'
,
true
);
if
(
size
!=
"
0
"
)
{
$
(
"
#
"
+
tid
).
rules
(
'
add
'
,
{
maxfilesize
:
[
$this
.
getNbOctet
(
size
),
size
]
});
}
}
else
{
$
(
"
#urlfile_btn_
"
+
tid
).
hide
();
$
(
"
#
"
+
tid
).
prop
(
'
readonly
'
,
false
);
if
(
$
(
"
#
"
+
tid
).
data
(
"
data2upload
"
))
{
$
(
"
#
"
+
tid
).
removeData
(
"
data2upload
"
);
}
if
(
$
(
this
).
html
()
==
"
url
"
)
{
$
(
"
#
"
+
tid
).
rules
(
'
add
'
,
{
remote
:
{
url
:
$this
.
options
.
serverURL
+
'
/validate_field?callback=?
'
,
type
:
"
post
"
,
data
:
{
type
:
"
urlfile
"
+
SIZE_LIMIT_SPLITER
+
size
}
}
});
// if server file
}
else
{
$
(
"
#
"
+
tid
).
rules
(
'
add
'
,
{
remote
:
{
url
:
$this
.
options
.
serverURL
+
'
/validate_field?callback=?
'
,
type
:
"
post
"
,
data
:
{
type
:
"
inputfile
"
+
SIZE_LIMIT_SPLITER
+
size
}
}
});
}
}
});
$
(
"
[id^=urlfile_btn_]
"
).
click
(
function
(){
...
...
@@ -356,36 +394,36 @@ jQuery.validator.addMethod("exclude_required", function(value, element, options)
});
}
WFForm
.
prototype
.
getOctetStringRepresentation
=
function
(
size
)
{
var
octets_link
=
[
"
bytes
"
,
"
Kb
"
,
"
Mb
"
,
"
Gb
"
,
"
Tb
"
,
"
Pb
"
,
"
Eb
"
,
"
Zb
"
],
p
=
Math
.
ceil
(
size
.
toString
().
length
/
3
-
1.0
),
pow_needed
=
p
*
10
,
pow_needed
=
Math
.
pow
(
2
,
pow_needed
),
value
=
(
size
/
pow_needed
).
toString
(),
tmp
=
value
.
split
(
"
.
"
);
value
=
tmp
[
0
]
+
"
.
"
+
tmp
[
1
].
substring
(
0
,
2
)
+
"
"
+
octets_link
[
p
];
return
value
;
}
WFForm
.
prototype
.
getNbOctet
=
function
(
size
)
{
var
octets_link
=
[
"
bytes
"
,
"
Kb
"
,
"
Mb
"
,
"
Gb
"
,
"
Tb
"
,
"
Pb
"
,
"
Eb
"
,
"
Zb
"
],
unit
=
size
.
substring
(
size
.
length
-
2
,
size
.
length
),
pow_val
=
parseInt
(
octets_link
.
indexOf
(
unit
))
*
10
,
val
=
Math
.
pow
(
2
,
pow_val
),
nb_octet
=
size
.
substring
(
0
,
size
.
length
-
2
)
*
val
;
return
nb_octet
;
}
WFForm
.
prototype
.
_getParameterRule
=
function
(
param
,
server_url
,
excludereq
)
{
var
crule
=
{};
crule
[
"
mparam
"
]
=
param
;
if
(
param
.
type
==
"
int
"
)
{
crule
[
"
number
"
]
=
true
;
}
else
if
(
param
.
type
==
"
date
"
)
{
crule
[
"
date
"
]
=
true
;
}
else
if
(
param
.
type
.
indexOf
(
"
browsefile
"
)
===
0
)
{
crule
[
"
remote
"
]
=
{
url
:
server_url
+
'
/validate_field?callback=?
'
,
type
:
"
post
"
,
data
:
{
type
:
"
str
"
}
};
}
else
if
(
param
.
type
.
indexOf
(
"
inputfile
"
)
===
0
)
{
crule
[
"
remote
"
]
=
{
url
:
server_url
+
'
/validate_field?callback=?
'
,
type
:
"
post
"
,
data
:
{
type
:
function
()
{
if
(
$
(
"
#inputfile_
"
+
param
.
name
).
html
()
==
"
url
"
)
{
return
param
.
type
;
}
else
if
(
$
(
"
#inputfile_
"
+
param
.
name
).
html
()
==
"
server file
"
)
{
return
param
.
type
;
}
else
if
(
$
(
"
#inputfile_
"
+
param
.
name
).
html
()
==
"
local file
"
)
{
return
"
str
"
;
}
}
}
};
var
size
=
param
.
type
.
split
(
SIZE_LIMIT_SPLITER
)[
1
];
crule
[
"
maxfilesize
"
]
=
[
this
.
getNbOctet
(
size
),
size
];
// if it is not a known type, check from the custom ones, using the validate_field address
}
else
{
crule
[
"
remote
"
]
=
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment