Very basic implemention of frontend logic required to display backups and create a new one
This commit is contained in:
parent
17ec4efd3b
commit
9991989f89
16 changed files with 431 additions and 2 deletions
32
resources/scripts/api/server/backups/getServerBackups.ts
Normal file
32
resources/scripts/api/server/backups/getServerBackups.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import http, { FractalResponseData, getPaginationSet, PaginatedResult } from '@/api/http';
|
||||
|
||||
export interface ServerBackup {
|
||||
uuid: string;
|
||||
name: string;
|
||||
contents: string;
|
||||
sha256Hash: string;
|
||||
bytes: number;
|
||||
createdAt: Date;
|
||||
completedAt: Date | null;
|
||||
}
|
||||
|
||||
export const rawDataToServerBackup = ({ attributes }: FractalResponseData): ServerBackup => ({
|
||||
uuid: attributes.uuid,
|
||||
name: attributes.name,
|
||||
contents: attributes.contents,
|
||||
sha256Hash: attributes.sha256_hash,
|
||||
bytes: attributes.bytes,
|
||||
createdAt: new Date(attributes.created_at),
|
||||
completedAt: attributes.completed_at ? new Date(attributes.completed_at) : null,
|
||||
});
|
||||
|
||||
export default (uuid: string, page?: number | string): Promise<PaginatedResult<ServerBackup>> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.get(`/api/client/servers/${uuid}/backups`, { params: { page } })
|
||||
.then(({ data }) => resolve({
|
||||
items: (data.data || []).map(rawDataToServerBackup),
|
||||
pagination: getPaginationSet(data.meta.pagination),
|
||||
}))
|
||||
.catch(reject);
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue