Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
erp5
Commits
9a064fec
Commit
9a064fec
authored
Sep 07, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_document_scanner: samsung browser randomize the device ID
Try to get the cropper options from previous device ID
parent
82c40e30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
18 deletions
+73
-18
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.js
...tem/web_page_module/scanner_gadget_document_scanner_js.js
+71
-16
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.xml
...em/web_page_module/scanner_gadget_document_scanner_js.xml
+2
-2
No files found.
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.js
View file @
9a064fec
...
...
@@ -829,7 +829,38 @@
return
getPreferredDevice
(
gadget
)
.
push
(
function
(
preferred_device_id
)
{
return
selectMediaDevice
(
camera_list
,
preferred_device_id
,
false
);
return
RSVP
.
all
([
selectMediaDevice
(
camera_list
,
preferred_device_id
,
false
),
preferred_device_id
]);
})
.
push
(
function
(
result_list
)
{
var
device_id
=
result_list
[
0
],
preferred_device_id
=
result_list
[
1
];
if
(
device_id
!==
preferred_device_id
)
{
// Previous camera used in the same session was not found
// Samsung browser seems to randomize the device ID every time
// it is accessed
// Duplicate previous crop options
return
gadget
.
session_storage_jio
.
get
(
CROPPER_DATA_JIO_KEY
+
preferred_device_id
)
.
push
(
function
(
data
)
{
return
gadget
.
session_storage_jio
.
put
(
CROPPER_DATA_JIO_KEY
+
device_id
,
data
);
},
function
(
error
)
{
if
((
error
instanceof
jIO
.
util
.
jIOError
)
&&
(
error
.
status_code
===
404
))
{
// If no previous crop data found, nothing to do
return
;
}
throw
error
;
})
.
push
(
function
()
{
return
device_id
;
});
}
return
device_id
;
})
.
push
(
function
(
device_id
)
{
if
(
camera_list
.
indexOf
(
device_id
)
===
-
1
)
{
...
...
@@ -851,10 +882,18 @@
.
onStateChange
(
function
(
modification_dict
)
{
var
gadget
=
this
,
display_step
,
thumbnail_container
;
thumbnail_container
,
result
;
// ALL DOM modifications must be done only in this method
// this prevent concurrency issue on DOM access
// Remember the current device id
if
(
modification_dict
.
hasOwnProperty
(
'
device_id
'
))
{
result
=
new
RSVP
.
Queue
(
putPreferredDevice
(
gadget
,
gadget
.
state
.
device_id
));
}
else
{
result
=
new
RSVP
.
Queue
();
}
// Only refresh the full gadget content after the first render call
// or if the display_step is modified
// or if displaying another image
...
...
@@ -864,26 +903,45 @@
display_step
=
modification_dict
.
display_step
;
}
if
(
display_step
===
'
display_video
'
||
modification_dict
.
hasOwnProperty
(
'
device_id
'
))
{
return
renderVideoCapture
(
gadget
);
return
result
.
push
(
function
()
{
return
renderVideoCapture
(
gadget
);
});
}
if
(
display_step
===
'
crop_picture
'
)
{
return
captureAndRenderPicture
(
gadget
);
return
result
.
push
(
function
()
{
return
captureAndRenderPicture
(
gadget
);
});
}
if
(
display_step
===
'
auto_crop_picture
'
)
{
return
captureAndRenderPicture
(
gadget
,
true
);
return
result
.
push
(
function
()
{
return
captureAndRenderPicture
(
gadget
,
true
);
});
}
if
(
display_step
===
'
show_picture
'
)
{
return
renderSubmittedPicture
(
gadget
);
return
result
.
push
(
function
()
{
return
renderSubmittedPicture
(
gadget
);
});
}
if
(
display_step
)
{
// Ease developper work by raising for not handled cases
throw
new
Error
(
'
Unhandled display step:
'
+
gadget
.
state
.
display_step
);
return
result
.
push
(
function
()
{
throw
new
Error
(
'
Unhandled display step:
'
+
gadget
.
state
.
display_step
);
});
}
// Only refresh the thumbnail area
// if display_step is not modified
return
buildPreviousThumbnailDom
(
gadget
)
return
result
.
push
(
function
()
{
return
buildPreviousThumbnailDom
(
gadget
);
})
.
push
(
function
(
result
)
{
thumbnail_container
=
gadget
.
element
.
querySelector
(
'
.thumbnail-list
'
);
thumbnail_container
.
parentElement
.
replaceChild
(
...
...
@@ -977,14 +1035,11 @@
}
else
{
camera_list
=
[
device_id
];
}
return
putPreferredDevice
(
gadget
,
device_id
)
.
push
(
function
()
{
return
gadget
.
changeState
({
display_step
:
'
display_video
'
,
camera_list
:
camera_list
,
device_id
:
device_id
});
});
return
gadget
.
changeState
({
display_step
:
'
display_video
'
,
camera_list
:
camera_list
,
device_id
:
device_id
});
});
}
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.xml
View file @
9a064fec
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
986.
29418.46329.1250
9
</string>
</value>
<value>
<string>
986.
32279.2119.197
9
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
1599
470361.92
</float>
<float>
1599
642009.31
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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