Fix sorting after merge.

This commit is contained in:
baldo 2022-08-23 22:20:14 +02:00
parent 4602aaa871
commit 22d7755215
3 changed files with 21 additions and 20 deletions

View file

@ -3,7 +3,7 @@ import {
type DomainSpecificNodeResponse, type DomainSpecificNodeResponse,
isDomainSpecificNodeResponse, isDomainSpecificNodeResponse,
type NodesFilter, type NodesFilter,
NodeSortField, NodeSortFieldEnum,
SortDirection, SortDirection,
} from "@/types"; } from "@/types";
import { internalApi } from "@/utils/Api"; import { internalApi } from "@/utils/Api";
@ -14,7 +14,7 @@ interface NodesStoreState {
nodesPerPage: number; nodesPerPage: number;
totalNodes: number; totalNodes: number;
sortDirection: SortDirection; sortDirection: SortDirection;
sortField: NodeSortField; sortField: NodeSortFieldEnum;
} }
export const useNodesStore = defineStore({ export const useNodesStore = defineStore({
@ -26,7 +26,7 @@ export const useNodesStore = defineStore({
nodesPerPage: 20, nodesPerPage: 20,
totalNodes: 0, totalNodes: 0,
sortDirection: SortDirection.ASCENDING, sortDirection: SortDirection.ASCENDING,
sortField: NodeSortField.HOSTNAME, sortField: NodeSortFieldEnum.HOSTNAME,
}; };
}, },
getters: { getters: {
@ -51,7 +51,7 @@ export const useNodesStore = defineStore({
page: number, page: number,
nodesPerPage: number, nodesPerPage: number,
sortDirection: SortDirection, sortDirection: SortDirection,
sortField: NodeSortField, sortField: NodeSortFieldEnum,
filter: NodesFilter, filter: NodesFilter,
searchTerm?: string searchTerm?: string
): Promise<void> { ): Promise<void> {
@ -63,7 +63,7 @@ export const useNodesStore = defineStore({
} }
const result = await internalApi.getPagedList< const result = await internalApi.getPagedList<
DomainSpecificNodeResponse, DomainSpecificNodeResponse,
NodeSortField NodeSortFieldEnum
>( >(
"nodes", "nodes",
isDomainSpecificNodeResponse, isDomainSpecificNodeResponse,

View file

@ -10,7 +10,8 @@ import type {
import { import {
ButtonSize, ButtonSize,
ComponentVariant, ComponentVariant,
NodeSortField, type NodeSortField,
NodeSortFieldEnum,
SortDirection, SortDirection,
} from "@/types"; } from "@/types";
import ListPager from "@/components/ListPager.vue"; import ListPager from "@/components/ListPager.vue";
@ -41,7 +42,7 @@ const props = defineProps({
}, },
sortField: { sortField: {
type: String as PropType<NodeSortField>, type: String as PropType<NodeSortField>,
default: NodeSortField.HOSTNAME, default: NodeSortFieldEnum.HOSTNAME,
}, },
}); });
@ -196,7 +197,7 @@ watch(props, async () => {
<thead> <thead>
<tr> <tr>
<sth <sth
:field="NodeSortField.HOSTNAME" :field="NodeSortFieldEnum.HOSTNAME"
:currentField="sortField" :currentField="sortField"
:currentDirection="sortDirection" :currentDirection="sortDirection"
@sort="updateSortOrder" @sort="updateSortOrder"
@ -204,7 +205,7 @@ watch(props, async () => {
Name Name
</sth> </sth>
<sth <sth
:field="NodeSortField.NICKNAME" :field="NodeSortFieldEnum.NICKNAME"
:currentField="sortField" :currentField="sortField"
:currentDirection="sortDirection" :currentDirection="sortDirection"
@sort="updateSortOrder" @sort="updateSortOrder"
@ -212,7 +213,7 @@ watch(props, async () => {
Besitzer*in Besitzer*in
</sth> </sth>
<sth <sth
:field="NodeSortField.EMAIL" :field="NodeSortFieldEnum.EMAIL"
:currentField="sortField" :currentField="sortField"
:currentDirection="sortDirection" :currentDirection="sortDirection"
@sort="updateSortOrder" @sort="updateSortOrder"
@ -220,7 +221,7 @@ watch(props, async () => {
E-Mail E-Mail
</sth> </sth>
<sth <sth
:field="NodeSortField.TOKEN" :field="NodeSortFieldEnum.TOKEN"
:currentField="sortField" :currentField="sortField"
:currentDirection="sortDirection" :currentDirection="sortDirection"
@sort="updateSortOrder" @sort="updateSortOrder"
@ -228,7 +229,7 @@ watch(props, async () => {
Token Token
</sth> </sth>
<sth <sth
:field="NodeSortField.MAC" :field="NodeSortFieldEnum.MAC"
:currentField="sortField" :currentField="sortField"
:currentDirection="sortDirection" :currentDirection="sortDirection"
@sort="updateSortOrder" @sort="updateSortOrder"
@ -236,7 +237,7 @@ watch(props, async () => {
MAC MAC
</sth> </sth>
<sth <sth
:field="NodeSortField.KEY" :field="NodeSortFieldEnum.KEY"
:currentField="sortField" :currentField="sortField"
:currentDirection="sortDirection" :currentDirection="sortDirection"
@sort="updateSortOrder" @sort="updateSortOrder"
@ -244,7 +245,7 @@ watch(props, async () => {
VPN VPN
</sth> </sth>
<sth <sth
:field="NodeSortField.SITE" :field="NodeSortFieldEnum.SITE"
:currentField="sortField" :currentField="sortField"
:currentDirection="sortDirection" :currentDirection="sortDirection"
@sort="updateSortOrder" @sort="updateSortOrder"
@ -252,7 +253,7 @@ watch(props, async () => {
Site Site
</sth> </sth>
<sth <sth
:field="NodeSortField.DOMAIN" :field="NodeSortFieldEnum.DOMAIN"
:currentField="sortField" :currentField="sortField"
:currentDirection="sortDirection" :currentDirection="sortDirection"
@sort="updateSortOrder" @sort="updateSortOrder"
@ -260,7 +261,7 @@ watch(props, async () => {
Domäne Domäne
</sth> </sth>
<sth <sth
:field="NodeSortField.COORDS" :field="NodeSortFieldEnum.COORDS"
:currentField="sortField" :currentField="sortField"
:currentDirection="sortDirection" :currentDirection="sortDirection"
@sort="updateSortOrder" @sort="updateSortOrder"
@ -268,7 +269,7 @@ watch(props, async () => {
GPS GPS
</sth> </sth>
<sth <sth
:field="NodeSortField.ONLINE_STATE" :field="NodeSortFieldEnum.ONLINE_STATE"
:currentField="sortField" :currentField="sortField"
:currentDirection="sortDirection" :currentDirection="sortDirection"
@sort="updateSortOrder" @sort="updateSortOrder"
@ -276,7 +277,7 @@ watch(props, async () => {
Status Status
</sth> </sth>
<sth <sth
:field="NodeSortField.MONITORING_STATE" :field="NodeSortFieldEnum.MONITORING_STATE"
:currentField="sortField" :currentField="sortField"
:currentDirection="sortDirection" :currentDirection="sortDirection"
@sort="updateSortOrder" @sort="updateSortOrder"

View file

@ -573,7 +573,7 @@ export function isMonitoringResponse(arg: unknown): arg is MonitoringResponse {
} }
// noinspection JSUnusedGlobalSymbols // noinspection JSUnusedGlobalSymbols
enum NodeSortFieldEnum { export enum NodeSortFieldEnum {
HOSTNAME = "hostname", HOSTNAME = "hostname",
NICKNAME = "nickname", NICKNAME = "nickname",
EMAIL = "email", EMAIL = "email",
@ -632,7 +632,7 @@ export function isNodesFilter(arg: unknown): arg is NodesFilter {
); );
} }
export type SearchTerm = string & { readonly __tag: unique symbol } export type SearchTerm = string & { readonly __tag: unique symbol };
export const isSearchTerm = isString; export const isSearchTerm = isString;
export enum MonitoringSortField { export enum MonitoringSortField {