Skip to content

Commit 3e41f93

Browse files
committed
Added maxSize validation
1 parent 50dd9ab commit 3e41f93

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</head>
1212

1313
<body>
14-
<mapping-input base-url="https://matwerk.datamanager.kit.edu:8095/" maxSize=10 id="input-component"></mapping-input>
14+
<mapping-input base-url="https://matwerk.datamanager.kit.edu:8095/" maxSize=a id="input-component"></mapping-input>
1515

1616
</body>
1717

src/main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ class MappingInputProvider extends HTMLElement {
129129
const maxSize = this.getAttribute(ATTRIBUTES[1]);
130130
if (maxSize != null) {
131131
this.maxSize = Number.parseInt(maxSize);
132+
if(isNaN(this.maxSize)){
133+
console.error("Invalid maxSize attribute. Setting value to default.")
134+
this.maxSize = 5;
135+
}
132136
}
133137

134138
// initialize and connect file uploader
@@ -138,7 +142,7 @@ class MappingInputProvider extends HTMLElement {
138142
FilePondLib.registerPlugin(FilePondPluginFileValidateSize);
139143
options.credits = false;
140144
options.maxFiles = 1;
141-
options.maxFileSize = `${maxSize}MB`;
145+
options.maxFileSize = `${this.maxSize}MB`;
142146
options.labelIdle = "Drag & Drop your files or <span class=\"filepond--label-action\"> Browse </span><br>" +
143147
`<span class=\"info-small\">(File size is limited to ${options.maxFileSize})</span>`;
144148
this.fileChooser = FilePondLib.create(filepondElement, options);

0 commit comments

Comments
 (0)