2020-07-10 02:56:46 +00:00
|
|
|
import { Allocation } from '@/api/server/getServer';
|
|
|
|
import { FractalResponseData } from '@/api/http';
|
2020-07-11 20:38:49 +00:00
|
|
|
import { FileObject } from '@/api/server/files/loadDirectory';
|
|
|
|
import v4 from 'uuid/v4';
|
2020-07-10 02:56:46 +00:00
|
|
|
|
|
|
|
export const rawDataToServerAllocation = (data: FractalResponseData): Allocation => ({
|
2020-07-10 03:36:08 +00:00
|
|
|
id: data.attributes.id,
|
2020-07-10 02:56:46 +00:00
|
|
|
ip: data.attributes.ip,
|
|
|
|
alias: data.attributes.ip_alias,
|
|
|
|
port: data.attributes.port,
|
2020-07-10 03:36:08 +00:00
|
|
|
notes: data.attributes.notes,
|
2020-07-10 02:56:46 +00:00
|
|
|
isDefault: data.attributes.is_default,
|
|
|
|
});
|
2020-07-11 20:38:49 +00:00
|
|
|
|
|
|
|
export const rawDataToFileObject = (data: FractalResponseData): FileObject => ({
|
|
|
|
uuid: v4(),
|
|
|
|
name: data.attributes.name,
|
|
|
|
mode: data.attributes.mode,
|
|
|
|
size: Number(data.attributes.size),
|
|
|
|
isFile: data.attributes.is_file,
|
|
|
|
isSymlink: data.attributes.is_symlink,
|
|
|
|
isEditable: data.attributes.is_editable,
|
|
|
|
mimetype: data.attributes.mimetype,
|
|
|
|
createdAt: new Date(data.attributes.created_at),
|
|
|
|
modifiedAt: new Date(data.attributes.modified_at),
|
|
|
|
});
|