chore: run prettier
This commit is contained in:
parent
9cdbbc3a00
commit
155d7bb876
76 changed files with 788 additions and 550 deletions
|
@ -28,12 +28,14 @@ export default (id: number, include: string[] = []) => {
|
|||
params.sort = (sortDirection ? '-' : '') + sort;
|
||||
}
|
||||
|
||||
return useSWR<PaginatedResult<Allocation>>([ 'allocations', page, filters, sort, sortDirection ], async () => {
|
||||
const { data } = await http.get(`/api/application/nodes/${id}/allocations`, { params: { include: include.join(','), page, ...params } });
|
||||
return useSWR<PaginatedResult<Allocation>>(['allocations', page, filters, sort, sortDirection], async () => {
|
||||
const { data } = await http.get(`/api/application/nodes/${id}/allocations`, {
|
||||
params: { include: include.join(','), page, ...params },
|
||||
});
|
||||
|
||||
return ({
|
||||
return {
|
||||
items: (data.data || []).map(rawDataToAllocation),
|
||||
pagination: getPaginationSet(data.meta.pagination),
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
||||
|
|
|
@ -25,7 +25,7 @@ export interface Values {
|
|||
export default (values: Values, include: string[] = []): Promise<Node> => {
|
||||
const data = {};
|
||||
|
||||
Object.keys(values).forEach((key) => {
|
||||
Object.keys(values).forEach(key => {
|
||||
const key2 = key
|
||||
.replace('HTTP', 'Http')
|
||||
.replace('SFTP', 'Sftp')
|
||||
|
|
|
@ -11,9 +11,9 @@ export interface Allocation {
|
|||
|
||||
relations: {
|
||||
server?: Server;
|
||||
}
|
||||
};
|
||||
|
||||
getDisplayText (): string;
|
||||
getDisplayText(): string;
|
||||
}
|
||||
|
||||
export const rawDataToAllocation = ({ attributes }: FractalResponseData): Allocation => ({
|
||||
|
@ -25,11 +25,14 @@ export const rawDataToAllocation = ({ attributes }: FractalResponseData): Alloca
|
|||
assigned: attributes.assigned,
|
||||
|
||||
relations: {
|
||||
server: attributes.relationships?.server?.object === 'server' ? rawDataToServer(attributes.relationships.server as FractalResponseData) : undefined,
|
||||
server:
|
||||
attributes.relationships?.server?.object === 'server'
|
||||
? rawDataToServer(attributes.relationships.server as FractalResponseData)
|
||||
: undefined,
|
||||
},
|
||||
|
||||
// TODO: If IP is an IPv6, wrap IP in [].
|
||||
getDisplayText (): string {
|
||||
getDisplayText(): string {
|
||||
if (attributes.alias !== null) {
|
||||
return `${attributes.ip}:${attributes.port} (${attributes.alias})`;
|
||||
}
|
||||
|
@ -38,7 +41,7 @@ export const rawDataToAllocation = ({ attributes }: FractalResponseData): Alloca
|
|||
});
|
||||
|
||||
export interface Filters {
|
||||
ip?: string
|
||||
ip?: string;
|
||||
/* eslint-disable camelcase */
|
||||
server_id?: string;
|
||||
/* eslint-enable camelcase */
|
||||
|
|
|
@ -33,7 +33,7 @@ export interface Node {
|
|||
relations: {
|
||||
databaseHost: Database | undefined;
|
||||
location: Location | undefined;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const rawDataToNode = ({ attributes }: FractalResponseData): Node => ({
|
||||
|
@ -63,8 +63,15 @@ export const rawDataToNode = ({ attributes }: FractalResponseData): Node => ({
|
|||
|
||||
relations: {
|
||||
// eslint-disable-next-line camelcase
|
||||
databaseHost: attributes.relationships?.database_host !== undefined && attributes.relationships?.database_host.object !== 'null_resource' ? rawDataToDatabase(attributes.relationships.database_host as FractalResponseData) : undefined,
|
||||
location: attributes.relationships?.location !== undefined ? rawDataToLocation(attributes.relationships.location as FractalResponseData) : undefined,
|
||||
databaseHost:
|
||||
attributes.relationships?.database_host !== undefined &&
|
||||
attributes.relationships?.database_host.object !== 'null_resource'
|
||||
? rawDataToDatabase(attributes.relationships.database_host as FractalResponseData)
|
||||
: undefined,
|
||||
location:
|
||||
attributes.relationships?.location !== undefined
|
||||
? rawDataToLocation(attributes.relationships.location as FractalResponseData)
|
||||
: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -96,12 +103,14 @@ export default (include: string[] = []) => {
|
|||
params.sort = (sortDirection ? '-' : '') + sort;
|
||||
}
|
||||
|
||||
return useSWR<PaginatedResult<Node>>([ 'nodes', page, filters, sort, sortDirection ], async () => {
|
||||
const { data } = await http.get('/api/application/nodes', { params: { include: include.join(','), page, ...params } });
|
||||
return useSWR<PaginatedResult<Node>>(['nodes', page, filters, sort, sortDirection], async () => {
|
||||
const { data } = await http.get('/api/application/nodes', {
|
||||
params: { include: include.join(','), page, ...params },
|
||||
});
|
||||
|
||||
return ({
|
||||
return {
|
||||
items: (data.data || []).map(rawDataToNode),
|
||||
pagination: getPaginationSet(data.meta.pagination),
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@ import { Node, rawDataToNode } from '@/api/admin/nodes/getNodes';
|
|||
export default (id: number, node: Partial<Node>, include: string[] = []): Promise<Node> => {
|
||||
const data = {};
|
||||
|
||||
Object.keys(node).forEach((key) => {
|
||||
Object.keys(node).forEach(key => {
|
||||
const key2 = key
|
||||
.replace('HTTP', 'Http')
|
||||
.replace('SFTP', 'Sftp')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue