|
|
@ -29,21 +29,21 @@ export class FilterQueryBuilder {
|
|
|
|
|
|
|
|
|
|
|
|
public static importedTime(date: Date, comparator: Comparator, max_date: Date): FilterQuery {
|
|
|
|
public static importedTime(date: Date, comparator: Comparator, max_date: Date): FilterQuery {
|
|
|
|
return filterQuery({
|
|
|
|
return filterQuery({
|
|
|
|
ImportedTime: valuesToCompareEnum(date, comparator,
|
|
|
|
ImportedTime: valuesToCompareEnum(formatDate(date)!!, comparator,
|
|
|
|
max_date
|
|
|
|
formatDate(max_date)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static changedTime(date: Date, comparator: Comparator, max_date: Date): FilterQuery {
|
|
|
|
public static changedTime(date: Date, comparator: Comparator, max_date: Date): FilterQuery {
|
|
|
|
return filterQuery({
|
|
|
|
return filterQuery({
|
|
|
|
ChangedTime: valuesToCompareEnum(date, comparator, max_date)
|
|
|
|
ChangedTime: valuesToCompareEnum(formatDate(date)!!, comparator, formatDate(max_date))
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static createdTime(date: Date, comparator: Comparator, max_date: Date): FilterQuery {
|
|
|
|
public static createdTime(date: Date, comparator: Comparator, max_date: Date): FilterQuery {
|
|
|
|
return filterQuery({
|
|
|
|
return filterQuery({
|
|
|
|
CreatedTime: valuesToCompareEnum(date, comparator, max_date)
|
|
|
|
CreatedTime: valuesToCompareEnum(formatDate(date)!!, comparator, formatDate(max_date))
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -150,6 +150,7 @@ export class FilterQueryBuilder {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case "ImportedTime":
|
|
|
|
case "ImportedTime":
|
|
|
|
|
|
|
|
console.debug(propertyName, rawComparator, compareValue);
|
|
|
|
value = this.parsePropertyValue(compareValue, parseDate);
|
|
|
|
value = this.parsePropertyValue(compareValue, parseDate);
|
|
|
|
if (value != undefined) {
|
|
|
|
if (value != undefined) {
|
|
|
|
return this.importedTime(value[0], comparator, value[1]);
|
|
|
|
return this.importedTime(value[0], comparator, value[1]);
|
|
|
@ -263,7 +264,7 @@ function filterQuery(propertyQuery: PropertyQuery): FilterQuery {
|
|
|
|
return { Property: propertyQuery };
|
|
|
|
return { Property: propertyQuery };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function valuesToCompareEnum<T>(min_value: T, comparator: Comparator, max_value?: T): ValueComparator<T> {
|
|
|
|
function valuesToCompareEnum<T>(min_value: T, comparator: Comparator, max_value: T | undefined): ValueComparator<T> {
|
|
|
|
switch (comparator) {
|
|
|
|
switch (comparator) {
|
|
|
|
case "Less":
|
|
|
|
case "Less":
|
|
|
|
return { Less: min_value };
|
|
|
|
return { Less: min_value };
|
|
|
@ -299,9 +300,9 @@ function parseByteSize(value: string): number | undefined {
|
|
|
|
if (number) {
|
|
|
|
if (number) {
|
|
|
|
for (const key of Object.keys(valueMappings)) {
|
|
|
|
for (const key of Object.keys(valueMappings)) {
|
|
|
|
if (checkUnit(key)) {
|
|
|
|
if (checkUnit(key)) {
|
|
|
|
console.log("key", key, "valueMapping", valueMappings[key]);
|
|
|
|
console.debug("key", key, "valueMapping", valueMappings[key]);
|
|
|
|
number *= valueMappings[key];
|
|
|
|
number *= valueMappings[key];
|
|
|
|
console.log("number", number);
|
|
|
|
console.debug("number", number);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -311,7 +312,7 @@ function parseByteSize(value: string): number | undefined {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function parseDate(value: string): Date | undefined {
|
|
|
|
function parseDate(value: string): Date | undefined {
|
|
|
|
const date = Date.parse(value);
|
|
|
|
const date = Date.parse(value.toUpperCase());
|
|
|
|
|
|
|
|
|
|
|
|
if (isNaN(date)) {
|
|
|
|
if (isNaN(date)) {
|
|
|
|
return undefined;
|
|
|
|
return undefined;
|
|
|
@ -331,3 +332,13 @@ function parseStatus(value: string): FileStatus | undefined {
|
|
|
|
return undefined;
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function formatDate(date?: Date): string | undefined {
|
|
|
|
|
|
|
|
if (date) {
|
|
|
|
|
|
|
|
const pad = (s: number) => s.toString().padStart(2, "0");
|
|
|
|
|
|
|
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(
|
|
|
|
|
|
|
|
date.getMinutes())}:${pad(
|
|
|
|
|
|
|
|
date.getSeconds())}`;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|