Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mirador annotations
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Loïs Poujade
Mirador annotations
Commits
664e8341
Commit
664e8341
authored
4 years ago
by
imranasghar96@hotmail.com
Browse files
Options
Downloads
Patches
Plain Diff
Update img input dialog style, fix linting errors
parent
a160f11d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/AnnotationCreation.js
+42
-37
42 additions, 37 deletions
src/AnnotationCreation.js
with
42 additions
and
37 deletions
src/AnnotationCreation.js
+
42
−
37
View file @
664e8341
...
@@ -29,7 +29,7 @@ import DialogContentText from '@material-ui/core/DialogContentText';
...
@@ -29,7 +29,7 @@ import DialogContentText from '@material-ui/core/DialogContentText';
import
DialogActions
from
'
@material-ui/core/DialogActions
'
;
import
DialogActions
from
'
@material-ui/core/DialogActions
'
;
import
TextField
from
'
@material-ui/core/TextField
'
;
import
TextField
from
'
@material-ui/core/TextField
'
;
import
Checkbox
from
'
@material-ui/core/Checkbox
'
;
import
Checkbox
from
'
@material-ui/core/Checkbox
'
;
import
FormControlLabel
from
"
@material-ui/core/FormControlLabel
"
;
import
FormControlLabel
from
'
@material-ui/core/FormControlLabel
'
;
import
ClickAwayListener
from
'
@material-ui/core/ClickAwayListener
'
;
import
ClickAwayListener
from
'
@material-ui/core/ClickAwayListener
'
;
import
{
SketchPicker
}
from
'
react-color
'
;
import
{
SketchPicker
}
from
'
react-color
'
;
import
{
v4
as
uuid
}
from
'
uuid
'
;
import
{
v4
as
uuid
}
from
'
uuid
'
;
...
@@ -83,35 +83,35 @@ class AnnotationCreation extends Component {
...
@@ -83,35 +83,35 @@ class AnnotationCreation extends Component {
this
.
state
=
{
this
.
state
=
{
activeTool
:
'
cursor
'
,
activeTool
:
'
cursor
'
,
textBody
:
''
,
closedMode
:
'
closed
'
,
closedMode
:
'
closed
'
,
colorPopoverOpen
:
false
,
colorPopoverOpen
:
false
,
currentColorType
:
false
,
currentColorType
:
false
,
fillColor
:
null
,
fillColor
:
null
,
imgConstrain
:
false
,
lineWeightPopoverOpen
:
false
,
lineWeightPopoverOpen
:
false
,
popoverAnchorEl
:
null
,
popoverAnchorEl
:
null
,
popoverLineWeightAnchorEl
:
null
,
popoverLineWeightAnchorEl
:
null
,
strokeColor
:
'
#00BFFF
'
,
strokeColor
:
'
#00BFFF
'
,
strokeWidth
:
1
,
strokeWidth
:
1
,
svg
:
null
,
svg
:
null
,
textBody
:
''
,
xywh
:
null
,
xywh
:
null
,
imgConstrain
:
false
,
imgHeight
:
{
imgWidth
:
{
value
:
''
,
srcValue
:
''
,
lastSubmittedValue
:
''
,
lastSubmittedValue
:
''
,
srcValue
:
''
,
validity
:
0
,
validity
:
0
,
},
imgHeight
:
{
value
:
''
,
value
:
''
,
srcValue
:
''
,
},
imgWidth
:
{
lastSubmittedValue
:
''
,
lastSubmittedValue
:
''
,
srcValue
:
''
,
validity
:
0
,
validity
:
0
,
value
:
''
,
},
},
imgUrl
:
{
imgUrl
:
{
value
:
''
,
lastSubmittedValue
:
''
,
lastSubmittedValue
:
''
,
validity
:
0
,
validity
:
0
,
value
:
''
,
},
},
openAddImgDialog
:
false
,
openAddImgDialog
:
false
,
...
annoState
,
...
annoState
,
...
@@ -206,12 +206,12 @@ class AnnotationCreation extends Component {
...
@@ -206,12 +206,12 @@ class AnnotationCreation extends Component {
let
open
=
true
;
let
open
=
true
;
const
{
imgUrl
,
imgHeight
,
imgWidth
}
=
this
.
state
;
const
{
imgUrl
,
imgHeight
,
imgWidth
}
=
this
.
state
;
const
expression
=
/
[
-a-zA-Z0-9@:%._
\+
~#=
]{1,256}\.[
a-zA-Z0-9()
]{1,6}\b([
-a-zA-Z0-9()@:%_
\+
.~#?&
//
=
]
*
)?
/
gi
;
const
expression
=
/
((([
A-Za-z
]{3,9}
:
(?:\/\/)?)(?:[
-;:&=
\+\$
,
\w]
+@
)?[
A-Za-z0-9.-
]
+|
(?:
www.|
[
-;:&=
\+\$
,
\w]
+@
)[
A-Za-z0-9.-
]
+
)((?:\/[\+
~%
\/
.
\w
-_
]
*
)?\??(?:[
-
\+
=&;%@.
\w
_
]
*
)
#
?(?:[\w
]
*
)
)
?
)
/
;
const
regex
=
new
RegExp
(
expression
);
const
regex
=
new
RegExp
(
expression
);
const
urlValidity
=
imgUrl
.
value
.
match
(
regex
)
?
1
:
2
;
const
urlValidity
=
imgUrl
.
value
.
match
(
regex
)
?
1
:
2
;
const
widthValidity
=
imgWidth
.
value
>
0
?
1
:
2
;
const
widthValidity
=
imgWidth
.
value
>
0
?
1
:
2
;
const
heightValidity
=
imgHeight
.
value
>
0
?
1
:
2
;
const
heightValidity
=
imgHeight
.
value
>
0
?
1
:
2
;
if
(
urlValidity
==
1
&&
widthValidity
==
1
&&
heightValidity
==
1
)
{
if
(
urlValidity
==
=
1
&&
widthValidity
==
=
1
&&
heightValidity
==
=
1
)
{
open
=
false
;
open
=
false
;
}
}
...
@@ -220,19 +220,19 @@ class AnnotationCreation extends Component {
...
@@ -220,19 +220,19 @@ class AnnotationCreation extends Component {
...
imgUrl
,
...
imgUrl
,
value
:
imgUrl
.
value
,
value
:
imgUrl
.
value
,
validity
:
urlValidity
,
validity
:
urlValidity
,
lastSubmittedValue
:
urlValidity
==
1
?
imgUrl
.
value
:
imgUrl
.
lastSubmittedValue
,
lastSubmittedValue
:
urlValidity
==
=
1
?
imgUrl
.
value
:
imgUrl
.
lastSubmittedValue
,
},
},
imgHeight
:
{
imgHeight
:
{
...
imgHeight
,
...
imgHeight
,
value
:
imgHeight
.
value
,
value
:
imgHeight
.
value
,
validity
:
heightValidity
,
validity
:
heightValidity
,
lastSubmittedValue
:
heightValidity
==
1
?
imgHeight
.
value
:
imgHeight
.
lastSubmittedValue
,
lastSubmittedValue
:
heightValidity
==
=
1
?
imgHeight
.
value
:
imgHeight
.
lastSubmittedValue
,
},
},
imgWidth
:
{
imgWidth
:
{
...
imgWidth
,
...
imgWidth
,
value
:
imgWidth
.
value
,
value
:
imgWidth
.
value
,
validity
:
widthValidity
,
validity
:
widthValidity
,
lastSubmittedValue
:
widthValidity
==
1
?
imgWidth
.
value
:
imgWidth
.
lastSubmittedValue
,
lastSubmittedValue
:
widthValidity
==
=
1
?
imgWidth
.
value
:
imgWidth
.
lastSubmittedValue
,
},
},
openAddImgDialog
:
open
,
openAddImgDialog
:
open
,
});
});
...
@@ -286,6 +286,7 @@ class AnnotationCreation extends Component {
...
@@ -286,6 +286,7 @@ class AnnotationCreation extends Component {
this
.
setState
({
this
.
setState
({
imgUrl
:
{
imgUrl
:
{
...
imgUrl
,
...
imgUrl
,
validity
:
1
,
value
:
url
,
value
:
url
,
},
},
imgHeight
:
{
imgHeight
:
{
...
@@ -300,7 +301,13 @@ class AnnotationCreation extends Component {
...
@@ -300,7 +301,13 @@ class AnnotationCreation extends Component {
},
},
});
});
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
'
Error! Dimensions could not be retrieved from image.
'
);
this
.
setState
({
imgUrl
:
{
...
imgUrl
,
validity
:
2
,
value
:
url
,
},
});
}
}
}
}
...
@@ -579,35 +586,37 @@ class AnnotationCreation extends Component {
...
@@ -579,35 +586,37 @@ class AnnotationCreation extends Component {
<
/ToggleButton
>
<
/ToggleButton
>
<
/Grid
>
<
/Grid
>
<
Dialog
open
=
{
openAddImgDialog
}
fullWidth
minWidth
=
"
20%
"
onClose
=
{()
=>
this
.
handleImgDialogChange
(
false
)}
aria
-
labelledby
=
"
form-dialog-title
"
>
<
Dialog
open
=
{
openAddImgDialog
}
fullWidth
minWidth
=
"
20%
"
onClose
=
{()
=>
this
.
handleImgDialogChange
(
false
)}
aria
-
labelledby
=
"
form-dialog-title
"
>
<
DialogTitle
id
=
"
form-dialog-title
"
>
Insert
/
Edit
Image
<
/DialogTitle
>
<
DialogTitle
id
=
"
form-dialog-title
"
>
<
Typography
variant
=
"
h2
"
>
Insert
image
<
/Typography
>
<
/DialogTitle
>
<
DialogContent
>
<
DialogContent
>
<
Dialog
ContentText
>
<
Dialog
Title
id
=
"
form-dialog-subtitle-1
"
style
=
{{
paddingLeft
:
0
}}
>
Source
<
Typography
variant
=
"
MuiTypography-h3
"
>
Image
source
<
/Typography
>
<
/Dialog
ContentText
>
<
/Dialog
Title
>
<
TextField
<
TextField
value
=
{
imgUrl
.
value
}
value
=
{
imgUrl
.
value
}
onChange
=
{
e
=>
this
.
setImgUrl
(
e
.
target
.
value
)}
onChange
=
{
e
=>
this
.
setImgUrl
(
e
.
target
.
value
)}
onBlur
=
{
e
=>
this
.
getImgDimensions
(
e
.
target
.
value
)}
onBlur
=
{
e
=>
this
.
getImgDimensions
(
e
.
target
.
value
)}
error
=
{
imgUrl
.
validity
==
2
}
error
=
{
imgUrl
.
validity
==
2
}
helperText
=
{
imgUrl
.
validity
==
2
?
"
Url
Invalid
"
:
""
}
helperText
=
{
imgUrl
.
validity
==
=
2
?
"
Invalid
URL
"
:
""
}
margin
=
"
dense
"
margin
=
"
dense
"
id
=
"
source
"
id
=
"
source
"
label
=
"
Image U
rl
"
label
=
"
Image U
RL
"
type
=
"
url
"
type
=
"
url
"
fullWidth
fullWidth
/>
/>
<
/DialogContent
>
<
/DialogContent
>
<
DialogContent
>
<
DialogContent
>
<
Dialog
ContentText
>
<
Dialog
Title
id
=
"
form-dialog-subtitle-2
"
style
=
{{
paddingLeft
:
0
}}
>
Dimensions
<
Typography
variant
=
"
MuiTypography-h3
"
>
Image
dimensions
<
/Typography
>
<
/Dialog
ContentText
>
<
/Dialog
Title
>
<
TextField
<
TextField
value
=
{
imgWidth
.
value
}
value
=
{
imgWidth
.
value
}
style
=
{{
width
:
100
,
marginRight
:
10
}}
style
=
{{
width
:
100
,
marginRight
:
10
}}
onChange
=
{
e
=>
this
.
setImgWidth
(
e
.
target
.
value
)}
onChange
=
{
e
=>
this
.
setImgWidth
(
e
.
target
.
value
)}
onBlur
=
{(
e
)
=>
this
.
isConstrained
(
e
)}
onBlur
=
{(
e
)
=>
this
.
isConstrained
(
e
)}
error
=
{
imgWidth
.
validity
==
2
}
error
=
{
imgWidth
.
validity
==
2
}
helperText
=
{
imgWidth
.
validity
==
2
?
"
Invalid
W
idth
"
:
""
}
helperText
=
{
imgWidth
.
validity
==
=
2
?
"
Invalid
w
idth
"
:
""
}
margin
=
"
dense
"
margin
=
"
dense
"
id
=
"
width
"
id
=
"
width
"
label
=
"
Width
"
label
=
"
Width
"
...
@@ -619,8 +628,8 @@ class AnnotationCreation extends Component {
...
@@ -619,8 +628,8 @@ class AnnotationCreation extends Component {
style
=
{{
width
:
100
,
marginLeft
:
10
}}
style
=
{{
width
:
100
,
marginLeft
:
10
}}
onChange
=
{
e
=>
this
.
setImgHeight
(
e
.
target
.
value
)}
onChange
=
{
e
=>
this
.
setImgHeight
(
e
.
target
.
value
)}
onBlur
=
{(
e
)
=>
this
.
isConstrained
(
e
)}
onBlur
=
{(
e
)
=>
this
.
isConstrained
(
e
)}
error
=
{
imgHeight
.
validity
==
2
}
error
=
{
imgHeight
.
validity
==
=
2
}
helperText
=
{
imgHeight
.
validity
==
2
?
"
Negative or i
nvalid height
.
"
:
""
}
helperText
=
{
imgHeight
.
validity
==
=
2
?
"
I
nvalid height
"
:
""
}
margin
=
"
dense
"
margin
=
"
dense
"
id
=
"
height
"
id
=
"
height
"
label
=
"
Height
"
label
=
"
Height
"
...
@@ -633,19 +642,15 @@ class AnnotationCreation extends Component {
...
@@ -633,19 +642,15 @@ class AnnotationCreation extends Component {
checked
=
{
imgConstrain
}
checked
=
{
imgConstrain
}
onChange
=
{(
e
)
=>
this
.
handleConstrainCheck
(
e
)}
onChange
=
{(
e
)
=>
this
.
handleConstrainCheck
(
e
)}
inputProps
=
{{
'
aria-label
'
:
'
primary checkbox
'
}}
inputProps
=
{{
'
aria-label
'
:
'
primary checkbox
'
}}
style
=
{{
marginLeft
:
1
0
}}
style
=
{{
marginLeft
:
3
0
}}
/
>
/
>
}
}
label
=
"
Constrain
P
roportions
"
label
=
"
Constrain
p
roportions
"
/>
/>
<
/DialogContent
>
<
/DialogContent
>
<
DialogActions
>
<
DialogActions
>
<
Button
onClick
=
{()
=>
this
.
handleImgDialogChange
(
false
)}
color
=
"
primary
"
>
<
Button
onClick
=
{()
=>
this
.
handleImgDialogChange
(
false
)}
>
Cancel
<
/Button
>
Cancel
<
Button
variant
=
"
contained
"
onClick
=
{
this
.
handleImgDialogSubmit
}
color
=
"
primary
"
>
Add
<
/Button
>
<
/Button
>
<
Button
onClick
=
{
this
.
handleImgDialogSubmit
}
color
=
"
primary
"
>
Add
<
/Button
>
<
/DialogActions
>
<
/DialogActions
>
<
/Dialog
>
<
/Dialog
>
<
Grid
item
xs
=
{
12
}
>
<
Grid
item
xs
=
{
12
}
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment