mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-08-05 05:25:26 +02:00
refactor: ♻️ rewrite migrations frontend/backend (#841)
* refactor(frontend): ♻️ rewrite migrations UI * refactor(backend): ♻️ rewrite recipe migrations * remove vue-demi Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
parent
afae0ef0f5
commit
2ce195a0d4
41 changed files with 1010 additions and 464 deletions
27
frontend/api/class-interfaces/group-migrations.ts
Normal file
27
frontend/api/class-interfaces/group-migrations.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { BaseAPI } from "../_base";
|
||||
import { ReportSummary } from "./group-reports";
|
||||
|
||||
const prefix = "/api";
|
||||
|
||||
export type SupportedMigration = "nextcloud" | "chowdown";
|
||||
|
||||
export interface MigrationPayload {
|
||||
migrationType: SupportedMigration;
|
||||
archive: File;
|
||||
}
|
||||
|
||||
const routes = {
|
||||
base: `${prefix}/groups/migrations`,
|
||||
};
|
||||
|
||||
export class GroupMigrationApi extends BaseAPI {
|
||||
async startMigration(payload: MigrationPayload) {
|
||||
const form = new FormData();
|
||||
form.append("migration_type", payload.migrationType);
|
||||
form.append("archive", payload.archive);
|
||||
|
||||
console.log(form);
|
||||
|
||||
return await this.requests.post<ReportSummary>(routes.base, form);
|
||||
}
|
||||
}
|
49
frontend/api/class-interfaces/group-reports.ts
Normal file
49
frontend/api/class-interfaces/group-reports.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
import { BaseAPI } from "../_base";
|
||||
|
||||
const prefix = "/api";
|
||||
|
||||
export type ReportCategory = "backup" | "restore" | "migration";
|
||||
|
||||
export type SummaryStatus = "success" | "failure" | "partial" | "in-progress";
|
||||
|
||||
export interface ReportEntry {
|
||||
id: string;
|
||||
reportId: string;
|
||||
timestamp: Date;
|
||||
success: boolean;
|
||||
message: string;
|
||||
exception: string;
|
||||
}
|
||||
|
||||
export interface ReportSummary {
|
||||
id: string;
|
||||
timestamp: Date;
|
||||
category: ReportCategory;
|
||||
groupId: number;
|
||||
name: string;
|
||||
status: SummaryStatus;
|
||||
}
|
||||
|
||||
export interface Report extends ReportSummary {
|
||||
entries: ReportEntry[];
|
||||
}
|
||||
|
||||
const routes = {
|
||||
base: `${prefix}/groups/reports`,
|
||||
getOne: (id: string) => `${prefix}/groups/reports/${id}`,
|
||||
};
|
||||
|
||||
export class GroupReportsApi extends BaseAPI {
|
||||
async getAll(category: ReportCategory | null) {
|
||||
const query = category ? `?report_type=${category}` : "";
|
||||
return await this.requests.get<ReportSummary[]>(routes.base + query);
|
||||
}
|
||||
|
||||
async getOne(id: string) {
|
||||
return await this.requests.get<Report>(routes.getOne(id));
|
||||
}
|
||||
|
||||
async deleteOne(id: string) {
|
||||
return await this.requests.delete(routes.getOne(id));
|
||||
}
|
||||
}
|
|
@ -19,6 +19,8 @@ import { BulkActionsAPI } from "./class-interfaces/recipe-bulk-actions";
|
|||
import { GroupServerTaskAPI } from "./class-interfaces/group-tasks";
|
||||
import { AdminAPI } from "./admin-api";
|
||||
import { ToolsApi } from "./class-interfaces/tools";
|
||||
import { GroupMigrationApi } from "./class-interfaces/group-migrations";
|
||||
import { GroupReportsApi } from "./class-interfaces/group-reports";
|
||||
import { ApiRequestInstance } from "~/types/api";
|
||||
|
||||
class Api {
|
||||
|
@ -40,6 +42,8 @@ class Api {
|
|||
public mealplans: MealPlanAPI;
|
||||
public email: EmailAPI;
|
||||
public bulk: BulkActionsAPI;
|
||||
public groupMigration: GroupMigrationApi;
|
||||
public groupReports: GroupReportsApi;
|
||||
public grouperServerTasks: GroupServerTaskAPI;
|
||||
public tools: ToolsApi;
|
||||
// Utils
|
||||
|
@ -67,6 +71,10 @@ class Api {
|
|||
this.mealplans = new MealPlanAPI(requests);
|
||||
this.grouperServerTasks = new GroupServerTaskAPI(requests);
|
||||
|
||||
// Group
|
||||
this.groupMigration = new GroupMigrationApi(requests);
|
||||
this.groupReports = new GroupReportsApi(requests);
|
||||
|
||||
// Admin
|
||||
this.events = new EventsAPI(requests);
|
||||
this.backups = new BackupAPI(requests);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue