diff --git a/mediarepo-ui/src/api/models/FilterQueryBuilder.ts b/mediarepo-ui/src/api/models/FilterQueryBuilder.ts
index b75c879..04a8a39 100644
--- a/mediarepo-ui/src/api/models/FilterQueryBuilder.ts
+++ b/mediarepo-ui/src/api/models/FilterQueryBuilder.ts
@@ -143,7 +143,7 @@ export class FilterQueryBuilder {
}
break;
case "FileSize":
- value = this.parsePropertyValue(compareValue, parseNumber);
+ value = this.parsePropertyValue(compareValue, parseByteSize);
if (value != undefined) {
return this.fileSize(value[0], comparator, value[1]);
}
@@ -280,6 +280,35 @@ function parseNumber(value: string): number | undefined {
return isNaN(num) ? undefined : num;
}
+function parseByteSize(value: string): number | undefined {
+ const valueMappings: { [key: string]: number } = {
+ "TiB": 1024 ** 4,
+ "GiB": 1024 ** 3,
+ "MiB": 1024 ** 2,
+ "KiB": 1024,
+ "TB": 1000 ** 4,
+ "GB": 1000 ** 3,
+ "MB": 1000 ** 2,
+ "KB": 1000
+ };
+ const stringValue = value.replace(/TiB|GiB|MiB|KiB|TB|GB|MB|KB$/i, "");
+ let number = parseNumber(stringValue);
+ const checkUnit = (unit: string) => value.toLowerCase().includes(unit.toLowerCase());
+
+ if (number) {
+ for (const key of Object.keys(valueMappings)) {
+ if (checkUnit(key)) {
+ console.log("key", key, "valueMapping", valueMappings[key]);
+ number *= valueMappings[key];
+ console.log("number", number);
+ break;
+ }
+ }
+ }
+
+ return number;
+}
+
function parseDate(value: string): Date | undefined {
const date = Date.parse(value);
diff --git a/mediarepo-ui/src/app/components/shared/input/filter-input/filter-input.component.html b/mediarepo-ui/src/app/components/shared/input/filter-input/filter-input.component.html
index 072c1fb..6b0788d 100644
--- a/mediarepo-ui/src/app/components/shared/input/filter-input/filter-input.component.html
+++ b/mediarepo-ui/src/app/components/shared/input/filter-input/filter-input.component.html
@@ -6,6 +6,7 @@
(keydown.enter)="addExpressionByInput()"
[formControl]="formControl"
[matAutocomplete]="auto"
+ [value]="this.value"
matInput>
();
@@ -57,6 +58,9 @@ export class FilterInputComponent implements OnChanges {
);
this.tagsForAutocomplete = this.availableTags.map(
t => t.getNormalizedOutput());
+ if (this.value) {
+ this.formControl.setValue(this.value);
+ }
}
ngOnChanges(changes: SimpleChanges): void {
@@ -64,6 +68,9 @@ export class FilterInputComponent implements OnChanges {
this.tagsForAutocomplete = this.availableTags.map(
t => t.getNormalizedOutput());
}
+ if (changes["value"] && this.value) {
+ this.formControl.setValue(this.value);
+ }
}
public addExpressionByInput(): void {
@@ -72,7 +79,6 @@ export class FilterInputComponent implements OnChanges {
return;
}
const expressions = FilterQueryBuilder.buildFilterExpressionsFromString(this.formControl.value);
- console.log(this.formControl.value, expressions);
let valid: boolean;
diff --git a/mediarepo-ui/src/app/components/shared/sidebar/file-search/file-search.component.html b/mediarepo-ui/src/app/components/shared/sidebar/file-search/file-search.component.html
index 6ff8e10..9910822 100644
--- a/mediarepo-ui/src/app/components/shared/sidebar/file-search/file-search.component.html
+++ b/mediarepo-ui/src/app/components/shared/sidebar/file-search/file-search.component.html
@@ -4,7 +4,9 @@