mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 07:39:41 +02:00
refactor(frontend): 🚧 Migrate Dashboard to Nuxt
Add API and Functinality for Admin Dashboard. Stills needs to clean-up. See // TODO's
This commit is contained in:
parent
41a6916771
commit
9386cc320b
32 changed files with 671 additions and 113 deletions
69
frontend/api/class-interfaces/backups.ts
Normal file
69
frontend/api/class-interfaces/backups.ts
Normal file
|
@ -0,0 +1,69 @@
|
|||
import { BaseAPI } from "./_base";
|
||||
|
||||
export interface BackupOptions {
|
||||
recipes?: boolean;
|
||||
settings?: boolean;
|
||||
pages?: boolean;
|
||||
themes?: boolean;
|
||||
groups?: boolean;
|
||||
users?: boolean;
|
||||
notifications?: boolean;
|
||||
}
|
||||
|
||||
export interface ImportBackup extends BackupOptions {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface BackupJob {
|
||||
tag?: string;
|
||||
options: BackupOptions;
|
||||
templates?: string[];
|
||||
}
|
||||
|
||||
export interface BackupFile {
|
||||
name: string;
|
||||
date: string;
|
||||
}
|
||||
|
||||
export interface AllBackups {
|
||||
imports: BackupFile[];
|
||||
templates: string[];
|
||||
}
|
||||
|
||||
const prefix = "/api";
|
||||
|
||||
const routes = {
|
||||
backupsAvailable: `${prefix}/backups/available`,
|
||||
backupsExportDatabase: `${prefix}/backups/export/database`,
|
||||
backupsUpload: `${prefix}/backups/upload`,
|
||||
|
||||
backupsFileNameDownload: (fileName: string) => `${prefix}/backups/${fileName}/download`,
|
||||
backupsFileNameImport: (fileName: string) => `${prefix}/backups/${fileName}/import`,
|
||||
backupsFileNameDelete: (fileName: string) => `${prefix}/backups/${fileName}/delete`,
|
||||
};
|
||||
|
||||
export class BackupAPI extends BaseAPI {
|
||||
/** Returns a list of avaiable .zip files for import into Mealie.
|
||||
*/
|
||||
async getAll() {
|
||||
return await this.requests.get<AllBackups>(routes.backupsAvailable);
|
||||
}
|
||||
|
||||
/** Generates a backup of the recipe database in json format.
|
||||
*/
|
||||
async createOne(payload: BackupJob) {
|
||||
return await this.requests.post(routes.backupsExportDatabase, payload);
|
||||
}
|
||||
|
||||
/** Import a database backup file generated from Mealie.
|
||||
*/
|
||||
async restoreDatabase(fileName: string, payload: BackupOptions) {
|
||||
return await this.requests.post(routes.backupsFileNameImport(fileName), payload);
|
||||
}
|
||||
|
||||
/** Removes a database backup from the file system
|
||||
*/
|
||||
async deleteOne(fileName: string) {
|
||||
return await this.requests.delete(routes.backupsFileNameDelete(fileName));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue