2023-07-30 14:02:18 +03:00
|
|
|
import { OPERATORS } from 'constants/queryBuilder';
|
|
|
|
|
import { ILog } from 'types/api/logs/log';
|
2023-09-15 10:21:42 +05:30
|
|
|
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
2023-07-30 14:02:18 +03:00
|
|
|
import { TagFilterItem } from 'types/api/queryBuilder/queryBuilderData';
|
|
|
|
|
import { v4 as uuid } from 'uuid';
|
|
|
|
|
|
|
|
|
|
export const getFiltersFromResources = (
|
|
|
|
|
resources: ILog['resources_string'],
|
|
|
|
|
): TagFilterItem[] =>
|
|
|
|
|
Object.keys(resources).map((key: string) => {
|
|
|
|
|
const resourceValue = resources[key] as string;
|
|
|
|
|
return {
|
|
|
|
|
id: uuid(),
|
|
|
|
|
key: {
|
|
|
|
|
key,
|
2023-09-15 10:21:42 +05:30
|
|
|
dataType: DataTypes.String,
|
2023-07-30 14:02:18 +03:00
|
|
|
type: 'resource',
|
|
|
|
|
isColumn: false,
|
|
|
|
|
},
|
|
|
|
|
op: OPERATORS['='],
|
|
|
|
|
value: resourceValue,
|
|
|
|
|
};
|
|
|
|
|
});
|