Skip to content

Commit

Permalink
Merge pull request #170 from sbs20/staging
Browse files Browse the repository at this point in the history
No matching pipeline
  • Loading branch information
sbs20 authored Apr 3, 2021
2 parents 57a9a06 + 207aab5 commit d234221
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 33 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
-- *A satisfied user*

scanservjs is a web-based UI for your scanner. It allows you to share one or
scanservjs is a web UI frontend for your scanner. It allows you to share one or
more scanners (using SANE) on a network without the need for drivers or
complicated installation.

Expand All @@ -26,7 +26,8 @@ complicated installation.
* Configurable overrides for all defaults as well as filters and formats
* Multipage scanning (with collation for double sided scans)
* Light and dark mode
* **NEW**: International translations: Czech, German, Italian, Spanish (**help requested**)
* **NEW**: International translations: Czech, German, Italian, Spanish (**help
requested**)

It supports any
[SANE compatible devices](http://www.sane-project.org/sane-supported-devices.html).
Expand Down
2 changes: 1 addition & 1 deletion server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scanservjs-server",
"version": "2.8.2",
"version": "2.8.3",
"description": "scanservjs is a simple web-based UI for SANE which allows you to share a scanner on a network without the need for drivers or complicated installation. scanserv does not do image conversion or manipulation (beyond the bare minimum necessary for the purposes of browser preview) or OCR.",
"scripts": {
"serve": "nodemon --exec 'vue-cli-service serve'",
Expand Down
7 changes: 5 additions & 2 deletions server/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Api {
* @returns {Promise.<FileInfo[]>}
*/
static async fileList() {
log.debug('fileList()');
log.trace('fileList()');
const dir = new FileInfo(Config.outputDirectory);
let files = await dir.list();
files = files
Expand All @@ -30,6 +30,7 @@ class Api {
* @returns {FileInfo}
*/
static fileDelete(fullpath) {
log.trace('fileDelete()');
const file = new FileInfo(fullpath);
const parent = new FileInfo(file.path);
const data = new FileInfo(Config.outputDirectory);
Expand Down Expand Up @@ -57,7 +58,7 @@ class Api {
});

const cmd = `${Scanimage.scan(request)} > ${Config.previewDirectory}preview.tif`;
log.debug('Executing cmd:', cmd);
log.trace('Executing cmd:', cmd);
await Process.spawn(cmd);
return {};
}
Expand All @@ -66,6 +67,7 @@ class Api {
* @returns {FileInfo}
*/
static deletePreview() {
log.trace('deletePreview()');
const file = new FileInfo(`${Config.previewDirectory}preview.tif`);
return file.delete();
}
Expand All @@ -75,6 +77,7 @@ class Api {
* @returns {Promise.<Buffer>}
*/
static async readPreview(filters) {
log.trace('readPreview()', filters);
// The UI relies on this image being the correct aspect ratio. If there is a
// preview image then just use it.
const source = new FileInfo(`${Config.previewDirectory}preview.tif`);
Expand Down
2 changes: 1 addition & 1 deletion server/src/command-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CmdBuilder {
if (ignoreStderr) {
cmd += ' 2>/dev/null';
}
log.debug('build()', cmd);
log.trace('build()', cmd);
return cmd;
}
}
Expand Down
4 changes: 1 addition & 3 deletions server/src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ const Config = require('./config');
const Devices = require('./devices');

const diagnostic = (path) => {
const exists = fs.existsSync(path);
const isDirectory = exists && fs.statSync(path).isDirectory();
const success = exists && !isDirectory;
const success = fs.existsSync(path) && !fs.statSync(path).isDirectory();
const message = success ? `Found ${path}` : `Unable to find file ${path}`;
return {
success,
Expand Down
2 changes: 1 addition & 1 deletion server/src/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Process = {
}

proc.on('close', (code) => {
log.debug(`close(${code}): ${cmd}`);
log.trace(`close(${code}): ${cmd}`);
if (code !== 0 && !options.ignoreErrors) {
reject(new Error(`${cmd} exited with code: ${code}, stderr: ${stderr}`));
} else {
Expand Down
50 changes: 28 additions & 22 deletions webui/src/components/Scan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<v-select
v-model="request.filters"
:items="context.filters"
:items="filters"
item-text="text"
item-value="value"
:label="$t('scan.filters')"
Expand All @@ -49,7 +49,7 @@
<v-select
:label="$t('scan.format')"
v-model="request.pipeline"
:items="context.pipelines"
:items="pipelines"
item-text="text"
item-value="value"></v-select>

Expand Down Expand Up @@ -166,6 +166,32 @@ export default {
});
},
computed: {
filters() {
return this.context.filters.map(f => {
return {
text: this.$t(`scan.${f}`),
value: f
};
});
},
pipelines() {
return this.context.pipelines.map(p => {
const variables = (p.match(/@:[a-z-.]+/ig) || []).map(s => s.substr(2));
let text = p;
variables.forEach(v => {
text = text.replaceAll(`@:${v}`, this.$t(v));
});
return {
text: text,
value: p
};
});
}
},
watch: {
request: {
handler(request) {
Expand Down Expand Up @@ -313,26 +339,6 @@ export default {
return this._fetch(url).then(context => {
window.clearTimeout(timer);
context.filters = context.filters.map(f => {
return {
text: this.$t(`scan.${f}`),
value: f
};
});
context.pipelines = context.pipelines.map(p => {
const variables = (p.match(/@:[a-z-.]+/ig) || []).map(s => s.substr(2));
let text = p;
variables.forEach(v => {
text = text.replaceAll(`@:${v}`, this.$t(v));
});
return {
text: text,
value: p
};
});
this.context = context;
if (context.devices.length > 0) {
Expand Down

0 comments on commit d234221

Please sign in to comment.