nextcloud-scanner icon indicating copy to clipboard operation
nextcloud-scanner copied to clipboard

VueJS Progress

Open Biont opened this issue 6 years ago • 19 comments

Hey since the PR is now merged into a separate branch, I wanted to create a new place to discuss changes for the upcoming JS rework.

I really really hope I can find the time to work on this soon. In the meantime, can you, @e-alfred please sum up what would be hard criteria for you to merge the branch? And can we please break it down to some "minimum viable product" kind of thing? The discussion in the old PR had a lot of nice-to-haves mentioned and I'm sure not everything discussed is needed for the very first step.

Biont avatar Apr 21 '19 22:04 Biont

Hello @Biont, awesome news! I think currently the most important problems are the bugs regarding different SANE backends (we should limit the options to a sensible level and leave away any unneeded and obscure options provided by the backends) and the major bug breaking the sharing options of Nextcloud (see here: https://github.com/e-alfred/nextcloud-scanner/pull/10#issuecomment-476864251)

Otherwise I would say the branch is pretty good already, but it shouldn't be released in a state breaking other parts of Nextcloud or not being able to use the app for its intended purpose. Therefore, as soon as we can fix the bugs I would love to merge it into the master branch and release it to the app store.

To keep things easier for now, we could limit the supported options to those offered by the master branch (Color + resolution) + the visual selection of a preview scan and the size option. Otherwise we should only offer options that are useful for our app or maybe the user and if the backend supports it (maybe by while-/blacklisting).

e-alfred avatar Apr 23 '19 14:04 e-alfred

@Biont Are you still working on your Vue.js rework?

e-alfred avatar May 25 '19 09:05 e-alfred

@e-alfred I'm sorry to keep you waiting for so long. This is definetely still on my list - and pretty much on top of it -, but I am sorely lacking spare time these days.

Biont avatar May 25 '19 23:05 Biont

@e-alfred I could not reproduce the sharing bug you mentioned. Can you verify that it still happens and provide me with steps to reproduce?

I am on NC 16.0.1

Biont avatar Jun 12 '19 13:06 Biont

Sorry for the delay, maybe the bug I experienced was caused by an older Nextcloud version or maybe I didn't build it right. Can you add some information on how to build your branch? This is probably helpful for anyone who wants to build/develop this app in the future anyway.

e-alfred avatar Jun 15 '19 08:06 e-alfred

I tried out the new version and it always fails at the "Fetching SANE Backends" step with an error "There was an error while performing the following task: Fetching SANE backends". I found this on the browser console:

{"reqId":"At5zI3nmjLT2kbjnF51G","level":3,"time":"2019-06-15T09:20:39+00:00","remoteAddr":"192.168.1.121","user":"admin","app":"PHP","method":"GET","url":"/index.php/apps/scanner/backends","message":"Undefined offset: 1 at /var/www/html/apps/scanner/lib/Sane/SaneBackend.php#52","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.172 Safari/537.36 Vivaldi/2.5.1525.48","version":"16.0.1.1"} {"reqId":"ZpaWdLbgxfeOzZgMI3bU","level":3,"time":"2019-06-15T09:22:03+00:00","remoteAddr":"192.168.1.121","user":"admin","app":"PHP","method":"POST","url":"/index.php/apps/scanner/scan","message":"Undefined offset: 1 at /var/www/html/apps/scanner/lib/Sane/SaneBackend.php#52","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.172 Safari/537.36 Vivaldi/2.5.1525.48","version":"16.0.1.1"} {"reqId":"ZpaWdLbgxfeOzZgMI3bU","level":3,"time":"2019-06-15T09:22:03+00:00","remoteAddr":"192.168.1.121","user":"admin","app":"PHP","method":"POST","url":"/index.php/apps/scanner/scan","message":"Undefined offset: 0 at /var/www/html/apps/scanner/lib/Sane/BackendCollection.php#48","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.172 Safari/537.36 Vivaldi/2.5.1525.48","version":"16.0.1.1"} {"reqId":"ZpaWdLbgxfeOzZgMI3bU","level":3,"time":"2019-06-15T09:22:03+00:00","remoteAddr":"192.168.1.121","user":"admin","app":"index","method":"POST","url":"/index.php/apps/scanner/scan","message":{"Exception":"TypeError","Message":"Return value of OCA\Scanner\Sane\BackendCollection::getByIndex() must be an instance of OCA\Scanner\Sane\SaneBackend, null returned","Code":0,"Trace":[{"file":"/var/www/html/apps/scanner/controller/scannercontroller.php","line":81,"function":"getByIndex","class":"OCA\Scanner\Sane\BackendCollection","type":"->","args":[0]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":166,"function":"scan","class":"OCA\Scanner\Controller\ScannerController","type":"->","args":["Scanned on 15.6.2019","/",null]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":99,"function":"executeController","class":"OC\AppFramework\Http\Dispatcher","type":"->","args":[{"class":"OCA\Scanner\Controller\ScannerController"},"scan"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":126,"function":"dispatch","class":"OC\AppFramework\Http\Dispatcher","type":"->","args":[{"class":"OCA\Scanner\Controller\ScannerController"},"scan"]},{"file":"/var/www/html/lib/private/AppFramework/Routing/RouteActionHandler.php","line":47,"function":"main","class":"OC\AppFramework\App","type":"::","args":["OCA\Scanner\Controller\ScannerController","scan",{"class":"OC\AppFramework\DependencyInjection\DIContainer"},{"_route":"scanner.scanner.scan"}]},{"function":"__invoke","class":"OC\AppFramework\Routing\RouteActionHandler","type":"->","args":[{"_route":"scanner.scanner.scan"}]},{"file":"/var/www/html/lib/private/Route/Router.php","line":297,"function":"call_user_func","args":[{"class":"OC\AppFramework\Routing\RouteActionHandler"},{"_route":"scanner.scanner.scan"}]},{"file":"/var/www/html/lib/base.php","line":975,"function":"match","class":"OC\Route\Router","type":"->","args":["/apps/scanner/scan"]},{"file":"/var/www/html/index.php","line":42,"function":"handleRequest","class":"OC","type":"::","args":[]}],"File":"/var/www/html/apps/scanner/lib/Sane/BackendCollection.php","Line":48,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.172 Safari/537.36 Vivaldi/2.5.1525.48","version":"16.0.1.1"} {"reqId":"3gVxWagEkPFOcrnC9NW0","level":3,"time":"2019-06-15T09:49:20+00:00","remoteAddr":"192.168.1.121","user":"admin","app":"PHP","method":"GET","url":"/index.php/apps/scanner/backends","message":"Undefined offset: 1 at /var/www/html/apps/scanner/lib/Sane/SaneBackend.php#52","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.172 Safari/537.36 Vivaldi/2.5.1525.48","version":"16.0.1.1"} {"reqId":"DInmnDLNC4t5VkYvlRK3","level":3,"time":"2019-06-15T09:50:28+00:00","remoteAddr":"192.168.1.121","user":"admin","app":"PHP","method":"GET","url":"/index.php/apps/scanner/backends","message":"Undefined offset: 1 at /var/www/html/apps/scanner/lib/Sane/SaneBackend.php#52","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.172 Safari/537.36 Vivaldi/2.5.1525.48","version":"16.0.1.1"}

I can see that it tries to execute "scanimage -L" on the CLI but fails to get a backend:

image

Also, even if an error message is shown, I can still start the scan process which fails as well.

e-alfred avatar Jun 15 '19 09:06 e-alfred

Thanks I will have a look at it soon.

Biont avatar Jun 15 '19 11:06 Biont

Okay, I tested the app on another system and here the mode setting is not supplied to the command line which results in an empty temp file and therefore, an empty scan file. Also it doesn't matter which mode I select, none is applied to the scanimage command:

www-data  2388  0.0  0.0   4628   820 ?        S    15:52   0:00 sh -c sudo scanimage --mode  --resolution 300 -x 215 -y 297| pnmtojpeg > /tmp/img
root      2389  0.0  0.0  60580  3712 ?        S    15:52   0:00 sudo scanimage --mode --resolution 300 -x 215 -y 297
root      2391  3.5  0.0 102648  6500 ?        Rl   15:52   0:00 scanimage --mode --resolution 300 -x 215 -y 297

e-alfred avatar Jun 15 '19 13:06 e-alfred

@e-alfred Can you post the result of the scanimage --device for that scanner? Then I can use that for debugging

Biont avatar Jun 17 '19 07:06 Biont

This is the output of scanimage --help --device=plustek:

Options specific to device `plustek':
  Scan Mode:
    --mode Lineart|Gray|Color [Color]
        Selects the scan mode (e.g., lineart, monochrome, or color).
    --depth 8|14bit [8]
        Number of bits per sample, typical values are 1 for "line-art" and 8
        for multibit scans.
    --source Normal|Transparency|Negative [Normal]
        Selects the scan source (such as a document-feeder).
    --resolution 50..1200dpi [50]
        Sets the resolution of the scanned image.
    --preview[=(yes|no)] [no]
        Request a preview-quality scan.
  Geometry:
    -l 0..215mm [0]
        Top-left x position of scan area.
    -t 0..297mm [0]
        Top-left y position of scan area.
    -x 0..215mm [103]
        Width of scan-area.
    -y 0..297mm [76.21]
        Height of scan-area.
  Enhancement:
    --brightness -100..100% (in steps of 1) [0]
        Controls the brightness of the acquired image.
    --contrast -100..100% (in steps of 1) [0]
        Controls the contrast of the acquired image.
    --custom-gamma[=(yes|no)] [no]
        Determines whether a builtin or a custom gamma-table should be used.
    --gamma-table 0..255,... [inactive]
        Gamma-correction table.  In color mode this option equally affects the
        red, green, and blue channels simultaneously (i.e., it is an intensity
        gamma table).
    --red-gamma-table 0..255,... [inactive]
        Gamma-correction table for the red band.
    --green-gamma-table 0..255,... [inactive]
        Gamma-correction table for the green band.
    --blue-gamma-table 0..255,... [inactive]
        Gamma-correction table for the blue band.
  Device-Settings:
    --lamp-switch[=(yes|no)] [no]
        Manually switching the lamp(s).
    --lampoff-time 0..999 (in steps of 1) [300]
        Lampoff-time in seconds.
    --lamp-off-at-exit[=(yes|no)] [yes]
        Turn off lamp when program exits
    --warmup-time -1..999 (in steps of 1) [-1]
        Warmup-time in seconds.
    --lamp-off-during-dcal[=(yes|no)] [inactive]
        Always switches lamp off when doing dark calibration.
    --calibration-cache[=(yes|no)] [no]
        Enables or disables calibration data cache.
    --speedup-switch[=(yes|no)] [yes]
        Enables or disables speeding up sensor movement.
    --calibrate [inactive]
        Performs calibration
  Analog frontend:
    --red-gain -1..63 (in steps of 1) [-1]
        Red gain value of the AFE
    --green-gain -1..63 (in steps of 1) [-1]
        Green gain value of the AFE
    --blue-gain -1..63 (in steps of 1) [-1]
        Blue gain value of the AFE
    --red-offset -1..63 (in steps of 1) [-1]
        Red offset value of the AFE
    --green-offset -1..63 (in steps of 1) [-1]
        Green offset value of the AFE
    --blue-offset -1..63 (in steps of 1) [-1]
        Blue offset value of the AFE
    --redlamp-off -1..16363 (in steps of 1) [inactive]
        Defines red lamp off parameter
    --greenlamp-off -1..16363 (in steps of 1) [inactive]
        Defines green lamp off parameter
    --bluelamp-off -1..16363 (in steps of 1) [inactive]
        Defines blue lamp off parameter
  Buttons:

Type ``scanimage --help -d DEVICE'' to get list of all options for DEVICE.


List of available devices:
    plustek:libusb:002:002

I also tried the test backend of SANE where the problem also happens additionally to not being able to see any option except for the color setting. You can enable it in the /etc/sane.d/dll.conf file.

e-alfred avatar Jun 17 '19 16:06 e-alfred

The vuejs-rework branch is currently not useable on Nextcloud 17 because of the deprecation of some JS functions. Master is fixed already.

e-alfred avatar Nov 15 '19 20:11 e-alfred

There were some changes to hplip and sane that rendered me unable to connect to my printer from any of my devices and reconfiguring from scratch did not help either. I hope I get this sorted out soon, because that's sort of a requirement for development (and usage of the NC app)

Biont avatar Nov 15 '19 20:11 Biont

This sounds pretty bad, is it a known bug in upstream HPLIP?

e-alfred avatar Nov 30 '19 17:11 e-alfred

@Biont It would be great to revive development of this branch. Do you need a scanner that works well with SANE? If yes, I probably could come up with something.

e-alfred avatar Jan 23 '20 15:01 e-alfred

I looked at the problem again some days ago and it appears that the scanner does indeed work when I specify the address of the scanner, just scanimage -L does return nothing.

I am not really sure what would fix that behavior, but maybe we can add some way to force a scanner address instead of parsing the output of the list of found scanners

Biont avatar Jan 23 '20 16:01 Biont

I merged the recent changes into the dev branch and set up a dev environment that should at least let me do some debugging with the test backend you mentioned earlier. Thanks for that hint, by the way.

Biont avatar Jan 24 '20 23:01 Biont

Which type of HP scanner do you have? Usually they are shown by scanimage -L so this is really strange. Can you run a VM and set up the scanner there by using USB passthrough or over the network?

e-alfred avatar Jan 25 '20 20:01 e-alfred

Just so your offer does not go unappreciated: Thank you for considering providing me with hardware, but I would - at least for now - prefer to explore the options we currently have. On one hand I need this to work with the hardware I have anyway. And on the other hand I would not even know where to put a new device :)

If the problem is just that the network scan is not returning devices that are otherwise properly configured that is something we can try to figure out, document, and work around.

I think a good idea would be to allow storing some configuration in nextcloud's config.php. If you hardcode a device address there, you can skip the network scan and the scan dialog app would load faster as well.

This would be easy to implement and it makes sense in that this is absolutely infrastructure-level configuration that is not expected to change often.

Biont avatar Jan 26 '20 12:01 Biont

@e-alfred Could you have another look at the plustek and test backends? I added some more test data and improved the regex that extracts the options. I'm getting pessimistic though that this catch-all regex to extract scan parameters can work given the immense range of diffferent formatting styles across the various backends. When not even the geometry parameters have a reliable structure in different backends, I feel we will either need a way better method of parsing shell output, or simply introduce device-specific "drivers" (basically objects that can translate JSON into command line arguments). The regex could then stay as a fallback - maybe it gets good enough so we don't even need that many custom drivers at some point. But I fear that there will be much more crazy stuff out there which simply does not fit any pattern

Biont avatar Jan 28 '20 20:01 Biont