Skip to content
Snippets Groups Projects
Commit c462869c authored by Steinwender, Tamara's avatar Steinwender, Tamara
Browse files

Add a notification to file-handling if a file extension isn't supported

parent 46e7b295
Branches
No related tags found
No related merge requests found
Pipeline #52068 failed
...@@ -3,7 +3,7 @@ import {css, html} from 'lit-element'; ...@@ -3,7 +3,7 @@ import {css, html} from 'lit-element';
import {ScopedElementsMixin} from '@open-wc/scoped-elements'; import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import * as commonUtils from "@dbp-toolkit/common/utils"; import * as commonUtils from "@dbp-toolkit/common/utils";
import {Icon, MiniSpinner} from '@dbp-toolkit/common'; import {Icon, MiniSpinner} from '@dbp-toolkit/common';
import {send as notify} from '@dbp-toolkit/common/notification'; import {send} from "@dbp-toolkit/common/notification";
import * as commonStyles from '@dbp-toolkit/common/styles'; import * as commonStyles from '@dbp-toolkit/common/styles';
import {NextcloudFilePicker} from "./nextcloud-file-picker"; import {NextcloudFilePicker} from "./nextcloud-file-picker";
import {classMap} from 'lit-html/directives/class-map.js'; import {classMap} from 'lit-html/directives/class-map.js';
...@@ -262,6 +262,7 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { ...@@ -262,6 +262,7 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) {
} }
checkFileType(file) { checkFileType(file) {
const i18n = this._i18n;
// check if file is allowed // check if file is allowed
const [fileMainType, fileSubType] = file.type.split('/'); const [fileMainType, fileSubType] = file.type.split('/');
const mimeTypes = this.allowedMimeTypes.split(','); const mimeTypes = this.allowedMimeTypes.split(',');
...@@ -274,6 +275,12 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { ...@@ -274,6 +275,12 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) {
if (deny) { if (deny) {
console.log(`mime type ${file.type} of file '${file.name}' is not compatible with ${this.allowedMimeTypes}`); console.log(`mime type ${file.type} of file '${file.name}' is not compatible with ${this.allowedMimeTypes}`);
send({
"summary": i18n.t('file-source.mime-type-title'),
"body": i18n.t('file-source.mime-type-body'),
"type": "danger",
"timeout": 5,
});
return false; return false;
} }
return true; return true;
...@@ -335,7 +342,7 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) { ...@@ -335,7 +342,7 @@ export class FileSource extends ScopedElementsMixin(DbpFileHandlingLitElement) {
const i18n = this._i18n; const i18n = this._i18n;
console.error('ZIP file does not contain any files of ' + this.allowedMimeTypes); console.error('ZIP file does not contain any files of ' + this.allowedMimeTypes);
//throw new Error('ZIP file does not contain any files of ' + this.allowedMimeTypes); //throw new Error('ZIP file does not contain any files of ' + this.allowedMimeTypes);
notify({ send({
"summary": i18n.t('file-source.no-usable-files-in-zip'), "summary": i18n.t('file-source.no-usable-files-in-zip'),
"body": i18n.t('file-source.no-usable-files-hint') + this.allowedMimeTypes, "body": i18n.t('file-source.no-usable-files-hint') + this.allowedMimeTypes,
"type": 'danger', "type": 'danger',
......
...@@ -17,7 +17,9 @@ ...@@ -17,7 +17,9 @@
"nav-local": "Lokaler Computer", "nav-local": "Lokaler Computer",
"no-usable-files-in-zip": "ZIP Datei enthält keine verwendbaren Dateien", "no-usable-files-in-zip": "ZIP Datei enthält keine verwendbaren Dateien",
"no-usable-files-hint": "Laden Sie eine ZIP Datei mit Dateien von folgendem Typ hoch: ", "no-usable-files-hint": "Laden Sie eine ZIP Datei mit Dateien von folgendem Typ hoch: ",
"clipboard": "Zwischenablage" "clipboard": "Zwischenablage",
"mime-type-title": "Nicht unterstützes Dateiformat",
"mime-type-body": "Das Dateiformat wird von dieser Applikation nicht unterstützt."
}, },
"file-sink": { "file-sink": {
"local-intro": "{{count}} Datei herunterladen", "local-intro": "{{count}} Datei herunterladen",
......
...@@ -21,7 +21,9 @@ ...@@ -21,7 +21,9 @@
"clipboard-body": "Here you can choose from the previously temporarily cached files.", "clipboard-body": "Here you can choose from the previously temporarily cached files.",
"clipboard-select-btn": "Select", "clipboard-select-btn": "Select",
"clipboard-no-files": "There are currently no files in the clipboard.", "clipboard-no-files": "There are currently no files in the clipboard.",
"clipboard": "Clipboard" "clipboard": "Clipboard",
"mime-type-title": "Unsupported file format",
"mime-type-body": "The file format is not supported by this application."
}, },
"file-sink": { "file-sink": {
"local-intro": "Download {{count}} file", "local-intro": "Download {{count}} file",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment