Refactor to a single transformer file
This commit is contained in:
parent
cae604e79d
commit
9b16f5883c
|
@ -1,6 +1,6 @@
|
||||||
import http from '@/api/http';
|
import http from '@/api/http';
|
||||||
import { ServerBackup } from '@/api/server/types';
|
import { ServerBackup } from '@/api/server/types';
|
||||||
import { rawDataToServerBackup } from '@/api/server/transformers';
|
import { rawDataToServerBackup } from '@/api/transformers';
|
||||||
|
|
||||||
export default (uuid: string, name?: string, ignored?: string): Promise<ServerBackup> => {
|
export default (uuid: string, name?: string, ignored?: string): Promise<ServerBackup> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
import { FractalResponseData } from '@/api/http';
|
|
||||||
import { ServerBackup } from '@/api/server/types';
|
|
||||||
|
|
||||||
export const rawDataToServerBackup = ({ attributes }: FractalResponseData): ServerBackup => ({
|
|
||||||
uuid: attributes.uuid,
|
|
||||||
isSuccessful: attributes.is_successful,
|
|
||||||
name: attributes.name,
|
|
||||||
ignoredFiles: attributes.ignored_files,
|
|
||||||
sha256Hash: attributes.sha256_hash,
|
|
||||||
bytes: attributes.bytes,
|
|
||||||
createdAt: new Date(attributes.created_at),
|
|
||||||
completedAt: attributes.completed_at ? new Date(attributes.completed_at) : null,
|
|
||||||
});
|
|
|
@ -1,7 +1,7 @@
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
import http, { getPaginationSet, PaginatedResult } from '@/api/http';
|
import http, { getPaginationSet, PaginatedResult } from '@/api/http';
|
||||||
import { ServerBackup } from '@/api/server/types';
|
import { ServerBackup } from '@/api/server/types';
|
||||||
import { rawDataToServerBackup } from '@/api/server/transformers';
|
import { rawDataToServerBackup } from '@/api/transformers';
|
||||||
import useServer from '@/plugins/useServer';
|
import useServer from '@/plugins/useServer';
|
||||||
|
|
||||||
export default (page?: number | string) => {
|
export default (page?: number | string) => {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { Allocation } from '@/api/server/getServer';
|
import { Allocation } from '@/api/server/getServer';
|
||||||
import { FractalResponseData } from '@/api/http';
|
import { FractalResponseData } from '@/api/http';
|
||||||
import { FileObject } from '@/api/server/files/loadDirectory';
|
import { FileObject } from '@/api/server/files/loadDirectory';
|
||||||
|
import { ServerBackup } from '@/api/server/types';
|
||||||
|
|
||||||
export const rawDataToServerAllocation = (data: FractalResponseData): Allocation => ({
|
export const rawDataToServerAllocation = (data: FractalResponseData): Allocation => ({
|
||||||
id: data.attributes.id,
|
id: data.attributes.id,
|
||||||
|
@ -39,3 +40,14 @@ export const rawDataToFileObject = (data: FractalResponseData): FileObject => ({
|
||||||
].indexOf(this.mimetype) >= 0;
|
].indexOf(this.mimetype) >= 0;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const rawDataToServerBackup = ({ attributes }: FractalResponseData): ServerBackup => ({
|
||||||
|
uuid: attributes.uuid,
|
||||||
|
isSuccessful: attributes.is_successful,
|
||||||
|
name: attributes.name,
|
||||||
|
ignoredFiles: attributes.ignored_files,
|
||||||
|
sha256Hash: attributes.sha256_hash,
|
||||||
|
bytes: attributes.bytes,
|
||||||
|
createdAt: new Date(attributes.created_at),
|
||||||
|
completedAt: attributes.completed_at ? new Date(attributes.completed_at) : null,
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue