2021-01-05 16:17:44 +00:00
|
|
|
import http, { FractalResponseData } from '@/api/http';
|
2021-01-01 00:27:16 +00:00
|
|
|
|
|
|
|
export interface Egg {
|
|
|
|
id: number;
|
|
|
|
uuid: string;
|
2021-01-08 21:55:34 +00:00
|
|
|
nestId: number;
|
2021-01-01 00:27:16 +00:00
|
|
|
author: string;
|
|
|
|
name: string;
|
|
|
|
description: string | null;
|
|
|
|
features: string[] | null;
|
|
|
|
dockerImages: string[];
|
|
|
|
configFiles: string | null;
|
|
|
|
configStartup: string | null;
|
|
|
|
configLogs: string | null;
|
|
|
|
configStop: string | null;
|
|
|
|
configFrom: number | null;
|
|
|
|
startup: string;
|
|
|
|
scriptContainer: string;
|
|
|
|
copyScriptFrom: number | null;
|
|
|
|
scriptEntry: string;
|
|
|
|
scriptIsPrivileged: boolean;
|
|
|
|
scriptInstall: string | null;
|
|
|
|
createdAt: Date;
|
|
|
|
updatedAt: Date;
|
|
|
|
}
|
|
|
|
|
2021-01-05 16:17:44 +00:00
|
|
|
export const rawDataToEgg = ({ attributes }: FractalResponseData): Egg => ({
|
|
|
|
id: attributes.id,
|
|
|
|
uuid: attributes.uuid,
|
2021-01-08 21:55:34 +00:00
|
|
|
nestId: attributes.nest_id,
|
2021-01-05 16:17:44 +00:00
|
|
|
author: attributes.author,
|
|
|
|
name: attributes.name,
|
|
|
|
description: attributes.description,
|
|
|
|
features: attributes.features,
|
|
|
|
dockerImages: attributes.docker_images,
|
|
|
|
configFiles: attributes.config_files,
|
|
|
|
configStartup: attributes.config_startup,
|
|
|
|
configLogs: attributes.config_logs,
|
|
|
|
configStop: attributes.config_stop,
|
|
|
|
configFrom: attributes.config_from,
|
|
|
|
startup: attributes.startup,
|
|
|
|
scriptContainer: attributes.script_container,
|
|
|
|
copyScriptFrom: attributes.copy_script_from,
|
|
|
|
scriptEntry: attributes.script_entry,
|
|
|
|
scriptIsPrivileged: attributes.script_is_privileged,
|
|
|
|
scriptInstall: attributes.script_install,
|
|
|
|
createdAt: new Date(attributes.created_at),
|
|
|
|
updatedAt: new Date(attributes.updated_at),
|
|
|
|
});
|
|
|
|
|
2021-01-08 16:25:40 +00:00
|
|
|
export default (id: number): Promise<Egg> => {
|
2021-01-01 00:27:16 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2021-01-08 16:25:40 +00:00
|
|
|
http.get(`/api/application/eggs/${id}`)
|
|
|
|
.then(({ data }) => resolve(rawDataToEgg(data)))
|
2021-01-01 00:27:16 +00:00
|
|
|
.catch(reject);
|
|
|
|
});
|
|
|
|
};
|