Add support for locking backups to prevent any accidental deletions
This commit is contained in:
parent
5f48712c28
commit
5d5e4ca7b1
18 changed files with 250 additions and 88 deletions
|
@ -2,12 +2,18 @@ import http from '@/api/http';
|
|||
import { ServerBackup } from '@/api/server/types';
|
||||
import { rawDataToServerBackup } from '@/api/transformers';
|
||||
|
||||
export default (uuid: string, name?: string, ignored?: string): Promise<ServerBackup> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.post(`/api/client/servers/${uuid}/backups`, {
|
||||
name, ignored,
|
||||
})
|
||||
.then(({ data }) => resolve(rawDataToServerBackup(data)))
|
||||
.catch(reject);
|
||||
interface RequestParameters {
|
||||
name?: string;
|
||||
ignored?: string;
|
||||
isLocked: boolean;
|
||||
}
|
||||
|
||||
export default async (uuid: string, params: RequestParameters): Promise<ServerBackup> => {
|
||||
const { data } = await http.post(`/api/client/servers/${uuid}/backups`, {
|
||||
name: params.name,
|
||||
ignored: params.ignored,
|
||||
is_locked: params.isLocked,
|
||||
});
|
||||
|
||||
return rawDataToServerBackup(data);
|
||||
};
|
||||
|
|
1
resources/scripts/api/server/types.d.ts
vendored
1
resources/scripts/api/server/types.d.ts
vendored
|
@ -3,6 +3,7 @@ export type ServerStatus = 'installing' | 'install_failed' | 'suspended' | 'rest
|
|||
export interface ServerBackup {
|
||||
uuid: string;
|
||||
isSuccessful: boolean;
|
||||
isLocked: boolean;
|
||||
name: string;
|
||||
ignoredFiles: string;
|
||||
checksum: string;
|
||||
|
|
|
@ -58,6 +58,7 @@ export const rawDataToFileObject = (data: FractalResponseData): FileObject => ({
|
|||
export const rawDataToServerBackup = ({ attributes }: FractalResponseData): ServerBackup => ({
|
||||
uuid: attributes.uuid,
|
||||
isSuccessful: attributes.is_successful,
|
||||
isLocked: attributes.is_locked,
|
||||
name: attributes.name,
|
||||
ignoredFiles: attributes.ignored_files,
|
||||
checksum: attributes.checksum,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue