mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-23 15:19:41 +02:00
refactor(♻️): update 'about' page to new composition API (#667)
* test-commit * Remove PR Name Checker * refactor(backend): ♻️ split unrelated routes into clearer router paths Add an /app and /admin router base paths to split previously grouped public/admin data into different paths. Part of a longer migration to move 'admin' operations under the admin path. * refactor(backend): ♻️ rename imports * refactor(frontend): ♻️ refactor frontend API and Pages to refelect new API design Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
parent
c7f8c96287
commit
abc0d0d59f
23 changed files with 317 additions and 275 deletions
37
frontend/api/class-interfaces/admin-about.ts
Normal file
37
frontend/api/class-interfaces/admin-about.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
import { BaseAPI } from "./_base";
|
||||
|
||||
const prefix = "/api";
|
||||
|
||||
const routes = {
|
||||
about: `${prefix}/admin/about`,
|
||||
aboutStatistics: `${prefix}/admin/about/statistics`,
|
||||
};
|
||||
|
||||
export interface AdminAboutInfo {
|
||||
production: boolean;
|
||||
version: string;
|
||||
demoStatus: boolean;
|
||||
apiPort: number;
|
||||
apiDocs: boolean;
|
||||
dbType: string;
|
||||
dbUrl: string;
|
||||
defaultGroup: string;
|
||||
}
|
||||
|
||||
export interface AdminStatistics {
|
||||
totalRecipes: number;
|
||||
totalUsers: number;
|
||||
totalGroups: number;
|
||||
uncategorizedRecipes: number;
|
||||
untaggedRecipes: number;
|
||||
}
|
||||
|
||||
export class AdminAboutAPI extends BaseAPI {
|
||||
async about() {
|
||||
return await this.requests.get<AdminAboutInfo>(routes.about);
|
||||
}
|
||||
|
||||
async statistics() {
|
||||
return await this.requests.get(routes.aboutStatistics);
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
import { BaseAPI } from "./_base";
|
||||
|
||||
export interface AppStatistics {
|
||||
totalRecipes: number;
|
||||
totalUsers: number;
|
||||
totalGroups: number;
|
||||
uncategorizedRecipes: number;
|
||||
untaggedRecipes: number;
|
||||
}
|
||||
|
||||
const prefix = "/api";
|
||||
|
||||
const routes = {
|
||||
debugVersion: `${prefix}/debug/version`,
|
||||
debug: `${prefix}/debug`,
|
||||
debugStatistics: `${prefix}/debug/statistics`,
|
||||
debugLastRecipeJson: `${prefix}/debug/last-recipe-json`,
|
||||
debugLog: `${prefix}/debug/log`,
|
||||
|
||||
debugLogNum: (num: number) => `${prefix}/debug/log/${num}`,
|
||||
};
|
||||
|
||||
export class DebugAPI extends BaseAPI {
|
||||
/** Returns the current version of mealie
|
||||
*/
|
||||
async getMealieVersion() {
|
||||
return await this.requests.get(routes.debugVersion);
|
||||
}
|
||||
|
||||
/** Returns general information about the application for debugging
|
||||
*/
|
||||
async getDebugInfo() {
|
||||
return await this.requests.get(routes.debug);
|
||||
}
|
||||
|
||||
async getAppStatistics() {
|
||||
return await this.requests.get<AppStatistics>(routes.debugStatistics);
|
||||
}
|
||||
|
||||
/** Doc Str
|
||||
*/
|
||||
async getLog(num: number) {
|
||||
return await this.requests.get(routes.debugLogNum(num));
|
||||
}
|
||||
|
||||
/** Returns a token to download a file
|
||||
*/
|
||||
async getLogFile() {
|
||||
return await this.requests.get(routes.debugLog);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
import { RecipeAPI } from "./class-interfaces/recipes";
|
||||
import { UserApi } from "./class-interfaces/users";
|
||||
import { GroupAPI } from "./class-interfaces/groups";
|
||||
import { DebugAPI } from "./class-interfaces/debug";
|
||||
import { EventsAPI } from "./class-interfaces/events";
|
||||
import { BackupAPI } from "./class-interfaces/backups";
|
||||
import { UploadFile } from "./class-interfaces/upload";
|
||||
|
@ -13,14 +12,30 @@ import { FoodAPI } from "./class-interfaces/recipe-foods";
|
|||
import { UnitAPI } from "./class-interfaces/recipe-units";
|
||||
import { CookbookAPI } from "./class-interfaces/cookbooks";
|
||||
import { WebhooksAPI } from "./class-interfaces/group-webhooks";
|
||||
import { AdminAboutAPI } from "./class-interfaces/admin-about";
|
||||
import { ApiRequestInstance } from "~/types/api";
|
||||
|
||||
class AdminAPI {
|
||||
private static instance: AdminAPI;
|
||||
public about: AdminAboutAPI;
|
||||
|
||||
constructor(requests: ApiRequestInstance) {
|
||||
if (AdminAPI.instance instanceof AdminAPI) {
|
||||
return AdminAPI.instance;
|
||||
}
|
||||
|
||||
this.about = new AdminAboutAPI(requests);
|
||||
|
||||
Object.freeze(this);
|
||||
AdminAPI.instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
class Api {
|
||||
private static instance: Api;
|
||||
public recipes: RecipeAPI;
|
||||
public users: UserApi;
|
||||
public groups: GroupAPI;
|
||||
public debug: DebugAPI;
|
||||
public events: EventsAPI;
|
||||
public backups: BackupAPI;
|
||||
public categories: CategoriesAPI;
|
||||
|
@ -54,7 +69,6 @@ class Api {
|
|||
this.groupWebhooks = new WebhooksAPI(requests);
|
||||
|
||||
// Admin
|
||||
this.debug = new DebugAPI(requests);
|
||||
this.events = new EventsAPI(requests);
|
||||
this.backups = new BackupAPI(requests);
|
||||
this.notifications = new NotificationsAPI(requests);
|
||||
|
@ -68,4 +82,4 @@ class Api {
|
|||
}
|
||||
}
|
||||
|
||||
export { Api };
|
||||
export { Api, AdminAPI };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue