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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Łukasz Nowak
erp5
Commits
afac180a
Commit
afac180a
authored
Apr 07, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_document_scanner: store the preferred device in session storage
parent
071d2901
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
9 deletions
+37
-9
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.js
...tem/web_page_module/scanner_gadget_document_scanner_js.js
+35
-7
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 @
afac180a
...
...
@@ -7,7 +7,8 @@
FileReader
,
DataView
,
URL
,
fx
)
{
"
use strict
"
;
var
CROPPER_DATA_JIO_KEY
=
'
cropperjs_data_
'
;
var
CROPPER_DATA_JIO_KEY
=
'
cropperjs_data_
'
,
DEVICE_JIO_KEY
=
'
preferred_device
'
;
function
getDevicePreferredCropperData
(
gadget
)
{
return
gadget
.
session_storage_jio
.
get
(
CROPPER_DATA_JIO_KEY
+
gadget
.
state
.
device_id
)
...
...
@@ -27,6 +28,27 @@
);
}
function
getPreferredDevice
(
gadget
)
{
return
gadget
.
session_storage_jio
.
get
(
DEVICE_JIO_KEY
)
.
push
(
undefined
,
function
(
error
)
{
if
((
error
instanceof
jIO
.
util
.
jIOError
)
&&
(
error
.
status_code
===
404
))
{
return
{};
}
throw
error
;
})
.
push
(
function
(
jio_document
)
{
return
jio_document
.
device_id
;
});
}
function
putPreferredDevice
(
gadget
,
device_id
)
{
return
gadget
.
session_storage_jio
.
put
(
DEVICE_JIO_KEY
,
{
device_id
:
device_id
}
);
}
//////////////////////////////////////////////////
// Browser API to promise
//////////////////////////////////////////////////
...
...
@@ -848,7 +870,10 @@
camera_list
=
gadget
.
state
.
camera_list
,
default_value
=
JSON
.
parse
(
options
.
value
);
return
selectMediaDevice
(
camera_list
,
gadget
.
state
.
device_id
,
false
)
return
getPreferredDevice
(
gadget
)
.
push
(
function
(
preferred_device_id
)
{
return
selectMediaDevice
(
camera_list
,
preferred_device_id
,
false
);
})
.
push
(
function
(
device_id
)
{
if
(
camera_list
.
indexOf
(
device_id
)
===
-
1
)
{
camera_list
.
push
(
device_id
);
...
...
@@ -995,12 +1020,15 @@
}
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
});
});
});
}
if
(
evt
.
target
.
className
.
indexOf
(
"
show-img
"
)
!==
-
1
)
{
...
...
bt5/erp5_document_scanner/PathTemplateItem/web_page_module/scanner_gadget_document_scanner_js.xml
View file @
afac180a
...
...
@@ -244,7 +244,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
983.
1729.31351.955
</string>
</value>
<value>
<string>
983.
2714.63510.3754
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>
1586
185444.24
</float>
<float>
1586
244257.05
</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