ESLint: Fix warnings.
This commit is contained in:
parent
2e72d42d22
commit
1a0fcbdd6f
|
@ -21,7 +21,7 @@ function toggleExpansion() {
|
|||
title="Hilfe"
|
||||
/>
|
||||
<p v-if="expanded" class="help-text">
|
||||
{{ text }}
|
||||
{{ props.text }}
|
||||
</p>
|
||||
</template>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { useConfigStore } from "@/stores/config";
|
||||
import { useNodeStore } from "@/stores/node";
|
||||
import { computed, nextTick, onMounted, ref } from "vue";
|
||||
import { nextTick, onMounted, ref } from "vue";
|
||||
import CONSTRAINTS from "@/shared/validation/constraints";
|
||||
import ActionButton from "@/components/form/ActionButton.vue";
|
||||
import type {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import ButtonGroup from "@/components/form/ButtonGroup.vue";
|
||||
import type { Hostname, StoredNode } from "@/types";
|
||||
import type { StoredNode } from "@/types";
|
||||
import { ButtonSize, ComponentAlignment, ComponentVariant } from "@/types";
|
||||
import { useConfigStore } from "@/stores/config";
|
||||
import { computed } from "vue";
|
||||
|
|
|
@ -3,12 +3,14 @@ import {
|
|||
isMap,
|
||||
isNodesFilter,
|
||||
isString,
|
||||
isUndefined,
|
||||
MonitoringState,
|
||||
NODES_FILTER_FIELDS,
|
||||
type NodesFilter,
|
||||
OnlineState,
|
||||
type SearchTerm,
|
||||
type UnixTimestampMilliseconds,
|
||||
type ValueOf,
|
||||
} from "@/types";
|
||||
import { computed, nextTick, onMounted, ref, watch } from "vue";
|
||||
import { useConfigStore } from "@/stores/config";
|
||||
|
@ -20,7 +22,10 @@ interface Props {
|
|||
|
||||
const SEARCH_THROTTLE_DELAY_MS = 500;
|
||||
|
||||
const FILTER_LABELS: Record<string, string | Map<string | boolean, any>> = {
|
||||
const FILTER_LABELS: Record<
|
||||
string,
|
||||
string | Map<ValueOf<NodesFilter>, string>
|
||||
> = {
|
||||
hasKey: new Map([
|
||||
[true, "Mit VPN-Schlüssel"],
|
||||
[false, "Ohne VPN-Schlüssel"],
|
||||
|
@ -54,7 +59,7 @@ const configStore = useConfigStore();
|
|||
|
||||
type Filter = {
|
||||
field: string;
|
||||
value: any;
|
||||
value: ValueOf<NodesFilter>;
|
||||
};
|
||||
const selectedFilters = ref<Filter[]>([]);
|
||||
|
||||
|
@ -153,15 +158,13 @@ function removeSelectedFilter(filter: Filter): void {
|
|||
}
|
||||
|
||||
function updateSelectedFilters() {
|
||||
const filter = props.filter as Record<string, any>;
|
||||
const filter = props.filter;
|
||||
selectedFilters.value = [];
|
||||
for (const field of Object.keys(NODES_FILTER_FIELDS)) {
|
||||
if (Object.prototype.hasOwnProperty.call(filter, field)) {
|
||||
addSelectedFilter({
|
||||
field,
|
||||
value: filter[field],
|
||||
});
|
||||
}
|
||||
for (const [field, value] of Object.entries(filter)) {
|
||||
addSelectedFilter({
|
||||
field,
|
||||
value,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,7 +181,8 @@ function renderFilter(filter: Filter): string {
|
|||
return `${label}: ${filter.value}`;
|
||||
}
|
||||
|
||||
if (!label.has(filter.value)) {
|
||||
const filterValue = label.get(filter.value);
|
||||
if (isUndefined(filterValue)) {
|
||||
throw new Error(
|
||||
`Filter ${filter.field} has no translation for value: ${
|
||||
filter.value
|
||||
|
@ -186,7 +190,7 @@ function renderFilter(filter: Filter): string {
|
|||
);
|
||||
}
|
||||
|
||||
return label.get(filter.value);
|
||||
return filterValue;
|
||||
}
|
||||
|
||||
function setFocus(focus: boolean): void {
|
||||
|
@ -202,7 +206,7 @@ function showSuggestedFilters(expanded: boolean): void {
|
|||
}
|
||||
|
||||
function buildNodesFilter(): NodesFilter {
|
||||
const nodesFilter: Record<string, any> = {};
|
||||
const nodesFilter: Record<string, ValueOf<NodesFilter>> = {};
|
||||
for (const filter of selectedFilters.value) {
|
||||
nodesFilter[filter.field] = filter.value;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<script lang="ts">
|
||||
import { type Component, defineComponent, type PropType } from "vue";
|
||||
import { type EnumValue, SortDirection } from "@/types";
|
||||
import { type ValueOf, SortDirection } from "@/types";
|
||||
|
||||
type Props<SortField> = {
|
||||
field: PropType<EnumValue<SortField>>;
|
||||
currentField: PropType<EnumValue<SortField>>;
|
||||
field: PropType<ValueOf<SortField>>;
|
||||
currentField: PropType<ValueOf<SortField>>;
|
||||
currentDirection: PropType<SortDirection>;
|
||||
};
|
||||
|
||||
|
@ -12,8 +12,8 @@ type SortTH<SortField> = Component<Props<SortField>>;
|
|||
|
||||
function defineGenericComponent<SortField>(): SortTH<SortField> {
|
||||
const props: Props<SortField> = {
|
||||
field: null as unknown as PropType<EnumValue<SortField>>,
|
||||
currentField: null as unknown as PropType<EnumValue<SortField>>,
|
||||
field: null as unknown as PropType<ValueOf<SortField>>,
|
||||
currentField: null as unknown as PropType<ValueOf<SortField>>,
|
||||
currentDirection: null as unknown as PropType<SortDirection>,
|
||||
};
|
||||
return defineComponent({
|
||||
|
@ -30,6 +30,7 @@ function defineGenericComponent<SortField>(): SortTH<SortField> {
|
|||
},
|
||||
},
|
||||
emits: {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
sort: (field: SortField, direction: SortDirection) => true,
|
||||
},
|
||||
methods: {
|
||||
|
@ -48,6 +49,7 @@ function defineGenericComponent<SortField>(): SortTH<SortField> {
|
|||
|
||||
const component = defineGenericComponent<unknown>();
|
||||
|
||||
// eslint-disable-next-line no-redeclare
|
||||
export function SortTH<SortField>(): SortTH<SortField> {
|
||||
return component as SortTH<SortField>;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue