This commit is contained in:
yoan
2024-08-21 12:19:12 +08:00
commit 50fa238d88
89 changed files with 11835 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
import { Access } from "@/domain/access";
import { getPb } from "./api";
import moment from "moment";
export const list = async () => {
return await getPb().collection("access").getFullList<Access>({
sort: "-created",
filter: "deleted = null",
});
};
export const save = async (data: Access) => {
if (data.id) {
return await getPb().collection("access").update(data.id, data);
}
return await getPb().collection("access").create(data);
};
export const remove = async (data: Access) => {
data.deleted = moment.utc().format("YYYY-MM-DD HH:mm:ss");
return await getPb().collection("access").update(data.id, data);
};

7
ui/src/repository/api.ts Normal file
View File

@@ -0,0 +1,7 @@
import PocketBase from "pocketbase";
let pb: PocketBase;
export const getPb = () => {
if (pb) return pb;
pb = new PocketBase("http://127.0.0.1:8090");
return pb;
};

View File

@@ -0,0 +1,25 @@
import { Deployment, DeploymentListReq } from "@/domain/deployment";
import { getPb } from "./api";
export const list = async (req: DeploymentListReq) => {
let page = 1;
if (req.page) {
page = req.page;
}
let perPage = 10;
if (req.perPage) {
perPage = req.perPage;
}
let filter = "domain!=null";
if (req.domain) {
filter = `domain="${req.domain}"`;
}
return await getPb()
.collection("deployments")
.getList<Deployment>(page, perPage, {
filter: filter,
sort: "-id",
expand: "domain",
});
};

View File

@@ -0,0 +1,27 @@
import { Domain } from "@/domain/domain";
import { getPb } from "./api";
export const list = async () => {
const response = getPb().collection("domains").getFullList<Domain>({
sort: "-created",
expand: "lastDeployment",
});
return response;
};
export const get = async (id: string) => {
const response = await getPb().collection("domains").getOne<Domain>(id);
return response;
};
export const save = async (data: Domain) => {
if (data.id) {
return await getPb().collection("domains").update(data.id, data);
}
return await getPb().collection("domains").create(data);
};
export const remove = async (id: string) => {
return await getPb().collection("domains").delete(id);
};